slitaz-forge 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 6ed4582df956
children eb06ca412415
files chub/chub chub/chub.conf chub/files/etc/lighttpd/vhosts.conf tank/files/etc/lighttpd/vhosts.conf tank/files/var/spool/cron/crontabs/root tank/tank
line diff
     1.1 --- a/chub/chub	Tue Mar 20 21:09:51 2012 +0100
     1.2 +++ b/chub/chub	Tue Mar 20 22:12:29 2012 +0100
     1.3 @@ -20,8 +20,8 @@
     1.4  
     1.5  Commands:
     1.6    stats        Display some server stats
     1.7 -  up-www       Update website http://www.slitaz.org/
     1.8 -  up-chub      Update Chub web interface http://chub.slitaz.org/
     1.9 +  up-chub      Update Chub web interface chub.slitaz.org
    1.10 +  up-doc       Update doc.slitaz.org Wiki template
    1.11    rrd          Update RRD graphs images
    1.12    backup       Backup MySQL DB and files"
    1.13  
    1.14 @@ -29,18 +29,19 @@
    1.15  }
    1.16  
    1.17  case "$1" in
    1.18 -	up-www)
    1.19 -		# Update website from repo.
    1.20 -		echo "Updating: www.slitaz.org..."
    1.21 -		cd $WEBSITE && hg pull -u ;;
    1.22  	up-chub)
    1.23  		# Update Chub web interface from repo.
    1.24  		echo "Updating: chub.slitaz.org..."
    1.25  		cd $REPOS/slitaz-forge
    1.26 -		#hg update if repos are on Chub
    1.27  		hg pull -u
    1.28  		rm -rf $VHOST/*.* $VHOST/images/*.png
    1.29  		cp -a chub/web/* $VHOST ;;
    1.30 +	up-doc)
    1.31 +		# Update Wiki doc template from Hg.
    1.32 +		echo "Updating Wiki documentation template..."
    1.33 +		cd $REPOS/slitaz-forge
    1.34 +		hg pull -u
    1.35 +		cp -a doc/lib/tpl/* $DOC_LIB/tpl ;;
    1.36  	stats)
    1.37  		# Echo some stats.
    1.38  		echo "======== Disk usage ============="
    1.39 @@ -52,6 +53,7 @@
    1.40  	rrd)
    1.41  		echo "Making RRD graphs images..."
    1.42  		$VHOST/lib/makegraphs >/dev/null ;;
    1.43 +	
    1.44  	backup)
    1.45  		echo "TODO: backup MySQL, SCN files, etc" ;;
    1.46  	*)
     2.1 --- a/chub/chub.conf	Tue Mar 20 21:09:51 2012 +0100
     2.2 +++ b/chub/chub.conf	Tue Mar 20 22:12:29 2012 +0100
     2.3 @@ -8,3 +8,6 @@
     2.4  WWW="/home/slitaz/www"
     2.5  VHOST="$WWW/chub"
     2.6  WEBSITE="$WWW/website"
     2.7 +
     2.8 +# Path to Dokuwiki template.
     2.9 +DOC_LIB="$WWW/doc/lib"
     3.1 --- a/chub/files/etc/lighttpd/vhosts.conf	Tue Mar 20 21:09:51 2012 +0100
     3.2 +++ b/chub/files/etc/lighttpd/vhosts.conf	Tue Mar 20 22:12:29 2012 +0100
     3.3 @@ -2,6 +2,7 @@
     3.4  #
     3.5  
     3.6  # chub.slitaz.org
     3.7 +#
     3.8  $HTTP["host"] =~ "^chub\.slitaz\.org$" {
     3.9    server.document-root = "/home/slitaz/www/chub"
    3.10    server.errorlog = "/var/log/lighttpd/chub.slitaz.org-error.log"
    3.11 @@ -12,6 +13,7 @@
    3.12  }
    3.13  
    3.14  # pizza.slitaz.me
    3.15 +#
    3.16  $HTTP["host"] =~ "^pizza\.slitaz\.me$" {
    3.17    server.document-root = "/home/slitaz/pizza/web"
    3.18    server.errorlog = "/var/log/lighttpd/pizza.slitaz.me-error.log"
    3.19 @@ -22,3 +24,25 @@
    3.20      ".py" => "/usr/bin/python"
    3.21    )
    3.22  }
    3.23 +
    3.24 +# doc.slitaz.org
    3.25 +#
    3.26 +$HTTP["host"] =~ "doc\.slitaz\.org" {
    3.27 +  server.document-root = "/home/slitaz/www/doc"
    3.28 +  index-file.names = ("doku.php") 
    3.29 +  var.dokudir = ""
    3.30 +   # Rewrites for dokuwiki
    3.31 +    url.rewrite = (
    3.32 +      "^" + var.dokudir + "/lib/.*$"              => "$0",
    3.33 +      "^" + var.dokudir + "/_media/(.*)?\?(.*)$"  => var.dokudir + "/lib/exe/fetch.php?media=$1&$2",
    3.34 +      "^" + var.dokudir + "/_media/(.*)$"         => var.dokudir + "/lib/exe/fetch.php?media=$1",
    3.35 +      "^" + var.dokudir + "/_detail/(.*)?\?(.*)$" => var.dokudir + "/lib/exe/detail.php?media=$1&$2",
    3.36 +      "^" + var.dokudir + "/_detail/(.*)?$"       => var.dokudir + "/lib/exe/detail.php?media=$1",
    3.37 +      "^" + var.dokudir + "/_export/([^/]+)/(.*)\?(.*)$" => var.dokudir + "/doku.php?do=export_$1&id=$2&$3",
    3.38 +      "^" + var.dokudir + "/_export/([^/]+)/(.*)" => var.dokudir + "/doku.php?do=export_$1&id=$2",
    3.39 +      "^" + var.dokudir + "/doku.php.*"           => "$0",
    3.40 +      "^" + var.dokudir + "/feed.php.*"           => "$0",
    3.41 +      "^" + var.dokudir + "/(.*)\?(.*)"           => var.dokudir + "/doku.php?id=$1&$2",
    3.42 +      "^" + var.dokudir + "/(.*)"                 => var.dokudir + "/doku.php?id=$1"
    3.43 +    )
    3.44 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tank/files/etc/lighttpd/vhosts.conf	Tue Mar 20 22:12:29 2012 +0100
     4.3 @@ -0,0 +1,107 @@
     4.4 +# /etc/lighttpd/vhosts.conf : Virtual hosts configuration file.
     4.5 +#
     4.6 +
     4.7 +# tank.slitaz.org (Server canonical hostname)
     4.8 +#
     4.9 +$HTTP["host"] =~ "tank\.slitaz\.org$" {
    4.10 +  server.document-root = "/home/slitaz/www/tank"
    4.11 +  server.errorlog = "/var/log/lighttpd/tank.slitaz.org-error.log"
    4.12 +  accesslog.filename = "/var/log/lighttpd/tank.slitaz.org-access.log"
    4.13 +  include "awstats.conf"
    4.14 +  index-file.names += ( "index.php" )
    4.15 +}
    4.16 +
    4.17 +# pro.slitaz.org
    4.18 +#
    4.19 +$HTTP["host"] =~ "pro\.slitaz\.org$" {
    4.20 +  server.document-root = "/home/slitaz/www/pro"
    4.21 +  server.errorlog = "/var/log/lighttpd/pro.slitaz.org-error.log"
    4.22 +  accesslog.filename = "/var/log/lighttpd/pro.slitaz.org-access.log"
    4.23 +  include "awstats.conf"
    4.24 +  cgi.assign = (
    4.25 +    ".cgi" => "/bin/sh"
    4.26 +  )
    4.27 +}
    4.28 +
    4.29 +# boot.slitaz.org
    4.30 +#
    4.31 +$HTTP["host"] =~ "boot\.slitaz\.org$" {
    4.32 +  server.document-root = "/home/slitaz/www/boot"
    4.33 +  server.errorlog = "/var/log/lighttpd/boot.slitaz.org-error.log"
    4.34 +  accesslog.filename = "/var/log/lighttpd/boot.slitaz.org-access.log"
    4.35 +  include "awstats.conf"
    4.36 +  cgi.assign = (
    4.37 +    ".cgi" => "/bin/sh"
    4.38 +  )
    4.39 +}
    4.40 +
    4.41 +# people.slitaz.org
    4.42 +#
    4.43 +$HTTP["host"] =~ "people\.slitaz\.org$" {
    4.44 +  userdir.path = "Public"
    4.45 +  userdir.exclude-user = ("root")
    4.46 +  server.document-root = "/home/slitaz/www/people"
    4.47 +  server.errorlog = "/var/log/lighttpd/people.slitaz.org-erro.log"
    4.48 +  accesslog.filename = "/var/log/lighttpd/people.slitaz.org-access.log"
    4.49 +  include "awstats.conf"
    4.50 +}
    4.51 +
    4.52 +# pkgs.slitaz.org
    4.53 +#
    4.54 +$HTTP["host"] =~ "pkgs\.slitaz\.org$" {
    4.55 +  server.document-root = "/home/slitaz/www/pkgs"
    4.56 +  server.errorlog = "/var/log/lighttpd/pkgs.slitaz.org-error.log"
    4.57 +  accesslog.filename = "/var/log/lighttpd/pkgs.slitaz.org-access.log"
    4.58 +  cgi.assign = (
    4.59 +    ".cgi" => "/bin/sh"
    4.60 +  )
    4.61 +}
    4.62 +
    4.63 +# cook.slitaz.org
    4.64 +#
    4.65 +$HTTP["host"] =~ "cook\.slitaz\.org$" {
    4.66 +  server.document-root = "/home/slitaz/www/cook"
    4.67 +  server.errorlog = "/var/log/lighttpd/cook.slitaz.org-error.log"
    4.68 +  accesslog.filename = "/var/log/lighttpd/cook.slitaz.org-access.log"
    4.69 +  cgi.assign = (
    4.70 +    ".cgi" => "/bin/sh"
    4.71 +  )
    4.72 +  index-file.names = ( "cooker.cgi" )
    4.73 +}
    4.74 +
    4.75 +# ssfs.slitaz.org
    4.76 +#
    4.77 +$HTTP["host"] =~ "ssfs\.slitaz\.org$" {
    4.78 +  cgi.assign = (
    4.79 +    ".cgi" => "/bin/sh"
    4.80 +  )
    4.81 +  index-file.names = ( "ssfs.cgi" )
    4.82 +  server.document-root = "/home/slitaz/www/ssfs"
    4.83 +  auth.backend = "plain"
    4.84 +  auth.backend.plain.userfile = "/etc/ssfs/httpd.users"
    4.85 +  auth.require = ( "/home/" =>
    4.86 +    (
    4.87 +    "method" => "basic",
    4.88 +    "realm" => "SliTaz Ssfs protected area",
    4.89 +    "require" => "valid-user"
    4.90 +    )
    4.91 +  )
    4.92 +}
    4.93 +
    4.94 +# These hosts are personnal website for me and my family, pankso.
    4.95 +
    4.96 +# pankso.com
    4.97 +#
    4.98 +$HTTP["host"] =~ "(^|\.)pankso\.com$" {
    4.99 +  server.document-root = "/home/pankso/vhosts/pankso"
   4.100 +  server.errorlog = "/var/log/lighttpd/pankso.error.log"
   4.101 +  accesslog.filename = "/var/log/lighttpd/pankso.access.log"
   4.102 +}
   4.103 +
   4.104 +# lincolm.ch
   4.105 +#
   4.106 +$HTTP["host"] =~ "(^|\.)lincolm\.ch$" {
   4.107 +  server.document-root = "/home/pankso/vhosts/lincolm"
   4.108 +  server.errorlog = "/var/log/lighttpd/lincolm.error.log"
   4.109 +  accesslog.filename = "/var/log/lighttpd/lincolm.access.log"
   4.110 +}
     5.1 --- a/tank/files/var/spool/cron/crontabs/root	Tue Mar 20 21:09:51 2012 +0100
     5.2 +++ b/tank/files/var/spool/cron/crontabs/root	Tue Mar 20 22:12:29 2012 +0100
     5.3 @@ -1,24 +1,23 @@
     5.4 +# Crond jobs for SliTaz Tank
     5.5 +#
     5.6 +
     5.7  # Update http://tank.slitaz.org/graphs.php pictures
     5.8  */5 * * * * /home/slitaz/www/tank/bin/makegraphs >/dev/null
     5.9  
    5.10  # Check Internet access
    5.11  #*/5 * * * * /usr/bin/chkwan
    5.12  
    5.13 -# purge php sessions
    5.14 +# Purge php sessions
    5.15  0 * * * * /usr/bin/find /tmp -name 'sess*' -type f -mmin +720 -exec rm -f {} \;
    5.16  
    5.17 -# rotate logs
    5.18 +# Rotate logs
    5.19  0 1 * * *  /usr/sbin/logrotate /etc/logrotate.conf > /dev/null 2>&1
    5.20  0 0 * * * /usr/bin/ntpclient -s -h fr.pool.ntp.org
    5.21  
    5.22 -# Update SliTaz stuff
    5.23 -#*/15 * * * * /home/slitaz/www/website/libs/get-feeds.sh
    5.24 -15 02 * * * /usr/bin/tank up-pro
    5.25 -20 02 * * * /usr/bin/tazpkg-web cooking
    5.26 -30 02 * * * /usr/bin/tazpkg-web stable
    5.27 -
    5.28 -#0,10,20,30,40,50 * * * * /usr/bin/roundup-mailgw /home/slitaz/bugs/ \
    5.29 -#	pop bugs@slitaz.org:Bugs4SliTaz@pop.slitaz.org
    5.30 -
    5.31 -# Build rolling release every day if necessary
    5.32 -0 4 * * * /home/bellard/rolling/rolling.sh
    5.33 +# Update SliTaz vhosts and Awstats
    5.34 +20 02 * * * /usr/bin/tank up-pro
    5.35 +22 02 * * * /usr/bin/tank up-people --nohg
    5.36 +24 02 * * * /usr/bin/tank up-boot --nohg
    5.37 +26 02 * * * /usr/bin/tank up-cook --nohg
    5.38 +28 02 * * * /usr/bin/tank up-boot --nohg
    5.39 +30 02 * * * /usr/bin/tank up-stats
     6.1 --- a/tank/tank	Tue Mar 20 21:09:51 2012 +0100
     6.2 +++ b/tank/tank	Tue Mar 20 22:12:29 2012 +0100
     6.3 @@ -1,4 +1,5 @@
     6.4  #!/bin/sh
     6.5 +#
     6.6  # Tank - Admin Tank, backup, update and give stats.
     6.7  #
     6.8  # (C) 2011 SliTaz - GNU General Public License.
     6.9 @@ -10,16 +11,14 @@
    6.10  VHOST="$WWW/tank"
    6.11  WEBSITE="$WWW/website"
    6.12  BACKUPS="/home/backups"
    6.13 -PYTHON_LIB="/usr/lib/python2.5"
    6.14 -DOC_LIB="$WWW/doc/lib"
    6.15  
    6.16  usage() {
    6.17 -	echo -e "\nUsage: `basename $0` [command]
    6.18 +	cat << EOT
    6.19 +
    6.20 +Usage: $(basename $0) [command]
    6.21  Commands:
    6.22 -  stats|-s     Display some Tank stats
    6.23    backup|-b    Backup files and MySQL DB
    6.24    adduser      Add user on Tank and create people files
    6.25 -  chroot|-c    Move a user into a new chroot location
    6.26    up-stats     Update Awstats statistics (run by cron)
    6.27    
    6.28    up-tank      Update http://tank.slitaz.org/
    6.29 @@ -27,87 +26,19 @@
    6.30    up-pro       Update http://pro.slitaz.org/
    6.31    up-boot      Update http://boot.slitaz.org/
    6.32    up-cook      Update http://cook.slitaz.org/
    6.33 -  
    6.34 -  #up-www       Update website http://www.slitaz.org/
    6.35 -  #up-hg        Update template for http://hg.slitaz.org/
    6.36 -  #up-doc       Update template for http://doc.slitaz.org/\n"
    6.37 +
    6.38 +EOT
    6.39  }
    6.40  
    6.41  case "$1" in
    6.42 -	stats|-s)
    6.43 -		# Report some stats
    6.44 -		clear
    6.45 -		cat << EOF
    6.46 -
    6.47 -Connected user
    6.48 ---------------
    6.49 -`who`
    6.50 -
    6.51 -System usage
    6.52 -------------
    6.53 -`df -h`
    6.54 -
    6.55 -`free`
    6.56 -
    6.57 -EOF
    6.58 -		;;
    6.59 -	chroot|-c)
    6.60 -		# Move a user into a new chroot location
    6.61 -		if [ -s $2/bin/sh ] && grep -qs $3: /etc/password ; then
    6.62 -			grep -q ^chroot /etc/busybox.conf ||
    6.63 -			echo 'chroot = ssx root.root' >> /etc/busybox.conf
    6.64 -			[ -s /bin/chrootsh ] || cat > /bin/chrootsh << EOF
    6.65 -#!/bin/sh
    6.66 -
    6.67 -#case " \$@ " in                                        
    6.68 -#*rsync*) exec /bin/sh "\$@" ;;
    6.69 -#esac
    6.70 -
    6.71 -case "\$USER" in                                        
    6.72 -pankso) exec /bin/sh "\$@" ;;                      
    6.73 -*) exec /usr/sbin/chroot $2 /bin/chrootsh "\$@" ;;
    6.74 -esac
    6.75 -EOF
    6.76 -			[ -s $2/bin/chrootsh ] || cat > $2/bin/chrootsh << EOF
    6.77 -#!/bin/sh
    6.78 -
    6.79 -export SHELL='/bin/sh'
    6.80 -cd \$HOME
    6.81 -. /etc/profile
    6.82 -exec /bin/sh "\$@"
    6.83 -EOF
    6.84 -			chmod +x /bin/chrootsh $2/bin/chrootsh
    6.85 -			base=$(awk -F: "/^$3:/ { print \$6 }" /etc/passwd)
    6.86 -			target=$base
    6.87 -			while [ -L $target ]; do
    6.88 -				target=$(readlink $target)
    6.89 -			done
    6.90 -			mv $target $2/$base
    6.91 -			[ -L $base ] && rm -f $base
    6.92 -			ln -s $2/$base $base
    6.93 -			if ! grep -q ^$3: $2/etc/passwd ; then
    6.94 -				grep ^$3: /etc/passwd >> $2/etc/passwd
    6.95 -				grep ^$3: /etc/shadow >> $2/etc/shadow		fi
    6.96 -			fi
    6.97 -		else
    6.98 -			cat << EOF
    6.99 -Usage: $0 $1 newchroot user
   6.100 -Move a user in a new chroot location
   6.101 -EOF
   6.102 -		fi ;;
   6.103  	backup|-b)
   6.104  		# Backup config files and SQL db.
   6.105  		echo "TODO" ;;
   6.106 -	up-www)
   6.107 -		# Update website from repo.
   6.108 -		echo -e "\nUpdating: www.slitaz.org..."
   6.109 -		cd $WEBSITE && hg pull -u
   6.110 -		echo "" ;;
   6.111  	up-tank)
   6.112  		# Update Tank web interface: http://tank.slitaz.org/
   6.113  		echo -e "\nUpdating: tank.slitaz.org..."
   6.114  		cd $REPOS/slitaz-forge
   6.115 -		hg pull -u
   6.116 +		[ "$2" == "--nohg" ] || hg pull -u
   6.117  		rm -rf $VHOST/*.* $VHOST/images
   6.118  		cp -a tank/web/* $VHOST 
   6.119  		echo "" ;;
   6.120 @@ -115,7 +46,7 @@
   6.121  		# Update People web interface: http://people.slitaz.org/
   6.122  		echo -e "\nUpdating: people.slitaz.org..."
   6.123  		cd $REPOS/slitaz-forge
   6.124 -		hg pull -u
   6.125 +		[ "$2" == "--nohg" ] || hg pull -u
   6.126  		rm -rf $WWW/people/*
   6.127  		cp -a people/* $WWW/people 
   6.128  		echo "" ;;
   6.129 @@ -123,7 +54,7 @@
   6.130  		# Update Pro website: http://pro.slitaz.org/
   6.131  		echo -e "\nUpdating: pro.slitaz.org..."
   6.132  		cd $REPOS/slitaz-forge
   6.133 -		hg pull -u
   6.134 +		[ "$2" == "--nohg" ] || hg pull -u
   6.135  		rm -rf $WWW/pro/*
   6.136  		cp -a pro/* $WWW/pro
   6.137  		echo "" ;;
   6.138 @@ -131,7 +62,7 @@
   6.139  		# Update Web Boot interface: http://boot.slitaz.org/
   6.140  		echo -e "\nUpdating: boot.slitaz.org..."
   6.141  		cd $REPOS/slitaz-forge
   6.142 -		hg pull -u
   6.143 +		[ "$2" == "--nohg" ] || hg pull -u
   6.144  		rm -rf $WWW/boot/*
   6.145  		cp -a boot/* $WWW/boot 
   6.146  		echo "" ;;
   6.147 @@ -139,30 +70,15 @@
   6.148  		# Update Web Boot interface: http://boot.slitaz.org/
   6.149  		echo -e "\nUpdating: cook.slitaz.org..."
   6.150  		cd $REPOS/slitaz-forge
   6.151 -		hg pull -u
   6.152 +		[ "$2" == "--nohg" ] || hg pull -u
   6.153  		cp -a cook/* $WWW/cook
   6.154  		cp -a cook/* $WWW/cook/undigest
   6.155  		echo "" ;;
   6.156 -	up-hg)
   6.157 -		# Since Tank runs stable and we update the style in slitaz-dev-tools
   6.158 -		# the cooking package is unbuildable because it uses the new Tazwok function
   6.159 -		# with mercurial|*
   6.160 -		echo -e "\nUpdating Mercurial template..."
   6.161 -		cd $REPOS/slitaz-dev-tools && hg pull -u
   6.162 -		cp -a slitaz-mercurial-style/* $PYTHON_LIB/site-packages/mercurial
   6.163 -		chown -R root.root $PYTHON_LIB/site-packages/mercurial/templates
   6.164 -		echo "" ;;
   6.165 -	up-doc)
   6.166 -		# Update Wiki doc template from Hg: http://doc.slitaz.org/
   6.167 -		echo -e "\nUpdating Wiki documentation template..."
   6.168 -		cd $REPOS/slitaz-forge && hg pull -u
   6.169 -		cp -a doc/lib/tpl/* $DOC_LIB/tpl
   6.170 -		echo "" ;;
   6.171  	up-stats)
   6.172  		echo -e "\nUpdating all awstats databases..."
   6.173 -		for vh in pro boot cook
   6.174 +		for vh in pro boot cook people
   6.175  		do
   6.176 -			/var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org 
   6.177 +			/var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org -update
   6.178  		done
   6.179  		echo "" ;;
   6.180  	adduser)