slitaz-forge diff tank/tank @ rev 186

Update tank util and add vhosts.conf
author Christophe Lincoln <pankso@slitaz.org>
date Tue Mar 20 22:12:29 2012 +0100 (2012-03-20)
parents 7bebd2b3700d
children eb06ca412415
line diff
     1.1 --- a/tank/tank	Wed Mar 14 03:12:37 2012 +0100
     1.2 +++ b/tank/tank	Tue Mar 20 22:12:29 2012 +0100
     1.3 @@ -1,4 +1,5 @@
     1.4  #!/bin/sh
     1.5 +#
     1.6  # Tank - Admin Tank, backup, update and give stats.
     1.7  #
     1.8  # (C) 2011 SliTaz - GNU General Public License.
     1.9 @@ -10,16 +11,14 @@
    1.10  VHOST="$WWW/tank"
    1.11  WEBSITE="$WWW/website"
    1.12  BACKUPS="/home/backups"
    1.13 -PYTHON_LIB="/usr/lib/python2.5"
    1.14 -DOC_LIB="$WWW/doc/lib"
    1.15  
    1.16  usage() {
    1.17 -	echo -e "\nUsage: `basename $0` [command]
    1.18 +	cat << EOT
    1.19 +
    1.20 +Usage: $(basename $0) [command]
    1.21  Commands:
    1.22 -  stats|-s     Display some Tank stats
    1.23    backup|-b    Backup files and MySQL DB
    1.24    adduser      Add user on Tank and create people files
    1.25 -  chroot|-c    Move a user into a new chroot location
    1.26    up-stats     Update Awstats statistics (run by cron)
    1.27    
    1.28    up-tank      Update http://tank.slitaz.org/
    1.29 @@ -27,87 +26,19 @@
    1.30    up-pro       Update http://pro.slitaz.org/
    1.31    up-boot      Update http://boot.slitaz.org/
    1.32    up-cook      Update http://cook.slitaz.org/
    1.33 -  
    1.34 -  #up-www       Update website http://www.slitaz.org/
    1.35 -  #up-hg        Update template for http://hg.slitaz.org/
    1.36 -  #up-doc       Update template for http://doc.slitaz.org/\n"
    1.37 +
    1.38 +EOT
    1.39  }
    1.40  
    1.41  case "$1" in
    1.42 -	stats|-s)
    1.43 -		# Report some stats
    1.44 -		clear
    1.45 -		cat << EOF
    1.46 -
    1.47 -Connected user
    1.48 ---------------
    1.49 -`who`
    1.50 -
    1.51 -System usage
    1.52 -------------
    1.53 -`df -h`
    1.54 -
    1.55 -`free`
    1.56 -
    1.57 -EOF
    1.58 -		;;
    1.59 -	chroot|-c)
    1.60 -		# Move a user into a new chroot location
    1.61 -		if [ -s $2/bin/sh ] && grep -qs $3: /etc/password ; then
    1.62 -			grep -q ^chroot /etc/busybox.conf ||
    1.63 -			echo 'chroot = ssx root.root' >> /etc/busybox.conf
    1.64 -			[ -s /bin/chrootsh ] || cat > /bin/chrootsh << EOF
    1.65 -#!/bin/sh
    1.66 -
    1.67 -#case " \$@ " in                                        
    1.68 -#*rsync*) exec /bin/sh "\$@" ;;
    1.69 -#esac
    1.70 -
    1.71 -case "\$USER" in                                        
    1.72 -pankso) exec /bin/sh "\$@" ;;                      
    1.73 -*) exec /usr/sbin/chroot $2 /bin/chrootsh "\$@" ;;
    1.74 -esac
    1.75 -EOF
    1.76 -			[ -s $2/bin/chrootsh ] || cat > $2/bin/chrootsh << EOF
    1.77 -#!/bin/sh
    1.78 -
    1.79 -export SHELL='/bin/sh'
    1.80 -cd \$HOME
    1.81 -. /etc/profile
    1.82 -exec /bin/sh "\$@"
    1.83 -EOF
    1.84 -			chmod +x /bin/chrootsh $2/bin/chrootsh
    1.85 -			base=$(awk -F: "/^$3:/ { print \$6 }" /etc/passwd)
    1.86 -			target=$base
    1.87 -			while [ -L $target ]; do
    1.88 -				target=$(readlink $target)
    1.89 -			done
    1.90 -			mv $target $2/$base
    1.91 -			[ -L $base ] && rm -f $base
    1.92 -			ln -s $2/$base $base
    1.93 -			if ! grep -q ^$3: $2/etc/passwd ; then
    1.94 -				grep ^$3: /etc/passwd >> $2/etc/passwd
    1.95 -				grep ^$3: /etc/shadow >> $2/etc/shadow		fi
    1.96 -			fi
    1.97 -		else
    1.98 -			cat << EOF
    1.99 -Usage: $0 $1 newchroot user
   1.100 -Move a user in a new chroot location
   1.101 -EOF
   1.102 -		fi ;;
   1.103  	backup|-b)
   1.104  		# Backup config files and SQL db.
   1.105  		echo "TODO" ;;
   1.106 -	up-www)
   1.107 -		# Update website from repo.
   1.108 -		echo -e "\nUpdating: www.slitaz.org..."
   1.109 -		cd $WEBSITE && hg pull -u
   1.110 -		echo "" ;;
   1.111  	up-tank)
   1.112  		# Update Tank web interface: http://tank.slitaz.org/
   1.113  		echo -e "\nUpdating: tank.slitaz.org..."
   1.114  		cd $REPOS/slitaz-forge
   1.115 -		hg pull -u
   1.116 +		[ "$2" == "--nohg" ] || hg pull -u
   1.117  		rm -rf $VHOST/*.* $VHOST/images
   1.118  		cp -a tank/web/* $VHOST 
   1.119  		echo "" ;;
   1.120 @@ -115,7 +46,7 @@
   1.121  		# Update People web interface: http://people.slitaz.org/
   1.122  		echo -e "\nUpdating: people.slitaz.org..."
   1.123  		cd $REPOS/slitaz-forge
   1.124 -		hg pull -u
   1.125 +		[ "$2" == "--nohg" ] || hg pull -u
   1.126  		rm -rf $WWW/people/*
   1.127  		cp -a people/* $WWW/people 
   1.128  		echo "" ;;
   1.129 @@ -123,7 +54,7 @@
   1.130  		# Update Pro website: http://pro.slitaz.org/
   1.131  		echo -e "\nUpdating: pro.slitaz.org..."
   1.132  		cd $REPOS/slitaz-forge
   1.133 -		hg pull -u
   1.134 +		[ "$2" == "--nohg" ] || hg pull -u
   1.135  		rm -rf $WWW/pro/*
   1.136  		cp -a pro/* $WWW/pro
   1.137  		echo "" ;;
   1.138 @@ -131,7 +62,7 @@
   1.139  		# Update Web Boot interface: http://boot.slitaz.org/
   1.140  		echo -e "\nUpdating: boot.slitaz.org..."
   1.141  		cd $REPOS/slitaz-forge
   1.142 -		hg pull -u
   1.143 +		[ "$2" == "--nohg" ] || hg pull -u
   1.144  		rm -rf $WWW/boot/*
   1.145  		cp -a boot/* $WWW/boot 
   1.146  		echo "" ;;
   1.147 @@ -139,30 +70,15 @@
   1.148  		# Update Web Boot interface: http://boot.slitaz.org/
   1.149  		echo -e "\nUpdating: cook.slitaz.org..."
   1.150  		cd $REPOS/slitaz-forge
   1.151 -		hg pull -u
   1.152 +		[ "$2" == "--nohg" ] || hg pull -u
   1.153  		cp -a cook/* $WWW/cook
   1.154  		cp -a cook/* $WWW/cook/undigest
   1.155  		echo "" ;;
   1.156 -	up-hg)
   1.157 -		# Since Tank runs stable and we update the style in slitaz-dev-tools
   1.158 -		# the cooking package is unbuildable because it uses the new Tazwok function
   1.159 -		# with mercurial|*
   1.160 -		echo -e "\nUpdating Mercurial template..."
   1.161 -		cd $REPOS/slitaz-dev-tools && hg pull -u
   1.162 -		cp -a slitaz-mercurial-style/* $PYTHON_LIB/site-packages/mercurial
   1.163 -		chown -R root.root $PYTHON_LIB/site-packages/mercurial/templates
   1.164 -		echo "" ;;
   1.165 -	up-doc)
   1.166 -		# Update Wiki doc template from Hg: http://doc.slitaz.org/
   1.167 -		echo -e "\nUpdating Wiki documentation template..."
   1.168 -		cd $REPOS/slitaz-forge && hg pull -u
   1.169 -		cp -a doc/lib/tpl/* $DOC_LIB/tpl
   1.170 -		echo "" ;;
   1.171  	up-stats)
   1.172  		echo -e "\nUpdating all awstats databases..."
   1.173 -		for vh in pro boot cook
   1.174 +		for vh in pro boot cook people
   1.175  		do
   1.176 -			/var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org 
   1.177 +			/var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org -update
   1.178  		done
   1.179  		echo "" ;;
   1.180  	adduser)