slitaz-forge view tank/tank @ rev 390

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