slitaz-forge view tank/taztank @ rev 47

taztank: Add profile.php as a file into /usr/share/taztank folder. The current method will not work since dollar sign versions in php are blank.
author Christopher Rogers <slaxemulator@gmail.com>
date Sun Apr 03 04:11:27 2011 +0000 (2011-04-03)
parents 444d36a84ce8
children 92ca357624a0
line source
1 #!/bin/sh
2 # Taztank - Admin Tank, backup, update and give stats.
3 #
4 # (C) 2011 SliTaz - GNU General Public License.
5 # Author: Christophe Lincoln <pankso@slitaz.org>
6 #
8 REPOS="/home/slitaz/repos"
9 WWW="/home/slitaz/www"
10 VHOST="$WWW/tank"
11 WEBSITE="$WWW/website"
12 BACKUPS="/home/backups"
14 usage() {
15 echo -e "\nUsage: `basename $0` [command]
16 Commands:
17 stats|-s Display some Tank stats
18 backup|-b Backup files and MySQL DB
19 chroot|-c Move a user into a new chroot location
20 up-www|-uw Update website http://www.slitaz.org/
21 up-tank|-ut Update http://tank.slitaz.org/
22 up-people|-up Update http://people.slitaz.org/
23 up-boot|-ub Update http://boot.slitaz.org/
24 up-stats|-us Update Awstats statistics (run by cron)
25 adduser|-au Add user on tank\n"
26 }
28 case "$1" in
29 stats|-s)
30 # Report some stats
31 clear
32 cat << EOF
34 Connected user
35 --------------
36 `who`
38 System usage
39 ------------
40 `df -h`
42 `free`
44 EOF
45 ;;
46 chroot|-c)
47 # Move a user into a new chroot location
48 if [ -s $2/bin/sh ] && grep -qs $3: /etc/password ; then
49 grep -q ^chroot /etc/busybox.conf ||
50 echo 'chroot = ssx root.root' >> /etc/busybox.conf
51 [ -s /bin/chrootsh ] || cat > /bin/chrootsh << EOF
52 #!/bin/sh
54 #case " \$@ " in
55 #*rsync*) exec /bin/sh "\$@" ;;
56 #esac
58 case "\$USER" in
59 pankso) exec /bin/sh "\$@" ;;
60 *) exec /usr/sbin/chroot $2 /bin/chrootsh "\$@" ;;
61 esac
62 EOF
63 [ -s $2/bin/chrootsh ] || cat > $2/bin/chrootsh << EOF
64 #!/bin/sh
66 export SHELL='/bin/sh'
67 cd \$HOME
68 . /etc/profile
69 exec /bin/sh "\$@"
70 EOF
71 chmod +x /bin/chrootsh $2/bin/chrootsh
72 base=$(awk -F: "/^$3:/ { print \$6 }" /etc/passwd)
73 target=$base
74 while [ -L $target ]; do
75 target=$(readlink $target)
76 done
77 mv $target $2/$base
78 [ -L $base ] && rm -f $base
79 ln -s $2/$base $base
80 if ! grep -q ^$3: $2/etc/passwd ; then
81 grep ^$3: /etc/passwd >> $2/etc/passwd
82 grep ^$3: /etc/shadow >> $2/etc/shadow fi
83 fi
84 else
85 cat << EOF
86 Usage: $0 $1 newchroot user
87 Move a user in a new chroot location
88 EOF
89 fi
90 ;;
91 backup|-b)
92 # Backup config files and SQL db.
93 echo "Not yet implemented..." ;;
94 update-www|-uw)
95 # Update website from repo.
96 echo -e "\nUpdating: www.slitaz.org..."
97 cd $WEBSITE && hg pull && hg update
98 echo "" ;;
99 up-tank|-ut)
100 # Update Tank web interface: http://tank.slitaz.org/
101 echo -e "\nUpdating: tank.slitaz.org..."
102 cd $REPOS/slitaz-forge
103 hg update
104 rm -rf $VHOST/*.* $VHOST/pics/website $VHOST/images
105 cp -a tank/web/* $VHOST
106 echo "" ;;
107 up-people|-up)
108 # Update People web interface: http://people.slitaz.org/
109 echo -e "\nUpdating: people.slitaz.org..."
110 cd $REPOS/slitaz-forge
111 hg update
112 rm -rf $WWW/people/*
113 cp -a people/* $WWW/people
114 echo "" ;;
115 up-boot|-ub)
116 # Update Web Boot interface: http://boot.slitaz.org/
117 echo -e "\nUpdating: boot.slitaz.org..."
118 cd $REPOS/slitaz-forge
119 hg update
120 rm -rf $WWW/boot/*
121 cp -a boot/* $WWW/boot
122 echo "" ;;
123 up-stats|-us)
124 echo -e "\nUpdating all awstats databases..."
125 for vh in www boot pkgs
126 do
127 /var/www/cgi-bin/awstats.pl -config=$vh.slitaz.org
128 done
129 echo "" ;;
130 adduser|-au)
131 # On Tank /etc/skel is empty to let taktank handle default user
132 # files.
133 echo ""
134 if [ -n "$2" ]; then
135 user=$2
136 else
137 echo -n "User name: " && read user
138 fi
139 if [ -d /home/$user ]; then
140 echo -e "User $user already exist...\n" && exit 1
141 fi
142 echo "Adding user: $user"
143 #adduser -s /bin/sh -g "SliTaz User" -G users -h /home/$user $user # for cooking
144 adduser $user
145 # HG access
146 echo -n "Hg password: " && read passwd
147 echo "$user:$passwd" >> /etc/lighttpd/plain.passwd
148 # README
149 echo -n "Creating default user files... "
150 cat > /home/$user/README << EOF
151 Welcome to Tank!
152 ================================================================================
154 Your Public directory URL is: http://people.slitaz.org/~$USER/
156 Please complet your public profile in ~/Public/profile.php and feel free
157 to use the service for your needs, if any thing goes wrong or is missing
158 please express your self :-)
160 EOF
161 # Public profile
162 mkdir -p /home/$user/Public
163 if [ -f /usr/share/taztank/profile.php ]; then
164 cp -a /usr/share/taztank/profile.php /home/$user/Public/profile.php
165 fi
166 # Shell profile
167 cat > /home/$user/.profile << EOF
168 # ~/.profile: Executed by Bourne-compatible login SHells.
169 #
170 EOF
171 echo -e "Done\n" ;;
172 *)
173 usage ;;
174 esac
175 exit 0