2019-10-29 17:02:40 +00:00
|
|
|
#!/bin/sh -e
|
|
|
|
|
|
|
|
set -e
|
2020-10-02 19:33:47 +00:00
|
|
|
. /usr/share/debconf/confmodule
|
2019-10-29 17:02:40 +00:00
|
|
|
|
|
|
|
if [ "$1" = configure ]; then
|
|
|
|
mkdir -p /etc/loki
|
|
|
|
datadir=/var/lib/lokinet/router
|
2019-12-16 03:20:08 +00:00
|
|
|
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
|
2019-10-29 17:02:40 +00:00
|
|
|
|
|
|
|
tmpdir=$(mktemp --tmpdir -d lokinet.XXXXXXXXXX)
|
2020-09-30 21:31:57 +00:00
|
|
|
/usr/bin/lokinet -r -g $tmpdir/lokinet.ini
|
2019-12-17 01:26:00 +00:00
|
|
|
perl -pi -e "
|
|
|
|
s#$tmpdir#$datadir#;
|
2019-12-28 17:31:43 +00:00
|
|
|
if (/^\[lokid/ ... /^\[/) {
|
2020-09-30 21:31:57 +00:00
|
|
|
s{^#?enabled=.*}{enabled=1};
|
2022-11-15 17:59:12 +00:00
|
|
|
s{^#?rpc=.*}{rpc=ipc:///var/lib/oxen/oxend.sock};
|
2019-12-17 01:26:00 +00:00
|
|
|
}" $tmpdir/lokinet.ini
|
2019-10-29 17:02:40 +00:00
|
|
|
chmod 640 $tmpdir/lokinet.ini
|
|
|
|
chgrp _loki $tmpdir/lokinet.ini
|
2020-10-02 19:33:47 +00:00
|
|
|
ucf --debconf-ok $tmpdir/lokinet.ini /etc/loki/lokinet-router.ini
|
2019-10-29 17:02:40 +00:00
|
|
|
ucfr lokinet /etc/loki/lokinet-router.ini
|
2019-12-16 03:20:08 +00:00
|
|
|
|
|
|
|
tmpdir=$(mktemp --tmpdir -d lokinet.XXXXXXXXXX)
|
2020-09-30 21:31:57 +00:00
|
|
|
/usr/bin/lokinet -r -g $tmpdir/lokinet.ini
|
2019-12-17 01:26:00 +00:00
|
|
|
perl -pi -e "
|
2019-12-28 16:57:12 +00:00
|
|
|
s#$tmpdir#$tn_datadir#;
|
2020-09-30 21:31:57 +00:00
|
|
|
if (/^\[router/ ... /^\[/) {
|
|
|
|
s{^#?netid=.*}{netid=gamma};
|
|
|
|
}
|
2019-12-28 17:31:43 +00:00
|
|
|
if (/^\[lokid/ ... /^\[/) {
|
2020-09-30 21:31:57 +00:00
|
|
|
s{^#?enabled=.*}{enabled=1};
|
2022-11-15 17:59:12 +00:00
|
|
|
s{^#?rpc=.*}{rpc=ipc:///var/lib/oxen/testnet/oxend.sock};
|
2019-12-17 01:26:00 +00:00
|
|
|
}" $tmpdir/lokinet.ini
|
2019-12-16 03:20:08 +00:00
|
|
|
chmod 640 $tmpdir/lokinet.ini
|
|
|
|
chgrp _loki $tmpdir/lokinet.ini
|
2020-10-02 19:33:47 +00:00
|
|
|
ucf --debconf-ok $tmpdir/lokinet.ini /etc/loki/lokinet-testnet-router.ini
|
2019-12-16 03:20:08 +00:00
|
|
|
ucfr lokinet /etc/loki/lokinet-testnet-router.ini
|
2020-10-02 19:33:47 +00:00
|
|
|
|
|
|
|
# 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
|
2019-10-29 17:02:40 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
#DEBHELPER#
|