wok-6.x view boxbackup-server/receipt @ rev 23854
Up dbus (1.12.18)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Jun 16 12:51:04 2020 +0000 (2020-06-16) |
parents | cc177a7db8f1 |
children | 5ea0ce1cecc0 |
line source
1 # SliTaz package receipt.
3 PACKAGE="boxbackup-server"
4 VERSION="0.12"
5 CATEGORY="network"
6 TAGS="backup automatic server network"
7 SHORT_DESC="Server for the BoxBackup on-line backup system."
8 MAINTAINER="domcox@slitaz.org"
9 LICENSE="GPL2"
10 WEB_SITE="https://www.boxbackup.org/"
12 SOURCE="boxbackup"
13 TARBALL="$SOURCE-$VERSION.tar.gz"
14 WGET_URL="https://github.com/$SOURCE/$SOURCE/archive/BoxBackup-$VERSION.master.190831.9e0e93e.tar.gz"
16 DEPENDS="db gcc-lib-base libedit openssl perl zlib"
17 BUILD_DEPENDS="autoconf automake db-dev libedit-dev libxslt openssl-dev zlib-dev"
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 ./bootstrap &&
30 ./configure --prefix=/usr $CONFIGURE_ARGS &&
31 make -j1 &&
32 {
33 mkdir -p $DESTDIR
34 cp -a parcels/boxbackup-git_-backup-client-i486-slitaz-linux-gnu $DESTDIR
35 cp -a parcels/boxbackup-git_-backup-server-i486-slitaz-linux-gnu $DESTDIR
36 rm -f $DESTDIR/boxbackup-git_-backup-server-i486-slitaz-linux-gnu/*.*
37 }
38 cook_pick_manpages $src/docs/man/*
39 }
41 # Rules to gen a SliTaz package suitable for Tazpkg.
42 genpkg_rules()
43 {
44 mkdir -p $fs/usr/bin
45 mkdir -p $fs/etc/init.d
47 cp -a $install/boxbackup-git_-backup-server-i486-slitaz-linux-gnu/bb* \
48 $fs/usr/bin
49 cp -a $install/boxbackup-git_-backup-server-i486-slitaz-linux-gnu/ra* \
50 $fs/usr/bin
51 cp -a $stuff/bbstored $fs/etc/init.d
52 }
55 # Pre and post install commands for Tazpkg.
57 pre_install()
58 {
59 # Stop daemon
60 if [ -z "$1" -a -e /var/run/bbstored.pid ]
61 then
62 /etc/init.d/bbstored stop
63 fi
64 }
66 post_install()
67 {
68 # default configuration directory is now /etc/boxbackup
69 if [ ! -e "$1/etc/box/bbstored.conf" ]
70 then
71 mv "$1/etc/box" "$1$CONF_DIR"
72 fi
74 # adduser BBUSER if needed
75 if ! grep -q $BBUSER "$1/etc/passwd"
76 then
77 echo
78 action "Adding user '$BBUSER'..."
79 echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> "$1/etc/passwd"
80 echo $BBUSER':!:14013:0:99999:7:::' >> "$1/etc/shadow"
81 echo $BBUSER':x:505:' >> "$1/etc/group"
82 echo $BBUSER':!::' >> "$1/etc/gshadow"
83 status
84 fi
86 # Create configuration as needed
87 if [ ! -e "$1$CONF_DIR" ]
88 then
89 mkdir -p "$1$CONF_DIR" &&
90 chroot "$1/" chown $BBUSER $CONF_DIR &&
91 chmod 700 "$1$CONF_DIR"
92 fi
94 if [ ! -e "$1$DATA_DIR/backup" ]
95 then
96 # Creating backup directory
97 action "Creating backup directory..."
98 mkdir -p "$1$DATA_DIR/backup" &&
99 chroot "$1/" chown -R $BBUSER $DATA_DIR &&
100 chmod -R 700 "$1$DATA_DIR"
101 status
102 fi
104 if [ ! -e "$1$CONF_DIR/raidfile.conf" ]
105 then
106 # RAID Setup
107 action "Disabling deprecated userland RAID..."
108 chroot "$1/" /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
109 status
110 chroot "$1/" chown -R $BBUSER $CONF_DIR/raidfile.conf &&
111 chmod 700 -R "$1$CONF_DIR/raidfile.conf"
112 fi
114 if [ ! -e "$1$CONF_DIR/bbstored.conf" ]
115 then
116 # Setting hostname
117 action "Setting hostname... "
118 if [ $(chroot "$1/" hostname -f 2>1 > /dev/null;echo $?) -eq 0 ]
119 then
120 HOSTNAME=$(chroot "$1/" hostname -f)
121 fi
122 if [ -z $HOSTNAME ]
123 then
124 HOSTNAME="127.0.0.1"
125 fi
126 export $HOSTNAME
127 echo $HOSTNAME
129 # Setting up the CA environment
130 action "Creating certificates..."
131 chroot "$1/" /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
132 status
134 # Generate server certificate request
135 action "Generate server certificate request..."
136 chroot "$1/" bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
137 status
139 # Sign the server certificate
140 action "Sign the server certificate..."
141 chroot "$1/" openssl x509 -req -sha1 -extensions usr_crt \
142 -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \
143 -CA $CA_DIR/roots/serverCA.pem \
144 -CAkey $CA_DIR/keys/serverRootKey.pem \
145 -out $CA_DIR/servers/${HOSTNAME}-cert.pem \
146 -days 5000 2>1 > /dev/null
147 status
149 # Preparing the server certificates
150 action "Installing server certificate..."
151 cp -a "$1$CA_DIR/servers/${HOSTNAME}-cert.pem" \
152 "$1$CONF_DIR/$BBUSER"
153 status
154 action "Installing client certificate..."
155 cp -a "$1$CA_DIR/roots/clientCA.pem" \
156 "$1$CONF_DIR/$BBUSER"
157 status
159 # Securing $CONF_DIR
160 chroot "$1/" chown -R $BBUSER $CONF_DIR/bbstored* &&
161 chmod 700 -R "$1$CONF_DIR/bbstored"*
162 fi
164 if [ -e "$1$CA_DIR" ]
165 then
166 # Warning
167 echo
168 echo "IMPORTANT NOTE:"
169 echo "--------------"
170 echo "The certificate authority directory $CA_DIR is intended to be"
171 echo "moved to another system. It should not be kept on the backup server"
172 echo "to limit the impact of a server compromise."
173 fi
174 }
176 # Pre and post remove commands for Tazpkg
178 pre_remove()
179 {
180 /etc/init.d/bbstored stop
181 }
183 post_remove()
184 {
185 echo
186 if grep -q $BBUSER /etc/passwd
187 then
188 action "Removing $BBUSER user..."
189 deluser bbstored
190 status
191 fi
193 # Delete data
194 if [ -e $DATA_DIR ]
195 then
196 action "Removing all backup data..."
197 rm -r $DATA_DIR
198 status
199 fi
201 # Delete bbstored configuration files
202 if [ -e $CONF_DIR/bbstored.conf ]
203 then
204 action "Removing config files..."
205 rm -rf $CONF_DIR/bbstored
206 rm -f $CONF_DIR/raidfile.conf
207 rm -f $CONF_DIR/bbstored.conf
208 status
209 fi
211 # Delete certificates
212 if [ -e $CA_DIR ]
213 then
214 action "Removing certificates..."
215 rm -r $CA_DIR
216 status
217 fi
219 # Delete $CONF_DIR (if empty)
220 if [ $(ls -lA $CONF_DIR | wc -l) -eq 0 ]
221 then
222 action "Removing $CONF_DIR..."
223 rm -r $CONF_DIR
224 status
225 fi
227 # Delete PID, sock files
228 rm -f /var/run/bbstored.*
229 }