slitaz-forge view tank/tank @ rev 467

tank: add arm.slitaz.org vhost
author Christophe Lincoln <pankso@slitaz.org>
date Sun Mar 02 19:58:22 2014 +0100 (2014-03-02)
parents cad23317627c
children a2364c457fb3
line source
1 #!/bin/sh
2 #
3 # Tank - Admin Tank, backup, update and give stats.
4 #
5 # (C) 2012-2014 SliTaz - GNU General Public License.
6 # Author: Christophe Lincoln <pankso@slitaz.org>
7 #
8 . /lib/libtaz.sh
10 REPOS="/home/slitaz/repos"
11 WWW="/home/slitaz/www"
12 VHOST="$WWW/tank"
13 WEBSITE="$WWW/website"
14 BACKUPS="/home/backups"
15 LOGFILE="/var/log/tank.log"
17 usage() {
18 cat << EOT
20 Usage: $(basename $0) [command]
21 Commands:
22 backup|-b Backup files and MySQL DB
23 adduser Add user on Tank and create people files
24 up-stats Update Awstats statistics (run by cron)
25 online Show online users
27 up-tank Update http://tank.slitaz.org/
28 up-people Update http://people.slitaz.org/
29 up-pro Update http://pro.slitaz.org/
30 up-boot Update http://boot.slitaz.org/
31 up-cook Update http://cook.slitaz.org/
32 up-roadmap Update http://roadmap.slitaz.org/
33 up-bugs Update http://bugs.slitaz.org/
34 up-irc Update http://irc.slitaz.org/
35 up-arm Update http://arm.slitaz.org/
37 EOT
38 }
40 case "$1" in
41 backup|-b)
42 # Backup config files and SQL db.
43 echo "TODO" ;;
44 up-tank)
45 # Update Tank web interface
46 echo -e "\nUpdating: tank.slitaz.org..."
47 cd $REPOS/slitaz-forge
48 [ "$2" == "--nohg" ] || hg pull -u
49 rm -rf $VHOST/*.* $VHOST/images
50 cp -a tank/web/* $VHOST
51 echo "" ;;
52 up-people)
53 # Update People web interface
54 echo -e "\nUpdating: people.slitaz.org..."
55 cd $REPOS/slitaz-forge
56 [ "$2" == "--nohg" ] || hg pull -u
57 rm -rf $WWW/people/*
58 cp -a people/* $WWW/people
59 echo "" ;;
60 up-pro)
61 # Update Pro website
62 echo -e "\nUpdating: pro.slitaz.org..."
63 cd $REPOS/slitaz-forge
64 [ "$2" == "--nohg" ] || hg pull -u
65 rm -rf $WWW/pro/web/*
66 cp -a pro/* $WWW/pro/web
67 echo "" ;;
68 up-boot)
69 # Update Web Boot interface
70 echo -e "\nUpdating: boot.slitaz.org..."
71 cd $REPOS/slitaz-forge
72 [ "$2" == "--nohg" ] || hg pull -u
73 rm -rf $WWW/boot/*
74 cp -a boot/* $WWW/boot
75 echo "" ;;
76 up-cook)
77 # Update Web Boot interface
78 echo -e "\nUpdating: cook.slitaz.org..."
79 cd $REPOS/cookutils
80 [ "$2" == "--nohg" ] || hg pull -u
81 cd $REPOS/slitaz-forge
82 [ "$2" == "--nohg" ] || hg pull -u
83 cp -a cook/* $WWW/cook
84 # We use symlinks for cooker's
85 cd $WWW/cook && rm -f style.css
86 ln -s $REPOS/cookutils/web/style.css .
87 cd $WWW/cook/cross && rm -f style.css
88 ln -s $REPOS/cookutils/web/style.css .
89 for web in stable undigest backports cross/arm cross/x86_64
90 do
91 echo "Linking: $web CSS/CGI files"
92 cd $WWW/cook/$web
93 for file in style.css cooker.cgi cookiso.cgi
94 do
95 rm -f $file
96 ln -s $REPOS/cookutils/web/$file .
97 done
98 # header.html
99 echo "Linking: $web/header.html"
100 rm -f header.html
101 ln -s ../header.html .
102 done
104 # No ISO's for undigest and ARM.
105 rm -f \
106 $WWW/cook/undigest/cookiso.cgi \
107 $WWW/cook/cross/arm/cookiso.cgi
108 echo "" ;;
109 up-roadmap)
110 # Update Roadmap Web interface
111 echo -e "\nUpdating: roadmap.slitaz.org..."
112 cd $REPOS/slitaz-forge
113 [ "$2" == "--nohg" ] || hg pull -u
114 cp -a roadmap/* $WWW/roadmap
115 echo "" ;;
116 up-bugs)
117 # Update Bugs Web interface
118 bugs="$WWW/bugs"
119 echo -e "\nUpdating: bugs.slitaz.org..."
120 cd $REPOS/tazbug
121 [ "$2" == "--nohg" ] || hg pull -u
122 cp -a web/* ${bugs}
123 cp README ${bugs}
124 chown -R www.www ${bugs}
125 echo "" ;;
126 up-irc)
127 # Update IRC interface
128 echo -e "\nUpdating: irc.slitaz.org..."
129 cd $REPOS/slitaz-forge
130 [ "$2" == "--nohg" ] || hg pull -u
131 rm -rf $WWW/irc/images $WWW/irc/lib
132 cp -a irc/* $WWW/irc
133 echo "" ;;
134 up-arm)
135 # Update ARM Web interface
136 echo -e "\nUpdating: arm.slitaz.org..."
137 cd $REPOS/slitaz-forge
138 [ "$2" == "--nohg" ] || hg pull -u
139 cp -a arm/* $WWW/arm
140 echo "" ;;
141 up-stats)
142 echo -e "\nUpdating all awstats databases..." | tee -a $LOGFILE
143 date >> $LOGFILE
144 for vh in pro boot cook people tank
145 do
146 /var/www/cgi-bin/awstats.pl \
147 -config=$vh.slitaz.org -update 2>&1 | tee -a $LOGFILE
148 done && echo "" ;;
149 adduser)
150 echo ""
151 if [ -d /home/$user ]; then
152 echo -e "User $user already exists...\n" && exit 1
153 fi
154 if [ -n "$2" ]; then
155 user=$2
156 else
157 echo -n "User name: " && read user
158 fi
159 if [ -n "$3" ]; then
160 gecos="$3"
161 else
162 echo -n "Real name: " && read name
163 fi
164 if [ -n "$4" ]; then
165 pass=$4
166 else
167 echo -n "Password: " && read pass
168 fi
169 echo "Adding user: $user"
170 adduser -D -g "$gecos" $user -G users
171 echo $user:$pass | chpasswd --md5
172 addgroup $user slitaz
173 # HG access
174 #echo "$user:$pass" >> /etc/lighttpd/plain.passwd
175 # Public dir at http://people.slitaz.org/~$user/
176 sed -i s/'%user%'/"$user"/ /home/$user/Public/index.html
177 sed -i s/'%name%'/"$gecos"/ /home/$user/Public/profile.php
178 # Empty Shell profile
179 cat > /home/$user/.profile << EOF
180 # ~/.profile: Executed by Bourne-compatible login SHells.
181 #
182 EOF
183 #chown -R $user.$user /home/$user
184 echo -e "Done\n" ;;
185 online)
186 echo -n "Bugs online users: "
187 colorize 34 "$(ls /tmp/bugs/sessions | wc -l)" ;;
188 *)
189 usage ;;
190 esac
191 exit 0