wok-6.x view boxbackup-server/receipt @ rev 13735
Up: pidgin (2.10.6)
author | Alexander Medvedev <devl547@gmail.com> |
---|---|
date | Tue Dec 25 20:59:04 2012 +0300 (2012-12-25) |
parents | 5c25d23ae728 |
children | 223b265f40fd |
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 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 WGET_URL="http://www.boxbackup.org/export/3106/box/packages/$TARBALL"
17 TAGS="backup automatic server network"
19 # Configuration variables
20 HOSTNAME=$(ifconfig | awk -F ":" '/cast/ {print substr($2,0, index($2," ")-1) }')
21 CONF_DIR="/etc/boxbackup"
22 DATA_DIR="/var/lib/bbstored"
23 CA_DIR="${CONF_DIR}/ca"
24 BBUSER="bbstored"
26 # Rules to configure and make the package.
27 compile_rules()
28 {
29 cd $src
30 ./configure --prefix=/usr $CONFIGURE_ARGS &&
31 make -j1 && {
32 mkdir -p $DESTDIR
33 cp -a parcels/boxbackup-${VERSION}-backup-client-linux-gnu $DESTDIR
34 cp -a parcels/boxbackup-${VERSION}-backup-server-linux-gnu $DESTDIR
35 rm -f $DESTDIR/boxbackup-${VERSION}-backup-server-linux-gnu/*.*
36 }
37 }
39 # Rules to gen a SliTaz package suitable for Tazpkg.
40 genpkg_rules()
41 {
42 mkdir -p $fs/usr/bin
43 cp -a $_pkg/boxbackup-${VERSION}-backup-server-linux-gnu/bb* $fs/usr/bin
44 cp -a $_pkg/boxbackup-${VERSION}-backup-server-linux-gnu/ra* $fs/usr/bin
45 mkdir -p $fs/etc/init.d
46 cp -a $stuff/bbstored $fs/etc/init.d
47 }
50 # Pre and post install commands for Tazpkg.
52 pre_install()
53 {
54 # Stop daemon
55 if [ -e /var/run/bbstored.pid ]; then
56 /etc/init.d/bbstored stop
57 fi
58 }
60 post_install()
61 {
62 # default conf dir is now /etc/boxbackup
63 if [ ! -e /etc/box/bbstored.conf ]; then
64 mv /etc/box $CONF_DIR
65 fi
67 # adduser BBUSER if needed
68 if ! grep -q $BBUSER $1/etc/passwd; then
69 echo -n "Adding user '$BBUSER'..."
70 echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> $1/etc/passwd
71 echo $BBUSER':!:14013:0:99999:7:::' >> $1/etc/shadow
72 echo $BBUSER':x:505:' >> $1/etc/group
73 echo $BBUSER':!::' >> $1/etc/gshadow
74 status
75 fi
77 # Create config is needed
78 if [ ! -e $CONF_DIR ]; then
79 mkdir -p $CONF_DIR && chown $BBUSER $CONF_DIR && chmod 700 $CONF_DIR
80 fi
82 if [ ! -e $DATA_DIR/backup ]; then
83 # Creating backup dir
84 echo -n "Creating backup directory..."
85 mkdir -p $DATA_DIR/backup && chown -R $BBUSER $DATA_DIR && chmod -R 700 $DATA_DIR
86 status
87 fi
89 if [ ! -e $CONF_DIR/raidfile.conf ]; then
90 # RAID Setup
91 echo -n "Disabling deprecated userland RAID..."
92 /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
93 status
94 chown -R $BBUSER $CONF_DIR/raidfile.conf && chmod 700 -R $CONF_DIR/raidfile.conf
95 fi
97 if [ ! -e $CONF_DIR/bbstored.conf ]; then
98 # Setting hostname
99 echo -n "Setting hostname... "
100 if [ $(hostname -f 2>1 > /dev/null;echo $?) -eq 0 ]; then
101 HOSTNAME=$(hostname -f)
102 fi
103 if [ -z $HOSTNAME ]; then
104 HOSTNAME="127.0.0.1"
105 fi
106 echo $HOSTNAME
108 # Setting up the CA environment
109 echo -n "Creating certificates..."
110 /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
111 status
113 # Generate server certificate request
114 echo -n "Generate server certificate request..."
115 bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
116 status
118 # Sign the server certificate
119 echo -n "Sign the server certificate..."
120 openssl x509 -req -sha1 -extensions usr_crt \
121 -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \
122 -CA $CA_DIR/roots/serverCA.pem \
123 -CAkey $CA_DIR/keys/serverRootKey.pem \
124 -out $CA_DIR/servers/${HOSTNAME}-cert.pem \
125 -days 5000 2>1 > /dev/null
126 status
128 # Preparing the server certificates
129 echo -n "Installing server certificate..."
130 cp -a $CA_DIR/servers/${HOSTNAME}-cert.pem $CONF_DIR/$BBUSER
131 status
132 echo -n "Installing client certificate..."
133 cp -a $CA_DIR/roots/clientCA.pem $CONF_DIR/$BBUSER
134 status
136 # Securing $CONF_DIR
137 chown -R $BBUSER $CONF_DIR/bbstored* && chmod 700 -R $CONF_DIR/bbstored*
138 fi
140 if [ -e $CA_DIR ]; then
141 # Warning
142 echo
143 echo "IMPORTANT NOTE:"
144 echo "--------------"
145 echo "The certificate authority directory $CA_DIR is intended to be"
146 echo "moved to another system. It should not be kept on the backup server"
147 echo "to limit the impact of a server compromise."
148 fi
149 }
151 # Pre and post remove commands for Tazpkg
153 pre_remove()
154 {
155 /etc/init.d/bbstored stop
156 }
158 post_remove()
159 {
160 if grep -q $BBUSER $1/etc/passwd; then
161 echo -n "Removing $BBUSER user..."
162 deluser bbstored
163 status
164 fi
165 # Delete data
166 if [ -e $DATA_DIR ]; then
167 echo -n "Removing all backup data..."
168 rm -r $DATA_DIR
169 status
170 fi
171 # Delete bbstored conf files
172 if [ -e $CONF_DIR/bbstored.conf ]; then
173 echo -n "Removing config files..."
174 rm -rf $CONF_DIR/bbstored
175 rm -f $CONF_DIR/raidfile.conf
176 rm -f $CONF_DIR/bbstored.conf
177 status
178 fi
179 # Delete certificates
180 if [ -e $CA_DIR ]; then
181 echo -n "Removing certificates..."
182 rm -r $CA_DIR
183 status
184 fi
185 # Delete $CONF_DIR (if empty)
186 if [ $(ls -lA $CONF_DIR | wc -l) -eq 0 ]; then
187 echo -n "Removing $CONF_DIR..."
188 rm -r $CONF_DIR
189 status
190 fi
191 # Delete PID, sock files
192 rm -f /var/run/bbstored.*
193 }