# HG changeset patch # User Christophe Lincoln # Date 1332277949 -3600 # Node ID fec794d4852fe3bdbee83e1f91d727639e814eac # Parent 6ed4582df956d8b7d8f3eb2944bf9f836566ea56 Update tank util and add vhosts.conf diff -r 6ed4582df956 -r fec794d4852f chub/chub --- a/chub/chub Tue Mar 20 21:09:51 2012 +0100 +++ b/chub/chub Tue Mar 20 22:12:29 2012 +0100 @@ -20,8 +20,8 @@ Commands: stats Display some server stats - up-www Update website http://www.slitaz.org/ - up-chub Update Chub web interface http://chub.slitaz.org/ + up-chub Update Chub web interface chub.slitaz.org + up-doc Update doc.slitaz.org Wiki template rrd Update RRD graphs images backup Backup MySQL DB and files" @@ -29,18 +29,19 @@ } case "$1" in - up-www) - # Update website from repo. - echo "Updating: www.slitaz.org..." - cd $WEBSITE && hg pull -u ;; up-chub) # Update Chub web interface from repo. echo "Updating: chub.slitaz.org..." cd $REPOS/slitaz-forge - #hg update if repos are on Chub hg pull -u rm -rf $VHOST/*.* $VHOST/images/*.png cp -a chub/web/* $VHOST ;; + up-doc) + # Update Wiki doc template from Hg. + echo "Updating Wiki documentation template..." + cd $REPOS/slitaz-forge + hg pull -u + cp -a doc/lib/tpl/* $DOC_LIB/tpl ;; stats) # Echo some stats. echo "======== Disk usage =============" @@ -52,6 +53,7 @@ rrd) echo "Making RRD graphs images..." $VHOST/lib/makegraphs >/dev/null ;; + backup) echo "TODO: backup MySQL, SCN files, etc" ;; *) diff -r 6ed4582df956 -r fec794d4852f chub/chub.conf --- a/chub/chub.conf Tue Mar 20 21:09:51 2012 +0100 +++ b/chub/chub.conf Tue Mar 20 22:12:29 2012 +0100 @@ -8,3 +8,6 @@ WWW="/home/slitaz/www" VHOST="$WWW/chub" WEBSITE="$WWW/website" + +# Path to Dokuwiki template. +DOC_LIB="$WWW/doc/lib" diff -r 6ed4582df956 -r fec794d4852f chub/files/etc/lighttpd/vhosts.conf --- a/chub/files/etc/lighttpd/vhosts.conf Tue Mar 20 21:09:51 2012 +0100 +++ b/chub/files/etc/lighttpd/vhosts.conf Tue Mar 20 22:12:29 2012 +0100 @@ -2,6 +2,7 @@ # # chub.slitaz.org +# $HTTP["host"] =~ "^chub\.slitaz\.org$" { server.document-root = "/home/slitaz/www/chub" server.errorlog = "/var/log/lighttpd/chub.slitaz.org-error.log" @@ -12,6 +13,7 @@ } # pizza.slitaz.me +# $HTTP["host"] =~ "^pizza\.slitaz\.me$" { server.document-root = "/home/slitaz/pizza/web" server.errorlog = "/var/log/lighttpd/pizza.slitaz.me-error.log" @@ -22,3 +24,25 @@ ".py" => "/usr/bin/python" ) } + +# doc.slitaz.org +# +$HTTP["host"] =~ "doc\.slitaz\.org" { + server.document-root = "/home/slitaz/www/doc" + index-file.names = ("doku.php") + var.dokudir = "" + # Rewrites for dokuwiki + url.rewrite = ( + "^" + var.dokudir + "/lib/.*$" => "$0", + "^" + var.dokudir + "/_media/(.*)?\?(.*)$" => var.dokudir + "/lib/exe/fetch.php?media=$1&$2", + "^" + var.dokudir + "/_media/(.*)$" => var.dokudir + "/lib/exe/fetch.php?media=$1", + "^" + var.dokudir + "/_detail/(.*)?\?(.*)$" => var.dokudir + "/lib/exe/detail.php?media=$1&$2", + "^" + var.dokudir + "/_detail/(.*)?$" => var.dokudir + "/lib/exe/detail.php?media=$1", + "^" + var.dokudir + "/_export/([^/]+)/(.*)\?(.*)$" => var.dokudir + "/doku.php?do=export_$1&id=$2&$3", + "^" + var.dokudir + "/_export/([^/]+)/(.*)" => var.dokudir + "/doku.php?do=export_$1&id=$2", + "^" + var.dokudir + "/doku.php.*" => "$0", + "^" + var.dokudir + "/feed.php.*" => "$0", + "^" + var.dokudir + "/(.*)\?(.*)" => var.dokudir + "/doku.php?id=$1&$2", + "^" + var.dokudir + "/(.*)" => var.dokudir + "/doku.php?id=$1" + ) +} diff -r 6ed4582df956 -r fec794d4852f tank/files/etc/lighttpd/vhosts.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tank/files/etc/lighttpd/vhosts.conf Tue Mar 20 22:12:29 2012 +0100 @@ -0,0 +1,107 @@ +# /etc/lighttpd/vhosts.conf : Virtual hosts configuration file. +# + +# tank.slitaz.org (Server canonical hostname) +# +$HTTP["host"] =~ "tank\.slitaz\.org$" { + server.document-root = "/home/slitaz/www/tank" + server.errorlog = "/var/log/lighttpd/tank.slitaz.org-error.log" + accesslog.filename = "/var/log/lighttpd/tank.slitaz.org-access.log" + include "awstats.conf" + index-file.names += ( "index.php" ) +} + +# pro.slitaz.org +# +$HTTP["host"] =~ "pro\.slitaz\.org$" { + server.document-root = "/home/slitaz/www/pro" + server.errorlog = "/var/log/lighttpd/pro.slitaz.org-error.log" + accesslog.filename = "/var/log/lighttpd/pro.slitaz.org-access.log" + include "awstats.conf" + cgi.assign = ( + ".cgi" => "/bin/sh" + ) +} + +# boot.slitaz.org +# +$HTTP["host"] =~ "boot\.slitaz\.org$" { + server.document-root = "/home/slitaz/www/boot" + server.errorlog = "/var/log/lighttpd/boot.slitaz.org-error.log" + accesslog.filename = "/var/log/lighttpd/boot.slitaz.org-access.log" + include "awstats.conf" + cgi.assign = ( + ".cgi" => "/bin/sh" + ) +} + +# people.slitaz.org +# +$HTTP["host"] =~ "people\.slitaz\.org$" { + userdir.path = "Public" + userdir.exclude-user = ("root") + server.document-root = "/home/slitaz/www/people" + server.errorlog = "/var/log/lighttpd/people.slitaz.org-erro.log" + accesslog.filename = "/var/log/lighttpd/people.slitaz.org-access.log" + include "awstats.conf" +} + +# pkgs.slitaz.org +# +$HTTP["host"] =~ "pkgs\.slitaz\.org$" { + server.document-root = "/home/slitaz/www/pkgs" + server.errorlog = "/var/log/lighttpd/pkgs.slitaz.org-error.log" + accesslog.filename = "/var/log/lighttpd/pkgs.slitaz.org-access.log" + cgi.assign = ( + ".cgi" => "/bin/sh" + ) +} + +# cook.slitaz.org +# +$HTTP["host"] =~ "cook\.slitaz\.org$" { + server.document-root = "/home/slitaz/www/cook" + server.errorlog = "/var/log/lighttpd/cook.slitaz.org-error.log" + accesslog.filename = "/var/log/lighttpd/cook.slitaz.org-access.log" + cgi.assign = ( + ".cgi" => "/bin/sh" + ) + index-file.names = ( "cooker.cgi" ) +} + +# ssfs.slitaz.org +# +$HTTP["host"] =~ "ssfs\.slitaz\.org$" { + cgi.assign = ( + ".cgi" => "/bin/sh" + ) + index-file.names = ( "ssfs.cgi" ) + server.document-root = "/home/slitaz/www/ssfs" + auth.backend = "plain" + auth.backend.plain.userfile = "/etc/ssfs/httpd.users" + auth.require = ( "/home/" => + ( + "method" => "basic", + "realm" => "SliTaz Ssfs protected area", + "require" => "valid-user" + ) + ) +} + +# These hosts are personnal website for me and my family, pankso. + +# pankso.com +# +$HTTP["host"] =~ "(^|\.)pankso\.com$" { + server.document-root = "/home/pankso/vhosts/pankso" + server.errorlog = "/var/log/lighttpd/pankso.error.log" + accesslog.filename = "/var/log/lighttpd/pankso.access.log" +} + +# lincolm.ch +# +$HTTP["host"] =~ "(^|\.)lincolm\.ch$" { + server.document-root = "/home/pankso/vhosts/lincolm" + server.errorlog = "/var/log/lighttpd/lincolm.error.log" + accesslog.filename = "/var/log/lighttpd/lincolm.access.log" +} diff -r 6ed4582df956 -r fec794d4852f tank/files/var/spool/cron/crontabs/root --- a/tank/files/var/spool/cron/crontabs/root Tue Mar 20 21:09:51 2012 +0100 +++ b/tank/files/var/spool/cron/crontabs/root Tue Mar 20 22:12:29 2012 +0100 @@ -1,24 +1,23 @@ +# Crond jobs for SliTaz Tank +# + # Update http://tank.slitaz.org/graphs.php pictures */5 * * * * /home/slitaz/www/tank/bin/makegraphs >/dev/null # Check Internet access #*/5 * * * * /usr/bin/chkwan -# purge php sessions +# Purge php sessions 0 * * * * /usr/bin/find /tmp -name 'sess*' -type f -mmin +720 -exec rm -f {} \; -# rotate logs +# Rotate logs 0 1 * * * /usr/sbin/logrotate /etc/logrotate.conf > /dev/null 2>&1 0 0 * * * /usr/bin/ntpclient -s -h fr.pool.ntp.org -# Update SliTaz stuff -#*/15 * * * * /home/slitaz/www/website/libs/get-feeds.sh -15 02 * * * /usr/bin/tank up-pro -20 02 * * * /usr/bin/tazpkg-web cooking -30 02 * * * /usr/bin/tazpkg-web stable - -#0,10,20,30,40,50 * * * * /usr/bin/roundup-mailgw /home/slitaz/bugs/ \ -# pop bugs@slitaz.org:Bugs4SliTaz@pop.slitaz.org - -# Build rolling release every day if necessary -0 4 * * * /home/bellard/rolling/rolling.sh +# Update SliTaz vhosts and Awstats +20 02 * * * /usr/bin/tank up-pro +22 02 * * * /usr/bin/tank up-people --nohg +24 02 * * * /usr/bin/tank up-boot --nohg +26 02 * * * /usr/bin/tank up-cook --nohg +28 02 * * * /usr/bin/tank up-boot --nohg +30 02 * * * /usr/bin/tank up-stats diff -r 6ed4582df956 -r fec794d4852f tank/tank --- a/tank/tank Tue Mar 20 21:09:51 2012 +0100 +++ b/tank/tank Tue Mar 20 22:12:29 2012 +0100 @@ -1,4 +1,5 @@ #!/bin/sh +# # Tank - Admin Tank, backup, update and give stats. # # (C) 2011 SliTaz - GNU General Public License. @@ -10,16 +11,14 @@ VHOST="$WWW/tank" WEBSITE="$WWW/website" BACKUPS="/home/backups" -PYTHON_LIB="/usr/lib/python2.5" -DOC_LIB="$WWW/doc/lib" usage() { - echo -e "\nUsage: `basename $0` [command] + cat << EOT + +Usage: $(basename $0) [command] Commands: - stats|-s Display some Tank stats backup|-b Backup files and MySQL DB adduser Add user on Tank and create people files - chroot|-c Move a user into a new chroot location up-stats Update Awstats statistics (run by cron) up-tank Update http://tank.slitaz.org/ @@ -27,87 +26,19 @@ up-pro Update http://pro.slitaz.org/ up-boot Update http://boot.slitaz.org/ up-cook Update http://cook.slitaz.org/ - - #up-www Update website http://www.slitaz.org/ - #up-hg Update template for http://hg.slitaz.org/ - #up-doc Update template for http://doc.slitaz.org/\n" + +EOT } case "$1" in - stats|-s) - # Report some stats - clear - cat << EOF - -Connected user --------------- -`who` - -System usage ------------- -`df -h` - -`free` - -EOF - ;; - chroot|-c) - # Move a user into a new chroot location - if [ -s $2/bin/sh ] && grep -qs $3: /etc/password ; then - grep -q ^chroot /etc/busybox.conf || - echo 'chroot = ssx root.root' >> /etc/busybox.conf - [ -s /bin/chrootsh ] || cat > /bin/chrootsh << EOF -#!/bin/sh - -#case " \$@ " in -#*rsync*) exec /bin/sh "\$@" ;; -#esac - -case "\$USER" in -pankso) exec /bin/sh "\$@" ;; -*) exec /usr/sbin/chroot $2 /bin/chrootsh "\$@" ;; -esac -EOF - [ -s $2/bin/chrootsh ] || cat > $2/bin/chrootsh << EOF -#!/bin/sh - -export SHELL='/bin/sh' -cd \$HOME -. /etc/profile -exec /bin/sh "\$@" -EOF - chmod +x /bin/chrootsh $2/bin/chrootsh - base=$(awk -F: "/^$3:/ { print \$6 }" /etc/passwd) - target=$base - while [ -L $target ]; do - target=$(readlink $target) - done - mv $target $2/$base - [ -L $base ] && rm -f $base - ln -s $2/$base $base - if ! grep -q ^$3: $2/etc/passwd ; then - grep ^$3: /etc/passwd >> $2/etc/passwd - grep ^$3: /etc/shadow >> $2/etc/shadow fi - fi - else - cat << EOF -Usage: $0 $1 newchroot user -Move a user in a new chroot location -EOF - fi ;; backup|-b) # Backup config files and SQL db. echo "TODO" ;; - up-www) - # Update website from repo. - echo -e "\nUpdating: www.slitaz.org..." - cd $WEBSITE && hg pull -u - echo "" ;; up-tank) # Update Tank web interface: http://tank.slitaz.org/ echo -e "\nUpdating: tank.slitaz.org..." cd $REPOS/slitaz-forge - hg pull -u + [ "$2" == "--nohg" ] || hg pull -u rm -rf $VHOST/*.* $VHOST/images cp -a tank/web/* $VHOST echo "" ;; @@ -115,7 +46,7 @@ # Update People web interface: http://people.slitaz.org/ echo -e "\nUpdating: people.slitaz.org..." cd $REPOS/slitaz-forge - hg pull -u + [ "$2" == "--nohg" ] || hg pull -u rm -rf $WWW/people/* cp -a people/* $WWW/people echo "" ;; @@ -123,7 +54,7 @@ # Update Pro website: http://pro.slitaz.org/ echo -e "\nUpdating: pro.slitaz.org..." cd $REPOS/slitaz-forge - hg pull -u + [ "$2" == "--nohg" ] || hg pull -u rm -rf $WWW/pro/* cp -a pro/* $WWW/pro echo "" ;; @@ -131,7 +62,7 @@ # Update Web Boot interface: http://boot.slitaz.org/ echo -e "\nUpdating: boot.slitaz.org..." cd $REPOS/slitaz-forge - hg pull -u + [ "$2" == "--nohg" ] || hg pull -u rm -rf $WWW/boot/* cp -a boot/* $WWW/boot echo "" ;; @@ -139,30 +70,15 @@ # Update Web Boot interface: http://boot.slitaz.org/ echo -e "\nUpdating: cook.slitaz.org..." cd $REPOS/slitaz-forge - hg pull -u + [ "$2" == "--nohg" ] || hg pull -u cp -a cook/* $WWW/cook cp -a cook/* $WWW/cook/undigest echo "" ;; - up-hg) - # Since Tank runs stable and we update the style in slitaz-dev-tools - # the cooking package is unbuildable because it uses the new Tazwok function - # with mercurial|* - echo -e "\nUpdating Mercurial template..." - cd $REPOS/slitaz-dev-tools && hg pull -u - cp -a slitaz-mercurial-style/* $PYTHON_LIB/site-packages/mercurial - chown -R root.root $PYTHON_LIB/site-packages/mercurial/templates - echo "" ;; - up-doc) - # Update Wiki doc template from Hg: http://doc.slitaz.org/ - echo -e "\nUpdating Wiki documentation template..." - cd $REPOS/slitaz-forge && hg pull -u - cp -a doc/lib/tpl/* $DOC_LIB/tpl - echo "" ;; up-stats) echo -e "\nUpdating all awstats databases..." - for vh in pro boot cook + for vh in pro boot cook people do - /var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org + /var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org -update done echo "" ;; adduser)