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