forked from I2P_Developers/i2p.i2p
112 lines
3.0 KiB
Plaintext
112 lines
3.0 KiB
Plaintext
![]() |
#!/bin/sh -e
|
||
|
|
||
|
I2PHOME=/var/lib/i2p
|
||
|
I2P=/usr/share/i2p
|
||
|
I2PUSER=i2psvc
|
||
|
|
||
|
conffile="/etc/default/i2p"
|
||
|
|
||
|
update_config_file()
|
||
|
{
|
||
|
db_field=$1
|
||
|
config_field=$2
|
||
|
|
||
|
RET=false
|
||
|
db_get $db_field
|
||
|
if [ -n "$RET" ] ; then
|
||
|
if grep -q "^$config_field" $conffile ; then
|
||
|
# keep any admin changes, while replacing the variable content
|
||
|
sed "s/^[ ]*$config_field=\".*\"/$config_field=\"$RET\"/" < $conffile > $conffile.new &&
|
||
|
mv $conffile.new $conffile
|
||
|
else
|
||
|
echo "$config_field=\"$RET\"" >> $conffile
|
||
|
fi
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
# 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 [ -f $conffile ] ; then
|
||
|
sed -i -e 's/^[ ]*STARTI2P/RUN_DAEMON/g' $conffile
|
||
|
if ! grep -q RUN_DAEMON $conffile ; then
|
||
|
cat << EOF >> $conffile
|
||
|
# I2P daemon. If set to true, I2P will start automatically
|
||
|
# when your computer boots.
|
||
|
RUN_DAEMON="false"
|
||
|
EOF
|
||
|
fi
|
||
|
if ! grep -q I2PUSER $conffile ; then
|
||
|
cat << EOF >> $conffile
|
||
|
# The user that runs the I2P daemon. By default this is set to i2psvc.
|
||
|
# You may want to change this to use a manually installed I2P profile.
|
||
|
I2PUSER="i2psvc"
|
||
|
EOF
|
||
|
fi
|
||
|
else
|
||
|
cat << EOF >> $conffile
|
||
|
# Defaults for i2p initscript (/etc/init.d/i2p)
|
||
|
# This is a posix shell fragment
|
||
|
|
||
|
# [automatically edited by postinst, do not change line format ]
|
||
|
# Run 'dpkg-reconfigure -plow i2p' to change these values.
|
||
|
|
||
|
# I2P daemon. If set to true, i2p will start automatically when
|
||
|
# the computer boots
|
||
|
RUN_DAEMON="false"
|
||
|
|
||
|
# The user that runs the I2P daemon. By default this is set to i2psvc.
|
||
|
# You may want to change this to use a manually installed I2P profile.
|
||
|
I2PUSER="i2psvc"
|
||
|
EOF
|
||
|
fi
|
||
|
update_config_file i2p/daemon RUN_DAEMON
|
||
|
update_config_file i2p/user I2PUSER
|
||
|
|
||
|
migrate_existing_user(){
|
||
|
# Adjust the user/group in /etc/passwd, mainly for upgrades from old packages that didn't
|
||
|
# create $I2PUSER as a system group/user
|
||
|
usermod -c "I2P Router Daemon" -m -d $I2PHOME -g $I2PUSER -s "/bin/false" \
|
||
|
-l $I2PUSER -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 $I2PUSER || migrate_existing_user
|
||
|
|
||
|
[ -d /var/log/i2p ] || mkdir -m0750 /var/log/i2p
|
||
|
chown -f -R $I2PUSER: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 $I2PUSER:$I2PUSER $I2PHOME
|
||
|
chmod -f u=rwx,g=rxs,o= $I2PHOME
|
||
|
fi
|
||
|
|
||
|
##if ! dpkg-statoverride --list $I2P > /dev/null
|
||
|
##then
|
||
|
## chown -f -R $I2PUSER:$I2PUSER $I2P
|
||
|
##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
|