slitaz-forge rev 54

Some rename and fixes to tank
author Christophe Lincoln <pankso@slitaz.org>
date Fri Apr 08 19:08:47 2011 +0200 (2011-04-08)
parents ec479bff3f1a
children b10c26a1b46e
files tank/Makefile tank/files/usr/share/tank/Public/profile.php tank/files/usr/share/tank/README tank/profile.php tank/tank tank/taztank
line diff
     1.1 --- a/tank/Makefile	Fri Apr 08 18:51:44 2011 +0200
     1.2 +++ b/tank/Makefile	Fri Apr 08 19:08:47 2011 +0200
     1.3 @@ -10,12 +10,20 @@
     1.4  	mkdir -p $(DESTDIR)$(PREFIX)/bin \
     1.5  		$(DESTDIR)$(PREFIX)/share/taztank
     1.6  	cp -f taztank $(DESTDIR)$(PREFIX)/bin
     1.7 -	cp -f profile.php $(DESTDIR)$(PREFIX)/share/taztank
     1.8 +	cp files/usr/share/tank $(DESTDIR)$(PREFIX)/share
     1.9  
    1.10  install-files:
    1.11  	cp -a files/var $(DESTDIR)/
    1.12  	chmod 0600 -p $(DESTDIR)/var/spool/cron/crontabs/root
    1.13  	cp -a files/etc $(DESTDIR)/
    1.14  	cp -a files/usr $(DESTDIR}/
    1.15 +
    1.16 +# Used to switc from taztank to tank (shorted :-)
    1.17 +uninstill:
    1.18 +	rm -f /usr/bin/taztank
    1.19 +	rm -f /usr/bin/tank
    1.20 +	rm -rf /usr/share/taztank
    1.21 +	rm -rf /usr/share/tank
    1.22 +	
    1.23  clean:
    1.24  	rm -rf _pkg
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tank/files/usr/share/tank/Public/profile.php	Fri Apr 08 19:08:47 2011 +0200
     2.3 @@ -0,0 +1,13 @@
     2.4 +<?php
     2.5 +
     2.6 +// Your custom SliTaz profile at http://people.slitaz.org/. This file must
     2.7 +// be located at ~/Public/profile.php. You must at least provide your real
     2.8 +// name and you can use the $wall variable for a personal message.
     2.9 +
    2.10 +$name = "Real Name";
    2.11 +$location = "";
    2.12 +$scn_user = "";
    2.13 +$skills = "";
    2.14 +$wall = "";
    2.15 +
    2.16 +?>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tank/files/usr/share/tank/README	Fri Apr 08 19:08:47 2011 +0200
     3.3 @@ -0,0 +1,9 @@
     3.4 +Welcome to Tank!
     3.5 +================================================================================
     3.6 +
     3.7 +Your Public directory URL is: http://people.slitaz.org/~$USER/
     3.8 +
     3.9 +Please complete your public profile in ~/Public/profile.php and feel free
    3.10 +to use the service for your needs, if anything goes wrong or is missing
    3.11 +please express yourself :-)
    3.12 +
     4.1 --- a/tank/profile.php	Fri Apr 08 18:51:44 2011 +0200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,13 +0,0 @@
     4.4 -<?php
     4.5 -
     4.6 -// Your custom SliTaz profile at http://people.slitaz.org/. This file must
     4.7 -// be located at ~/Public/profile.php. You must at least provide your real
     4.8 -// name and you can use the $wall variable for a personal message.
     4.9 -
    4.10 -$name = "Real Name";
    4.11 -$location = "";
    4.12 -$scn_user = "";
    4.13 -$skills = "";
    4.14 -$wall = "";
    4.15 -
    4.16 -?>
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/tank/tank	Fri Apr 08 19:08:47 2011 +0200
     5.3 @@ -0,0 +1,161 @@
     5.4 +#!/bin/sh
     5.5 +# Taztank - Admin Tank, backup, update and give stats.
     5.6 +#
     5.7 +# (C) 2011 SliTaz - GNU General Public License.
     5.8 +# Author: Christophe Lincoln <pankso@slitaz.org>
     5.9 +#
    5.10 +
    5.11 +REPOS="/home/slitaz/repos"
    5.12 +WWW="/home/slitaz/www"
    5.13 +VHOST="$WWW/tank"
    5.14 +WEBSITE="$WWW/website"
    5.15 +BACKUPS="/home/backups"
    5.16 +
    5.17 +usage() {
    5.18 +	echo -e "\nUsage: `basename $0` [command]
    5.19 +Commands:
    5.20 +  stats|-s         Display some Tank stats
    5.21 +  backup|-b        Backup files and MySQL DB
    5.22 +  chroot|-c        Move a user into a new chroot location
    5.23 +  up-www|-uw       Update website http://www.slitaz.org/
    5.24 +  up-tank|-ut      Update http://tank.slitaz.org/
    5.25 +  up-people|-up    Update http://people.slitaz.org/
    5.26 +  up-boot|-ub      Update http://boot.slitaz.org/
    5.27 +  up-stats|-us     Update Awstats statistics (run by cron)
    5.28 +  adduser|-au      Add user on tank\n"
    5.29 +}
    5.30 +
    5.31 +case "$1" in
    5.32 +	stats|-s)
    5.33 +		# Report some stats
    5.34 +		clear
    5.35 +		cat << EOF
    5.36 +
    5.37 +Connected user
    5.38 +--------------
    5.39 +`who`
    5.40 +
    5.41 +System usage
    5.42 +------------
    5.43 +`df -h`
    5.44 +
    5.45 +`free`
    5.46 +
    5.47 +EOF
    5.48 +		;;
    5.49 +	chroot|-c)
    5.50 +		# Move a user into a new chroot location
    5.51 +		if [ -s $2/bin/sh ] && grep -qs $3: /etc/password ; then
    5.52 +			grep -q ^chroot /etc/busybox.conf ||
    5.53 +			echo 'chroot = ssx root.root' >> /etc/busybox.conf
    5.54 +			[ -s /bin/chrootsh ] || cat > /bin/chrootsh << EOF
    5.55 +#!/bin/sh
    5.56 +
    5.57 +#case " \$@ " in                                        
    5.58 +#*rsync*) exec /bin/sh "\$@" ;;
    5.59 +#esac
    5.60 +
    5.61 +case "\$USER" in                                        
    5.62 +pankso) exec /bin/sh "\$@" ;;                      
    5.63 +*) exec /usr/sbin/chroot $2 /bin/chrootsh "\$@" ;;
    5.64 +esac
    5.65 +EOF
    5.66 +			[ -s $2/bin/chrootsh ] || cat > $2/bin/chrootsh << EOF
    5.67 +#!/bin/sh
    5.68 +
    5.69 +export SHELL='/bin/sh'
    5.70 +cd \$HOME
    5.71 +. /etc/profile
    5.72 +exec /bin/sh "\$@"
    5.73 +EOF
    5.74 +			chmod +x /bin/chrootsh $2/bin/chrootsh
    5.75 +			base=$(awk -F: "/^$3:/ { print \$6 }" /etc/passwd)
    5.76 +			target=$base
    5.77 +			while [ -L $target ]; do
    5.78 +				target=$(readlink $target)
    5.79 +			done
    5.80 +			mv $target $2/$base
    5.81 +			[ -L $base ] && rm -f $base
    5.82 +			ln -s $2/$base $base
    5.83 +			if ! grep -q ^$3: $2/etc/passwd ; then
    5.84 +				grep ^$3: /etc/passwd >> $2/etc/passwd
    5.85 +				grep ^$3: /etc/shadow >> $2/etc/shadow		fi
    5.86 +			fi
    5.87 +		else
    5.88 +			cat << EOF
    5.89 +Usage: $0 $1 newchroot user
    5.90 +Move a user in a new chroot location
    5.91 +EOF
    5.92 +		fi
    5.93 +		;;
    5.94 +	backup|-b)
    5.95 +		# Backup config files and SQL db.
    5.96 +		echo "Not yet implemented..." ;;
    5.97 +	up-www|-uw)
    5.98 +		# Update website from repo.
    5.99 +		echo -e "\nUpdating: www.slitaz.org..."
   5.100 +		cd $WEBSITE && hg pull && hg update
   5.101 +		echo "" ;;
   5.102 +	up-tank|-ut)
   5.103 +		# Update Tank web interface: http://tank.slitaz.org/
   5.104 +		echo -e "\nUpdating: tank.slitaz.org..."
   5.105 +		cd $REPOS/slitaz-forge
   5.106 +		hg update
   5.107 +		rm -rf $VHOST/*.* $VHOST/pics/website $VHOST/images
   5.108 +		cp -a tank/web/* $VHOST 
   5.109 +		echo "" ;;
   5.110 +	up-people|-up)
   5.111 +		# Update People web interface: http://people.slitaz.org/
   5.112 +		echo -e "\nUpdating: people.slitaz.org..."
   5.113 +		cd $REPOS/slitaz-forge
   5.114 +		hg update
   5.115 +		rm -rf $WWW/people/*
   5.116 +		cp -a people/* $WWW/people 
   5.117 +		echo "" ;;
   5.118 +	up-boot|-ub)
   5.119 +		# Update Web Boot interface: http://boot.slitaz.org/
   5.120 +		echo -e "\nUpdating: boot.slitaz.org..."
   5.121 +		cd $REPOS/slitaz-forge
   5.122 +		hg update
   5.123 +		rm -rf $WWW/boot/*
   5.124 +		cp -a boot/* $WWW/boot 
   5.125 +		echo "" ;;
   5.126 +	up-stats|-us)
   5.127 +		echo -e "\nUpdating all awstats databases..."
   5.128 +		for vh in www boot pkgs
   5.129 +		do
   5.130 +			/var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org 
   5.131 +		done
   5.132 +		echo "" ;;
   5.133 +	adduser|-au)
   5.134 +		# On Tank /etc/skel is empty to let taktank handle default user
   5.135 +		# files.
   5.136 +		echo ""
   5.137 +		if [ -n "$2" ]; then
   5.138 +			user=$2
   5.139 +		else
   5.140 +			echo -n "User name: " && read user
   5.141 +		fi
   5.142 +		if [ -d /home/$user ]; then
   5.143 +			echo -e "User $user already exists...\n" && exit 1
   5.144 +		fi
   5.145 +		echo "Adding user: $user"
   5.146 +		#adduser -s /bin/sh -g "SliTaz User" -G users -h /home/$user $user # for cooking
   5.147 +		adduser $user
   5.148 +		# HG access
   5.149 +		echo -n "Hg password: " && read passwd
   5.150 +		echo "$user:$passwd" >> /etc/lighttpd/plain.passwd
   5.151 +		# Public dir at http://people.slitaz.org/~$user/
   5.152 +		cp -a /usr/share/tank/Public /home/$user/Public
   5.153 +		# README and empty Shell profile
   5.154 +		cp -a /usr/share/tank/README /home/$user/
   5.155 +		cat > /home/$user/.profile << EOF
   5.156 +# ~/.profile: Executed by Bourne-compatible login SHells.
   5.157 +#
   5.158 +EOF
   5.159 +		chown -R $user.$user /home/$user
   5.160 +		echo -e "Done\n" ;;
   5.161 +	*)
   5.162 +		usage ;;
   5.163 +esac
   5.164 +exit 0
     6.1 --- a/tank/taztank	Fri Apr 08 18:51:44 2011 +0200
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,175 +0,0 @@
     6.4 -#!/bin/sh
     6.5 -# Taztank - Admin Tank, backup, update and give stats.
     6.6 -#
     6.7 -# (C) 2011 SliTaz - GNU General Public License.
     6.8 -# Author: Christophe Lincoln <pankso@slitaz.org>
     6.9 -#
    6.10 -
    6.11 -REPOS="/home/slitaz/repos"
    6.12 -WWW="/home/slitaz/www"
    6.13 -VHOST="$WWW/tank"
    6.14 -WEBSITE="$WWW/website"
    6.15 -BACKUPS="/home/backups"
    6.16 -
    6.17 -usage() {
    6.18 -	echo -e "\nUsage: `basename $0` [command]
    6.19 -Commands:
    6.20 -  stats|-s         Display some Tank stats
    6.21 -  backup|-b        Backup files and MySQL DB
    6.22 -  chroot|-c        Move a user into a new chroot location
    6.23 -  up-www|-uw       Update website http://www.slitaz.org/
    6.24 -  up-tank|-ut      Update http://tank.slitaz.org/
    6.25 -  up-people|-up    Update http://people.slitaz.org/
    6.26 -  up-boot|-ub      Update http://boot.slitaz.org/
    6.27 -  up-stats|-us     Update Awstats statistics (run by cron)
    6.28 -  adduser|-au      Add user on tank\n"
    6.29 -}
    6.30 -
    6.31 -case "$1" in
    6.32 -	stats|-s)
    6.33 -		# Report some stats
    6.34 -		clear
    6.35 -		cat << EOF
    6.36 -
    6.37 -Connected user
    6.38 ---------------
    6.39 -`who`
    6.40 -
    6.41 -System usage
    6.42 -------------
    6.43 -`df -h`
    6.44 -
    6.45 -`free`
    6.46 -
    6.47 -EOF
    6.48 -		;;
    6.49 -	chroot|-c)
    6.50 -		# Move a user into a new chroot location
    6.51 -		if [ -s $2/bin/sh ] && grep -qs $3: /etc/password ; then
    6.52 -			grep -q ^chroot /etc/busybox.conf ||
    6.53 -			echo 'chroot = ssx root.root' >> /etc/busybox.conf
    6.54 -			[ -s /bin/chrootsh ] || cat > /bin/chrootsh << EOF
    6.55 -#!/bin/sh
    6.56 -
    6.57 -#case " \$@ " in                                        
    6.58 -#*rsync*) exec /bin/sh "\$@" ;;
    6.59 -#esac
    6.60 -
    6.61 -case "\$USER" in                                        
    6.62 -pankso) exec /bin/sh "\$@" ;;                      
    6.63 -*) exec /usr/sbin/chroot $2 /bin/chrootsh "\$@" ;;
    6.64 -esac
    6.65 -EOF
    6.66 -			[ -s $2/bin/chrootsh ] || cat > $2/bin/chrootsh << EOF
    6.67 -#!/bin/sh
    6.68 -
    6.69 -export SHELL='/bin/sh'
    6.70 -cd \$HOME
    6.71 -. /etc/profile
    6.72 -exec /bin/sh "\$@"
    6.73 -EOF
    6.74 -			chmod +x /bin/chrootsh $2/bin/chrootsh
    6.75 -			base=$(awk -F: "/^$3:/ { print \$6 }" /etc/passwd)
    6.76 -			target=$base
    6.77 -			while [ -L $target ]; do
    6.78 -				target=$(readlink $target)
    6.79 -			done
    6.80 -			mv $target $2/$base
    6.81 -			[ -L $base ] && rm -f $base
    6.82 -			ln -s $2/$base $base
    6.83 -			if ! grep -q ^$3: $2/etc/passwd ; then
    6.84 -				grep ^$3: /etc/passwd >> $2/etc/passwd
    6.85 -				grep ^$3: /etc/shadow >> $2/etc/shadow		fi
    6.86 -			fi
    6.87 -		else
    6.88 -			cat << EOF
    6.89 -Usage: $0 $1 newchroot user
    6.90 -Move a user in a new chroot location
    6.91 -EOF
    6.92 -		fi
    6.93 -		;;
    6.94 -	backup|-b)
    6.95 -		# Backup config files and SQL db.
    6.96 -		echo "Not yet implemented..." ;;
    6.97 -	update-www|-uw)
    6.98 -		# Update website from repo.
    6.99 -		echo -e "\nUpdating: www.slitaz.org..."
   6.100 -		cd $WEBSITE && hg pull && hg update
   6.101 -		echo "" ;;
   6.102 -	up-tank|-ut)
   6.103 -		# Update Tank web interface: http://tank.slitaz.org/
   6.104 -		echo -e "\nUpdating: tank.slitaz.org..."
   6.105 -		cd $REPOS/slitaz-forge
   6.106 -		hg update
   6.107 -		rm -rf $VHOST/*.* $VHOST/pics/website $VHOST/images
   6.108 -		cp -a tank/web/* $VHOST 
   6.109 -		echo "" ;;
   6.110 -	up-people|-up)
   6.111 -		# Update People web interface: http://people.slitaz.org/
   6.112 -		echo -e "\nUpdating: people.slitaz.org..."
   6.113 -		cd $REPOS/slitaz-forge
   6.114 -		hg update
   6.115 -		rm -rf $WWW/people/*
   6.116 -		cp -a people/* $WWW/people 
   6.117 -		echo "" ;;
   6.118 -	up-boot|-ub)
   6.119 -		# Update Web Boot interface: http://boot.slitaz.org/
   6.120 -		echo -e "\nUpdating: boot.slitaz.org..."
   6.121 -		cd $REPOS/slitaz-forge
   6.122 -		hg update
   6.123 -		rm -rf $WWW/boot/*
   6.124 -		cp -a boot/* $WWW/boot 
   6.125 -		echo "" ;;
   6.126 -	up-stats|-us)
   6.127 -		echo -e "\nUpdating all awstats databases..."
   6.128 -		for vh in www boot pkgs
   6.129 -		do
   6.130 -			/var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org 
   6.131 -		done
   6.132 -		echo "" ;;
   6.133 -	adduser|-au)
   6.134 -		# On Tank /etc/skel is empty to let taktank handle default user
   6.135 -		# files.
   6.136 -		echo ""
   6.137 -		if [ -n "$2" ]; then
   6.138 -			user=$2
   6.139 -		else
   6.140 -			echo -n "User name: " && read user
   6.141 -		fi
   6.142 -		if [ -d /home/$user ]; then
   6.143 -			echo -e "User $user already exists...\n" && exit 1
   6.144 -		fi
   6.145 -		echo "Adding user: $user"
   6.146 -		#adduser -s /bin/sh -g "SliTaz User" -G users -h /home/$user $user # for cooking
   6.147 -		adduser $user
   6.148 -		# HG access
   6.149 -		echo -n "Hg password: " && read passwd
   6.150 -		echo "$user:$passwd" >> /etc/lighttpd/plain.passwd
   6.151 -		# README
   6.152 -		echo -n "Creating default user files... "
   6.153 -		cat > /home/$user/README << EOF
   6.154 -Welcome to Tank!
   6.155 -================================================================================
   6.156 -
   6.157 -Your Public directory URL is: http://people.slitaz.org/~$USER/
   6.158 -
   6.159 -Please complete your public profile in ~/Public/profile.php and feel free
   6.160 -to use the service for your needs, if anything goes wrong or is missing
   6.161 -please express yourself :-)
   6.162 -
   6.163 -EOF
   6.164 -		# Public profile
   6.165 -		mkdir -p /home/$user/Public
   6.166 -		if [ -f /usr/share/taztank/profile.php ]; then
   6.167 -			cp -a /usr/share/taztank/profile.php /home/$user/Public/profile.php
   6.168 -		fi
   6.169 -		# Shell profile
   6.170 -		cat > /home/$user/.profile << EOF
   6.171 -# ~/.profile: Executed by Bourne-compatible login SHells.
   6.172 -#
   6.173 -EOF
   6.174 -		echo -e "Done\n" ;;
   6.175 -	*)
   6.176 -		usage ;;
   6.177 -esac
   6.178 -exit 0