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

boxbackup-server: do not compute $_pkg
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Mar 04 09:06:40 2011 +0100 (2011-03-04)
parents d7a620ee3f50
children 2696d353965c
line source
1 # SliTaz package receipt.
3 PACKAGE="boxbackup-server"
4 VERSION="0.11rc8"
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 ./configure --prefix=/usr $CONFIGURE_ARGS &&
30 make -j1 && {
31 mkdir -p $DESTDIR
32 cp -a parcels/boxbackup-${VERSION}-backup-server-linux-gnu/* $DESTDIR
33 }
34 }
36 # Rules to gen a SliTaz package suitable for Tazpkg.
37 genpkg_rules()
38 {
39 mkdir -p $fs/usr/bin
40 cp -a $_pkg/bb* $fs/usr/bin
41 cp -a $_pkg/ra* $fs/usr/bin
42 mkdir -p $fs/etc/init.d
43 cp -a stuff/bbstored $fs/etc/init.d
44 }
47 # Pre and post install commands for Tazpkg.
49 pre_install()
50 {
51 # Stop daemon
52 if [ -e /var/run/bbstored.pid ]; then
53 /etc/init.d/bbstored stop
54 fi
55 }
57 post_install()
58 {
59 # adduser BBUSER if needed
60 if ! grep -q $BBUSER $1/etc/passwd; then
61 echo -n "Adding user '$BBUSER'..."
62 echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> $1/etc/passwd
63 echo $BBUSER':!:14013:0:99999:7:::' >> $1/etc/shadow
64 echo $BBUSER':x:505:' >> $1/etc/group
65 echo $BBUSER':!::' >> $1/etc/gshadow
66 status
67 fi
69 # Create config is needed
70 if [ ! -e $CONF_DIR ]; then
71 mkdir -p $CONF_DIR && chown $BBUSER $CONF_DIR && chmod 700 $CONF_DIR
72 fi
74 if [ ! -e $DATA_DIR/backup ]; then
75 # Creating backup dir
76 echo -n "Creating backup directory..."
77 mkdir -p $DATA_DIR/backup && chown -R $BBUSER $DATA_DIR && chmod -R 700 $DATA_DIR
78 status
79 fi
81 if [ ! -e $CONF_DIR/raidfile.conf ]; then
82 # RAID Setup
83 echo -n "Disabling deprecated userland RAID..."
84 /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
85 status
86 chown -R $BBUSER $CONF_DIR/raidfile.conf && chmod 700 -R $CONF_DIR/raidfile.conf
87 fi
89 if [ ! -e $CONF_DIR/bbstored.conf ]; then
90 # Setting hostname
91 echo -n "Setting hostname... "
92 if [ `hostname -f 2>1 > /dev/null;echo $?` -eq 0 ]; then
93 HOSTNAME=`hostname -f`
94 fi
95 if [ -z $HOSTNAME ]; then
96 HOSTNAME="127.0.0.1"
97 fi
98 echo $HOSTNAME
100 # Setting up the CA environment
101 echo -n "Creating certificates..."
102 /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
103 status
105 # Generate server certificate request
106 echo -n "Generate server certificate request..."
107 bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
108 status
110 # Sign the server certificate
111 echo -n "Sign the server certificate..."
112 openssl x509 -req -sha1 -extensions usr_crt \
113 -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \
114 -CA $CA_DIR/roots/serverCA.pem \
115 -CAkey $CA_DIR/keys/serverRootKey.pem \
116 -out $CA_DIR/servers/${HOSTNAME}-cert.pem \
117 -days 5000 2>1 > /dev/null
118 status
120 # Preparing the server certificates
121 echo -n "Installing server certificate..."
122 cp -a $CA_DIR/servers/${HOSTNAME}-cert.pem $CONF_DIR/$BBUSER
123 status
124 echo -n "Installing client certificate..."
125 cp -a $CA_DIR/roots/clientCA.pem $CONF_DIR/$BBUSER
126 status
128 # Securing $CONF_DIR
129 chown -R $BBUSER $CONF_DIR/bbstored* && chmod 700 -R $CONF_DIR/bbstored*
130 fi
132 if [ -e $CA_DIR ]; then
133 # Warning
134 echo
135 echo "IMPORTANT NOTE:"
136 echo "--------------"
137 echo "The certificate authority directory $CA_DIR is intended to be"
138 echo "moved to another system. It should not be kept on the backup server"
139 echo "to limit the impact of a server compromise."
140 fi
141 }
143 # Pre and post remove commands for Tazpkg
145 pre_remove()
146 {
147 /etc/init.d/bbstored stop
148 }
150 post_remove()
151 {
152 if grep -q $BBUSER $1/etc/passwd; then
153 echo -n "Removing $BBUSER user..."
154 deluser bbstored
155 status
156 fi
157 # Delete data
158 if [ -e $DATA_DIR ]; then
159 echo -n "Removing all backup data..."
160 rm -r $DATA_DIR
161 status
162 fi
163 # Delete bbstored conf files
164 if [ -e $CONF_DIR/bbstored.conf ]; then
165 echo -n "Removing config files..."
166 rm -rf $CONF_DIR/bbstored
167 rm -f $CONF_DIR/raidfile.conf
168 rm -f $CONF_DIR/bbstored.conf
169 status
170 fi
171 # Delete certificates
172 if [ -e $CA_DIR ]; then
173 echo -n "Removing certificates..."
174 rm -r $CA_DIR
175 status
176 fi
177 # Delete $CONF_DIR (if empty)
178 if [ `ls -lA $CONF_DIR | wc -l` -eq 0 ]; then
179 echo -n "Removing $CONF_DIR..."
180 rm -r $CONF_DIR
181 status
182 fi
183 # Delete PID, sock files
184 rm -f /var/run/bbstored.*
185 }