# HG changeset patch # User Christophe Lincoln # Date 1302282527 -7200 # Node ID 8ec2a7e051e8b58ad770cbdcde0b7d52cdbc1603 # Parent ec479bff3f1ad8f033eefbe37a3616b9cc48aa1f Some rename and fixes to tank diff -r ec479bff3f1a -r 8ec2a7e051e8 tank/Makefile --- a/tank/Makefile Fri Apr 08 18:51:44 2011 +0200 +++ b/tank/Makefile Fri Apr 08 19:08:47 2011 +0200 @@ -10,12 +10,20 @@ mkdir -p $(DESTDIR)$(PREFIX)/bin \ $(DESTDIR)$(PREFIX)/share/taztank cp -f taztank $(DESTDIR)$(PREFIX)/bin - cp -f profile.php $(DESTDIR)$(PREFIX)/share/taztank + cp files/usr/share/tank $(DESTDIR)$(PREFIX)/share install-files: cp -a files/var $(DESTDIR)/ chmod 0600 -p $(DESTDIR)/var/spool/cron/crontabs/root cp -a files/etc $(DESTDIR)/ cp -a files/usr $(DESTDIR}/ + +# Used to switc from taztank to tank (shorted :-) +uninstill: + rm -f /usr/bin/taztank + rm -f /usr/bin/tank + rm -rf /usr/share/taztank + rm -rf /usr/share/tank + clean: rm -rf _pkg diff -r ec479bff3f1a -r 8ec2a7e051e8 tank/files/usr/share/tank/Public/profile.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tank/files/usr/share/tank/Public/profile.php Fri Apr 08 19:08:47 2011 +0200 @@ -0,0 +1,13 @@ + diff -r ec479bff3f1a -r 8ec2a7e051e8 tank/files/usr/share/tank/README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tank/files/usr/share/tank/README Fri Apr 08 19:08:47 2011 +0200 @@ -0,0 +1,9 @@ +Welcome to Tank! +================================================================================ + +Your Public directory URL is: http://people.slitaz.org/~$USER/ + +Please complete your public profile in ~/Public/profile.php and feel free +to use the service for your needs, if anything goes wrong or is missing +please express yourself :-) + diff -r ec479bff3f1a -r 8ec2a7e051e8 tank/profile.php --- a/tank/profile.php Fri Apr 08 18:51:44 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ - diff -r ec479bff3f1a -r 8ec2a7e051e8 tank/tank --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tank/tank Fri Apr 08 19:08:47 2011 +0200 @@ -0,0 +1,161 @@ +#!/bin/sh +# Taztank - Admin Tank, backup, update and give stats. +# +# (C) 2011 SliTaz - GNU General Public License. +# Author: Christophe Lincoln +# + +REPOS="/home/slitaz/repos" +WWW="/home/slitaz/www" +VHOST="$WWW/tank" +WEBSITE="$WWW/website" +BACKUPS="/home/backups" + +usage() { + echo -e "\nUsage: `basename $0` [command] +Commands: + stats|-s Display some Tank stats + backup|-b Backup files and MySQL DB + chroot|-c Move a user into a new chroot location + up-www|-uw Update website http://www.slitaz.org/ + up-tank|-ut Update http://tank.slitaz.org/ + up-people|-up Update http://people.slitaz.org/ + up-boot|-ub Update http://boot.slitaz.org/ + up-stats|-us Update Awstats statistics (run by cron) + adduser|-au Add user on tank\n" +} + +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 "Not yet implemented..." ;; + up-www|-uw) + # Update website from repo. + echo -e "\nUpdating: www.slitaz.org..." + cd $WEBSITE && hg pull && hg update + echo "" ;; + up-tank|-ut) + # Update Tank web interface: http://tank.slitaz.org/ + echo -e "\nUpdating: tank.slitaz.org..." + cd $REPOS/slitaz-forge + hg update + rm -rf $VHOST/*.* $VHOST/pics/website $VHOST/images + cp -a tank/web/* $VHOST + echo "" ;; + up-people|-up) + # Update People web interface: http://people.slitaz.org/ + echo -e "\nUpdating: people.slitaz.org..." + cd $REPOS/slitaz-forge + hg update + rm -rf $WWW/people/* + cp -a people/* $WWW/people + echo "" ;; + up-boot|-ub) + # Update Web Boot interface: http://boot.slitaz.org/ + echo -e "\nUpdating: boot.slitaz.org..." + cd $REPOS/slitaz-forge + hg update + rm -rf $WWW/boot/* + cp -a boot/* $WWW/boot + echo "" ;; + up-stats|-us) + echo -e "\nUpdating all awstats databases..." + for vh in www boot pkgs + do + /var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org + done + echo "" ;; + adduser|-au) + # On Tank /etc/skel is empty to let taktank handle default user + # files. + echo "" + if [ -n "$2" ]; then + user=$2 + else + echo -n "User name: " && read user + fi + if [ -d /home/$user ]; then + echo -e "User $user already exists...\n" && exit 1 + fi + echo "Adding user: $user" + #adduser -s /bin/sh -g "SliTaz User" -G users -h /home/$user $user # for cooking + adduser $user + # HG access + echo -n "Hg password: " && read passwd + echo "$user:$passwd" >> /etc/lighttpd/plain.passwd + # Public dir at http://people.slitaz.org/~$user/ + cp -a /usr/share/tank/Public /home/$user/Public + # README and empty Shell profile + cp -a /usr/share/tank/README /home/$user/ + cat > /home/$user/.profile << EOF +# ~/.profile: Executed by Bourne-compatible login SHells. +# +EOF + chown -R $user.$user /home/$user + echo -e "Done\n" ;; + *) + usage ;; +esac +exit 0 diff -r ec479bff3f1a -r 8ec2a7e051e8 tank/taztank --- a/tank/taztank Fri Apr 08 18:51:44 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,175 +0,0 @@ -#!/bin/sh -# Taztank - Admin Tank, backup, update and give stats. -# -# (C) 2011 SliTaz - GNU General Public License. -# Author: Christophe Lincoln -# - -REPOS="/home/slitaz/repos" -WWW="/home/slitaz/www" -VHOST="$WWW/tank" -WEBSITE="$WWW/website" -BACKUPS="/home/backups" - -usage() { - echo -e "\nUsage: `basename $0` [command] -Commands: - stats|-s Display some Tank stats - backup|-b Backup files and MySQL DB - chroot|-c Move a user into a new chroot location - up-www|-uw Update website http://www.slitaz.org/ - up-tank|-ut Update http://tank.slitaz.org/ - up-people|-up Update http://people.slitaz.org/ - up-boot|-ub Update http://boot.slitaz.org/ - up-stats|-us Update Awstats statistics (run by cron) - adduser|-au Add user on tank\n" -} - -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 "Not yet implemented..." ;; - update-www|-uw) - # Update website from repo. - echo -e "\nUpdating: www.slitaz.org..." - cd $WEBSITE && hg pull && hg update - echo "" ;; - up-tank|-ut) - # Update Tank web interface: http://tank.slitaz.org/ - echo -e "\nUpdating: tank.slitaz.org..." - cd $REPOS/slitaz-forge - hg update - rm -rf $VHOST/*.* $VHOST/pics/website $VHOST/images - cp -a tank/web/* $VHOST - echo "" ;; - up-people|-up) - # Update People web interface: http://people.slitaz.org/ - echo -e "\nUpdating: people.slitaz.org..." - cd $REPOS/slitaz-forge - hg update - rm -rf $WWW/people/* - cp -a people/* $WWW/people - echo "" ;; - up-boot|-ub) - # Update Web Boot interface: http://boot.slitaz.org/ - echo -e "\nUpdating: boot.slitaz.org..." - cd $REPOS/slitaz-forge - hg update - rm -rf $WWW/boot/* - cp -a boot/* $WWW/boot - echo "" ;; - up-stats|-us) - echo -e "\nUpdating all awstats databases..." - for vh in www boot pkgs - do - /var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org - done - echo "" ;; - adduser|-au) - # On Tank /etc/skel is empty to let taktank handle default user - # files. - echo "" - if [ -n "$2" ]; then - user=$2 - else - echo -n "User name: " && read user - fi - if [ -d /home/$user ]; then - echo -e "User $user already exists...\n" && exit 1 - fi - echo "Adding user: $user" - #adduser -s /bin/sh -g "SliTaz User" -G users -h /home/$user $user # for cooking - adduser $user - # HG access - echo -n "Hg password: " && read passwd - echo "$user:$passwd" >> /etc/lighttpd/plain.passwd - # README - echo -n "Creating default user files... " - cat > /home/$user/README << EOF -Welcome to Tank! -================================================================================ - -Your Public directory URL is: http://people.slitaz.org/~$USER/ - -Please complete your public profile in ~/Public/profile.php and feel free -to use the service for your needs, if anything goes wrong or is missing -please express yourself :-) - -EOF - # Public profile - mkdir -p /home/$user/Public - if [ -f /usr/share/taztank/profile.php ]; then - cp -a /usr/share/taztank/profile.php /home/$user/Public/profile.php - fi - # Shell profile - cat > /home/$user/.profile << EOF -# ~/.profile: Executed by Bourne-compatible login SHells. -# -EOF - echo -e "Done\n" ;; - *) - usage ;; -esac -exit 0