wok view boxbackup-server/receipt @ rev 25682

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