postinst is in mldonkey-server 3.1.5-3build2.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | #!/bin/sh
set -e
init_error ()
{
exit 1
}
# Source debconf library
. /usr/share/debconf/confmodule
DEBUG=false
db_get mldonkey-server/launch_at_startup
launch_at_startup="$RET"
case "$1" in
configure)
CONF=/etc/default/mldonkey-server
##################
# Default values #
##################
mldonkey_umask=0022
run_as_user=mldonkey
mldonkey_group=mldonkey
new_mldonkey_dir="/var/lib/mldonkey"
client_name=`hostname`
if [ -r "$CONF" ]; then
. $CONF;
if [ -n "$MLDONKEY_USER" ]; then
run_as_user="$MLDONKEY_USER";
fi
if [ -n "$MLDONKEY_GROUP" ]; then
mldonkey_group="$MLDONKEY_GROUP";
fi
if [ -n "$MLDONKEY_DIR" ]; then
new_mldonkey_dir="$MLDONKEY_DIR";
fi
if [ -n "$MLDONKEY_UMASK" ]; then
mldonkey_umask="$MLDONKEY_UMASK";
fi
fi
umask $mldonkey_umask
###################
# User management #
###################
# Creating MLDonkey group if it isn't already there
if ! getent group $mldonkey_group > /dev/null ; then
$DEBUG && echo -n "Creating mldonkey group: "
addgroup --system --quiet $mldonkey_group
$DEBUG && echo "done."
fi
# Creating MLDonkey user if it isn't already there
if ! getent passwd $run_as_user > /dev/null ; then
$DEBUG && echo -n "Creating mldonkey user: "
adduser --quiet --system --ingroup $mldonkey_group \
--home "$new_mldonkey_dir" --no-create-home $run_as_user
$DEBUG && echo "done."
fi
run_as_useruid=`id -u $run_as_user`
if [ ! -d $new_mldonkey_dir ]; then
$DEBUG && echo -n "Creating mldonkey home directory: "
mkdir "$new_mldonkey_dir"
$DEBUG && echo "done."
fi
#################
# Downloads.ini #
#################
if [ ! -e "$new_mldonkey_dir/downloads.ini" ]; then
$DEBUG && echo -n "Creating a new $new_mldonkey_dir/downloads.ini: "
touch "$new_mldonkey_dir/downloads.ini"
cat > "$new_mldonkey_dir/downloads.ini" <<EOF
run_as_useruid=$run_as_useruid
run_as_user="$run_as_user"
client_name="$client_name"
EOF
$DEBUG && echo "done."
fi
#############
# Files.ini #
#############
# Handling fasttrack file split here, better than in the mldonkey-server.init
if [ -e "$new_mldonkey_dir/files.ini" ] \
&& [ ! -e "$new_mldonkey_dir/files.ini.fasttrack" ] \
&& /usr/lib/mldonkey/mldonkey_files --test Fasttrack -q -f0 "$new_mldonkey_dir/files.ini"; then
echo "Correction of the Fasttrack problem (see /usr/share/doc/mldonkey-server/README.Debian)"
echo -n "Splitting $new_mldonkey_dir/files.ini (backup in $new_mldonkey_dir/files.ini.fasttrack): "
/usr/lib/mldonkey/mldonkey_files --split Fasttrack -f0 "$new_mldonkey_dir/files.ini" \
-f1 "$new_mldonkey_dir/files.ini.fasttrack" \
-f2 "$new_mldonkey_dir/files.ini"
echo "done."
fi
####################
# Files permission #
####################
for file in \
"$new_mldonkey_dir" \
"/var/run/mldonkey" \
"/var/log/mldonkey" \
"$new_mldonkey_dir/downloads.ini" \
"$new_mldonkey_dir/downloads.ini.dpkg" \
"$new_mldonkey_dir/downloads.ini.old" \
"$new_mldonkey_dir/downloads.ini.tmp" \
"$new_mldonkey_dir/files.ini" \
"$new_mldonkey_dir/files.ini.fasttrack"; do
$DEBUG && echo -n "Changing owner and file permission of $file: "
if ! dpkg-statoverride --list "$file" >/dev/null; then
# BUG: cf dpkg-statoverride above
if [ -e "$file" ]; then
chown -R $run_as_user:$mldonkey_group $file
$DEBUG && echo "done."
else
$DEBUG && echo "$file doesn't exist."
fi
else
$DEBUG && echo "$file is listed in dpkg-statoverride."
fi
done
for file in \
"$new_mldonkey_dir/users.ini" \
"$new_mldonkey_dir/users.ini.dpkg" \
"$new_mldonkey_dir/users.ini.old" \
"$new_mldonkey_dir/users.ini.tmp"; do
$DEBUG && echo -n "Changing owner and file permission of $file: "
if ! dpkg-statoverride --list "$file" >/dev/null; then
# BUG: cf dpkg-statoverride above
if [ -e "$file" ]; then
chown $run_as_user:$mldonkey_group "$file"
chmod 0600 "$file"
$DEBUG && echo "done."
else
$DEBUG && echo "$file doesn't exist."
fi
else
$DEBUG && echo "$file is listed in dpkg-statoverride."
fi
done
################################
# /etc/default/mldonkey-server #
################################
CONF_NEW=`tempfile`
$DEBUG && echo -n "Writing new values to $CONF_NEW: "
cat > "$CONF_NEW" <<EOF
# MLDonkey configuration file
# This file is loaded by /etc/init.d/mldonkey-server.
# This file is managed using ucf(1).
MLDONKEY_DIR=$new_mldonkey_dir
MLDONKEY_USER=$run_as_user
MLDONKEY_GROUP=$mldonkey_group
MLDONKEY_UMASK=$mldonkey_umask
LAUNCH_AT_STARTUP=$launch_at_startup
EOF
ucf --debconf-ok "$CONF_NEW" "$CONF"
$DEBUG && echo "done."
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
db_stop
# Automatically added by dh_installinit
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
if [ -x "/etc/init.d/mldonkey-server" ]; then
update-rc.d mldonkey-server start 98 2 3 4 5 . stop 20 0 1 6 . >/dev/null
fi
if [ -x "/etc/init.d/mldonkey-server" ] || [ -e "/etc/init/mldonkey-server.conf" ]; then
invoke-rc.d mldonkey-server start || init_error
fi
fi
# End automatically added section
|