wok view boxbackup-server/receipt @ rev 9065

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