lokinet/debian/lokinet.postinst

47 lines
1.6 KiB
Plaintext
Raw Normal View History

2018-10-23 11:45:14 +00:00
#!/bin/sh -e
set -e
if [ "$1" = configure ]; then
mkdir -p /etc/loki
datadir=/var/lib/lokinet
tn_datadir=/var/lib/lokinet/testnet
mkdir -p $datadir $tn_datadir
su -s /bin/sh _lokinet -c "test -O $datadir && test -G $datadir" || \
chown _lokinet:_loki $datadir
su -s /bin/sh _lokinet -c "test -O $tn_datadir && test -G $tn_datadir" || \
chown _lokinet:_loki $tn_datadir
if ! [ -e /var/lib/lokinet/bootstrap.signed ]; then
/usr/bin/lokinet-bootstrap lokinet /var/lib/lokinet/bootstrap.signed
chown _lokinet:_loki /var/lib/lokinet/bootstrap.signed
fi
if ! [ -e /var/lib/lokinet/testnet/bootstrap.signed ]; then
/usr/bin/lokinet-bootstrap testnet /var/lib/lokinet/testnet/bootstrap.signed
chown _lokinet:_loki /var/lib/lokinet/testnet/bootstrap.signed
fi
tmpdir=$(mktemp --tmpdir -d lokinet.XXXXXXXXXX)
/usr/bin/lokinet -g $tmpdir/lokinet.ini
sed -i -e "s#$tmpdir#$datadir#" $tmpdir/lokinet.ini
chmod 640 $tmpdir/lokinet.ini
chgrp _loki $tmpdir/lokinet.ini
ucf $tmpdir/lokinet.ini /etc/loki/lokinet.ini
ucfr lokinet /etc/loki/lokinet.ini
tmpdir=$(mktemp --tmpdir -d lokinet.XXXXXXXXXX)
/usr/bin/lokinet -g $tmpdir/lokinet.ini
sed -i -e "s#$tmpdir#$tn_datadir#" $tmpdir/lokinet.ini
chmod 640 $tmpdir/lokinet.ini
chgrp _loki $tmpdir/lokinet.ini
ucf $tmpdir/lokinet.ini /etc/loki/lokinet-testnet.ini
ucfr lokinet /etc/loki/lokinet-testnet.ini
if [ -x /bin/systemctl ] && /bin/systemctl --quiet is-active systemd-resolved.service; then
/bin/systemctl restart systemd-resolved.service
fi
fi
#DEBHELPER#