slitaz-forge view tank/tank @ 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 7bebd2b3700d
children eb06ca412415
line source
1 #!/bin/sh
2 #
3 # Tank - Admin Tank, backup, update and give stats.
4 #
5 # (C) 2011 SliTaz - GNU General Public License.
6 # Author: Christophe Lincoln <pankso@slitaz.org>
7 #
9 REPOS="/home/slitaz/repos"
10 WWW="/home/slitaz/www"
11 VHOST="$WWW/tank"
12 WEBSITE="$WWW/website"
13 BACKUPS="/home/backups"
15 usage() {
16 cat << EOT
18 Usage: $(basename $0) [command]
19 Commands:
20 backup|-b Backup files and MySQL DB
21 adduser Add user on Tank and create people files
22 up-stats Update Awstats statistics (run by cron)
24 up-tank Update http://tank.slitaz.org/
25 up-people Update http://people.slitaz.org/
26 up-pro Update http://pro.slitaz.org/
27 up-boot Update http://boot.slitaz.org/
28 up-cook Update http://cook.slitaz.org/
30 EOT
31 }
33 case "$1" in
34 backup|-b)
35 # Backup config files and SQL db.
36 echo "TODO" ;;
37 up-tank)
38 # Update Tank web interface: http://tank.slitaz.org/
39 echo -e "\nUpdating: tank.slitaz.org..."
40 cd $REPOS/slitaz-forge
41 [ "$2" == "--nohg" ] || hg pull -u
42 rm -rf $VHOST/*.* $VHOST/images
43 cp -a tank/web/* $VHOST
44 echo "" ;;
45 up-people)
46 # Update People web interface: http://people.slitaz.org/
47 echo -e "\nUpdating: people.slitaz.org..."
48 cd $REPOS/slitaz-forge
49 [ "$2" == "--nohg" ] || hg pull -u
50 rm -rf $WWW/people/*
51 cp -a people/* $WWW/people
52 echo "" ;;
53 up-pro)
54 # Update Pro website: http://pro.slitaz.org/
55 echo -e "\nUpdating: pro.slitaz.org..."
56 cd $REPOS/slitaz-forge
57 [ "$2" == "--nohg" ] || hg pull -u
58 rm -rf $WWW/pro/*
59 cp -a pro/* $WWW/pro
60 echo "" ;;
61 up-boot)
62 # Update Web Boot interface: http://boot.slitaz.org/
63 echo -e "\nUpdating: boot.slitaz.org..."
64 cd $REPOS/slitaz-forge
65 [ "$2" == "--nohg" ] || hg pull -u
66 rm -rf $WWW/boot/*
67 cp -a boot/* $WWW/boot
68 echo "" ;;
69 up-cook)
70 # Update Web Boot interface: http://boot.slitaz.org/
71 echo -e "\nUpdating: cook.slitaz.org..."
72 cd $REPOS/slitaz-forge
73 [ "$2" == "--nohg" ] || hg pull -u
74 cp -a cook/* $WWW/cook
75 cp -a cook/* $WWW/cook/undigest
76 echo "" ;;
77 up-stats)
78 echo -e "\nUpdating all awstats databases..."
79 for vh in pro boot cook people
80 do
81 /var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org -update
82 done
83 echo "" ;;
84 adduser)
85 # On Tank /etc/skel is empty to let tank handle default user
86 # files.
87 echo ""
88 if [ -n "$2" ]; then
89 user=$2
90 else
91 echo -n "User name: " && read user
92 fi
93 if [ -d /home/$user ]; then
94 echo -e "User $user already exists...\n" && exit 1
95 fi
96 echo "Adding user: $user"
97 # adduser -s /bin/sh -g "SliTaz User" -G users -h /home/$user $user # for cooking
98 adduser $user
99 # HG access
100 echo -n "Hg password: " && read passwd
101 echo "$user:$passwd" >> /etc/lighttpd/plain.passwd
102 # Public dir at http://people.slitaz.org/~$user/
103 cp -a /usr/share/tank/Public/* /home/$user/Public
104 sed -i s/'%user%'/"$user"/ /home/$user/Public/index.html
105 # README and empty Shell profile
106 cp -a /usr/share/tank/README /home/$user/
107 cat > /home/$user/.profile << EOF
108 # ~/.profile: Executed by Bourne-compatible login SHells.
109 #
110 EOF
111 chown -R $user.$user /home/$user
112 echo -e "Done\n" ;;
113 *)
114 usage ;;
115 esac
116 exit 0