slitaz-forge view pangolin/pangolin @ rev 423

pangolin: few fixes
author Christophe Lincoln <pankso@slitaz.org>
date Wed Jan 15 14:28:14 2014 +0100 (2014-01-15)
parents 0c2b437cde56
children 3f34b2640d12
line source
1 #!/bin/sh
2 #
3 # Pangolin admin utility
4 #
5 # Copyright (C) 2012-2014 SliTaz GNU/Linux - BSD License
6 #
7 # Authors : Christophe Lincoln <pankso@slitaz.org>
8 #
10 REPOS="/home/slitaz/repos"
11 WWW="/home/vhost"
12 WEBSITE="$WWW/www.slitaz.org/website"
13 PYTHON_LIB="/usr/lib/python2.7"
14 HGUSERS="/home/slitaz/auth/hgusers"
16 usage() {
17 cat << EOT
19 Usage: $(basename $0) [command]
20 Commands:
21 up-www Update website www.slitaz.org
22 up-forum Update forum.slitaz.org theme
23 up-doc Update doc.slitaz.org theme and configs
24 up-hg Update Hg web interface hg.slitaz.org
25 adduser Add a user to Hg.
26 stats Display some server stats.
27 backup Backup MySQL DB and files.
29 EOT
30 }
32 # While libtaz.sh is not installed on Pangolin
33 #
34 newline() {
35 echo ""
36 }
38 boldify() {
39 echo -e "\\033[1m$@\\033[0m"
40 }
42 separator() {
43 echo "================================================================================="
44 }
46 #
47 # handle commands
48 #
50 case "$1" in
51 up-www)
52 # Update website from repo.
53 newline
54 boldify "Updating: www.slitaz.org..."
55 cd ${WEBSITE} && hg pull -u
56 newline;;
57 up-forum)
58 # Update forum.slitaz.org theme
59 newline
60 boldify "Updating: forum.slitaz.org..."
61 cd ${REPOS}/slitaz-forge && hg up
62 cp -a forum/my-templates ${WWW}/forum.slitaz.org/public_html
63 newline ;;
64 up-doc)
65 # Update doc.slitaz.org theme
66 newline
67 boldify "Updating: doc.slitaz.org..."
68 cd ${REPOS}/slitaz-forge && hg up
69 cp -a doc/* ${WWW}/doc.slitaz.org/public_html
70 newline ;;
71 up-hg)
72 # Update hg.slitaz.org template.
73 newline
74 boldify "Updating Mercurial template..."
75 cd $REPOS/slitaz-dev-tools && hg update
76 cp -a slitaz-mercurial-style/* $PYTHON_LIB/site-packages/mercurial
77 chown -R root.root $PYTHON_LIB/site-packages/mercurial/templates
78 newline ;;
79 adduser)
80 [ ! "$2" ] && echo "Missing user name arg" && exit 0
81 [ ! "$3" ] && echo "Missing password arg" && exit 0
82 htpasswd -b $HGUSERS $2 $3 ;;
83 stats)
84 # Echo some stats.
85 newline
86 boldify "Disk usage"
87 separator
88 df -h | grep ^/dev
89 boldify "Memory usage"
90 separator
91 free -m | grep ^Mem
92 boldify "Connected users"
93 separator
94 who
95 newline ;;
96 backup)
97 echo "TODO: backup MySQL, SCN files, etc" ;;
98 *)
99 usage ;;
100 esac
101 exit 0