wok-current annotate boxbackup-server/receipt @ rev 24624
updated grep (3.4 -> 3.7)
author | Hans-G?nter Theisgen |
---|---|
date | Mon Mar 07 16:56:05 2022 +0100 (2022-03-07) |
parents | fca69926510b |
children |
rev | line source |
---|---|
domcox@1357 | 1 # SliTaz package receipt. |
domcox@1357 | 2 |
domcox@1357 | 3 PACKAGE="boxbackup-server" |
Hans-G?nter@22561 | 4 VERSION="0.12" |
domcox@1357 | 5 CATEGORY="network" |
Hans-G?nter@22561 | 6 TAGS="backup automatic server network" |
Hans-G?nter@22561 | 7 SHORT_DESC="Server for the BoxBackup on-line backup system." |
domcox@12350 | 8 MAINTAINER="domcox@slitaz.org" |
pascal@15202 | 9 LICENSE="GPL2" |
pascal@21601 | 10 WEB_SITE="https://www.boxbackup.org/" |
Hans-G?nter@22561 | 11 |
domcox@1357 | 12 SOURCE="boxbackup" |
Hans-G?nter@22561 | 13 TARBALL="$SOURCE-$VERSION.tar.gz" |
Hans-G?nter@22561 | 14 WGET_URL="https://github.com/$SOURCE/$SOURCE/archive/BoxBackup-$VERSION.master.190831.9e0e93e.tar.gz" |
domcox@1357 | 15 |
Hans-G?nter@22561 | 16 DEPENDS="db gcc-lib-base libedit openssl perl zlib" |
Hans-G?nter@22562 | 17 BUILD_DEPENDS="autoconf automake db-dev libedit-dev libxslt openssl-dev zlib-dev" |
pascal@15202 | 18 |
domcox@1357 | 19 # Configuration variables |
domcox@12350 | 20 HOSTNAME=$(ifconfig | awk -F ":" '/cast/ {print substr($2,0, index($2," ")-1) }') |
domcox@12350 | 21 CONF_DIR="/etc/boxbackup" |
domcox@1357 | 22 DATA_DIR="/var/lib/bbstored" |
domcox@1357 | 23 CA_DIR="${CONF_DIR}/ca" |
domcox@1357 | 24 BBUSER="bbstored" |
domcox@1357 | 25 |
pascal@24055 | 26 current_version() |
pascal@24055 | 27 { |
pascal@24055 | 28 wget -O - ${WGET_URL%/arch*}/releases 2>/dev/null | \ |
pascal@24055 | 29 sed '/archive.*tar/!d;s|.*/BoxBackup-\(.*\).master.*|\1|;q' |
pascal@24055 | 30 } |
pascal@24055 | 31 |
domcox@1357 | 32 # Rules to configure and make the package. |
domcox@1357 | 33 compile_rules() |
domcox@1357 | 34 { |
Hans-G?nter@22561 | 35 ./bootstrap && |
pascal@4998 | 36 ./configure --prefix=/usr $CONFIGURE_ARGS && |
Hans-G?nter@22561 | 37 make -j1 && |
Hans-G?nter@22561 | 38 { |
pascal@9047 | 39 mkdir -p $DESTDIR |
Hans-G?nter@22561 | 40 cp -a parcels/boxbackup-git_-backup-client-i486-slitaz-linux-gnu $DESTDIR |
Hans-G?nter@22561 | 41 cp -a parcels/boxbackup-git_-backup-server-i486-slitaz-linux-gnu $DESTDIR |
Hans-G?nter@22561 | 42 rm -f $DESTDIR/boxbackup-git_-backup-server-i486-slitaz-linux-gnu/*.* |
pascal@9047 | 43 } |
al@19288 | 44 cook_pick_manpages $src/docs/man/* |
domcox@1357 | 45 } |
domcox@1357 | 46 |
domcox@1357 | 47 # Rules to gen a SliTaz package suitable for Tazpkg. |
domcox@1357 | 48 genpkg_rules() |
domcox@1357 | 49 { |
domcox@1357 | 50 mkdir -p $fs/usr/bin |
domcox@1357 | 51 mkdir -p $fs/etc/init.d |
Hans-G?nter@22561 | 52 |
Hans-G?nter@22561 | 53 cp -a $install/boxbackup-git_-backup-server-i486-slitaz-linux-gnu/bb* \ |
Hans-G?nter@22561 | 54 $fs/usr/bin |
Hans-G?nter@22561 | 55 cp -a $install/boxbackup-git_-backup-server-i486-slitaz-linux-gnu/ra* \ |
Hans-G?nter@22561 | 56 $fs/usr/bin |
pankso@9697 | 57 cp -a $stuff/bbstored $fs/etc/init.d |
domcox@1357 | 58 } |
domcox@1357 | 59 |
domcox@1357 | 60 |
domcox@1357 | 61 # Pre and post install commands for Tazpkg. |
domcox@1357 | 62 |
domcox@1357 | 63 pre_install() |
domcox@1357 | 64 { |
domcox@1357 | 65 # Stop daemon |
Hans-G?nter@22561 | 66 if [ -z "$1" -a -e /var/run/bbstored.pid ] |
Hans-G?nter@22561 | 67 then |
domcox@1357 | 68 /etc/init.d/bbstored stop |
domcox@1357 | 69 fi |
domcox@1357 | 70 } |
domcox@1357 | 71 |
domcox@1357 | 72 post_install() |
domcox@1357 | 73 { |
Hans-G?nter@22561 | 74 # default configuration directory is now /etc/boxbackup |
Hans-G?nter@22561 | 75 if [ ! -e "$1/etc/box/bbstored.conf" ] |
Hans-G?nter@22561 | 76 then |
pascal@18732 | 77 mv "$1/etc/box" "$1$CONF_DIR" |
domcox@12350 | 78 fi |
domcox@12350 | 79 |
domcox@1357 | 80 # adduser BBUSER if needed |
Hans-G?nter@22561 | 81 if ! grep -q $BBUSER "$1/etc/passwd" |
Hans-G?nter@22561 | 82 then |
al@18668 | 83 echo |
al@18668 | 84 action "Adding user '$BBUSER'..." |
pascal@18730 | 85 echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> "$1/etc/passwd" |
pascal@18730 | 86 echo $BBUSER':!:14013:0:99999:7:::' >> "$1/etc/shadow" |
pascal@18730 | 87 echo $BBUSER':x:505:' >> "$1/etc/group" |
pascal@18730 | 88 echo $BBUSER':!::' >> "$1/etc/gshadow" |
domcox@1357 | 89 status |
domcox@1357 | 90 fi |
domcox@1357 | 91 |
Hans-G?nter@22561 | 92 # Create configuration as needed |
Hans-G?nter@22561 | 93 if [ ! -e "$1$CONF_DIR" ] |
Hans-G?nter@22561 | 94 then |
pascal@18730 | 95 mkdir -p "$1$CONF_DIR" && |
pascal@18730 | 96 chroot "$1/" chown $BBUSER $CONF_DIR && |
pascal@18730 | 97 chmod 700 "$1$CONF_DIR" |
domcox@1357 | 98 fi |
domcox@1357 | 99 |
Hans-G?nter@22561 | 100 if [ ! -e "$1$DATA_DIR/backup" ] |
Hans-G?nter@22561 | 101 then |
Hans-G?nter@22561 | 102 # Creating backup directory |
al@18668 | 103 action "Creating backup directory..." |
pascal@18730 | 104 mkdir -p "$1$DATA_DIR/backup" && |
pascal@18730 | 105 chroot "$1/" chown -R $BBUSER $DATA_DIR && |
pascal@18730 | 106 chmod -R 700 "$1$DATA_DIR" |
domcox@1357 | 107 status |
domcox@1357 | 108 fi |
domcox@1357 | 109 |
Hans-G?nter@22561 | 110 if [ ! -e "$1$CONF_DIR/raidfile.conf" ] |
Hans-G?nter@22561 | 111 then |
domcox@1357 | 112 # RAID Setup |
al@18668 | 113 action "Disabling deprecated userland RAID..." |
pascal@18730 | 114 chroot "$1/" /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null |
domcox@1357 | 115 status |
pascal@18730 | 116 chroot "$1/" chown -R $BBUSER $CONF_DIR/raidfile.conf && |
pascal@18730 | 117 chmod 700 -R "$1$CONF_DIR/raidfile.conf" |
domcox@1357 | 118 fi |
domcox@1357 | 119 |
Hans-G?nter@22561 | 120 if [ ! -e "$1$CONF_DIR/bbstored.conf" ] |
Hans-G?nter@22561 | 121 then |
domcox@1357 | 122 # Setting hostname |
al@18668 | 123 action "Setting hostname... " |
Hans-G?nter@22561 | 124 if [ $(chroot "$1/" hostname -f 2>1 > /dev/null;echo $?) -eq 0 ] |
Hans-G?nter@22561 | 125 then |
pascal@18730 | 126 HOSTNAME=$(chroot "$1/" hostname -f) |
domcox@1357 | 127 fi |
Hans-G?nter@22561 | 128 if [ -z $HOSTNAME ] |
Hans-G?nter@22561 | 129 then |
domcox@1357 | 130 HOSTNAME="127.0.0.1" |
domcox@1357 | 131 fi |
pascal@17940 | 132 export $HOSTNAME |
domcox@1357 | 133 echo $HOSTNAME |
domcox@1357 | 134 |
domcox@1357 | 135 # Setting up the CA environment |
al@18668 | 136 action "Creating certificates..." |
pascal@18730 | 137 chroot "$1/" /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null |
domcox@1357 | 138 status |
domcox@1357 | 139 |
domcox@1357 | 140 # Generate server certificate request |
al@18668 | 141 action "Generate server certificate request..." |
pascal@18730 | 142 chroot "$1/" bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null |
domcox@1357 | 143 status |
domcox@1357 | 144 |
domcox@1357 | 145 # Sign the server certificate |
al@18668 | 146 action "Sign the server certificate..." |
Hans-G?nter@22561 | 147 chroot "$1/" openssl x509 -req -sha1 -extensions usr_crt \ |
Hans-G?nter@22561 | 148 -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \ |
Hans-G?nter@22561 | 149 -CA $CA_DIR/roots/serverCA.pem \ |
Hans-G?nter@22561 | 150 -CAkey $CA_DIR/keys/serverRootKey.pem \ |
Hans-G?nter@22561 | 151 -out $CA_DIR/servers/${HOSTNAME}-cert.pem \ |
domcox@1357 | 152 -days 5000 2>1 > /dev/null |
domcox@1357 | 153 status |
domcox@1357 | 154 |
domcox@1357 | 155 # Preparing the server certificates |
al@18668 | 156 action "Installing server certificate..." |
Hans-G?nter@22561 | 157 cp -a "$1$CA_DIR/servers/${HOSTNAME}-cert.pem" \ |
Hans-G?nter@22561 | 158 "$1$CONF_DIR/$BBUSER" |
domcox@1357 | 159 status |
al@18668 | 160 action "Installing client certificate..." |
Hans-G?nter@22561 | 161 cp -a "$1$CA_DIR/roots/clientCA.pem" \ |
Hans-G?nter@22561 | 162 "$1$CONF_DIR/$BBUSER" |
domcox@1357 | 163 status |
domcox@1357 | 164 |
domcox@1357 | 165 # Securing $CONF_DIR |
pascal@18730 | 166 chroot "$1/" chown -R $BBUSER $CONF_DIR/bbstored* && |
pascal@18730 | 167 chmod 700 -R "$1$CONF_DIR/bbstored"* |
domcox@1357 | 168 fi |
domcox@1357 | 169 |
Hans-G?nter@22561 | 170 if [ -e "$1$CA_DIR" ] |
Hans-G?nter@22561 | 171 then |
domcox@1357 | 172 # Warning |
domcox@1357 | 173 echo |
domcox@1357 | 174 echo "IMPORTANT NOTE:" |
domcox@1357 | 175 echo "--------------" |
domcox@1357 | 176 echo "The certificate authority directory $CA_DIR is intended to be" |
domcox@1357 | 177 echo "moved to another system. It should not be kept on the backup server" |
domcox@1357 | 178 echo "to limit the impact of a server compromise." |
domcox@1357 | 179 fi |
domcox@1357 | 180 } |
domcox@1357 | 181 |
domcox@1357 | 182 # Pre and post remove commands for Tazpkg |
domcox@1357 | 183 |
domcox@1357 | 184 pre_remove() |
domcox@1357 | 185 { |
domcox@1357 | 186 /etc/init.d/bbstored stop |
domcox@1357 | 187 } |
domcox@1357 | 188 |
domcox@1357 | 189 post_remove() |
domcox@1357 | 190 { |
al@18668 | 191 echo |
Hans-G?nter@22561 | 192 if grep -q $BBUSER /etc/passwd |
Hans-G?nter@22561 | 193 then |
al@18668 | 194 action "Removing $BBUSER user..." |
domcox@1357 | 195 deluser bbstored |
domcox@1357 | 196 status |
domcox@1357 | 197 fi |
Hans-G?nter@22561 | 198 |
domcox@1357 | 199 # Delete data |
Hans-G?nter@22561 | 200 if [ -e $DATA_DIR ] |
Hans-G?nter@22561 | 201 then |
al@18668 | 202 action "Removing all backup data..." |
domcox@1357 | 203 rm -r $DATA_DIR |
domcox@1357 | 204 status |
domcox@1357 | 205 fi |
Hans-G?nter@22561 | 206 |
Hans-G?nter@22561 | 207 # Delete bbstored configuration files |
Hans-G?nter@22561 | 208 if [ -e $CONF_DIR/bbstored.conf ] |
Hans-G?nter@22561 | 209 then |
al@18668 | 210 action "Removing config files..." |
domcox@1357 | 211 rm -rf $CONF_DIR/bbstored |
domcox@1357 | 212 rm -f $CONF_DIR/raidfile.conf |
domcox@1357 | 213 rm -f $CONF_DIR/bbstored.conf |
domcox@1357 | 214 status |
domcox@1357 | 215 fi |
Hans-G?nter@22561 | 216 |
domcox@1357 | 217 # Delete certificates |
Hans-G?nter@22561 | 218 if [ -e $CA_DIR ] |
Hans-G?nter@22561 | 219 then |
al@18668 | 220 action "Removing certificates..." |
al@18668 | 221 rm -r $CA_DIR |
domcox@1357 | 222 status |
al@18668 | 223 fi |
Hans-G?nter@22561 | 224 |
domcox@1357 | 225 # Delete $CONF_DIR (if empty) |
Hans-G?nter@22561 | 226 if [ $(ls -lA $CONF_DIR | wc -l) -eq 0 ] |
Hans-G?nter@22561 | 227 then |
al@18668 | 228 action "Removing $CONF_DIR..." |
domcox@1357 | 229 rm -r $CONF_DIR |
domcox@1357 | 230 status |
domcox@1357 | 231 fi |
Hans-G?nter@22561 | 232 |
domcox@1357 | 233 # Delete PID, sock files |
domcox@1357 | 234 rm -f /var/run/bbstored.* |
jozee@3568 | 235 } |