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

freetype: splashutils *needs* static lib
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Sep 30 15:03:13 2013 +0000 (2013-09-30)
parents 54b68abc52df
children 82816c8eb08b
line source
1 # SliTaz package receipt.
3 PACKAGE="boxbackup-server"
4 VERSION="0.11.1"
5 CATEGORY="network"
6 SHORT_DESC="Server for the BoxBackup on-line backup system"
7 MAINTAINER="domcox@slitaz.org"
8 LICENSE="GPL2"
9 SOURCE="boxbackup"
10 TARBALL="$SOURCE-$VERSION.tgz"
11 WEB_SITE="http://www.boxbackup.org/"
12 # stable
13 # WGET_URL="$SF_MIRROR/$SOURCE/$TARBALL"
14 #WGET_URL="http://www.boxbackup.org/svn/box/packages/$TARBALL"
15 WGET_URL="http://www.boxbackup.org/export/3106/box/packages/$TARBALL"
16 TAGS="backup automatic server network"
18 DEPENDS="db libedit openssl perl zlib gcc-lib-base"
19 BUILD_DEPENDS="db-dev libedit-dev openssl-dev zlib-dev"
21 # Configuration variables
22 HOSTNAME=$(ifconfig | awk -F ":" '/cast/ {print substr($2,0, index($2," ")-1) }')
23 CONF_DIR="/etc/boxbackup"
24 DATA_DIR="/var/lib/bbstored"
25 CA_DIR="${CONF_DIR}/ca"
26 BBUSER="bbstored"
28 # Rules to configure and make the package.
29 compile_rules()
30 {
31 cd $src
32 ./configure --prefix=/usr $CONFIGURE_ARGS &&
33 make -j1 && {
34 mkdir -p $DESTDIR
35 cp -a parcels/boxbackup-${VERSION}-backup-client-linux-gnu $DESTDIR
36 cp -a parcels/boxbackup-${VERSION}-backup-server-linux-gnu $DESTDIR
37 rm -f $DESTDIR/boxbackup-${VERSION}-backup-server-linux-gnu/*.*
38 }
39 }
41 # Rules to gen a SliTaz package suitable for Tazpkg.
42 genpkg_rules()
43 {
44 mkdir -p $fs/usr/bin
45 cp -a $install/boxbackup-${VERSION}-backup-server-linux-gnu/bb* $fs/usr/bin
46 cp -a $install/boxbackup-${VERSION}-backup-server-linux-gnu/ra* $fs/usr/bin
47 mkdir -p $fs/etc/init.d
48 cp -a $stuff/bbstored $fs/etc/init.d
49 }
52 # Pre and post install commands for Tazpkg.
54 pre_install()
55 {
56 # Stop daemon
57 if [ -e /var/run/bbstored.pid ]; then
58 /etc/init.d/bbstored stop
59 fi
60 }
62 post_install()
63 {
64 # default conf dir is now /etc/boxbackup
65 if [ ! -e /etc/box/bbstored.conf ]; then
66 mv /etc/box $CONF_DIR
67 fi
69 # adduser BBUSER if needed
70 if ! grep -q $BBUSER $1/etc/passwd; then
71 echo -n "Adding user '$BBUSER'..."
72 echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> $1/etc/passwd
73 echo $BBUSER':!:14013:0:99999:7:::' >> $1/etc/shadow
74 echo $BBUSER':x:505:' >> $1/etc/group
75 echo $BBUSER':!::' >> $1/etc/gshadow
76 status
77 fi
79 # Create config is needed
80 if [ ! -e $CONF_DIR ]; then
81 mkdir -p $CONF_DIR && chown $BBUSER $CONF_DIR && chmod 700 $CONF_DIR
82 fi
84 if [ ! -e $DATA_DIR/backup ]; then
85 # Creating backup dir
86 echo -n "Creating backup directory..."
87 mkdir -p $DATA_DIR/backup && chown -R $BBUSER $DATA_DIR && chmod -R 700 $DATA_DIR
88 status
89 fi
91 if [ ! -e $CONF_DIR/raidfile.conf ]; then
92 # RAID Setup
93 echo -n "Disabling deprecated userland RAID..."
94 /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
95 status
96 chown -R $BBUSER $CONF_DIR/raidfile.conf && chmod 700 -R $CONF_DIR/raidfile.conf
97 fi
99 if [ ! -e $CONF_DIR/bbstored.conf ]; then
100 # Setting hostname
101 echo -n "Setting hostname... "
102 if [ $(hostname -f 2>1 > /dev/null;echo $?) -eq 0 ]; then
103 HOSTNAME=$(hostname -f)
104 fi
105 if [ -z $HOSTNAME ]; then
106 HOSTNAME="127.0.0.1"
107 fi
108 echo $HOSTNAME
110 # Setting up the CA environment
111 echo -n "Creating certificates..."
112 /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
113 status
115 # Generate server certificate request
116 echo -n "Generate server certificate request..."
117 bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
118 status
120 # Sign the server certificate
121 echo -n "Sign the server certificate..."
122 openssl x509 -req -sha1 -extensions usr_crt \
123 -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \
124 -CA $CA_DIR/roots/serverCA.pem \
125 -CAkey $CA_DIR/keys/serverRootKey.pem \
126 -out $CA_DIR/servers/${HOSTNAME}-cert.pem \
127 -days 5000 2>1 > /dev/null
128 status
130 # Preparing the server certificates
131 echo -n "Installing server certificate..."
132 cp -a $CA_DIR/servers/${HOSTNAME}-cert.pem $CONF_DIR/$BBUSER
133 status
134 echo -n "Installing client certificate..."
135 cp -a $CA_DIR/roots/clientCA.pem $CONF_DIR/$BBUSER
136 status
138 # Securing $CONF_DIR
139 chown -R $BBUSER $CONF_DIR/bbstored* && chmod 700 -R $CONF_DIR/bbstored*
140 fi
142 if [ -e $CA_DIR ]; then
143 # Warning
144 echo
145 echo "IMPORTANT NOTE:"
146 echo "--------------"
147 echo "The certificate authority directory $CA_DIR is intended to be"
148 echo "moved to another system. It should not be kept on the backup server"
149 echo "to limit the impact of a server compromise."
150 fi
151 }
153 # Pre and post remove commands for Tazpkg
155 pre_remove()
156 {
157 /etc/init.d/bbstored stop
158 }
160 post_remove()
161 {
162 if grep -q $BBUSER $1/etc/passwd; then
163 echo -n "Removing $BBUSER user..."
164 deluser bbstored
165 status
166 fi
167 # Delete data
168 if [ -e $DATA_DIR ]; then
169 echo -n "Removing all backup data..."
170 rm -r $DATA_DIR
171 status
172 fi
173 # Delete bbstored conf files
174 if [ -e $CONF_DIR/bbstored.conf ]; then
175 echo -n "Removing config files..."
176 rm -rf $CONF_DIR/bbstored
177 rm -f $CONF_DIR/raidfile.conf
178 rm -f $CONF_DIR/bbstored.conf
179 status
180 fi
181 # Delete certificates
182 if [ -e $CA_DIR ]; then
183 echo -n "Removing certificates..."
184 rm -r $CA_DIR
185 status
186 fi
187 # Delete $CONF_DIR (if empty)
188 if [ $(ls -lA $CONF_DIR | wc -l) -eq 0 ]; then
189 echo -n "Removing $CONF_DIR..."
190 rm -r $CONF_DIR
191 status
192 fi
193 # Delete PID, sock files
194 rm -f /var/run/bbstored.*
195 }