slitaz-forge view tank/tank @ rev 300

tank: create also css symlink in cross
author Christophe Lincoln <pankso@slitaz.org>
date Sun May 13 00:29:00 2012 +0200 (2012-05-13)
parents 0b5e92c974ca
children d90ffa5f0434
line source
1 #!/bin/sh
2 #
3 # Tank - Admin Tank, backup, update and give stats.
4 #
5 # (C) 2012 SliTaz - GNU General Public License.
6 # Author: Christophe Lincoln <pankso@slitaz.org>
7 #
9 REPOS="/home/slitaz/repos"
10 WWW="/home/slitaz/www"
11 VHOST="$WWW/tank"
12 WEBSITE="$WWW/website"
13 BACKUPS="/home/backups"
14 LOGFILE="/var/log/tank.log"
16 usage() {
17 cat << EOT
19 Usage: $(basename $0) [command]
20 Commands:
21 backup|-b Backup files and MySQL DB
22 adduser Add user on Tank and create people files
23 up-stats Update Awstats statistics (run by cron)
25 up-tank Update http://tank.slitaz.org/
26 up-people Update http://people.slitaz.org/
27 up-pro Update http://pro.slitaz.org/
28 up-boot Update http://boot.slitaz.org/
29 up-cook Update http://cook.slitaz.org/
30 up-roadmap Update http://roadmap.slitaz.org/
32 EOT
33 }
35 case "$1" in
36 backup|-b)
37 # Backup config files and SQL db.
38 echo "TODO" ;;
39 up-tank)
40 # Update Tank web interface
41 echo -e "\nUpdating: tank.slitaz.org..."
42 cd $REPOS/slitaz-forge
43 [ "$2" == "--nohg" ] || hg pull -u
44 rm -rf $VHOST/*.* $VHOST/images
45 cp -a tank/web/* $VHOST
46 echo "" ;;
47 up-people)
48 # Update People web interface
49 echo -e "\nUpdating: people.slitaz.org..."
50 cd $REPOS/slitaz-forge
51 [ "$2" == "--nohg" ] || hg pull -u
52 rm -rf $WWW/people/*
53 cp -a people/* $WWW/people
54 echo "" ;;
55 up-pro)
56 # Update Pro website
57 echo -e "\nUpdating: pro.slitaz.org..."
58 cd $REPOS/slitaz-forge
59 [ "$2" == "--nohg" ] || hg pull -u
60 rm -rf $WWW/pro/web/*
61 cp -a pro/* $WWW/pro/web
62 echo "" ;;
63 up-boot)
64 # Update Web Boot interface
65 echo -e "\nUpdating: boot.slitaz.org..."
66 cd $REPOS/slitaz-forge
67 [ "$2" == "--nohg" ] || hg pull -u
68 rm -rf $WWW/boot/*
69 cp -a boot/* $WWW/boot
70 echo "" ;;
71 up-cook)
72 # Update Web Boot interface
73 echo -e "\nUpdating: cook.slitaz.org..."
74 cd $REPOS/cookutils
75 [ "$2" == "--nohg" ] || hg pull -u
76 cd $REPOS/slitaz-forge
77 [ "$2" == "--nohg" ] || hg pull -u
78 cp -a cook/* $WWW/cook
79 # We use symlinks for cooker's
80 cd $WWW/cook && rm -f style.css
81 ln -s $REPOS/cookutils/web/style.css .
82 cd $WWW/cook/cross && rm -f style.css
83 ln -s $REPOS/cookutils/web/style.css .
84 for web in stable undigest cross/arm
85 do
86 echo "Creating: $web symlinks"
87 cd $WWW/cook/$web
88 for file in style.css cooker.cgi cookiso.cgi
89 do
90 rm -f $file
91 ln -s $REPOS/cookutils/web/$file .
92 done
93 done
94 # No ISO's for undigest and ARM.
95 rm -f \
96 $WWW/cook/undigest/cookiso.cgi \
97 $WWW/cook/cross/arm/cookiso.cgi
98 echo "" ;;
99 up-roadmap)
100 # Update Roadmap Web interface
101 echo -e "\nUpdating: roadmap.slitaz.org..."
102 cd $REPOS/slitaz-forge
103 [ "$2" == "--nohg" ] || hg pull -u
104 cp -a roadmap/* $WWW/roadmap
105 echo "" ;;
106 up-stats)
107 echo -e "\nUpdating all awstats databases..." | tee -a $LOGFILE
108 date >> $LOGFILE
109 for vh in pro boot cook people tank
110 do
111 /var/www/cgi-bin/awstats.pl \
112 -config=$vh.slitaz.org -update 2>&1 | tee -a $LOGFILE
113 done && echo "" ;;
114 adduser)
115 echo ""
116 if [ -d /home/$user ]; then
117 echo -e "User $user already exists...\n" && exit 1
118 fi
119 if [ -n "$2" ]; then
120 user=$2
121 else
122 echo -n "User name: " && read user
123 fi
124 if [ -n "$3" ]; then
125 gecos="$3"
126 else
127 echo -n "Real name: " && read name
128 fi
129 if [ -n "$4" ]; then
130 pass=$4
131 else
132 echo -n "Password: " && read pass
133 fi
134 echo "Adding user: $user"
135 adduser -D -g "$gecos" $user -G users
136 echo $user:$pass | chpasswd --md5
137 addgroup $user slitaz
138 # HG access
139 #echo "$user:$pass" >> /etc/lighttpd/plain.passwd
140 # Public dir at http://people.slitaz.org/~$user/
141 sed -i s/'%user%'/"$user"/ /home/$user/Public/index.html
142 sed -i s/'%name%'/"$gecos"/ /home/$user/Public/profile.php
143 # Empty Shell profile
144 cat > /home/$user/.profile << EOF
145 # ~/.profile: Executed by Bourne-compatible login SHells.
146 #
147 EOF
148 #chown -R $user.$user /home/$user
149 echo -e "Done\n" ;;
150 *)
151 usage ;;
152 esac
153 exit 0