slitaz-forge view tank/taztank @ rev 41

tank: update taztank to use slitaz-forge repo
author Christophe Lincoln <pankso@slitaz.org>
date Mon Mar 28 15:18:40 2011 +0200 (2011-03-28)
parents 24c246a96526
children 4a50c3b5987f
line source
1 #!/bin/sh
2 # Taztank - Admin Tank, backup, update and give stats.
3 # (C) 2011 SliTaz - GNU General Public License.
4 # Author: Christophe Lincoln <pankso@slitaz.org>
5 #
7 REPOS="/home/slitaz/repos"
8 WWW="/home/slitaz/www"
9 VHOST="$WWW/tank"
10 BACKUPS="/home/backups"
12 usage() {
13 echo -e "\nUsage: `basename $0` [command]
14 Commands:
15 stats Display some Tank stats
16 backup Backup files and MySQL DB
17 chroot Move a user into a new chroot location
18 up-web Update http://tank.slitaz.org/
19 up-people Update http://people.slitaz.org/
20 up-boot Update http://boot.slitaz.org/
21 up-web-stats Update Awstats statistics (run by cron)
22 clean-labs Clean Redmine Labs (no longer on Tank)\n"
23 }
25 case "$1" in
26 stats)
27 # Report some stats
28 clear
29 cat << EOF
31 Connected user
32 --------------
33 `who`
35 System usage
36 ------------
37 `df -h`
39 `free`
41 EOF
42 ;;
43 chroot)
44 if [ -s $2/bin/sh ] && grep -qs $3: /etc/password ; then
45 grep -q ^chroot /etc/busybox.conf ||
46 echo 'chroot = ssx root.root' >> /etc/busybox.conf
47 [ -s /bin/chrootsh ] || cat > /bin/chrootsh << EOF
48 #!/bin/sh
50 #case " \$@ " in
51 #*rsync*) exec /bin/sh "\$@" ;;
52 #esac
54 case "\$USER" in
55 pankso) exec /bin/sh "\$@" ;;
56 *) exec /usr/sbin/chroot $2 /bin/chrootsh "\$@" ;;
57 esac
58 EOF
59 [ -s $2/bin/chrootsh ] || cat > $2/bin/chrootsh << EOF
60 #!/bin/sh
62 export SHELL='/bin/sh'
63 cd \$HOME
64 . /etc/profile
65 exec /bin/sh "\$@"
66 EOF
67 chmod +x /bin/chrootsh $2/bin/chrootsh
68 base=$(awk -F: "/^$3:/ { print \$6 }" /etc/passwd)
69 target=$base
70 while [ -L $target ]; do
71 target=$(readlink $target)
72 done
73 mv $target $2/$base
74 [ -L $base ] && rm -f $base
75 ln -s $2/$base $base
76 if ! grep -q ^$3: $2/etc/passwd ; then
77 grep ^$3: /etc/passwd >> $2/etc/passwd
78 grep ^$3: /etc/shadow >> $2/etc/shadow fi
79 fi
80 else
81 cat << EOF
82 Usage: $0 $1 newchroot user
83 Move a user in a new chroot location
84 EOF
85 fi
86 ;;
87 backup)
88 # Backup config files and SQL db.
89 echo "Not yet implemented..." ;;
90 up-web)
91 # Update Tank web interface: http://tank.slitaz.org/
92 echo -e "\nUpdating: tank.slitaz.org..."
93 cd $REPOS/slitaz-forge
94 hg update
95 rm -rf $VHOST/*.* $VHOST/pics/website $VHOST/images
96 cp -a tank/web/* $VHOST ;;
97 up-people)
98 # Update People web interface: http://people.slitaz.org/
99 echo -e "\nUpdating: people.slitaz.org..."
100 cd $REPOS/slitaz-forge
101 hg update
102 rm -rf $WWW/people/*
103 cp -a people/* $WWW/people ;;
104 up-boot)
105 # Update Web Boot interface: http://boot.slitaz.org/
106 echo -e "\nUpdating: boot.slitaz.org..."
107 cd $REPOS/slitaz-forge
108 hg update
109 rm -rf $WWW/boot/*
110 cp -a boot/* $WWW/boot ;;
111 up-web-stats)
112 echo -e "\nUpdating all awstats databases...\n"
113 for vh in www boot pkgs
114 do
115 /var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org
116 done ;;
117 *)
118 usage ;;
119 esac
120 exit 0