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