forked from I2P_Developers/i2p.i2p
Fix ticket #514 (debconf values are overwritten upon installation)
This commit is contained in:
41
debian/i2p.config
vendored
41
debian/i2p.config
vendored
@@ -3,37 +3,20 @@
|
|||||||
|
|
||||||
conffile="/etc/default/i2p"
|
conffile="/etc/default/i2p"
|
||||||
|
|
||||||
get_config_file()
|
|
||||||
{
|
|
||||||
config_field=$1
|
|
||||||
db_field=$2
|
|
||||||
|
|
||||||
if [ -f "$conffile" ] ; then
|
|
||||||
VALUE="$(grep "^[ ]*$config_field" $conffile | sed -e "s/^$config_field *= *\"\(.*\)\"/\1/g")"
|
|
||||||
if [ -n "$VALUE" ] ; then
|
|
||||||
db_set $db_field "$VALUE"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
. /usr/share/debconf/confmodule
|
. /usr/share/debconf/confmodule
|
||||||
db_version 2.0
|
|
||||||
|
|
||||||
if [ "$1" = configure -o "$1" = reconfigure ] ; then
|
# Load config file if it exists
|
||||||
get_config_file STARTI2P i2p/daemon
|
if [ -e $conffile ]; then
|
||||||
get_config_file RUN_DAEMON i2p/daemon
|
. $conffile
|
||||||
db_input medium i2p/daemon || true
|
|
||||||
|
|
||||||
get_config_file I2PUSER i2p/user
|
|
||||||
db_input medium i2p/user || true
|
|
||||||
#db_input high i2p/stop_running_router || true
|
|
||||||
|
|
||||||
db_go
|
|
||||||
if dpkg --compare-versions "$2" lt 0.8.4-2 ; then
|
|
||||||
rm -f $conffile
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
db_set i2p/daemon "$RUN_DAEMON"
|
||||||
|
db_set i2p/user "$I2PUSER"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
db_input medium i2p/daemon || true
|
||||||
|
db_go
|
||||||
|
db_get i2p/daemon || true
|
||||||
|
if [ "$RET" = "true" ]; then
|
||||||
|
db_input medium i2p/user || true
|
||||||
|
db_go
|
||||||
|
fi
|
||||||
|
13
debian/i2p.default
vendored
13
debian/i2p.default
vendored
@@ -1,13 +0,0 @@
|
|||||||
# 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"
|
|
5
debian/i2p.init
vendored
5
debian/i2p.init
vendored
@@ -52,6 +52,11 @@ I2P_ARGS="/etc/i2p/wrapper.config \
|
|||||||
# read config file
|
# read config file
|
||||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||||
|
|
||||||
|
if [ -z "$RUN_DAEMON" ]; then
|
||||||
|
echo "/etc/default/$NAME is not set. Aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
case "$RUN_DAEMON" in
|
case "$RUN_DAEMON" in
|
||||||
[NnFf]*)
|
[NnFf]*)
|
||||||
log_action_msg "$DESC daemon disabled in /etc/default/$NAME".
|
log_action_msg "$DESC daemon disabled in /etc/default/$NAME".
|
||||||
|
105
debian/i2p.postinst
vendored
105
debian/i2p.postinst
vendored
@@ -1,29 +1,10 @@
|
|||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
I2PHOME=/var/lib/i2p
|
I2PHOME=/var/lib/i2p
|
||||||
I2P=/usr/share/i2p
|
I2PSYSUSER=i2psvc
|
||||||
I2PUSER=i2psvc
|
|
||||||
|
|
||||||
conffile="/etc/default/i2p"
|
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
|
# Source debconf library -- we have a Depends line
|
||||||
# to make sure it is there...
|
# to make sure it is there...
|
||||||
. /usr/share/debconf/confmodule
|
. /usr/share/debconf/confmodule
|
||||||
@@ -32,68 +13,62 @@ db_version 2.0
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
configure|reconfigure)
|
configure|reconfigure)
|
||||||
if [ -f $conffile ] ; then
|
if [ ! -e $conffile ]; then
|
||||||
sed -i -e 's/^[ ]*STARTI2P/RUN_DAEMON/g' $conffile
|
echo "# Defaults for i2p initscript (/etc/init.d/i2p" >> $conffile
|
||||||
if ! grep -q RUN_DAEMON $conffile ; then
|
echo "# This is a posix shell fragment" >> $conffile
|
||||||
cat << EOF >> $conffile
|
echo >> $conffile
|
||||||
# I2P daemon. If set to true, I2P will start automatically
|
echo "# [automatically edited by postinst, do not change line format ]" >> $conffile
|
||||||
# when your computer boots.
|
echo "# Run 'dpkg-reconfigure -plow i2p' to change these values." >> $conffile
|
||||||
RUN_DAEMON="false"
|
echo >> $conffile
|
||||||
EOF
|
echo "RUN_DAEMON=" >> $conffile
|
||||||
fi
|
echo "I2PUSER=" >> $conffile
|
||||||
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
|
fi
|
||||||
update_config_file i2p/daemon RUN_DAEMON
|
|
||||||
update_config_file i2p/user I2PUSER
|
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(){
|
migrate_existing_user(){
|
||||||
# Adjust the user/group in /etc/passwd, mainly for upgrades from old packages that didn't
|
# Adjust the user/group in /etc/passwd, mainly for upgrades from old packages that didn't
|
||||||
# create $I2PUSER as a system group/user
|
# create $I2PSYSUSER as a system group/user
|
||||||
usermod -c "I2P Router Daemon" -m -d $I2PHOME -g $I2PUSER -s "/bin/false" \
|
usermod -c "I2P Router Daemon" -m -d $I2PHOME -g $I2PSYSUSER -s "/bin/false" \
|
||||||
-l $I2PUSER -e 1 > /dev/null 2>&1
|
-l $I2PSYSUSER -e 1 > /dev/null 2>&1
|
||||||
echo "Existing user migrated, home directory moved to $I2PHOME"
|
echo "Existing user migrated, home directory moved to $I2PHOME"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create user and group as a system user.
|
# Create user and group as a system user.
|
||||||
adduser --system --quiet --group --home $I2PHOME $I2PUSER || migrate_existing_user
|
adduser --system --quiet --group --home $I2PHOME $I2PSYSUSER || migrate_existing_user
|
||||||
|
|
||||||
[ -d /var/log/i2p ] || mkdir -m0750 /var/log/i2p
|
[ -d /var/log/i2p ] || mkdir -m0750 /var/log/i2p
|
||||||
chown -f -R $I2PUSER:adm /var/log/i2p
|
chown -f -R $I2PSYSUSER:adm /var/log/i2p
|
||||||
|
|
||||||
# Has someone set the permissions with dpkg-statoverride? If so, obey them.
|
# Has someone set the permissions with dpkg-statoverride? If so, obey them.
|
||||||
if ! dpkg-statoverride --list $I2PHOME > /dev/null 2>&1
|
if ! dpkg-statoverride --list $I2PHOME > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
chown -f -R $I2PUSER:$I2PUSER $I2PHOME
|
chown -f -R $I2PSYSUSER:$I2PSYSUSER $I2PHOME
|
||||||
chmod -f u=rwx,g=rxs,o= $I2PHOME
|
chmod -f u=rwx,g=rxs,o= $I2PHOME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
##if ! dpkg-statoverride --list $I2P > /dev/null
|
|
||||||
##then
|
|
||||||
## chown -f -R $I2PUSER:$I2PUSER $I2P
|
|
||||||
##fi
|
|
||||||
|
|
||||||
db_stop
|
db_stop
|
||||||
;;
|
;;
|
||||||
abort-upgrade|abort-remove|abort-deconfigure)
|
abort-upgrade|abort-remove|abort-deconfigure)
|
||||||
|
Reference in New Issue
Block a user