mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
3152eba01c
We now how the bootstrap in the binary itself. This doesn't remove the installed bootstrap files, though, for backwards compat: existing configs may be referencing the system path.
63 lines
2.3 KiB
Bash
63 lines
2.3 KiB
Bash
#!/bin/sh -e
|
|
|
|
set -e
|
|
. /usr/share/debconf/confmodule
|
|
|
|
if [ "$1" = configure ]; then
|
|
mkdir -p /etc/loki
|
|
datadir=/var/lib/lokinet/router
|
|
tn_datadir=/var/lib/lokinet/testnet-router
|
|
mkdir -p $datadir $tn_datadir /var/lib/lokinet/testnet
|
|
for d in $datadir $tn_datadir /var/lib/lokinet/testnet; do
|
|
su -s /bin/sh _lokinet -c "test -O $d && test -G $d" || \
|
|
chown _lokinet:_loki $d
|
|
done
|
|
|
|
tmpdir=$(mktemp --tmpdir -d lokinet.XXXXXXXXXX)
|
|
/usr/bin/lokinet -r -g $tmpdir/lokinet.ini
|
|
perl -pi -e "
|
|
s#$tmpdir#$datadir#;
|
|
if (/^\[lokid/ ... /^\[/) {
|
|
s{^#?enabled=.*}{enabled=1};
|
|
s{^#?rpc=.*}{rpc=ipc:///var/lib/loki/lokid.sock};
|
|
}" $tmpdir/lokinet.ini
|
|
chmod 640 $tmpdir/lokinet.ini
|
|
chgrp _loki $tmpdir/lokinet.ini
|
|
ucf --debconf-ok $tmpdir/lokinet.ini /etc/loki/lokinet-router.ini
|
|
ucfr lokinet /etc/loki/lokinet-router.ini
|
|
|
|
tmpdir=$(mktemp --tmpdir -d lokinet.XXXXXXXXXX)
|
|
/usr/bin/lokinet -r -g $tmpdir/lokinet.ini
|
|
perl -pi -e "
|
|
s#$tmpdir#$tn_datadir#;
|
|
if (/^\[router/ ... /^\[/) {
|
|
s{^#?netid=.*}{netid=gamma};
|
|
}
|
|
if (/^\[lokid/ ... /^\[/) {
|
|
s{^#?enabled=.*}{enabled=1};
|
|
s{^#?rpc=.*}{rpc=ipc:///var/lib/loki/testnet/lokid.sock};
|
|
}" $tmpdir/lokinet.ini
|
|
chmod 640 $tmpdir/lokinet.ini
|
|
chgrp _loki $tmpdir/lokinet.ini
|
|
ucf --debconf-ok $tmpdir/lokinet.ini /etc/loki/lokinet-testnet-router.ini
|
|
ucfr lokinet /etc/loki/lokinet-testnet-router.ini
|
|
|
|
# If this system has only private IPs and warn the user that they need to update the config file
|
|
if ! grep -q '^public-\(ip\|address\)=' /etc/loki/lokinet-router.ini; then
|
|
if ! ip -4 addr show | perl -le '
|
|
while (<>) {
|
|
next if !m{^ +inet +(\d+)\.(\d+)\.(\d+)\.(\d+)/};
|
|
exit 0 if not ($1 == 0 or $1 == 10 or ($1 == 100 and ($2 >= 64 and $2 <= 127)) or $1 == 127 or
|
|
($1 == 169 and $1 == 254) or ($1 == 172 and $2 >= 16 and $2 <= 31) or ($1 == 192 and $2 == 168) or $1 >= 224);
|
|
}
|
|
exit 1'; then
|
|
|
|
db_reset lokinet-router/no-public-ip || true
|
|
db_input critical lokinet-router/no-public-ip || true
|
|
db_go || true
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
#DEBHELPER#
|