slitaz-forge view tank/tank @ rev 661

tank: up tank tool to update sup plugin in SCN
author Christophe Lincoln <pankso@slitaz.org>
date Fri Feb 24 07:54:55 2017 +0100 (2017-02-24)
parents 2b38b7489a33
children 6a6c2f111dea
line source
1 #!/bin/sh
2 #
3 # Tank - Admin Tank, backup, update and give stats.
4 #
5 # (C) 2012-2017 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/
36 up-scn Update http://scn.slitaz.org/
38 EOT
39 }
41 case "$1" in
42 backup|-b)
43 # Backup config files and SQL db.
44 echo "TODO" ;;
46 up-tank)
47 # Update Tank web interface
48 echo -e "\nUpdating: tank.slitaz.org..."
49 cd $REPOS/slitaz-forge
50 [ "$2" == "--nohg" ] || hg pull -u
51 rm -rf $VHOST/*.* $VHOST/images
52 cp -a tank/web/* $VHOST
53 # Be sure we have last version of libtaz.sh httphelper.sh
54 #echo "$(colorize 33 'Updating:') libtaz.sh && httphelper.sh"
55 #cd $REPOS/slitaz-base-files
56 #[ "$2" == "--nohg" ] || hg pull -u
57 #cp -f rootfs/lib/libtaz.sh /lib
58 #cp -f rootfs/usr/lib/slitaz/httphelper.sh /usr/lib/slitaz
59 echo "" ;;
61 up-people)
62 # Update People web interface
63 echo -e "\nUpdating: people.slitaz.org..."
64 cd $REPOS/slitaz-forge
65 [ "$2" == "--nohg" ] || hg pull -u
66 rm -rf $WWW/people/*
67 cp -a people/* $WWW/people
68 echo "" ;;
70 up-pro)
71 # Update Pro website
72 echo -e "\nUpdating: pro.slitaz.org..."
73 cd $REPOS/slitaz-forge
74 [ "$2" == "--nohg" ] || hg pull -u
75 rm -rf $WWW/pro/web/*
76 cp -a pro/* $WWW/pro/web
77 echo "" ;;
79 up-boot)
80 # Update Web Boot interface
81 echo -e "\nUpdating: boot.slitaz.org..."
82 cd $REPOS/slitaz-forge
83 [ "$2" == "--nohg" ] || hg pull -u
84 rm -rf $WWW/boot/*
85 cp -a boot/* $WWW/boot
86 echo "" ;;
88 up-cook)
89 # Update Web Boot interface
90 echo -e "\nUpdating: cook.slitaz.org..."
91 cd $REPOS/cookutils
92 [ "$2" == "--nohg" ] || hg pull -u
93 cd $REPOS/slitaz-forge
94 [ "$2" == "--nohg" ] || hg pull -u
95 cp -a cook/* $WWW/cook
96 # We use symlinks for cooker's
97 cd $WWW/cook && rm -f style.css
98 ln -s $REPOS/cookutils/web/style.css .
99 cd $WWW/cook/cross && rm -f style.css
100 ln -s $REPOS/cookutils/web/style.css .
101 for web in stable undigest backports cross/arm cross/x86_64
102 do
103 echo "Linking: $web CSS/CGI files"
104 cd $WWW/cook/$web
105 for file in style.css cooker.cgi cookiso.cgi
106 do
107 rm -f $file
108 ln -s $REPOS/cookutils/web/$file .
109 done
110 # header.html
111 echo "Linking: $web/header.html"
112 rm -f header.html
113 ln -s ../header.html .
114 done
116 # No ISO's for undigest and ARM.
117 rm -f \
118 $WWW/cook/undigest/cookiso.cgi \
119 $WWW/cook/cross/arm/cookiso.cgi
120 echo "" ;;
122 up-roadmap)
123 # Update Roadmap Web interface
124 echo -e "\nUpdating: roadmap.slitaz.org..."
125 cd $REPOS/slitaz-forge
126 [ "$2" == "--nohg" ] || hg pull -u
127 cp -a roadmap/* $WWW/roadmap
128 echo "" ;;
130 up-bugs)
131 # Update Bugs Web interface
132 bugs="$WWW/bugs"
133 echo -e "\nUpdating: bugs.slitaz.org..."
134 cd $REPOS/tazbug
135 [ "$2" == "--nohg" ] || hg pull -u
136 cp -a web/* ${bugs}
137 cp README ${bugs}
138 chown -R www.www ${bugs}
139 echo "" ;;
141 up-irc)
142 # Update IRC interface
143 echo -e "\nUpdating: irc.slitaz.org..."
144 cd $REPOS/slitaz-forge
145 [ "$2" == "--nohg" ] || hg pull -u
146 rm -rf $WWW/irc/images $WWW/irc/lib
147 cp -a irc/* $WWW/irc
148 echo "" ;;
150 up-arm)
151 # Update ARM Web interface
152 echo -e "\nUpdating: arm.slitaz.org..."
153 cd $REPOS/slitaz-forge && hg pull -u
154 cp -a arm/* $WWW/arm
155 echo "Updating: slitaz-arm Hg repo..."
156 cd $REPOS/slitaz-arm && hg pull -u
157 echo "" ;;
159 up-scn)
160 # Update scn.slitaz.org
161 echo -e "\nUpdating: scn.slitaz.org..."
162 cd $REPOS/slitaz-forge && hg pull -u
163 cp -f scn/style* $WWW/scn
164 cp -f scn/header.html $WWW/scn/lib
165 cp -a scn/plugins $WWW/scn
166 cp -a scn/images $WWW/scn
167 # SUP plugin hg.slitaz.org/sup
168 cd $REPOS/sup && hg pull -u
169 cp -a server/sup $WWW/scn/plugins
170 # Use TinyCM cmdline tool
171 cd $REPOS/tinycm && hg pull -u
172 ./tinycm up $WWW/scn ;;
174 up-stats)
175 echo -e "\nUpdating all awstats databases..." | tee -a $LOGFILE
176 date >> $LOGFILE
177 for vh in pro boot cook people tank
178 do
179 /var/www/cgi-bin/awstats.pl \
180 -config=$vh.slitaz.org -update 2>&1 | tee -a $LOGFILE
181 done && echo "" ;;
183 adduser)
184 echo ""
185 if [ -n "$2" ]; then
186 user=$2
187 else
188 echo -n "User name: " && read user
189 fi
190 if [ -d /home/$user ]; then
191 echo -e "User $user already exists...\n" && exit 1
192 fi
193 if [ -n "$3" ]; then
194 gecos="$3"
195 else
196 echo -n "Real name: " && read name
197 fi
198 if [ -n "$4" ]; then
199 pass=$4
200 else
201 echo -n "Password: " && read pass
202 fi
203 echo "Adding user: $user"
204 adduser -D -g "$gecos" $user -G users
205 echo $user:$pass | chpasswd --md5
206 addgroup $user slitaz
207 # HG access
208 #echo "$user:$pass" >> /etc/lighttpd/plain.passwd
209 # Public dir at http://people.slitaz.org/~$user/
210 sed -i s/'%user%'/"$user"/ /home/$user/Public/index.html
211 sed -i s/'%name%'/"$gecos"/ /home/$user/Public/profile.php
212 # Empty Shell profile
213 cat > /home/$user/.profile << EOF
214 # ~/.profile: Executed by Bourne-compatible login SHells.
215 #
216 EOF
217 #chown -R $user.$user /home/$user
218 echo -e "Done\n" ;;
220 online)
221 echo -n "Bugs online users: "
222 colorize 34 "$(ls /tmp/bugs/sessions | wc -l)"
223 echo -n "SCN online users: "
224 colorize 34 "$(ls /tmp/tinycm/sessions | wc -l)" ;;
226 *)
227 usage ;;
229 esac && exit 0