wok-6.x view boxbackup-server/receipt @ rev 3937
mirror-tools: update tazwok.conf.mirror
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Aug 21 21:17:15 2009 +0200 (2009-08-21) |
parents | f9e78593eb58 |
children | 395ec8205cff |
line source
1 # SliTaz package receipt.
3 PACKAGE="boxbackup-server"
4 VERSION="0.10"
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"
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 WGET_URL="$SF_MIRROR/$SOURCE/$TARBALL"
14 TAGS="backup automatic server network"
16 # Configuration variables
17 HOSTNAME=`ifconfig | awk -F ":" '/cast/ {print substr($2,0, index($2," ")-1) }'`
18 CONF_DIR="/etc/box"
19 DATA_DIR="/var/lib/bbstored"
20 CA_DIR="${CONF_DIR}/ca"
21 BBUSER="bbstored"
23 # Rules to configure and make the package.
24 compile_rules()
25 {
26 cd $src
27 while read patch_file; do
28 if [ -f done.$patch_file ]; then
29 echo "Skipping $patch_file"
30 continue
31 fi
32 echo "Apply $patch_file"
33 patch -p1 < ../stuff/$patch_file || return 1
34 touch done.$patch_file
35 done <<EOF
36 boxbackup-0.10_gcc43.u
37 EOF
38 ./configure --prefix=/usr $CONFIGURE_ARGS
39 make
40 }
42 # Rules to gen a SliTaz package suitable for Tazpkg.
43 genpkg_rules()
44 {
45 _pkg=$WOK/$PACKAGE/${SOURCE}-${VERSION}/parcels/boxbackup-${VERSION}-backup-server-linux-gnu
46 mkdir -p $fs/usr/bin
47 cp -a $_pkg/bb* $fs/usr/bin
48 cp -a $_pkg/ra* $fs/usr/bin
49 mkdir -p $fs/etc/init.d
50 cp -a stuff/bbstored $fs/etc/init.d
51 }
54 # Pre and post install commands for Tazpkg.
56 pre_install()
57 {
58 # Stop daemon
59 if [ -e /var/run/bbstored.pid ]; then
60 /etc/init.d/bbstored stop
61 fi
62 }
64 post_install()
65 {
66 # adduser BBUSER if needed
67 if ! grep -q $BBUSER $1/etc/passwd; then
68 echo -n "Adding user '$BBUSER'..."
69 echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> $1/etc/passwd
70 echo $BBUSER':!:14013:0:99999:7:::' >> $1/etc/shadow
71 echo $BBUSER':x:505:' >> $1/etc/group
72 echo $BBUSER':!::' >> $1/etc/gshadow
73 status
74 fi
76 # Create config is needed
77 if [ ! -e $CONF_DIR ]; then
78 mkdir -p $CONF_DIR && chown $BBUSER $CONF_DIR && chmod 700 $CONF_DIR
79 fi
81 if [ ! -e $DATA_DIR/backup ]; then
82 # Creating backup dir
83 echo -n "Creating backup directory..."
84 mkdir -p $DATA_DIR/backup && chown -R $BBUSER $DATA_DIR && chmod -R 700 $DATA_DIR
85 status
86 fi
88 if [ ! -e $CONF_DIR/raidfile.conf ]; then
89 # RAID Setup
90 echo -n "Disabling deprecated userland RAID..."
91 /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
92 status
93 chown -R $BBUSER $CONF_DIR/raidfile.conf && chmod 700 -R $CONF_DIR/raidfile.conf
94 fi
96 if [ ! -e $CONF_DIR/bbstored.conf ]; then
97 # Setting hostname
98 echo -n "Setting hostname... "
99 if [ `hostname -f 2>1 > /dev/null;echo $?` -eq 0 ]; then
100 HOSTNAME=`hostname -f`
101 fi
102 if [ -z $HOSTNAME ]; then
103 HOSTNAME="127.0.0.1"
104 fi
105 echo $HOSTNAME
107 # Setting up the CA environment
108 echo -n "Creating certificates..."
109 /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
110 status
112 # Generate server certificate request
113 echo -n "Generate server certificate request..."
114 bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
115 status
117 # Sign the server certificate
118 echo -n "Sign the server certificate..."
119 openssl x509 -req -sha1 -extensions usr_crt \
120 -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \
121 -CA $CA_DIR/roots/serverCA.pem \
122 -CAkey $CA_DIR/keys/serverRootKey.pem \
123 -out $CA_DIR/servers/${HOSTNAME}-cert.pem \
124 -days 5000 2>1 > /dev/null
125 status
127 # Preparing the server certificates
128 echo -n "Installing server certificate..."
129 cp -a $CA_DIR/servers/${HOSTNAME}-cert.pem $CONF_DIR/$BBUSER
130 status
131 echo -n "Installing client certificate..."
132 cp -a $CA_DIR/roots/clientCA.pem $CONF_DIR/$BBUSER
133 status
135 # Securing $CONF_DIR
136 chown -R $BBUSER $CONF_DIR/bbstored* && chmod 700 -R $CONF_DIR/bbstored*
137 fi
139 if [ -e $CA_DIR ]; then
140 # Warning
141 echo
142 echo "IMPORTANT NOTE:"
143 echo "--------------"
144 echo "The certificate authority directory $CA_DIR is intended to be"
145 echo "moved to another system. It should not be kept on the backup server"
146 echo "to limit the impact of a server compromise."
147 fi
148 }
150 # Pre and post remove commands for Tazpkg
152 pre_remove()
153 {
154 /etc/init.d/bbstored stop
155 }
157 post_remove()
158 {
159 if grep -q $BBUSER $1/etc/passwd; then
160 echo -n "Removing $BBUSER user..."
161 deluser bbstored
162 status
163 fi
164 # Delete data
165 if [ -e $DATA_DIR ]; then
166 echo -n "Removing all backup data..."
167 rm -r $DATA_DIR
168 status
169 fi
170 # Delete bbstored conf files
171 if [ -e $CONF_DIR/bbstored.conf ]; then
172 echo -n "Removing config files..."
173 rm -rf $CONF_DIR/bbstored
174 rm -f $CONF_DIR/raidfile.conf
175 rm -f $CONF_DIR/bbstored.conf
176 status
177 fi
178 # Delete certificates
179 if [ -e $CA_DIR ]; then
180 echo -n "Removing certificates..."
181 rm -r $CA_DIR
182 status
183 fi
184 # Delete $CONF_DIR (if empty)
185 if [ `ls -lA $CONF_DIR | wc -l` -eq 0 ]; then
186 echo -n "Removing $CONF_DIR..."
187 rm -r $CONF_DIR
188 status
189 fi
190 # Delete PID, sock files
191 rm -f /var/run/bbstored.*
192 }