forked from I2P_Developers/i2p.i2p
87 lines
2.4 KiB
Bash
Executable File
87 lines
2.4 KiB
Bash
Executable File
#!/bin/sh -e
|
|
|
|
I2PHOME=/var/lib/i2p
|
|
I2PSYSUSER=i2psvc
|
|
|
|
conffile="/etc/default/i2p"
|
|
|
|
# Source debconf library -- we have a Depends line
|
|
# to make sure it is there...
|
|
. /usr/share/debconf/confmodule
|
|
db_version 2.0
|
|
|
|
|
|
case "$1" in
|
|
configure|reconfigure)
|
|
if [ ! -e $conffile ]; then
|
|
echo "# Defaults for i2p initscript (/etc/init.d/i2p" >> $conffile
|
|
echo "# This is a posix shell fragment" >> $conffile
|
|
echo >> $conffile
|
|
echo "# [automatically edited by postinst, do not change line format ]" >> $conffile
|
|
echo "# Run 'dpkg-reconfigure -plow i2p' to change these values." >> $conffile
|
|
echo >> $conffile
|
|
echo "RUN_DAEMON=" >> $conffile
|
|
echo "I2PUSER=" >> $conffile
|
|
fi
|
|
|
|
db_get i2p/daemon
|
|
RUN_DAEMON="$RET"
|
|
db_get i2p/user
|
|
I2PUSER="$RET"
|
|
|
|
cp -a -f $conffile $conffile.tmp
|
|
|
|
# If the admin deleted or commented some variables but then set them via debconf,
|
|
# (re-)add them to the conffile.
|
|
test -z "$RUN_DAEMON" || grep -Eq '^ *RUN_DAEMON=' $conffile || \
|
|
echo "RUN_DAEMON=" >> $conffile
|
|
test -z "$I2PUSER" || grep -Eq '^ *I2PUSER=' $conffile || \
|
|
echo "I2PUSER=" >> $conffile
|
|
|
|
if [ -z $RUN_DAEMON ]; then
|
|
RUN_DAEMON="false"
|
|
I2PUSER="i2psvc"
|
|
fi
|
|
|
|
sed -e "s/^ *RUN_DAEMON=.*/RUN_DAEMON=\"$RUN_DAEMON\"/" \
|
|
-e "s/^ *I2PUSER=.*/I2PUSER=\"$I2PUSER\"/" \
|
|
< $conffile > $conffile.tmp
|
|
mv -f $conffile.tmp $conffile
|
|
|
|
migrate_existing_user(){
|
|
# Adjust the user/group in /etc/passwd, mainly for upgrades from old packages that didn't
|
|
# create $I2PSYSUSER as a system group/user
|
|
usermod -c "I2P Router Daemon" -m -d $I2PHOME -g $I2PSYSUSER -s "/bin/false" \
|
|
-l $I2PSYSUSER -e 1 > /dev/null 2>&1
|
|
echo "Existing user migrated, home directory moved to $I2PHOME"
|
|
}
|
|
|
|
# Create user and group as a system user.
|
|
adduser --system --quiet --group --home $I2PHOME $I2PSYSUSER || migrate_existing_user
|
|
|
|
[ -d /var/log/i2p ] || mkdir -m0750 /var/log/i2p
|
|
chown -f -R $I2PSYSUSER:adm /var/log/i2p
|
|
|
|
# Has someone set the permissions with dpkg-statoverride? If so, obey them.
|
|
if ! dpkg-statoverride --list $I2PHOME > /dev/null 2>&1
|
|
then
|
|
chown -f -R $I2PSYSUSER:$I2PSYSUSER $I2PHOME
|
|
chmod -f u=rwx,g=rxs,o= $I2PHOME
|
|
fi
|
|
|
|
db_stop
|
|
;;
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
|
echo "Aborting upgrade"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
#DEBHELPER#
|
|
|
|
exit 0
|