Add debconf warning when no public ip

debian/buster
Jason Rhinelander 4 years ago
parent 13e83cfee3
commit d2d22a0342

@ -1,6 +1,7 @@
#!/bin/sh -e
set -e
. /usr/share/debconf/confmodule
if [ "$1" = configure ]; then
mkdir -p /etc/loki
@ -35,7 +36,7 @@ if [ "$1" = configure ]; then
}" $tmpdir/lokinet.ini
chmod 640 $tmpdir/lokinet.ini
chgrp _loki $tmpdir/lokinet.ini
ucf $tmpdir/lokinet.ini /etc/loki/lokinet-router.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)
@ -54,8 +55,24 @@ if [ "$1" = configure ]; then
}" $tmpdir/lokinet.ini
chmod 640 $tmpdir/lokinet.ini
chgrp _loki $tmpdir/lokinet.ini
ucf $tmpdir/lokinet.ini /etc/loki/lokinet-testnet-router.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#

@ -0,0 +1,17 @@
Template: lokinet-router/no-public-ip
Type: note
Description: No public IP detected!
This system does not appear to have any public IPv4 address, which Lokinet
service nodes require.
.
This is not necessarily an error: some VPS providers use exotic setups that
automatically forward your public IP traffic to your internal IP.
.
Assuming this machine is publicly reachable, Lokinet needs to be told the
public IP and port by updating the configuration file
(/etc/loki/lokinet-router.ini) to set the following [router] options:
.
public-ip=YOURPUBLICIP
public-port=1090
.
Until this change is made, lokinet will not properly start up.
Loading…
Cancel
Save