wok-next view boxbackup/receipt @ rev 21020
Cleaning is almost finished... I should proceed to upgrades.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Nov 02 14:15:08 2018 +0200 (2018-11-02) |
parents | 471441bc00c3 |
children |
line source
1 # SliTaz package receipt v2.
3 PACKAGE="boxbackup"
4 VERSION="0.12"
5 CATEGORY="meta"
6 SHORT_DESC="BoxBackup on-line backup system"
7 MAINTAINER="devel@slitaz.org"
8 LICENSE="GPL2"
9 WEB_SITE="https://www.boxbackup.org/"
11 # for the latest releases weird names please visit:
12 # https://github.com/boxbackup/boxbackup/releases
13 TARBALL="BoxBackup-0.12.mark_master_builds_as_full_releases.180326.161ceef.tar.gz"
14 WGET_URL="https://github.com/boxbackup/boxbackup/archive/$TARBALL"
16 BUILD_DEPENDS="automake zlib-dev libedit-dev db-dev openssl-dev libxslt"
17 SPLIT="$PACKAGE-client $PACKAGE-server"
19 compile_rules() {
20 ./bootstrap
21 ./configure \
22 $CONFIGURE_ARGS &&
23 make ||return 1
24 sed -i 's|usr/man|usr/share/man|' parcels/*/install*
25 make install-backup-client
26 make install-backup-server
28 install -Dm755 $stuff/bbackupd $install/etc/init.d/bbackupd
29 install -Dm755 $stuff/bbstored $install/etc/init.d/bbstored
30 }
32 genpkg_rules() {
33 case $PACKAGE in
34 boxbackup)
35 DEPENDS="$SPLIT"
36 ;;
37 *-client)
38 copy bbackupd bbackupquery bbackupctl bbackupd-config
39 CAT="network|client"
40 DEPENDS="libedit openssl zlib"
41 TAGS="backup automatic client"
42 ;;
43 *-server)
44 copy bbstored bbstoreaccounts bbstored-certs bbstored-config \
45 raidfile-config
46 CAT="network|server"
47 DEPENDS="openssl zlib"
48 TAGS="backup automatic server network"
49 ;;
50 esac
51 }
53 pre_install_boxbackup_client() {
54 RUN_DMON=0
56 # Stop daemon
57 if [ -z "$1" -a -e /var/run/bbackupd.pid ]; then
58 /etc/init.d/bbackupd stop
59 RUN_DMON=1
60 fi
61 }
63 post_install_boxbackup_client() {
64 CONF_DIR="/etc/boxbackup"
65 DATA_DIR="/var/lib/bbackupd"
67 # Creating conf dir
68 if [ ! -e "$1/$CONF_DIR" ]; then
69 mkdir -p "$1/$CONF_DIR" && chmod 755 "$1/$CONF_DIR"
70 fi
71 if [ ! -e "$1/$DATA_DIR" ]; then
72 mkdir -p "$1/$DATA_DIR" && chmod 700 "$1/$DATA_DIR"
73 fi
74 if [ -z "$1" ]; then
75 # Start daemon (if stopped by install)
76 if [ $RUN_DMON -eq 1 ]; then
77 /etc/init.d/bbackupd start
78 fi
79 fi
80 true
81 }
83 pre_remove_boxbackup_client() {
84 # Stop daemon
85 if [ -z "$1" ]; then
86 if [ -e /var/run/bbackupd.pid ]; then
87 /etc/init.d/bbackupd stop
88 fi
89 fi
90 }
92 post_remove_boxbackup_client() {
93 CONF_DIR="/etc/boxbackup"
94 DATA_DIR="/var/lib/bbackupd"
96 # Delete DATA directory
97 rm -rf "$1/$DATA_DIR"
99 # Delete Client config files
100 rm -rf "$1/$CONF_DIR"/bbackupd*
102 # Delete CONF dir (if empty)
103 if [ $(ls -lA "$1/$CONF_DIR" | wc -l) -eq 0 ]; then
104 echo
105 action "Removing $CONF_DIR..."
106 rm -rf "$1/$CONF_DIR"
107 status
108 fi
109 # Delete PID, sock files
110 rm -f "$1/var/run/bbackupd".*
111 }
114 pre_install_boxbackup_server() {
115 # Stop daemon
116 if [ -z "$1" -a -e /var/run/bbstored.pid ]; then
117 /etc/init.d/bbstored stop
118 fi
119 }
121 post_install_boxbackup_server() {
122 HOSTNAME=$(ifconfig | awk -F ":" '/cast/ {print substr($2,0, index($2," ")-1) }') #'MC
123 CONF_DIR="/etc/boxbackup"
124 DATA_DIR="/var/lib/bbstored"
125 CA_DIR="${CONF_DIR}/ca"
126 BBUSER="bbstored"
128 # default conf dir is now /etc/boxbackup
129 if [ ! -e "$1/etc/box/bbstored.conf" ]; then
130 mv "$1/etc/box" "$1$CONF_DIR"
131 fi
133 # adduser BBUSER if needed
134 if ! grep -q $BBUSER "$1/etc/passwd"; then
135 echo
136 action "Adding user '$BBUSER'..."
137 echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> "$1/etc/passwd"
138 echo $BBUSER':!:14013:0:99999:7:::' >> "$1/etc/shadow"
139 echo $BBUSER':x:505:' >> "$1/etc/group"
140 echo $BBUSER':!::' >> "$1/etc/gshadow"
141 status
142 fi
144 # Create config is needed
145 if [ ! -e "$1$CONF_DIR" ]; then
146 mkdir -p "$1$CONF_DIR" &&
147 chroot "$1/" chown $BBUSER $CONF_DIR &&
148 chmod 700 "$1$CONF_DIR"
149 fi
151 if [ ! -e "$1$DATA_DIR/backup" ]; then
152 # Creating backup dir
153 action "Creating backup directory..."
154 mkdir -p "$1$DATA_DIR/backup" &&
155 chroot "$1/" chown -R $BBUSER $DATA_DIR &&
156 chmod -R 700 "$1$DATA_DIR"
157 status
158 fi
160 if [ ! -e "$1$CONF_DIR/raidfile.conf" ]; then
161 # RAID Setup
162 action "Disabling deprecated userland RAID..."
163 chroot "$1/" /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
164 status
165 chroot "$1/" chown -R $BBUSER $CONF_DIR/raidfile.conf &&
166 chmod 700 -R "$1$CONF_DIR/raidfile.conf"
167 fi
169 if [ ! -e "$1$CONF_DIR/bbstored.conf" ]; then
170 # Setting hostname
171 action "Setting hostname... "
172 if [ $(chroot "$1/" hostname -f 2>1 > /dev/null;echo $?) -eq 0 ]; then
173 HOSTNAME=$(chroot "$1/" hostname -f)
174 fi
175 if [ -z $HOSTNAME ]; then
176 HOSTNAME="127.0.0.1"
177 fi
178 export $HOSTNAME
179 echo $HOSTNAME
181 # Setting up the CA environment
182 action "Creating certificates..."
183 chroot "$1/" /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
184 status
186 # Generate server certificate request
187 action "Generate server certificate request..."
188 chroot "$1/" bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
189 status
191 # Sign the server certificate
192 action "Sign the server certificate..."
193 chroot "$1/" openssl x509 -req -sha1 -extensions usr_crt \
194 -in $CONF_DIR/$BBUSER/$HOSTNAME-csr.pem \
195 -CA $CA_DIR/roots/serverCA.pem \
196 -CAkey $CA_DIR/keys/serverRootKey.pem \
197 -out $CA_DIR/servers/$HOSTNAME-cert.pem \
198 -days 5000 2>1 > /dev/null
199 status
201 # Preparing the server certificates
202 action "Installing server certificate..."
203 cp -a "$1$CA_DIR/servers/$HOSTNAME-cert.pem" "$1$CONF_DIR/$BBUSER"
204 status
205 action "Installing client certificate..."
206 cp -a "$1$CA_DIR/roots/clientCA.pem" "$1$CONF_DIR/$BBUSER"
207 status
209 # Securing $CONF_DIR
210 chroot "$1/" chown -R $BBUSER $CONF_DIR/bbstored* &&
211 chmod 700 -R "$1$CONF_DIR/bbstored"*
212 fi
214 if [ -e "$1$CA_DIR" ]; then
215 # Warning
216 echo
217 echo "IMPORTANT NOTE:"
218 echo "--------------"
219 echo "The certificate authority directory $CA_DIR is intended to be"
220 echo "moved to another system. It should not be kept on the backup server"
221 echo "to limit the impact of a server compromise."
222 fi
223 }
225 pre_remove_boxbackup_server() {
226 /etc/init.d/bbstored stop
227 }
229 post_remove_boxbackup_server() {
230 CONF_DIR="/etc/boxbackup"
231 DATA_DIR="/var/lib/bbstored"
232 CA_DIR="${CONF_DIR}/ca"
233 BBUSER="bbstored"
235 echo
236 if grep -q $BBUSER /etc/passwd; then
237 action "Removing $BBUSER user..."
238 deluser bbstored
239 status
240 fi
241 # Delete data
242 if [ -e $DATA_DIR ]; then
243 action "Removing all backup data..."
244 rm -r $DATA_DIR
245 status
246 fi
247 # Delete bbstored conf files
248 if [ -e $CONF_DIR/bbstored.conf ]; then
249 action "Removing config files..."
250 rm -rf $CONF_DIR/bbstored
251 rm -f $CONF_DIR/raidfile.conf
252 rm -f $CONF_DIR/bbstored.conf
253 status
254 fi
255 # Delete certificates
256 if [ -e $CA_DIR ]; then
257 action "Removing certificates..."
258 rm -r $CA_DIR
259 status
260 fi
261 # Delete $CONF_DIR (if empty)
262 if [ $(ls -lA $CONF_DIR | wc -l) -eq 0 ]; then
263 action "Removing $CONF_DIR..."
264 rm -r $CONF_DIR
265 status
266 fi
267 # Delete PID, sock files
268 rm -f /var/run/bbstored.*
269 }