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