wok-next view boxbackup-server/receipt @ rev 3568

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