freedomboneeee/src/freedombone-utils-i2p

124 lines
3.8 KiB
Plaintext
Raw Permalink Normal View History

2018-02-11 14:44:17 +01:00
#!/bin/bash
2018-04-08 14:30:21 +02:00
# _____ _ _
# | __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
# | __| _| -_| -_| . | . | | . | . | | -_|
# |__| |_| |___|___|___|___|_|_|_|___|___|_|_|___|
2018-02-11 14:44:17 +01:00
#
2018-04-08 14:30:21 +02:00
# Freedom in the Cloud
2018-02-11 14:44:17 +01:00
#
# i2p functions
#
# There's a problem with installing this onto mesh images, which is
# that qemu appears to run out of RAM when using yarn to add webpack.
#
# License
# =======
#
# Copyright (C) 2017-2018 Bob Mottram <bob@freedombone.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
I2P_DOMAIN='deb.i2p2.de'
function install_i2p {
2018-02-26 14:50:40 +01:00
if [ ! -d "$INSTALL_DIR" ]; then
mkdir -p "$INSTALL_DIR"
2018-02-11 14:44:17 +01:00
fi
# install the gpg key
2018-02-26 14:50:40 +01:00
cd "$INSTALL_DIR" || exit 346735
2018-02-11 14:44:17 +01:00
if [ -f i2p-debian-repo.key.asc ]; then
rm i2p-debian-repo.key.asc
fi
wget https://geti2p.net/_static/i2p-debian-repo.key.asc
if [ ! -f i2p-debian-repo.key.asc ]; then
echo $'failed to ontain i2p repo gpg key'
exit 7834627345
fi
apt-key add i2p-debian-repo.key.asc
echo "deb https://${I2P_DOMAIN}/ stretch main" > /etc/apt/sources.list.d/i2p.list
echo "deb-src https://${I2P_DOMAIN}/ stretch main" >> /etc/apt/sources.list.d/i2p.list
2018-02-11 20:38:05 +01:00
# i2p needs ipv6 to be enabled
sed -i 's|net.ipv6.conf.all.disable_ipv6.*|net.ipv6.conf.all.disable_ipv6 = 0|g' /etc/sysctl.conf
/sbin/sysctl -p -q
2018-02-11 14:44:17 +01:00
apt-get update
apt-get -yq install i2p i2p-keyring
2018-02-12 15:33:18 +01:00
systemctl restart i2p
2018-02-11 14:44:17 +01:00
}
function remove_i2p {
2018-02-14 20:10:25 +01:00
service i2p stop
2018-02-12 11:09:10 +01:00
apt-get -yq remove i2p-router --purge
apt-get -yq remove i2p --purge
apt-get -yq remove i2p-keyring --purge
2018-02-12 00:36:07 +01:00
apt-get -yq autoremove
2018-02-11 20:38:05 +01:00
# It's assumed here that ipv6 is only needed for i2p
# This might not be true in future
sed -i 's|net.ipv6.conf.all.disable_ipv6.*|net.ipv6.conf.all.disable_ipv6 = 1|g' /etc/sysctl.conf
/sbin/sysctl -p -q
2018-02-11 20:41:55 +01:00
if [ -d /var/lib/i2p ]; then
rm -rf /var/lib/i2p
fi
if [ -d /etc/i2p ]; then
rm -rf /etc/i2p
fi
2018-02-11 23:40:33 +01:00
if [ -d /usr/share/i2p ]; then
rm -rf /usr/share/i2p
fi
2018-02-14 19:18:49 +01:00
if [ -d /var/log/i2p ]; then
rm /var/log/i2p
fi
2018-02-15 19:21:59 +01:00
rm -rf /tmp/i2p*
2018-02-23 21:41:42 +01:00
rm /etc/apt/sources.list.d/i2p.list
2018-02-11 20:38:05 +01:00
}
function i2p_enable_sam {
2018-02-12 15:33:18 +01:00
if [ ! -f /var/lib/i2p/i2p-config/clients.config ]; then
2018-02-14 20:10:25 +01:00
service i2p stop
2018-02-15 19:21:59 +01:00
apt-get -yq remove i2p i2p-keyring --purge
2018-02-14 15:18:25 +01:00
apt-get -yq remove i2p-router --purge
2018-02-14 18:59:38 +01:00
if [ -d /var/lib/i2p ]; then
rm -rf /var/lib/i2p
fi
if [ -d /etc/i2p ]; then
rm -rf /etc/i2p
fi
if [ -d /usr/share/i2p ]; then
rm -rf /usr/share/i2p
fi
2018-02-14 19:18:49 +01:00
if [ -d /var/log/i2p ]; then
rm /var/log/i2p
fi
2018-02-15 19:21:59 +01:00
rm -rf /tmp/i2p*
2018-02-14 18:59:38 +01:00
apt-get -yq install i2p i2p-keyring
2018-02-15 19:21:59 +01:00
apt-get -yq install i2p-router --reinstall
systemctl restart i2p
2018-02-14 18:59:38 +01:00
sleep 10
2018-02-12 15:33:18 +01:00
fi
2018-02-12 00:36:07 +01:00
if [ ! -f /var/lib/i2p/i2p-config/clients.config ]; then
echo $'File not found /var/lib/i2p/i2p-config/clients.config'
exit 483648364834
fi
2018-02-11 20:38:05 +01:00
sed -i 's|clientApp.1.startOnLoad=.*|clientApp.1.startOnLoad=true|g' /var/lib/i2p/i2p-config/clients.config
systemctl restart i2p
2018-02-11 14:44:17 +01:00
}
2018-02-26 14:50:40 +01:00
# NOTE: deliberately no exit 0