wok-current rev 9282

Add backuppc
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Mar 16 09:13:12 2011 +0100 (2011-03-16)
parents 84e5f2e10ea6
children 6551d4df1ace
files backuppc/receipt backuppc/stuff/etc/BackupPC/shutdown.sh backuppc/stuff/etc/BackupPC/woh.sh backuppc/stuff/etc/init.d/backuppc
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/backuppc/receipt	Wed Mar 16 09:13:12 2011 +0100
     1.3 @@ -0,0 +1,74 @@
     1.4 +# SliTaz package receipt.
     1.5 +
     1.6 +PACKAGE="backuppc"
     1.7 +SOURCE="BackupPC"
     1.8 +VERSION="3.2.0"
     1.9 +CATEGORY="network"
    1.10 +SHORT_DESC="high-performance, enterprise-grade system for backing up Linux"
    1.11 +MAINTAINER="pascal.bellard@slitaz.org"
    1.12 +TARBALL="$SOURCE-$VERSION.tar.gz"
    1.13 +WEB_SITE="http://backuppc.sourceforge.net/"
    1.14 +WGET_URL="$SF_MIRROR/$PACKAGE/$TARBALL"
    1.15 +DEPENDS="tar perl-file-rsync perl perl-compress-raw-zlib perl-archive-zip \
    1.16 +rsync bzip2 apache-mod-perl perl-xml-rss perl-net-ftp \
    1.17 +perl-net-ftp-retrhandle perl-net-ftp-autoreconnect smbclient samba postfix \
    1.18 +bzip2 openssh perl-lwp-useragent"
    1.19 +BUILD_DEPENDS="par2"
    1.20 +SUGGESTED="par2"
    1.21 +CONFIG_FILES="/etc/BackupPC/config.pl"
    1.22 +
    1.23 +# Rules to configure and make the package.
    1.24 +compile_rules()
    1.25 +{
    1.26 +	cd $src
    1.27 +	mkdir -p $PWD/_pkg/etc/apache/conf.d
    1.28 +	cp httpd/BackupPC.conf $PWD/_pkg/etc/apache/conf.d
    1.29 +	perl configure.pl --batch --dest-dir=$PWD/_pkg --install-dir=/usr \
    1.30 +		--data-dir=/var/lib/BackupPC --config-dir=/etc/BackupPC \
    1.31 +		--log-dir=/var/log/BackupPC --backuppc-user=www \
    1.32 +		--hostname=localhost --html-dir=/usr/share/BackupPC/www \
    1.33 +		--html-dir-url=/BackupPC/img --cgi-dir=/usr/share/BackupPC/cgi
    1.34 +}
    1.35 +
    1.36 +# Rules to gen a SliTaz package suitable for Tazpkg.
    1.37 +genpkg_rules()
    1.38 +{
    1.39 +	cp -a $_pkg/* $fs
    1.40 +	cp -a stuff/* $fs
    1.41 +	sed -i -e "s/''http/'http/;s/min''/min'/" \
    1.42 +	       -e 's/-E -N -d/-E -d/' \
    1.43 +	       -e "s/^\\\$Conf{CgiAdminUsers}.*/\$Conf{CgiAdminUsers} = 'root';/" \
    1.44 +	       -e 's|sshPath -q -x|sshPath -i /etc/BackupPC/.ssh/id_rsa -q -x|' \
    1.45 +		$fs/etc/BackupPC/config.pl
    1.46 +	chown www.www $fs/etc/BackupPC/config.pl
    1.47 +	chmod 755 $fs/etc $fs/var $fs/var/*
    1.48 +}
    1.49 +
    1.50 +post_install()
    1.51 +{
    1.52 +	grep -qs backuppc $1/etc/rcS.conf ||
    1.53 +	sed -i 's/^RUN_DAEMONS="/RUN_DAEMONS="backuppc /' $1/etc/rcS.conf
    1.54 +	loc=$LANG
    1.55 +	[ -s $1/usr/lib/BackupPC/Lang/$loc.pm ] || loc=${loc:0:2}
    1.56 +	[ -s $1/usr/lib/BackupPC/Lang/$loc.pm ] &&
    1.57 +	sed -i "s/'en'/'$loc'/" $1/etc/BackupPC/config.pl
    1.58 +	[ -x /usr/bin/par2 ] &&
    1.59 +	sed -i 's/{ArchivePar} =.*/{ArchivePar} = 5;/' $1/etc/BackupPC/config.pl
    1.60 +	if [ ! -d $1/etc/BackupPC/.ssh ]; then
    1.61 +		mkdir $1/etc/BackupPC/.ssh
    1.62 +		ssh-keygen -t rsa -f $1/etc/BackupPC/.ssh/id_rsa -C '' -N ''
    1.63 +	fi
    1.64 +	if [ -z "$1" ]; then
    1.65 +		/etc/init.d/apache stop
    1.66 +		sleep 2
    1.67 +		/etc/init.d/backuppc start
    1.68 +		/etc/init.d/apache start
    1.69 +	fi
    1.70 +	cat <<EOT
    1.71 +Now you should :
    1.72 +- append $1/etc/BackupPC/.ssh/id_rsa.pub to every unix client /root/.ssh/authorized_keys file
    1.73 +- update \$Conf{CgiAdminUsers} in $1/etc/BackupPC/config.pl 
    1.74 +- enable web access with 'htpasswd -c root /etc/BackupPC/BackupPC.users'
    1.75 +- update passwords in /etc/BackupPC/*.sh
    1.76 +EOT
    1.77 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/backuppc/stuff/etc/BackupPC/shutdown.sh	Wed Mar 16 09:13:12 2011 +0100
     2.3 @@ -0,0 +1,15 @@
     2.4 +#!/bin/sh
     2.5 +
     2.6 +# In /etc/BackupPC/config.pl:
     2.7 +# $Conf{DumpPostUserCmd} = '/etc/backuppc/shutdown.sh $host $xferOK';
     2.8 +
     2.9 +ADMUSER=administrator
    2.10 +ADMPASS=passwdadministrator
    2.11 +
    2.12 +if [ $(date +%k) -lt 07 -o $(date +%k ) -gt 20 ]; then
    2.13 +	/usr/bin/net rpc SHUTDOWN -f -I $1 -U $ADMUSER%$ADMPASS -t 30
    2.14 +else
    2.15 +	msg="Backup failed."
    2.16 +	[ $2 = 1 ] && msg="Backup successful."
    2.17 +	echo "$msg" | smbclient -M $1 --user="backuppc"
    2.18 +fi
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/backuppc/stuff/etc/BackupPC/woh.sh	Wed Mar 16 09:13:12 2011 +0100
     3.3 @@ -0,0 +1,14 @@
     3.4 +#!/bin/sh
     3.5 +
     3.6 +# In /etc/BackupPC/config.pl:
     3.7 +# $Conf{DumpPreUserCmd} = '/etc/backuppc/wol.sh $host $userName';
     3.8 +
     3.9 +USER=$2
    3.10 +#USER=$2%thepassword
    3.11 +
    3.12 +/usr/bin/ether-wake $1
    3.13 +sleep 60
    3.14 +for i in $(seq 1 15); do
    3.15 +	smbclient -L $1 -U $USER >/dev/null && break
    3.16 +	sleep 10
    3.17 +done
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/backuppc/stuff/etc/init.d/backuppc	Wed Mar 16 09:13:12 2011 +0100
     4.3 @@ -0,0 +1,64 @@
     4.4 +#!/bin/sh
     4.5 +# /etc/init.d/backuppc: Start, stop and restart backuppc daemon on SliTaz, at boot
     4.6 +# time or with the command line.
     4.7 +#
     4.8 +# To start daemon at boot time, just put the right name in the $RUN_DAEMONS
     4.9 +# variable of /etc/rcS.conf and configure options with /etc/daemons.conf.
    4.10 +#
    4.11 +. /etc/init.d/rc.functions
    4.12 +. /etc/daemons.conf
    4.13 +
    4.14 +NAME=BackupPC
    4.15 +DESC="backuppc deamon"
    4.16 +DAEMON=/usr/bin/BackupPC
    4.17 +OPTIONS=$BACKUPPC_OPTIONS
    4.18 +[ -n "$OPTIONS" ] || OPTIONS="-d"
    4.19 +PIDFILE=/var/run/backuppc.pid
    4.20 +
    4.21 +case "$1" in
    4.22 +  start)
    4.23 +    if active_pidfile $PIDFILE $NAME ; then
    4.24 +      echo "$NAME already running."
    4.25 +      exit 1
    4.26 +    fi
    4.27 +    echo -n "Starting $DESC: $NAME... "
    4.28 +    su -s /bin/sh -c "$DAEMON $OPTIONS" www
    4.29 +    pidof $NAME | awk '{ print $1 }' > $PIDFILE
    4.30 +    status
    4.31 +    ;;
    4.32 +  stop)
    4.33 +    if ! active_pidfile $PIDFILE $NAME ; then
    4.34 +      echo "$NAME is not running."
    4.35 +      exit 1
    4.36 +    fi
    4.37 +    echo -n "Stopping $DESC: $NAME... "
    4.38 +    kill `cat $PIDFILE`
    4.39 +    rm $PIDFILE
    4.40 +    status
    4.41 +    ;;
    4.42 +  restart)
    4.43 +    if ! active_pidfile $PIDFILE $NAME ; then
    4.44 +      echo "$NAME is not running."
    4.45 +      exit 1
    4.46 +    fi
    4.47 +    echo -n "Restarting $DESC: $NAME... "
    4.48 +    kill `cat $PIDFILE`
    4.49 +    rm $PIDFILE
    4.50 +    sleep 2
    4.51 +    su -c "$DAEMON $OPTIONS" www
    4.52 +    pidof $NAME | awk '{ print $1 }' > $PIDFILE
    4.53 +    status
    4.54 +    ;;
    4.55 +  reload)
    4.56 +    kill -1 `cat $PIDFILE`
    4.57 +    status
    4.58 +    ;;
    4.59 +  *)
    4.60 +    echo ""
    4.61 +    echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
    4.62 +    echo ""
    4.63 +    exit 1
    4.64 +    ;;
    4.65 +esac
    4.66 +
    4.67 +exit 0