wok view boxbackup-server/receipt @ rev 22384
updated blender again (2.75a -> 2.81)
author | Hans-G?nter Theisgen |
---|---|
date | Thu Nov 28 10:12:34 2019 +0100 (2019-11-28) |
parents | a511baf85854 |
children | cc177a7db8f1 |
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 WEB_SITE="https://www.boxbackup.org/"
10 SOURCE="boxbackup"
11 TARBALL="$SOURCE-$VERSION.tgz"
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 }
39 cook_pick_manpages $src/docs/man/*
40 }
42 # Rules to gen a SliTaz package suitable for Tazpkg.
43 genpkg_rules()
44 {
45 mkdir -p $fs/usr/bin
46 cp -a $install/boxbackup-${VERSION}-backup-server-linux-gnu/bb* $fs/usr/bin
47 cp -a $install/boxbackup-${VERSION}-backup-server-linux-gnu/ra* $fs/usr/bin
48 mkdir -p $fs/etc/init.d
49 cp -a $stuff/bbstored $fs/etc/init.d
50 }
53 # Pre and post install commands for Tazpkg.
55 pre_install()
56 {
57 # Stop daemon
58 if [ -z "$1" -a -e /var/run/bbstored.pid ]; then
59 /etc/init.d/bbstored stop
60 fi
61 }
63 post_install()
64 {
65 # default conf dir is now /etc/boxbackup
66 if [ ! -e "$1/etc/box/bbstored.conf" ]; then
67 mv "$1/etc/box" "$1$CONF_DIR"
68 fi
70 # adduser BBUSER if needed
71 if ! grep -q $BBUSER "$1/etc/passwd"; then
72 echo
73 action "Adding user '$BBUSER'..."
74 echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> "$1/etc/passwd"
75 echo $BBUSER':!:14013:0:99999:7:::' >> "$1/etc/shadow"
76 echo $BBUSER':x:505:' >> "$1/etc/group"
77 echo $BBUSER':!::' >> "$1/etc/gshadow"
78 status
79 fi
81 # Create config is needed
82 if [ ! -e "$1$CONF_DIR" ]; then
83 mkdir -p "$1$CONF_DIR" &&
84 chroot "$1/" chown $BBUSER $CONF_DIR &&
85 chmod 700 "$1$CONF_DIR"
86 fi
88 if [ ! -e "$1$DATA_DIR/backup" ]; then
89 # Creating backup dir
90 action "Creating backup directory..."
91 mkdir -p "$1$DATA_DIR/backup" &&
92 chroot "$1/" chown -R $BBUSER $DATA_DIR &&
93 chmod -R 700 "$1$DATA_DIR"
94 status
95 fi
97 if [ ! -e "$1$CONF_DIR/raidfile.conf" ]; then
98 # RAID Setup
99 action "Disabling deprecated userland RAID..."
100 chroot "$1/" /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
101 status
102 chroot "$1/" chown -R $BBUSER $CONF_DIR/raidfile.conf &&
103 chmod 700 -R "$1$CONF_DIR/raidfile.conf"
104 fi
106 if [ ! -e "$1$CONF_DIR/bbstored.conf" ]; then
107 # Setting hostname
108 action "Setting hostname... "
109 if [ $(chroot "$1/" hostname -f 2>1 > /dev/null;echo $?) -eq 0 ]; then
110 HOSTNAME=$(chroot "$1/" hostname -f)
111 fi
112 if [ -z $HOSTNAME ]; then
113 HOSTNAME="127.0.0.1"
114 fi
115 export $HOSTNAME
116 echo $HOSTNAME
118 # Setting up the CA environment
119 action "Creating certificates..."
120 chroot "$1/" /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
121 status
123 # Generate server certificate request
124 action "Generate server certificate request..."
125 chroot "$1/" bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
126 status
128 # Sign the server certificate
129 action "Sign the server certificate..."
130 chroot "$1/" openssl x509 -req -sha1 -extensions usr_crt \
131 -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \
132 -CA $CA_DIR/roots/serverCA.pem \
133 -CAkey $CA_DIR/keys/serverRootKey.pem \
134 -out $CA_DIR/servers/${HOSTNAME}-cert.pem \
135 -days 5000 2>1 > /dev/null
136 status
138 # Preparing the server certificates
139 action "Installing server certificate..."
140 cp -a "$1$CA_DIR/servers/${HOSTNAME}-cert.pem" "$1$CONF_DIR/$BBUSER"
141 status
142 action "Installing client certificate..."
143 cp -a "$1$CA_DIR/roots/clientCA.pem" "$1$CONF_DIR/$BBUSER"
144 status
146 # Securing $CONF_DIR
147 chroot "$1/" chown -R $BBUSER $CONF_DIR/bbstored* &&
148 chmod 700 -R "$1$CONF_DIR/bbstored"*
149 fi
151 if [ -e "$1$CA_DIR" ]; then
152 # Warning
153 echo
154 echo "IMPORTANT NOTE:"
155 echo "--------------"
156 echo "The certificate authority directory $CA_DIR is intended to be"
157 echo "moved to another system. It should not be kept on the backup server"
158 echo "to limit the impact of a server compromise."
159 fi
160 }
162 # Pre and post remove commands for Tazpkg
164 pre_remove()
165 {
166 /etc/init.d/bbstored stop
167 }
169 post_remove()
170 {
171 echo
172 if grep -q $BBUSER /etc/passwd; then
173 action "Removing $BBUSER user..."
174 deluser bbstored
175 status
176 fi
177 # Delete data
178 if [ -e $DATA_DIR ]; then
179 action "Removing all backup data..."
180 rm -r $DATA_DIR
181 status
182 fi
183 # Delete bbstored conf files
184 if [ -e $CONF_DIR/bbstored.conf ]; then
185 action "Removing config files..."
186 rm -rf $CONF_DIR/bbstored
187 rm -f $CONF_DIR/raidfile.conf
188 rm -f $CONF_DIR/bbstored.conf
189 status
190 fi
191 # Delete certificates
192 if [ -e $CA_DIR ]; then
193 action "Removing certificates..."
194 rm -r $CA_DIR
195 status
196 fi
197 # Delete $CONF_DIR (if empty)
198 if [ $(ls -lA $CONF_DIR | wc -l) -eq 0 ]; then
199 action "Removing $CONF_DIR..."
200 rm -r $CONF_DIR
201 status
202 fi
203 # Delete PID, sock files
204 rm -f /var/run/bbstored.*
205 }