slitaz-forge view tank/tank @ rev 383

tank: add backports
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Dec 24 06:57:33 2013 +0000 (2013-12-24)
parents d90ffa5f0434
children b34ee9cca8a1
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 backports cross/arm cross/x86_64
85 do
86 echo "Linking: $web CSS/CGI files"
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 # header.html
94 echo "Linking: $web/header.html"
95 rm -f header.html
96 ln -s ../header.html .
97 done
99 # No ISO's for undigest and ARM.
100 rm -f \
101 $WWW/cook/undigest/cookiso.cgi \
102 $WWW/cook/cross/arm/cookiso.cgi
103 echo "" ;;
104 up-roadmap)
105 # Update Roadmap Web interface
106 echo -e "\nUpdating: roadmap.slitaz.org..."
107 cd $REPOS/slitaz-forge
108 [ "$2" == "--nohg" ] || hg pull -u
109 cp -a roadmap/* $WWW/roadmap
110 echo "" ;;
111 up-stats)
112 echo -e "\nUpdating all awstats databases..." | tee -a $LOGFILE
113 date >> $LOGFILE
114 for vh in pro boot cook people tank
115 do
116 /var/www/cgi-bin/awstats.pl \
117 -config=$vh.slitaz.org -update 2>&1 | tee -a $LOGFILE
118 done && echo "" ;;
119 adduser)
120 echo ""
121 if [ -d /home/$user ]; then
122 echo -e "User $user already exists...\n" && exit 1
123 fi
124 if [ -n "$2" ]; then
125 user=$2
126 else
127 echo -n "User name: " && read user
128 fi
129 if [ -n "$3" ]; then
130 gecos="$3"
131 else
132 echo -n "Real name: " && read name
133 fi
134 if [ -n "$4" ]; then
135 pass=$4
136 else
137 echo -n "Password: " && read pass
138 fi
139 echo "Adding user: $user"
140 adduser -D -g "$gecos" $user -G users
141 echo $user:$pass | chpasswd --md5
142 addgroup $user slitaz
143 # HG access
144 #echo "$user:$pass" >> /etc/lighttpd/plain.passwd
145 # Public dir at http://people.slitaz.org/~$user/
146 sed -i s/'%user%'/"$user"/ /home/$user/Public/index.html
147 sed -i s/'%name%'/"$gecos"/ /home/$user/Public/profile.php
148 # Empty Shell profile
149 cat > /home/$user/.profile << EOF
150 # ~/.profile: Executed by Bourne-compatible login SHells.
151 #
152 EOF
153 #chown -R $user.$user /home/$user
154 echo -e "Done\n" ;;
155 *)
156 usage ;;
157 esac
158 exit 0