wok-6.x view boxbackup-server/receipt @ rev 17941

boxbackup-server, privoxy: fix post_install (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Apr 15 10:45:00 2015 +0200 (2015-04-15)
parents 82816c8eb08b
children fca172c323cf
line source
1 # SliTaz package receipt.
3 PACKAGE="boxbackup-server"
4 VERSION="0.11.1"
5 CATEGORY="network"
6 SHORT_DESC="Server for the BoxBackup on-line backup system"
7 MAINTAINER="domcox@slitaz.org"
8 LICENSE="GPL2"
9 SOURCE="boxbackup"
10 TARBALL="$SOURCE-$VERSION.tgz"
11 WEB_SITE="http://www.boxbackup.org/"
12 # stable
13 # WGET_URL="$SF_MIRROR/$SOURCE/$TARBALL"
14 #WGET_URL="http://www.boxbackup.org/svn/box/packages/$TARBALL"
15 WGET_URL="http://www.boxbackup.org/export/3106/box/packages/$TARBALL"
16 TAGS="backup automatic server network"
18 DEPENDS="db libedit openssl perl zlib gcc-lib-base"
19 BUILD_DEPENDS="db-dev libedit-dev openssl-dev zlib-dev"
21 # Configuration variables
22 HOSTNAME=$(ifconfig | awk -F ":" '/cast/ {print substr($2,0, index($2," ")-1) }')
23 CONF_DIR="/etc/boxbackup"
24 DATA_DIR="/var/lib/bbstored"
25 CA_DIR="${CONF_DIR}/ca"
26 BBUSER="bbstored"
28 # Rules to configure and make the package.
29 compile_rules()
30 {
31 ./configure --prefix=/usr $CONFIGURE_ARGS &&
32 make -j1 && {
33 mkdir -p $DESTDIR
34 cp -a parcels/boxbackup-${VERSION}-backup-client-linux-gnu $DESTDIR
35 cp -a parcels/boxbackup-${VERSION}-backup-server-linux-gnu $DESTDIR
36 rm -f $DESTDIR/boxbackup-${VERSION}-backup-server-linux-gnu/*.*
37 }
38 }
40 # Rules to gen a SliTaz package suitable for Tazpkg.
41 genpkg_rules()
42 {
43 mkdir -p $fs/usr/bin
44 cp -a $install/boxbackup-${VERSION}-backup-server-linux-gnu/bb* $fs/usr/bin
45 cp -a $install/boxbackup-${VERSION}-backup-server-linux-gnu/ra* $fs/usr/bin
46 mkdir -p $fs/etc/init.d
47 cp -a $stuff/bbstored $fs/etc/init.d
48 }
51 # Pre and post install commands for Tazpkg.
53 pre_install()
54 {
55 # Stop daemon
56 if [ -e /var/run/bbstored.pid ]; then
57 /etc/init.d/bbstored stop
58 fi
59 }
61 post_install()
62 {
63 # default conf dir is now /etc/boxbackup
64 if [ ! -e $1/etc/box/bbstored.conf ]; then
65 mv /etc/box $1$CONF_DIR
66 fi
68 # adduser BBUSER if needed
69 if ! grep -q $BBUSER $1/etc/passwd; then
70 echo -n "Adding user '$BBUSER'..."
71 echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> $1/etc/passwd
72 echo $BBUSER':!:14013:0:99999:7:::' >> $1/etc/shadow
73 echo $BBUSER':x:505:' >> $1/etc/group
74 echo $BBUSER':!::' >> $1/etc/gshadow
75 status
76 fi
78 # Create config is needed
79 if [ ! -e $1$CONF_DIR ]; then
80 mkdir -p $1$CONF_DIR &&
81 chroot $1/ chown $BBUSER $CONF_DIR &&
82 chmod 700 $1$CONF_DIR
83 fi
85 if [ ! -e $1$DATA_DIR/backup ]; then
86 # Creating backup dir
87 echo -n "Creating backup directory..."
88 mkdir -p $1$DATA_DIR/backup &&
89 chroot $1/ chown -R $BBUSER $DATA_DIR &&
90 chmod -R 700 $1$DATA_DIR
91 status
92 fi
94 if [ ! -e $1$CONF_DIR/raidfile.conf ]; then
95 # RAID Setup
96 echo -n "Disabling deprecated userland RAID..."
97 chroot $1/ /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
98 status
99 chroot $1/ chown -R $BBUSER $CONF_DIR/raidfile.conf &&
100 chmod 700 -R $1$CONF_DIR/raidfile.conf
101 fi
103 if [ ! -e $1$CONF_DIR/bbstored.conf ]; then
104 # Setting hostname
105 echo -n "Setting hostname... "
106 if [ $(chroot $1/ hostname -f 2>1 > /dev/null;echo $?) -eq 0 ]; then
107 HOSTNAME=$(chroot $1/ hostname -f)
108 fi
109 if [ -z $HOSTNAME ]; then
110 HOSTNAME="127.0.0.1"
111 fi
112 export $HOSTNAME
113 echo $HOSTNAME
115 # Setting up the CA environment
116 echo -n "Creating certificates..."
117 chroot $1/ /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
118 status
120 # Generate server certificate request
121 echo -n "Generate server certificate request..."
122 chroot $1/ bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
123 status
125 # Sign the server certificate
126 echo -n "Sign the server certificate..."
127 chroot $1/ openssl x509 -req -sha1 -extensions usr_crt \
128 -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \
129 -CA $CA_DIR/roots/serverCA.pem \
130 -CAkey $CA_DIR/keys/serverRootKey.pem \
131 -out $CA_DIR/servers/${HOSTNAME}-cert.pem \
132 -days 5000 2>1 > /dev/null
133 status
135 # Preparing the server certificates
136 echo -n "Installing server certificate..."
137 cp -a $1$CA_DIR/servers/${HOSTNAME}-cert.pem $1$CONF_DIR/$BBUSER
138 status
139 echo -n "Installing client certificate..."
140 cp -a $1$CA_DIR/roots/clientCA.pem $1$CONF_DIR/$BBUSER
141 status
143 # Securing $CONF_DIR
144 chroot $1/ chown -R $BBUSER $CONF_DIR/bbstored* &&
145 chmod 700 -R $1$CONF_DIR/bbstored*
146 fi
148 if [ -e $1$CA_DIR ]; then
149 # Warning
150 echo
151 echo "IMPORTANT NOTE:"
152 echo "--------------"
153 echo "The certificate authority directory $CA_DIR is intended to be"
154 echo "moved to another system. It should not be kept on the backup server"
155 echo "to limit the impact of a server compromise."
156 fi
157 }
159 # Pre and post remove commands for Tazpkg
161 pre_remove()
162 {
163 /etc/init.d/bbstored stop
164 }
166 post_remove()
167 {
168 if grep -q $BBUSER $1/etc/passwd; then
169 echo -n "Removing $BBUSER user..."
170 deluser bbstored
171 status
172 fi
173 # Delete data
174 if [ -e $DATA_DIR ]; then
175 echo -n "Removing all backup data..."
176 rm -r $DATA_DIR
177 status
178 fi
179 # Delete bbstored conf files
180 if [ -e $CONF_DIR/bbstored.conf ]; then
181 echo -n "Removing config files..."
182 rm -rf $CONF_DIR/bbstored
183 rm -f $CONF_DIR/raidfile.conf
184 rm -f $CONF_DIR/bbstored.conf
185 status
186 fi
187 # Delete certificates
188 if [ -e $CA_DIR ]; then
189 echo -n "Removing certificates..."
190 rm -r $CA_DIR
191 status
192 fi
193 # Delete $CONF_DIR (if empty)
194 if [ $(ls -lA $CONF_DIR | wc -l) -eq 0 ]; then
195 echo -n "Removing $CONF_DIR..."
196 rm -r $CONF_DIR
197 status
198 fi
199 # Delete PID, sock files
200 rm -f /var/run/bbstored.*
201 }