postinst is in boxbackup-server 0.11.1~r2837-1.
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 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | #! /bin/sh
# postinst script for boxbackup-server
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# quoting from the policy:
# Any necessary prompting should almost always be confined to the
# post-installation script, and should be protected with a conditional
# so that unnecessary prompting doesn't happen if a package's
# installation fails and the `postinst' is called with `abort-upgrade',
# `abort-remove' or `abort-deconfigure'.
#loading debconf module
. /usr/share/debconf/confmodule
CONFDIR=/etc/boxbackup
DEBCONFRAID=$CONFDIR/raidfile.debconf
DEBCONFBB=$CONFDIR/bbstored.debconf
RAIDCONF=$CONFDIR/raidfile.conf
BBCONF=$CONFDIR/bbstored.conf
BBACCOUNTS=$CONFDIR/bbstored/boxbackup-server-accounts.txt
BBUSER=bbstored
BBPRIVKEY=$CONFDIR/bbstored/boxbackup-server-key.pem
BBCERTREQ=$CONFDIR/bbstored/boxbackup-server-cert-req.pem
BBCERT=$CONFDIR/bbstored/boxbackup-server-cert.pem
BBCACERT=$CONFDIR/bbstored/boxbackup-client-ca-cert.pem
case "$1" in
configure)
# Set up the bbstored user
if [ -z "`getent passwd $BBUSER`" ]; then
echo "Creating $BBUSER user." >&2
adduser --system --no-create-home \
--disabled-password --disabled-login \
--shell /bin/false --group --home /var $BBUSER
else
echo "User $BBUSER already exists." >&2
fi
db_get boxbackup-server/debconf
if [ "$RET" = "true" ]; then
# Generate configuration files
# raidfile.conf
echo "#To reconfigure boxbackup-server run #dpkg-reconfigure boxbackup-server" >> $DEBCONFRAID
echo "disc0" >> $DEBCONFRAID
echo "{" >> $DEBCONFRAID
echo " SetNumber = 0" >> $DEBCONFRAID
db_get boxbackup-server/raidBlockSize
echo " BlockSize = $RET" >> $DEBCONFRAID
db_get boxbackup-server/raidDirectories
DIR1=`echo "$RET" | awk '{ print $1 }'`
DIR2=`echo "$RET" | awk '{ print $2 }'`
DIR3=`echo "$RET" | awk '{ print $3 }'`
if [ -n $DIR1 ]; then
if [ -z "$DIR2" -o -z "$DIR3" ]; then
DIR2=$DIR1
DIR3=$DIR1
fi
fi
echo " Dir0 = $DIR1" >> $DEBCONFRAID
echo " Dir1 = $DIR2" >> $DEBCONFRAID
echo " Dir2 = $DIR3" >> $DEBCONFRAID
echo "}" >> $DEBCONFRAID
# Handle backup directories creation/permissions
for dir in "$DIR1" "$DIR2" "$DIR3"; do
if [ -d "$dir/backup" ]; then
# need stat package on Woody
#if (`stat -c %U $dir/backup` != $BBUSER); then
if [ `ls -ld $dir/backup | awk '{ print $3 }'` != "$BBUSER" ]; then
echo "Incorrect owner of backup directory. Changing it to $BBUSER..." >&2
chown $BBUSER:$BBUSER $dir/backup
fi
#if [ `stat -c %a $dir/backup` != "700" ]; then
if [ `ls -ld $dir/backup | awk '{ print $1 }'` != "drwx------" ]; then
chmod 700 $dir/backup
fi
else
echo "Creating $dir/backup directory..." >&2
mkdir -p $dir/backup
chown $BBUSER:$BBUSER $dir/backup
chmod 700 $dir/backup
fi
done
if ! dpkg-statoverride --list $CONFDIR/bbstored > /dev/null; then
dpkg-statoverride --update --add $BBUSER $BBUSER 700 $CONFDIR/bbstored
fi
# Accounts file
if [ ! -e $BBACCOUNTS ]; then
touch $BBACCOUNTS
fi
#if [ `stat -c %U $BBACCOUNTS` != $BBUSER ]; then
if [ `ls -ld $BBACCOUNTS | awk '{ print $3 }'` != "$BBUSER" ]; then
chown $BBUSER:$BBUSER $BBACCOUNTS
fi
#if [ `stat -c %a $BBACCOUNTS` != "600" ]; then
if [ `ls -ld $BBACCOUNTS | awk '{ print $1 }'` != "drw-------" ]; then
chmod 600 $BBACCOUNTS
fi
SERVNAME=`hostname --fqdn`
# SSL stuff
if [ ! -e $BBPRIVKEY -a ! -e $BBCERT ]; then
db_get boxbackup-server/generateCertificate
if [ "$RET" = "true" ]; then
if ! openssl genrsa -out $BBPRIVKEY 2048 >&2; then
echo "Private key generation failed! Check why." >&2
else
chown $BBUSER: $BBPRIVKEY
chmod 600 $BBPRIVKEY || true
fi
if ! openssl req -new -key $BBPRIVKEY -sha1 -out $BBCERTREQ >&2 <<EOF
.
.
.
.
.
$SERVNAME
.
.
.
EOF
then
echo "Certificate request generation failed ! Check why." >&2
fi
fi
fi
# Generate bbstored.conf
echo "#To reconfigure boxbackup-server run #dpkg-reconfigure boxbackup-server" >> $DEBCONFBB
echo "RaidFileConf = $RAIDCONF" >> $DEBCONFBB
echo "AccountDatabase = $BBACCOUNTS" >> $DEBCONFBB
echo >> $DEBCONFBB
echo "# Uncomment this line to see exactly what commands are being received from clients." >> $DEBCONFBB
echo "# ExtendedLogging = yes" >> $DEBCONFBB
echo >> $DEBCONFBB
echo "# scan all accounts for files which need deleting every 15 minutes." >> $DEBCONFBB
echo "TimeBetweenHousekeeping = 900" >> $DEBCONFBB
echo >> $DEBCONFBB
echo "Server" >> $DEBCONFBB
echo "{" >> $DEBCONFBB
echo " PidFile = /var/run/bbstored.pid" >> $DEBCONFBB
echo " User = bbstored" >> $DEBCONFBB
echo " ListenAddresses = inet:$SERVNAME" >> $DEBCONFBB
echo " CertificateFile = $BBCERT" >> $DEBCONFBB
echo " PrivateKeyFile = $BBPRIVKEY" >> $DEBCONFBB
echo " TrustedCAsFile = $BBCACERT" >> $DEBCONFBB
echo "}" >> $DEBCONFBB
if [ -x "`which ucf`" ]; then
ucf --three-way --debconf-ok $DEBCONFRAID $RAIDCONF
fi
rm -f $DEBCONFRAID
chmod 644 $RAIDCONF || true
chown root:root $RAIDCONF || true
if [ -x "`which ucf`" ]; then
ucf --three-way --debconf-ok $DEBCONFBB $BBCONF
fi
rm -f $DEBCONFBB
chmod 644 $BBCONF || true
chown root:root $BBCONF || true
fi
db_stop
;;
abort-upgrade|abort-remove|abort-deconfigure)
db_stop
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
db_stop
exit 1
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
# Automatically added by dh_installinit
if [ -x "/etc/init.d/boxbackup-server" ]; then
if [ ! -e "/etc/init/boxbackup-server.conf" ]; then
update-rc.d boxbackup-server defaults >/dev/null
fi
invoke-rc.d boxbackup-server start || exit $?
fi
# End automatically added section
exit 0
|