slitaz-forge diff tank/taztank @ rev 18

Add: actionmailer, actionpack, activerecord, activeresource, activesupport'
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Wed Mar 02 01:14:55 2011 +0100 (2011-03-02)
parents
children 24c246a96526
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tank/taztank	Wed Mar 02 01:14:55 2011 +0100
     1.3 @@ -0,0 +1,122 @@
     1.4 +#!/bin/sh
     1.5 +# Taztank - Admin Tank, backup, update and give stats.
     1.6 +# (C) 2011 SliTaz - GNU General Public License.
     1.7 +# Author: Christophe Lincoln <pankso@slitaz.org>
     1.8 +#
     1.9 +
    1.10 +REPOS="/home/slitaz/repos"
    1.11 +WWW="/home/slitaz/www"
    1.12 +VHOST="$WWW/tank"
    1.13 +BACKUPS="/home/backups"
    1.14 +
    1.15 +usage() {
    1.16 +	echo -e "\nUsage: `basename $0` [command]
    1.17 +Commands:
    1.18 +  stats         Display some Tank stats
    1.19 +  backup        Backup files and MySQL DB
    1.20 +  chroot	Move a user in a new chroot location
    1.21 +  up-web        Update http://tank.slitaz.org/
    1.22 +  up-people     Update http://people.slitaz.org/
    1.23 +  up-web-stats  Update Awstats statistics (run by cron)
    1.24 +  clean-labs    Clean Redmine Labs (no more on Tank)\n"
    1.25 +}
    1.26 +
    1.27 +case "$1" in
    1.28 +	stats)
    1.29 +		# Report some stats
    1.30 +		clear
    1.31 +		cat << EOF
    1.32 +
    1.33 +Connected user
    1.34 +--------------
    1.35 +`who`
    1.36 +
    1.37 +System usage
    1.38 +------------
    1.39 +`df -h`
    1.40 +
    1.41 +`free`
    1.42 +
    1.43 +EOF
    1.44 +		;;
    1.45 +	chroot)
    1.46 +		if [ -s $2/bin/sh ] && grep -qs $3: /etc/password ; then
    1.47 +			grep -q ^chroot /etc/busybox.conf ||
    1.48 +			echo 'chroot = ssx root.root' >> /etc/busybox.conf
    1.49 +			[ -s /bin/chrootsh ] || cat > /bin/chrootsh << EOF
    1.50 +#!/bin/sh
    1.51 +
    1.52 +#case " \$@ " in                                        
    1.53 +#*rsync*) exec /bin/sh "\$@" ;;
    1.54 +#esac
    1.55 +
    1.56 +case "\$USER" in                                        
    1.57 +pankso) exec /bin/sh "\$@" ;;                      
    1.58 +*) exec /usr/sbin/chroot $2 /bin/chrootsh "\$@" ;;
    1.59 +esac
    1.60 +EOF
    1.61 +			[ -s $2/bin/chrootsh ] || cat > $2/bin/chrootsh << EOF
    1.62 +#!/bin/sh
    1.63 +
    1.64 +export SHELL='/bin/sh'
    1.65 +cd \$HOME
    1.66 +. /etc/profile
    1.67 +exec /bin/sh "\$@"
    1.68 +EOF
    1.69 +			chmod +x /bin/chrootsh $2/bin/chrootsh
    1.70 +			base=$(awk -F: "/^$3:/ { print \$6 }" /etc/passwd)
    1.71 +			target=$base
    1.72 +			while [ -L $target ]; do
    1.73 +				target=$(readlink $target)
    1.74 +			done
    1.75 +			mv $target $2/$base
    1.76 +			[ -L $base ] && rm -f $base
    1.77 +			ln -s $2/$base $base
    1.78 +			if ! grep -q ^$3: $2/etc/passwd ; then
    1.79 +				grep ^$3: /etc/passwd >> $2/etc/passwd
    1.80 +				grep ^$3: /etc/shadow >> $2/etc/shadow		fi
    1.81 +			fi
    1.82 +		else
    1.83 +			cat << EOF
    1.84 +Usage: $0 $1 newchroot user
    1.85 +Move a user in a new chroot location
    1.86 +EOF
    1.87 +		fi
    1.88 +		;;
    1.89 +	backup)
    1.90 +		# Backup config files and SQL db.
    1.91 +		echo "Not yet implemented..." ;;
    1.92 +	up-web)
    1.93 +		# Update Tank web interface: http://tank.slitaz.org/
    1.94 +		echo -e "\nUpdating: tank.slitaz.org..."
    1.95 +		cd $REPOS/tank
    1.96 +		hg update
    1.97 +		rm -rf $VHOST/*.* $VHOST/pics/website
    1.98 +		cp -a web/* $VHOST ;;
    1.99 +	up-people)
   1.100 +		# Update People web interface: http://people.slitaz.org/
   1.101 +		echo -e "\nUpdating: people.slitaz.org..."
   1.102 +		cd $REPOS/slitaz-forge
   1.103 +		hg update
   1.104 +		rm -rf $WWW/people/*
   1.105 +		cp -a people/* $WWW/people ;;
   1.106 +	up-web-stats)
   1.107 +		echo -e "\nUpdating all awstats database...\n"
   1.108 +		for vh in www boot pkgs
   1.109 +		do
   1.110 +			/var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org 
   1.111 +		done ;;
   1.112 +	clean-labs)
   1.113 +		# Redmin need some time help
   1.114 +		/etc/init.d/lighttpd stop
   1.115 +		/etc/init.d/mysql stop
   1.116 +		killall ruby
   1.117 +		rm -rf labs/tmp/sessions
   1.118 +		mkdir -p labs/tmp/sessions
   1.119 +		chown www.www labs/tmp/sessions
   1.120 +		/etc/init.d/mysql start
   1.121 +		/etc/init.d/lighttpd start ;;
   1.122 +	*)
   1.123 +		usage ;;
   1.124 +esac
   1.125 +exit 0