wok-next diff 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
line diff
     1.1 --- a/boxbackup-server/receipt	Fri Dec 04 17:18:44 2015 +0200
     1.2 +++ b/boxbackup-server/receipt	Sun Dec 20 15:13:45 2015 +0100
     1.3 @@ -61,51 +61,51 @@
     1.4  post_install()
     1.5  {
     1.6  	# default conf dir is now /etc/boxbackup
     1.7 -	if [ ! -e $1/etc/box/bbstored.conf ]; then
     1.8 -		mv /etc/box $1$CONF_DIR
     1.9 +	if [ ! -e "$1/etc/box/bbstored.conf" ]; then
    1.10 +		mv /etc/box "$1$CONF_DIR"
    1.11  	fi
    1.12  
    1.13  	# adduser BBUSER if needed
    1.14 -	if  ! grep -q $BBUSER $1/etc/passwd; then
    1.15 +	if  ! grep -q $BBUSER "$1/etc/passwd"; then
    1.16  		echo
    1.17  		action "Adding user '$BBUSER'..."
    1.18 -		echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> $1/etc/passwd
    1.19 -		echo $BBUSER':!:14013:0:99999:7:::' >> $1/etc/shadow
    1.20 -		echo $BBUSER':x:505:' >> $1/etc/group
    1.21 -		echo $BBUSER':!::' >> $1/etc/gshadow
    1.22 +		echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> "$1/etc/passwd"
    1.23 +		echo $BBUSER':!:14013:0:99999:7:::' >> "$1/etc/shadow"
    1.24 +		echo $BBUSER':x:505:' >> "$1/etc/group"
    1.25 +		echo $BBUSER':!::' >> "$1/etc/gshadow"
    1.26  		status
    1.27  	fi
    1.28  
    1.29  	# Create config is needed
    1.30 -	if [ ! -e $1$CONF_DIR ]; then
    1.31 -		mkdir -p $1$CONF_DIR &&
    1.32 -		chroot $1/ chown $BBUSER $CONF_DIR &&
    1.33 -		chmod 700 $1$CONF_DIR
    1.34 +	if [ ! -e "$1$CONF_DIR" ]; then
    1.35 +		mkdir -p "$1$CONF_DIR" &&
    1.36 +		chroot "$1/" chown $BBUSER $CONF_DIR &&
    1.37 +		chmod 700 "$1$CONF_DIR"
    1.38  	fi
    1.39  
    1.40 -	if [ ! -e $1$DATA_DIR/backup ]; then
    1.41 +	if [ ! -e "$1$DATA_DIR/backup" ]; then
    1.42  		# Creating backup dir
    1.43  		action "Creating backup directory..."
    1.44 -		mkdir -p $1$DATA_DIR/backup &&
    1.45 -		chroot $1/ chown -R $BBUSER $DATA_DIR &&
    1.46 -		chmod -R 700 $1$DATA_DIR
    1.47 +		mkdir -p "$1$DATA_DIR/backup" &&
    1.48 +		chroot "$1/" chown -R $BBUSER $DATA_DIR &&
    1.49 +		chmod -R 700 "$1$DATA_DIR"
    1.50  		status
    1.51  	fi
    1.52  
    1.53 -	if [ ! -e $1$CONF_DIR/raidfile.conf ]; then
    1.54 +	if [ ! -e "$1$CONF_DIR/raidfile.conf" ]; then
    1.55  		# RAID Setup
    1.56  		action "Disabling deprecated userland RAID..."
    1.57 -		chroot $1/ /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
    1.58 +		chroot "$1/" /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null
    1.59  		status
    1.60 -		chroot $1/ chown -R $BBUSER $CONF_DIR/raidfile.conf &&
    1.61 -		chmod 700 -R $1$CONF_DIR/raidfile.conf
    1.62 +		chroot "$1/" chown -R $BBUSER $CONF_DIR/raidfile.conf &&
    1.63 +		chmod 700 -R "$1$CONF_DIR/raidfile.conf"
    1.64  	fi
    1.65  
    1.66 -	if [ ! -e $1$CONF_DIR/bbstored.conf ]; then
    1.67 +	if [ ! -e "$1$CONF_DIR/bbstored.conf" ]; then
    1.68  		# Setting hostname
    1.69  		action "Setting hostname... "
    1.70 -		if [ $(chroot $1/ hostname -f 2>1 > /dev/null;echo $?) -eq 0 ]; then
    1.71 -			HOSTNAME=$(chroot $1/ hostname -f)
    1.72 +		if [ $(chroot "$1/" hostname -f 2>1 > /dev/null;echo $?) -eq 0 ]; then
    1.73 +			HOSTNAME=$(chroot "$1/" hostname -f)
    1.74  		fi
    1.75  		if [ -z $HOSTNAME ]; then
    1.76  			HOSTNAME="127.0.0.1"
    1.77 @@ -115,17 +115,17 @@
    1.78  
    1.79  		# Setting up the CA environment
    1.80  		action "Creating certificates..."
    1.81 -		chroot $1/ /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
    1.82 +		chroot "$1/" /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null
    1.83  		status
    1.84  
    1.85  		# Generate server certificate request
    1.86  		action "Generate server certificate request..."
    1.87 -		chroot $1/ bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
    1.88 +		chroot "$1/" bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null
    1.89  		status
    1.90  
    1.91  		# Sign the server certificate
    1.92  		action "Sign the server certificate..."
    1.93 -		chroot $1/ openssl x509 -req -sha1 -extensions usr_crt \
    1.94 +		chroot "$1/" openssl x509 -req -sha1 -extensions usr_crt \
    1.95  			-in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \
    1.96  			-CA $CA_DIR/roots/serverCA.pem \
    1.97  			-CAkey $CA_DIR/keys/serverRootKey.pem \
    1.98 @@ -135,18 +135,18 @@
    1.99  
   1.100  		# Preparing the server certificates
   1.101  		action "Installing server certificate..."
   1.102 -		cp -a $1$CA_DIR/servers/${HOSTNAME}-cert.pem $1$CONF_DIR/$BBUSER
   1.103 +		cp -a "$1$CA_DIR/servers/${HOSTNAME}-cert.pem" "$1$CONF_DIR/$BBUSER"
   1.104  		status
   1.105  		action "Installing client certificate..."
   1.106 -		cp -a $1$CA_DIR/roots/clientCA.pem $1$CONF_DIR/$BBUSER
   1.107 +		cp -a "$1$CA_DIR/roots/clientCA.pem" "$1$CONF_DIR/$BBUSER"
   1.108  		status
   1.109  
   1.110  		# Securing $CONF_DIR
   1.111 -		chroot $1/ chown -R $BBUSER $CONF_DIR/bbstored* &&
   1.112 -		chmod 700 -R $1$CONF_DIR/bbstored*
   1.113 +		chroot "$1/" chown -R $BBUSER $CONF_DIR/bbstored* &&
   1.114 +		chmod 700 -R "$1$CONF_DIR/bbstored"*
   1.115  	fi
   1.116  
   1.117 -	if [ -e $1$CA_DIR ]; then
   1.118 +	if [ -e "$1$CA_DIR" ]; then
   1.119  		# Warning
   1.120  		echo
   1.121  		echo "IMPORTANT NOTE:"
   1.122 @@ -167,7 +167,7 @@
   1.123  post_remove()
   1.124  {
   1.125  	echo
   1.126 -	if  grep -q $BBUSER $1/etc/passwd; then
   1.127 +	if  grep -q $BBUSER /etc/passwd; then
   1.128  		action "Removing $BBUSER user..."
   1.129  		deluser bbstored
   1.130  		status