wok-6.x view boxbackup-server/receipt @ rev 18892
remove: tazpanel-ttf-css, tazpanel-theme-sandfive(in wok-backports)
author | Xander Ziiryanoff <psychomaniak@xakep.ru> |
---|---|
date | Fri Feb 12 20:27:04 2016 +0000 (2016-02-12) |
parents | 9e01bc6321ea |
children | a511baf85854 |
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 ./configure --prefix=/usr $CONFIGURE_ARGS &&
32 make -j1 && {
33 mkdir -p $DESTDIR
34 cp -a parcels/boxbackup-${VERSION}-backup-client-linux-gnu $DESTDIR
35 cp -a parcels/boxbackup-${VERSION}-backup-server-linux-gnu $DESTDIR
36 rm -f $DESTDIR/boxbackup-${VERSION}-backup-server-linux-gnu/*.*
37 }
38 }
40 # Rules to gen a SliTaz package suitable for Tazpkg.
41 genpkg_rules()
42 {
43 mkdir -p $fs/usr/bin
44 cp -a $install/boxbackup-${VERSION}-backup-server-linux-gnu/bb* $fs/usr/bin
45 cp -a $install/boxbackup-${VERSION}-backup-server-linux-gnu/ra* $fs/usr/bin
46 mkdir -p $fs/etc/init.d
47 cp -a $stuff/bbstored $fs/etc/init.d
48 }
51 # Pre and post install commands for Tazpkg.
53 pre_install()
54 {
55 # Stop daemon
56 if [ -z "$1" -a -e /var/run/bbstored.pid ]; then
57 /etc/init.d/bbstored stop
58 fi
59 }
61 post_install()
62 {
63 # default conf dir is now /etc/boxbackup
64 if [ ! -e "$1/etc/box/bbstored.conf" ]; then
65 mv "$1/etc/box" "$1$CONF_DIR"
66 fi
68 # adduser BBUSER if needed
69 if ! grep -q $BBUSER "$1/etc/passwd"; then
70 echo
71 action "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 "$1$CONF_DIR" ]; then
81 mkdir -p "$1$CONF_DIR" &&
82 chroot "$1/" chown $BBUSER $CONF_DIR &&
83 chmod 700 "$1$CONF_DIR"
84 fi
86 if [ ! -e "$1$DATA_DIR/backup" ]; then
87 # Creating backup dir
88 action "Creating backup directory..."
89 mkdir -p "$1$DATA_DIR/backup" &&
90 chroot "$1/" chown -R $BBUSER $DATA_DIR &&
91 chmod -R 700 "$1$DATA_DIR"
92 status
93 fi
95 if [ ! -e "$1$CONF_DIR/raidfile.conf" ]; then
96 # RAID Setup
97 action "Disabling deprecated userland RAID..."
98 chroot "$1/" /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
99 status
100 chroot "$1/" chown -R $BBUSER $CONF_DIR/raidfile.conf &&
101 chmod 700 -R "$1$CONF_DIR/raidfile.conf"
102 fi
104 if [ ! -e "$1$CONF_DIR/bbstored.conf" ]; then
105 # Setting hostname
106 action "Setting hostname... "
107 if [ $(chroot "$1/" hostname -f 2>1 > /dev/null;echo $?) -eq 0 ]; then
108 HOSTNAME=$(chroot "$1/" hostname -f)
109 fi
110 if [ -z $HOSTNAME ]; then
111 HOSTNAME="127.0.0.1"
112 fi
113 export $HOSTNAME
114 echo $HOSTNAME
116 # Setting up the CA environment
117 action "Creating certificates..."
118 chroot "$1/" /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
119 status
121 # Generate server certificate request
122 action "Generate server certificate request..."
123 chroot "$1/" bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
124 status
126 # Sign the server certificate
127 action "Sign the server certificate..."
128 chroot "$1/" openssl x509 -req -sha1 -extensions usr_crt \
129 -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \
130 -CA $CA_DIR/roots/serverCA.pem \
131 -CAkey $CA_DIR/keys/serverRootKey.pem \
132 -out $CA_DIR/servers/${HOSTNAME}-cert.pem \
133 -days 5000 2>1 > /dev/null
134 status
136 # Preparing the server certificates
137 action "Installing server certificate..."
138 cp -a "$1$CA_DIR/servers/${HOSTNAME}-cert.pem" "$1$CONF_DIR/$BBUSER"
139 status
140 action "Installing client certificate..."
141 cp -a "$1$CA_DIR/roots/clientCA.pem" "$1$CONF_DIR/$BBUSER"
142 status
144 # Securing $CONF_DIR
145 chroot "$1/" chown -R $BBUSER $CONF_DIR/bbstored* &&
146 chmod 700 -R "$1$CONF_DIR/bbstored"*
147 fi
149 if [ -e "$1$CA_DIR" ]; then
150 # Warning
151 echo
152 echo "IMPORTANT NOTE:"
153 echo "--------------"
154 echo "The certificate authority directory $CA_DIR is intended to be"
155 echo "moved to another system. It should not be kept on the backup server"
156 echo "to limit the impact of a server compromise."
157 fi
158 }
160 # Pre and post remove commands for Tazpkg
162 pre_remove()
163 {
164 /etc/init.d/bbstored stop
165 }
167 post_remove()
168 {
169 echo
170 if grep -q $BBUSER /etc/passwd; then
171 action "Removing $BBUSER user..."
172 deluser bbstored
173 status
174 fi
175 # Delete data
176 if [ -e $DATA_DIR ]; then
177 action "Removing all backup data..."
178 rm -r $DATA_DIR
179 status
180 fi
181 # Delete bbstored conf files
182 if [ -e $CONF_DIR/bbstored.conf ]; then
183 action "Removing config files..."
184 rm -rf $CONF_DIR/bbstored
185 rm -f $CONF_DIR/raidfile.conf
186 rm -f $CONF_DIR/bbstored.conf
187 status
188 fi
189 # Delete certificates
190 if [ -e $CA_DIR ]; then
191 action "Removing certificates..."
192 rm -r $CA_DIR
193 status
194 fi
195 # Delete $CONF_DIR (if empty)
196 if [ $(ls -lA $CONF_DIR | wc -l) -eq 0 ]; then
197 action "Removing $CONF_DIR..."
198 rm -r $CONF_DIR
199 status
200 fi
201 # Delete PID, sock files
202 rm -f /var/run/bbstored.*
203 }