slitaz-forge view tank/tank @ rev 659

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