wok view boxbackup-server/receipt @ rev 1423

Fix CATEGORY in receipts
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Sep 26 09:21:16 2008 +0000 (2008-09-26)
parents
children a7e71267442a
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"
15 # Configuration variables
16 HOSTNAME=`ifconfig | awk -F ":" '/cast/ {print substr($2,0, index($2," ")-1) }'`
17 CONF_DIR="/etc/box"
18 DATA_DIR="/var/lib/bbstored"
19 CA_DIR="${CONF_DIR}/ca"
20 BBUSER="bbstored"
22 # Rules to configure and make the package.
23 compile_rules()
24 {
25 cd $src
26 ./configure --prefix=/usr $CONFIGURE_ARGS
27 make
28 }
30 # Rules to gen a SliTaz package suitable for Tazpkg.
31 genpkg_rules()
32 {
33 _pkg=$WOK/$PACKAGE/${SOURCE}-${VERSION}/parcels/boxbackup-${VERSION}-backup-server-linux-gnu
34 mkdir -p $fs/usr/bin
35 cp -a $_pkg/bb* $fs/usr/bin
36 cp -a $_pkg/ra* $fs/usr/bin
37 mkdir -p $fs/etc/init.d
38 cp -a stuff/bbstored $fs/etc/init.d
39 }
42 # Pre and post install commands for Tazpkg.
44 pre_install()
45 {
46 # Stop daemon
47 if [ -e /var/run/bbstored.pid ]; then
48 /etc/init.d/bbstored stop
49 fi
50 }
52 post_install()
53 {
54 # adduser BBUSER if needed
55 if ! grep -q $BBUSER $1/etc/passwd; then
56 echo -n "Adding user '$BBUSER'..."
57 echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> $1/etc/passwd
58 echo $BBUSER':!:14013:0:99999:7:::' >> $1/etc/shadow
59 echo $BBUSER':x:505:' >> $1/etc/group
60 echo $BBUSER':!::' >> $1/etc/gshadow
61 status
62 fi
64 # Create config is needed
65 if [ ! -e $CONF_DIR ]; then
66 mkdir -p $CONF_DIR && chown $BBUSER $CONF_DIR && chmod 700 $CONF_DIR
67 fi
69 if [ ! -e $DATA_DIR/backup ]; then
70 # Creating backup dir
71 echo -n "Creating backup directory..."
72 mkdir -p $DATA_DIR/backup && chown -R $BBUSER $DATA_DIR && chmod -R 700 $DATA_DIR
73 status
74 fi
76 if [ ! -e $CONF_DIR/raidfile.conf ]; then
77 # RAID Setup
78 echo -n "Disabling deprecated userland RAID..."
79 /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
80 status
81 chown -R $BBUSER $CONF_DIR/raidfile.conf && chmod 700 -R $CONF_DIR/raidfile.conf
82 fi
84 if [ ! -e $CONF_DIR/bbstored.conf ]; then
85 # Setting hostname
86 echo -n "Setting hostname... "
87 if [ `hostname -f 2>1 > /dev/null;echo $?` -eq 0 ]; then
88 HOSTNAME=`hostname -f`
89 fi
90 if [ -z $HOSTNAME ]; then
91 HOSTNAME="127.0.0.1"
92 fi
93 echo $HOSTNAME
95 # Setting up the CA environment
96 echo -n "Creating certificates..."
97 /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
98 status
100 # Generate server certificate request
101 echo -n "Generate server certificate request..."
102 bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
103 status
105 # Sign the server certificate
106 echo -n "Sign the server certificate..."
107 openssl x509 -req -sha1 -extensions usr_crt \
108 -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \
109 -CA $CA_DIR/roots/serverCA.pem \
110 -CAkey $CA_DIR/keys/serverRootKey.pem \
111 -out $CA_DIR/servers/${HOSTNAME}-cert.pem \
112 -days 5000 2>1 > /dev/null
113 status
115 # Preparing the server certificates
116 echo -n "Installing server certificate..."
117 cp -a $CA_DIR/servers/${HOSTNAME}-cert.pem $CONF_DIR/$BBUSER
118 status
119 echo -n "Installing client certificate..."
120 cp -a $CA_DIR/roots/clientCA.pem $CONF_DIR/$BBUSER
121 status
123 # Securing $CONF_DIR
124 chown -R $BBUSER $CONF_DIR/bbstored* && chmod 700 -R $CONF_DIR/bbstored*
125 fi
127 if [ -e $CA_DIR ]; then
128 # Warning
129 echo
130 echo "IMPORTANT NOTE:"
131 echo "--------------"
132 echo "The certificate authority directory $CA_DIR is intended to be"
133 echo "moved to another system. It should not be kept on the backup server"
134 echo "to limit the impact of a server compromise."
135 fi
136 }
138 # Pre and post remove commands for Tazpkg
140 pre_remove()
141 {
142 /etc/init.d/bbstored stop
143 }
145 post_remove()
146 {
147 if grep -q $BBUSER $1/etc/passwd; then
148 echo -n "Removing $BBUSER user..."
149 deluser bbstored
150 status
151 fi
152 # Delete data
153 if [ -e $DATA_DIR ]; then
154 echo -n "Removing all backup data..."
155 rm -r $DATA_DIR
156 status
157 fi
158 # Delete bbstored conf files
159 if [ -e $CONF_DIR/bbstored.conf ]; then
160 echo -n "Removing config files..."
161 rm -rf $CONF_DIR/bbstored
162 rm -f $CONF_DIR/raidfile.conf
163 rm -f $CONF_DIR/bbstored.conf
164 status
165 fi
166 # Delete certificates
167 if [ -e $CA_DIR ]; then
168 echo -n "Removing certificates..."
169 rm -r $CA_DIR
170 status
171 fi
172 # Delete $CONF_DIR (if empty)
173 if [ `ls $CONF_DIR | wc -l` -eq 0 ]; then
174 echo -n "Removing $CONF_DIR..."
175 rm -r $CONF_DIR
176 status
177 fi
178 # Delete PID, sock files
179 rm -f /var/run/bbstored.*