wok-4.x view boxbackup-server/receipt @ rev 5320

Up: boxbackup-server (0.11rc7)
author Dominique Corbex <domcox@slitaz.org>
date Wed Apr 21 19:52:28 2010 +0200 (2010-04-21)
parents 395ec8205cff
children d7a620ee3f50
line source
1 # SliTaz package receipt.
3 PACKAGE="boxbackup-server"
4 VERSION="0.11rc7"
5 CATEGORY="network"
6 SHORT_DESC="Server for the BoxBackup on-line backup system"
7 MAINTAINER="domcox@users.sourceforge.net"
8 DEPENDS="db libedit openssl perl zlib gcc-lib-base"
9 BUILD_DEPENDS="db-dev libedit-dev openssl-dev zlib-dev"
10 SOURCE="boxbackup"
11 TARBALL="$SOURCE-$VERSION.tgz"
12 WEB_SITE="http://www.boxbackup.org/"
13 # stable
14 # WGET_URL="$SF_MIRROR/$SOURCE/$TARBALL"
15 WGET_URL="http://www.boxbackup.org/svn/box/packages/$TARBALL"
16 TAGS="backup automatic server network"
18 # Configuration variables
19 HOSTNAME=`ifconfig | awk -F ":" '/cast/ {print substr($2,0, index($2," ")-1) }'`
20 CONF_DIR="/etc/box"
21 DATA_DIR="/var/lib/bbstored"
22 CA_DIR="${CONF_DIR}/ca"
23 BBUSER="bbstored"
25 # Rules to configure and make the package.
26 compile_rules()
27 {
28 cd $src
29 # while read patch_file; do
30 # if [ -f done.$patch_file ]; then
31 # echo "Skipping $patch_file"
32 # continue
33 # fi
34 # echo "Apply $patch_file"
35 # patch -p1 < ../stuff/$patch_file || return 1
36 # touch done.$patch_file
37 # done <<EOF
38 #boxbackup-0.10_gcc43.u
39 #EOF
40 ./configure --prefix=/usr $CONFIGURE_ARGS &&
41 make
42 }
44 # Rules to gen a SliTaz package suitable for Tazpkg.
45 genpkg_rules()
46 {
47 _pkg=$WOK/$PACKAGE/${SOURCE}-${VERSION}/parcels/boxbackup-${VERSION}-backup-server-linux-gnu
48 mkdir -p $fs/usr/bin
49 cp -a $_pkg/bb* $fs/usr/bin
50 cp -a $_pkg/ra* $fs/usr/bin
51 mkdir -p $fs/etc/init.d
52 cp -a stuff/bbstored $fs/etc/init.d
53 }
56 # Pre and post install commands for Tazpkg.
58 pre_install()
59 {
60 # Stop daemon
61 if [ -e /var/run/bbstored.pid ]; then
62 /etc/init.d/bbstored stop
63 fi
64 }
66 post_install()
67 {
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 $CONF_DIR ]; then
80 mkdir -p $CONF_DIR && chown $BBUSER $CONF_DIR && chmod 700 $CONF_DIR
81 fi
83 if [ ! -e $DATA_DIR/backup ]; then
84 # Creating backup dir
85 echo -n "Creating backup directory..."
86 mkdir -p $DATA_DIR/backup && chown -R $BBUSER $DATA_DIR && chmod -R 700 $DATA_DIR
87 status
88 fi
90 if [ ! -e $CONF_DIR/raidfile.conf ]; then
91 # RAID Setup
92 echo -n "Disabling deprecated userland RAID..."
93 /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
94 status
95 chown -R $BBUSER $CONF_DIR/raidfile.conf && chmod 700 -R $CONF_DIR/raidfile.conf
96 fi
98 if [ ! -e $CONF_DIR/bbstored.conf ]; then
99 # Setting hostname
100 echo -n "Setting hostname... "
101 if [ `hostname -f 2>1 > /dev/null;echo $?` -eq 0 ]; then
102 HOSTNAME=`hostname -f`
103 fi
104 if [ -z $HOSTNAME ]; then
105 HOSTNAME="127.0.0.1"
106 fi
107 echo $HOSTNAME
109 # Setting up the CA environment
110 echo -n "Creating certificates..."
111 /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
112 status
114 # Generate server certificate request
115 echo -n "Generate server certificate request..."
116 bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
117 status
119 # Sign the server certificate
120 echo -n "Sign the server certificate..."
121 openssl x509 -req -sha1 -extensions usr_crt \
122 -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \
123 -CA $CA_DIR/roots/serverCA.pem \
124 -CAkey $CA_DIR/keys/serverRootKey.pem \
125 -out $CA_DIR/servers/${HOSTNAME}-cert.pem \
126 -days 5000 2>1 > /dev/null
127 status
129 # Preparing the server certificates
130 echo -n "Installing server certificate..."
131 cp -a $CA_DIR/servers/${HOSTNAME}-cert.pem $CONF_DIR/$BBUSER
132 status
133 echo -n "Installing client certificate..."
134 cp -a $CA_DIR/roots/clientCA.pem $CONF_DIR/$BBUSER
135 status
137 # Securing $CONF_DIR
138 chown -R $BBUSER $CONF_DIR/bbstored* && chmod 700 -R $CONF_DIR/bbstored*
139 fi
141 if [ -e $CA_DIR ]; then
142 # Warning
143 echo
144 echo "IMPORTANT NOTE:"
145 echo "--------------"
146 echo "The certificate authority directory $CA_DIR is intended to be"
147 echo "moved to another system. It should not be kept on the backup server"
148 echo "to limit the impact of a server compromise."
149 fi
150 }
152 # Pre and post remove commands for Tazpkg
154 pre_remove()
155 {
156 /etc/init.d/bbstored stop
157 }
159 post_remove()
160 {
161 if grep -q $BBUSER $1/etc/passwd; then
162 echo -n "Removing $BBUSER user..."
163 deluser bbstored
164 status
165 fi
166 # Delete data
167 if [ -e $DATA_DIR ]; then
168 echo -n "Removing all backup data..."
169 rm -r $DATA_DIR
170 status
171 fi
172 # Delete bbstored conf files
173 if [ -e $CONF_DIR/bbstored.conf ]; then
174 echo -n "Removing config files..."
175 rm -rf $CONF_DIR/bbstored
176 rm -f $CONF_DIR/raidfile.conf
177 rm -f $CONF_DIR/bbstored.conf
178 status
179 fi
180 # Delete certificates
181 if [ -e $CA_DIR ]; then
182 echo -n "Removing certificates..."
183 rm -r $CA_DIR
184 status
185 fi
186 # Delete $CONF_DIR (if empty)
187 if [ `ls -lA $CONF_DIR | wc -l` -eq 0 ]; then
188 echo -n "Removing $CONF_DIR..."
189 rm -r $CONF_DIR
190 status
191 fi
192 # Delete PID, sock files
193 rm -f /var/run/bbstored.*
194 }