slitaz-forge view tank/tank @ rev 401

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