slitaz-forge rev 11

Start adding tank repo to slitaz-forge. Only README, Makefile, and taztank.
author Christopher Rogers <slaxemulator@gmail.com>
date Wed Feb 23 22:04:10 2011 +0000 (2011-02-23)
parents 19bb493d351d
children 33479b294b31
files tank/Makefile tank/README tank/taztank
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tank/Makefile	Wed Feb 23 22:04:10 2011 +0000
     1.3 @@ -0,0 +1,19 @@
     1.4 +# Makefile for Tank tools.
     1.5 +# Check the README for more information.
     1.6 +#
     1.7 +PREFIX?=/usr
     1.8 +DESTDIR?=
     1.9 +	
    1.10 +all:
    1.11 +
    1.12 +install:
    1.13 +	mkdir -p $(DESTDIR)$(PREFIX)/bin
    1.14 +	cp -f taztank $(DESTDIR)$(PREFIX)/bin
    1.15 +
    1.16 +install-files:
    1.17 +	cp -a files/var $(DESTDIR)/
    1.18 +	chmod 0600 -p $(DESTDIR)/var/spool/cron/crontabs/root
    1.19 +	cp -a files/etc $(DESTDIR)/
    1.20 +
    1.21 +clean:
    1.22 +	rm -rf _pkg
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tank/README	Wed Feb 23 22:04:10 2011 +0000
     2.3 @@ -0,0 +1,19 @@
     2.4 +README for Tank - SliTaz main server and build host
     2.5 +===============================================================================
     2.6 +
     2.7 +
     2.8 +Tank is the hostname for SliTaz main server and build host. This package 
     2.9 +provides the web interface accessible at http://tank.slitaz.org/ and a tiny
    2.10 +tool (taztank) to help maintain and administer services.
    2.11 +
    2.12 +Build host documentation: http://doc.slitaz.org/en:cookbook:buildhost
    2.13 +
    2.14 +IP's
    2.15 +----
    2.16 +Tank:         213.3.10.214
    2.17 +Mirror:       94.23.60.116 (mirror,pizza,archives,ajaxterm)
    2.18 +Forum & labs: 94.23.34.123
    2.19 +
    2.20 +Check /home/slitaz/www for Tank vhosts.
    2.21 +
    2.22 +===============================================================================
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tank/taztank	Wed Feb 23 22:04:10 2011 +0000
     3.3 @@ -0,0 +1,122 @@
     3.4 +#!/bin/sh
     3.5 +# Taztank - Admin Tank, backup, update and give stats.
     3.6 +# (C) 2011 SliTaz - GNU General Public License.
     3.7 +# Author: Christophe Lincoln <pankso@slitaz.org>
     3.8 +#
     3.9 +
    3.10 +REPOS="/home/slitaz/repos"
    3.11 +WWW="/home/slitaz/www"
    3.12 +VHOST="$WWW/tank"
    3.13 +BACKUPS="/home/backups"
    3.14 +
    3.15 +usage() {
    3.16 +	echo -e "\nUsage: `basename $0` [command]
    3.17 +Commands:
    3.18 +  stats         Display some Tank stats
    3.19 +  backup        Backup files and MySQL DB
    3.20 +  chroot	Move a user in a new chroot location
    3.21 +  up-web        Update http://tank.slitaz.org/
    3.22 +  up-people     Update http://people.slitaz.org/
    3.23 +  up-web-stats  Update Awstats statistics (run by cron)
    3.24 +  clean-labs    Clean Redmine Labs (no more on Tank)\n"
    3.25 +}
    3.26 +
    3.27 +case "$1" in
    3.28 +	stats)
    3.29 +		# Report some stats
    3.30 +		clear
    3.31 +		cat << EOF
    3.32 +
    3.33 +Connected user
    3.34 +--------------
    3.35 +`who`
    3.36 +
    3.37 +System usage
    3.38 +------------
    3.39 +`df -h`
    3.40 +
    3.41 +`free`
    3.42 +
    3.43 +EOF
    3.44 +		;;
    3.45 +	chroot)
    3.46 +		if [ -s $2/bin/sh ] && grep -qs $3: /etc/password ; then
    3.47 +			grep -q ^chroot /etc/busybox.conf ||
    3.48 +			echo 'chroot = ssx root.root' >> /etc/busybox.conf
    3.49 +			[ -s /bin/chrootsh ] || cat > /bin/chrootsh << EOF
    3.50 +#!/bin/sh
    3.51 +
    3.52 +#case " \$@ " in                                        
    3.53 +#*rsync*) exec /bin/sh "\$@" ;;
    3.54 +#esac
    3.55 +
    3.56 +case "\$USER" in                                        
    3.57 +pankso) exec /bin/sh "\$@" ;;                      
    3.58 +*) exec /usr/sbin/chroot $2 /bin/chrootsh "\$@" ;;
    3.59 +esac
    3.60 +EOF
    3.61 +			[ -s $2/bin/chrootsh ] || cat > $2/bin/chrootsh << EOF
    3.62 +#!/bin/sh
    3.63 +
    3.64 +export SHELL='/bin/sh'
    3.65 +cd \$HOME
    3.66 +. /etc/profile
    3.67 +exec /bin/sh "\$@"
    3.68 +EOF
    3.69 +			chmod +x /bin/chrootsh $2/bin/chrootsh
    3.70 +			base=$(awk -F: "/^$3:/ { print \$6 }" /etc/passwd)
    3.71 +			target=$base
    3.72 +			while [ -L $target ]; do
    3.73 +				target=$(readlink $target)
    3.74 +			done
    3.75 +			mv $target $2/$base
    3.76 +			[ -L $base ] && rm -f $base
    3.77 +			ln -s $2/$base $base
    3.78 +			if ! grep -q ^$3: $2/etc/passwd ; then
    3.79 +				grep ^$3: /etc/passwd >> $2/etc/passwd
    3.80 +				grep ^$3: /etc/shadow >> $2/etc/shadow		fi
    3.81 +			fi
    3.82 +		else
    3.83 +			cat << EOF
    3.84 +Usage: $0 $1 newchroot user
    3.85 +Move a user in a new chroot location
    3.86 +EOF
    3.87 +		fi
    3.88 +		;;
    3.89 +	backup)
    3.90 +		# Backup config files and SQL db.
    3.91 +		echo "Not yet implemented..." ;;
    3.92 +	up-web)
    3.93 +		# Update Tank web interface: http://tank.slitaz.org/
    3.94 +		echo -e "\nUpdating: tank.slitaz.org..."
    3.95 +		cd $REPOS/tank
    3.96 +		hg update
    3.97 +		rm -rf $VHOST/*.* $VHOST/pics/website
    3.98 +		cp -a web/* $VHOST ;;
    3.99 +	up-people)
   3.100 +		# Update People web interface: http://people.slitaz.org/
   3.101 +		echo -e "\nUpdating: people.slitaz.org..."
   3.102 +		cd $REPOS/slitaz-forge
   3.103 +		hg update
   3.104 +		rm -rf $WWW/people/*
   3.105 +		cp -a people/* $WWW/people ;;
   3.106 +	up-web-stats)
   3.107 +		echo -e "\nUpdating all awstats database...\n"
   3.108 +		for vh in www boot pkgs
   3.109 +		do
   3.110 +			/var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org 
   3.111 +		done ;;
   3.112 +	clean-labs)
   3.113 +		# Redmin need some time help
   3.114 +		/etc/init.d/lighttpd stop
   3.115 +		/etc/init.d/mysql stop
   3.116 +		killall ruby
   3.117 +		rm -rf labs/tmp/sessions
   3.118 +		mkdir -p labs/tmp/sessions
   3.119 +		chown www.www labs/tmp/sessions
   3.120 +		/etc/init.d/mysql start
   3.121 +		/etc/init.d/lighttpd start ;;
   3.122 +	*)
   3.123 +		usage ;;
   3.124 +esac
   3.125 +exit 0