slitaz-forge view tank/tank @ rev 662

tank: include sup-demo package on up-scn
author Christophe Lincoln <pankso@slitaz.org>
date Fri Feb 24 08:53:29 2017 +0100 (2017-02-24)
parents 16e28c1e9ec6
children af57a0cc4aa6
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 cp -a wok/sup-demo $WWW/scn/content/sup/wok
171 # Use TinyCM cmdline tool
172 cd $REPOS/tinycm && hg pull -u
173 ./tinycm up $WWW/scn ;;
175 up-stats)
176 echo -e "\nUpdating all awstats databases..." | tee -a $LOGFILE
177 date >> $LOGFILE
178 for vh in pro boot cook people tank
179 do
180 /var/www/cgi-bin/awstats.pl \
181 -config=$vh.slitaz.org -update 2>&1 | tee -a $LOGFILE
182 done && echo "" ;;
184 adduser)
185 echo ""
186 if [ -n "$2" ]; then
187 user=$2
188 else
189 echo -n "User name: " && read user
190 fi
191 if [ -d /home/$user ]; then
192 echo -e "User $user already exists...\n" && exit 1
193 fi
194 if [ -n "$3" ]; then
195 gecos="$3"
196 else
197 echo -n "Real name: " && read name
198 fi
199 if [ -n "$4" ]; then
200 pass=$4
201 else
202 echo -n "Password: " && read pass
203 fi
204 echo "Adding user: $user"
205 adduser -D -g "$gecos" $user -G users
206 echo $user:$pass | chpasswd --md5
207 addgroup $user slitaz
208 # HG access
209 #echo "$user:$pass" >> /etc/lighttpd/plain.passwd
210 # Public dir at http://people.slitaz.org/~$user/
211 sed -i s/'%user%'/"$user"/ /home/$user/Public/index.html
212 sed -i s/'%name%'/"$gecos"/ /home/$user/Public/profile.php
213 # Empty Shell profile
214 cat > /home/$user/.profile << EOF
215 # ~/.profile: Executed by Bourne-compatible login SHells.
216 #
217 EOF
218 #chown -R $user.$user /home/$user
219 echo -e "Done\n" ;;
221 online)
222 echo -n "Bugs online users: "
223 colorize 34 "$(ls /tmp/bugs/sessions | wc -l)"
224 echo -n "SCN online users: "
225 colorize 34 "$(ls /tmp/tinycm/sessions | wc -l)" ;;
227 *)
228 usage ;;
230 esac && exit 0