wok-current diff boxbackup-server/receipt @ rev 1664
Add perl-convert-asn1
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Nov 08 13:52:54 2008 +0000 (2008-11-08) |
parents | |
children | a7e71267442a |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/boxbackup-server/receipt Sat Nov 08 13:52:54 2008 +0000 1.3 @@ -0,0 +1,180 @@ 1.4 +# SliTaz package receipt. 1.5 + 1.6 +PACKAGE="boxbackup-server" 1.7 +VERSION="0.10" 1.8 +CATEGORY="network" 1.9 +SHORT_DESC="Server for the BoxBackup on-line backup system" 1.10 +MAINTAINER="domcox@users.sourceforge.net" 1.11 +DEPENDS="db libedit openssl perl zlib" 1.12 +BUILD_DEPENDS="db-dev libedit-dev openssl-dev zlib-dev" 1.13 +SOURCE="boxbackup" 1.14 +TARBALL="$SOURCE-$VERSION.tgz" 1.15 +WEB_SITE="http://www.boxbackup.org/" 1.16 +WGET_URL="$SF_MIRROR/$SOURCE/$TARBALL" 1.17 + 1.18 +# Configuration variables 1.19 +HOSTNAME=`ifconfig | awk -F ":" '/cast/ {print substr($2,0, index($2," ")-1) }'` 1.20 +CONF_DIR="/etc/box" 1.21 +DATA_DIR="/var/lib/bbstored" 1.22 +CA_DIR="${CONF_DIR}/ca" 1.23 +BBUSER="bbstored" 1.24 + 1.25 +# Rules to configure and make the package. 1.26 +compile_rules() 1.27 +{ 1.28 + cd $src 1.29 + ./configure --prefix=/usr $CONFIGURE_ARGS 1.30 + make 1.31 +} 1.32 + 1.33 +# Rules to gen a SliTaz package suitable for Tazpkg. 1.34 +genpkg_rules() 1.35 +{ 1.36 + _pkg=$WOK/$PACKAGE/${SOURCE}-${VERSION}/parcels/boxbackup-${VERSION}-backup-server-linux-gnu 1.37 + mkdir -p $fs/usr/bin 1.38 + cp -a $_pkg/bb* $fs/usr/bin 1.39 + cp -a $_pkg/ra* $fs/usr/bin 1.40 + mkdir -p $fs/etc/init.d 1.41 + cp -a stuff/bbstored $fs/etc/init.d 1.42 +} 1.43 + 1.44 + 1.45 +# Pre and post install commands for Tazpkg. 1.46 + 1.47 +pre_install() 1.48 +{ 1.49 + # Stop daemon 1.50 + if [ -e /var/run/bbstored.pid ]; then 1.51 + /etc/init.d/bbstored stop 1.52 + fi 1.53 +} 1.54 + 1.55 +post_install() 1.56 +{ 1.57 + # adduser BBUSER if needed 1.58 + if ! grep -q $BBUSER $1/etc/passwd; then 1.59 + echo -n "Adding user '$BBUSER'..." 1.60 + echo $BBUSER':x:505:505:BoxBackup Network Backup:/dev/null:/bin/false' >> $1/etc/passwd 1.61 + echo $BBUSER':!:14013:0:99999:7:::' >> $1/etc/shadow 1.62 + echo $BBUSER':x:505:' >> $1/etc/group 1.63 + echo $BBUSER':!::' >> $1/etc/gshadow 1.64 + status 1.65 + fi 1.66 + 1.67 + # Create config is needed 1.68 + if [ ! -e $CONF_DIR ]; then 1.69 + mkdir -p $CONF_DIR && chown $BBUSER $CONF_DIR && chmod 700 $CONF_DIR 1.70 + fi 1.71 + 1.72 + if [ ! -e $DATA_DIR/backup ]; then 1.73 + # Creating backup dir 1.74 + echo -n "Creating backup directory..." 1.75 + mkdir -p $DATA_DIR/backup && chown -R $BBUSER $DATA_DIR && chmod -R 700 $DATA_DIR 1.76 + status 1.77 + fi 1.78 + 1.79 + if [ ! -e $CONF_DIR/raidfile.conf ]; then 1.80 + # RAID Setup 1.81 + echo -n "Disabling deprecated userland RAID..." 1.82 + /usr/bin/raidfile-config $CONF_DIR 2048 $DATA_DIR 2>1 > /dev/null 1.83 + status 1.84 + chown -R $BBUSER $CONF_DIR/raidfile.conf && chmod 700 -R $CONF_DIR/raidfile.conf 1.85 + fi 1.86 + 1.87 + if [ ! -e $CONF_DIR/bbstored.conf ]; then 1.88 + # Setting hostname 1.89 + echo -n "Setting hostname... " 1.90 + if [ `hostname -f 2>1 > /dev/null;echo $?` -eq 0 ]; then 1.91 + HOSTNAME=`hostname -f` 1.92 + fi 1.93 + if [ -z $HOSTNAME ]; then 1.94 + HOSTNAME="127.0.0.1" 1.95 + fi 1.96 + echo $HOSTNAME 1.97 + 1.98 + # Setting up the CA environment 1.99 + echo -n "Creating certificates..." 1.100 + /usr/bin/bbstored-certs $CA_DIR init 2>1 > /dev/null 1.101 + status 1.102 + 1.103 + # Generate server certificate request 1.104 + echo -n "Generate server certificate request..." 1.105 + bbstored-config $CONF_DIR $HOSTNAME $BBUSER 2>1 > /dev/null 1.106 + status 1.107 + 1.108 + # Sign the server certificate 1.109 + echo -n "Sign the server certificate..." 1.110 + openssl x509 -req -sha1 -extensions usr_crt \ 1.111 + -in $CONF_DIR/$BBUSER/${HOSTNAME}-csr.pem \ 1.112 + -CA $CA_DIR/roots/serverCA.pem \ 1.113 + -CAkey $CA_DIR/keys/serverRootKey.pem \ 1.114 + -out $CA_DIR/servers/${HOSTNAME}-cert.pem \ 1.115 + -days 5000 2>1 > /dev/null 1.116 + status 1.117 + 1.118 + # Preparing the server certificates 1.119 + echo -n "Installing server certificate..." 1.120 + cp -a $CA_DIR/servers/${HOSTNAME}-cert.pem $CONF_DIR/$BBUSER 1.121 + status 1.122 + echo -n "Installing client certificate..." 1.123 + cp -a $CA_DIR/roots/clientCA.pem $CONF_DIR/$BBUSER 1.124 + status 1.125 + 1.126 + # Securing $CONF_DIR 1.127 + chown -R $BBUSER $CONF_DIR/bbstored* && chmod 700 -R $CONF_DIR/bbstored* 1.128 + fi 1.129 + 1.130 + if [ -e $CA_DIR ]; then 1.131 + # Warning 1.132 + echo 1.133 + echo "IMPORTANT NOTE:" 1.134 + echo "--------------" 1.135 + echo "The certificate authority directory $CA_DIR is intended to be" 1.136 + echo "moved to another system. It should not be kept on the backup server" 1.137 + echo "to limit the impact of a server compromise." 1.138 + fi 1.139 +} 1.140 + 1.141 +# Pre and post remove commands for Tazpkg 1.142 + 1.143 +pre_remove() 1.144 +{ 1.145 + /etc/init.d/bbstored stop 1.146 +} 1.147 + 1.148 +post_remove() 1.149 +{ 1.150 + if grep -q $BBUSER $1/etc/passwd; then 1.151 + echo -n "Removing $BBUSER user..." 1.152 + deluser bbstored 1.153 + status 1.154 + fi 1.155 + # Delete data 1.156 + if [ -e $DATA_DIR ]; then 1.157 + echo -n "Removing all backup data..." 1.158 + rm -r $DATA_DIR 1.159 + status 1.160 + fi 1.161 + # Delete bbstored conf files 1.162 + if [ -e $CONF_DIR/bbstored.conf ]; then 1.163 + echo -n "Removing config files..." 1.164 + rm -rf $CONF_DIR/bbstored 1.165 + rm -f $CONF_DIR/raidfile.conf 1.166 + rm -f $CONF_DIR/bbstored.conf 1.167 + status 1.168 + fi 1.169 + # Delete certificates 1.170 + if [ -e $CA_DIR ]; then 1.171 + echo -n "Removing certificates..." 1.172 + rm -r $CA_DIR 1.173 + status 1.174 + fi 1.175 + # Delete $CONF_DIR (if empty) 1.176 + if [ `ls $CONF_DIR | wc -l` -eq 0 ]; then 1.177 + echo -n "Removing $CONF_DIR..." 1.178 + rm -r $CONF_DIR 1.179 + status 1.180 + fi 1.181 + # Delete PID, sock files 1.182 + rm -f /var/run/bbstored.* 1.183 +} 1.184 \ No newline at end of file