slitaz-forge view tank/tank @ rev 702

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