wok view boxbackup-server/receipt @ rev 24263

updated perl-time-hires (1.9760 -> 1.9764)
author Hans-G?nter Theisgen
date Sun Jan 02 10:20:35 2022 +0100 (2022-01-02)
parents fca69926510b
children 343c093ad221
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 current_version()
27 {
28 wget -O - ${WGET_URL%/arch*}/releases 2>/dev/null | \
29 sed '/archive.*tar/!d;s|.*/BoxBackup-\(.*\).master.*|\1|;q'
30 }
32 # Rules to configure and make the package.
33 compile_rules()
34 {
35 ./bootstrap &&
36 ./configure --prefix=/usr $CONFIGURE_ARGS &&
37 make -j1 &&
38 {
39 mkdir -p $DESTDIR
40 cp -a parcels/boxbackup-git_-backup-client-i486-slitaz-linux-gnu $DESTDIR
41 cp -a parcels/boxbackup-git_-backup-server-i486-slitaz-linux-gnu $DESTDIR
42 rm -f $DESTDIR/boxbackup-git_-backup-server-i486-slitaz-linux-gnu/*.*
43 }
44 cook_pick_manpages $src/docs/man/*
45 }
47 # Rules to gen a SliTaz package suitable for Tazpkg.
48 genpkg_rules()
49 {
50 mkdir -p $fs/usr/bin
51 mkdir -p $fs/etc/init.d
53 cp -a $install/boxbackup-git_-backup-server-i486-slitaz-linux-gnu/bb* \
54 $fs/usr/bin
55 cp -a $install/boxbackup-git_-backup-server-i486-slitaz-linux-gnu/ra* \
56 $fs/usr/bin
57 cp -a $stuff/bbstored $fs/etc/init.d
58 }
61 # Pre and post install commands for Tazpkg.
63 pre_install()
64 {
65 # Stop daemon
66 if [ -z "$1" -a -e /var/run/bbstored.pid ]
67 then
68 /etc/init.d/bbstored stop
69 fi
70 }
72 post_install()
73 {
74 # default configuration directory is now /etc/boxbackup
75 if [ ! -e "$1/etc/box/bbstored.conf" ]
76 then
77 mv "$1/etc/box" "$1$CONF_DIR"
78 fi
80 # adduser BBUSER if needed
81 if ! grep -q $BBUSER "$1/etc/passwd"
82 then
83 echo
84 action "Adding user '$BBUSER'..."
85 echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> "$1/etc/passwd"
86 echo $BBUSER':!:14013:0:99999:7:::' >> "$1/etc/shadow"
87 echo $BBUSER':x:505:' >> "$1/etc/group"
88 echo $BBUSER':!::' >> "$1/etc/gshadow"
89 status
90 fi
92 # Create configuration as needed
93 if [ ! -e "$1$CONF_DIR" ]
94 then
95 mkdir -p "$1$CONF_DIR" &&
96 chroot "$1/" chown $BBUSER $CONF_DIR &&
97 chmod 700 "$1$CONF_DIR"
98 fi
100 if [ ! -e "$1$DATA_DIR/backup" ]
101 then
102 # Creating backup directory
103 action "Creating backup directory..."
104 mkdir -p "$1$DATA_DIR/backup" &&
105 chroot "$1/" chown -R $BBUSER $DATA_DIR &&
106 chmod -R 700 "$1$DATA_DIR"
107 status
108 fi
110 if [ ! -e "$1$CONF_DIR/raidfile.conf" ]
111 then
112 # RAID Setup
113 action "Disabling deprecated userland RAID..."
114 chroot "$1/" /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
115 status
116 chroot "$1/" chown -R $BBUSER $CONF_DIR/raidfile.conf &&
117 chmod 700 -R "$1$CONF_DIR/raidfile.conf"
118 fi
120 if [ ! -e "$1$CONF_DIR/bbstored.conf" ]
121 then
122 # Setting hostname
123 action "Setting hostname... "
124 if [ $(chroot "$1/" hostname -f 2>1 > /dev/null;echo $?) -eq 0 ]
125 then
126 HOSTNAME=$(chroot "$1/" hostname -f)
127 fi
128 if [ -z $HOSTNAME ]
129 then
130 HOSTNAME="127.0.0.1"
131 fi
132 export $HOSTNAME
133 echo $HOSTNAME
135 # Setting up the CA environment
136 action "Creating certificates..."
137 chroot "$1/" /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
138 status
140 # Generate server certificate request
141 action "Generate server certificate request..."
142 chroot "$1/" bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
143 status
145 # Sign the server certificate
146 action "Sign the server certificate..."
147 chroot "$1/" openssl x509 -req -sha1 -extensions usr_crt \
148 -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \
149 -CA $CA_DIR/roots/serverCA.pem \
150 -CAkey $CA_DIR/keys/serverRootKey.pem \
151 -out $CA_DIR/servers/${HOSTNAME}-cert.pem \
152 -days 5000 2>1 > /dev/null
153 status
155 # Preparing the server certificates
156 action "Installing server certificate..."
157 cp -a "$1$CA_DIR/servers/${HOSTNAME}-cert.pem" \
158 "$1$CONF_DIR/$BBUSER"
159 status
160 action "Installing client certificate..."
161 cp -a "$1$CA_DIR/roots/clientCA.pem" \
162 "$1$CONF_DIR/$BBUSER"
163 status
165 # Securing $CONF_DIR
166 chroot "$1/" chown -R $BBUSER $CONF_DIR/bbstored* &&
167 chmod 700 -R "$1$CONF_DIR/bbstored"*
168 fi
170 if [ -e "$1$CA_DIR" ]
171 then
172 # Warning
173 echo
174 echo "IMPORTANT NOTE:"
175 echo "--------------"
176 echo "The certificate authority directory $CA_DIR is intended to be"
177 echo "moved to another system. It should not be kept on the backup server"
178 echo "to limit the impact of a server compromise."
179 fi
180 }
182 # Pre and post remove commands for Tazpkg
184 pre_remove()
185 {
186 /etc/init.d/bbstored stop
187 }
189 post_remove()
190 {
191 echo
192 if grep -q $BBUSER /etc/passwd
193 then
194 action "Removing $BBUSER user..."
195 deluser bbstored
196 status
197 fi
199 # Delete data
200 if [ -e $DATA_DIR ]
201 then
202 action "Removing all backup data..."
203 rm -r $DATA_DIR
204 status
205 fi
207 # Delete bbstored configuration files
208 if [ -e $CONF_DIR/bbstored.conf ]
209 then
210 action "Removing config files..."
211 rm -rf $CONF_DIR/bbstored
212 rm -f $CONF_DIR/raidfile.conf
213 rm -f $CONF_DIR/bbstored.conf
214 status
215 fi
217 # Delete certificates
218 if [ -e $CA_DIR ]
219 then
220 action "Removing certificates..."
221 rm -r $CA_DIR
222 status
223 fi
225 # Delete $CONF_DIR (if empty)
226 if [ $(ls -lA $CONF_DIR | wc -l) -eq 0 ]
227 then
228 action "Removing $CONF_DIR..."
229 rm -r $CONF_DIR
230 status
231 fi
233 # Delete PID, sock files
234 rm -f /var/run/bbstored.*
235 }