slitaz-forge view pangolin/pangolin @ rev 685

pangolin: up utility to use tazcraft repo
author Christophe Lincoln <pankso@slitaz.org>
date Sun Mar 19 23:40:34 2017 +0100 (2017-03-19)
parents 896db259d19d
children beb069382492
line source
1 #!/bin/sh
2 #
3 # Pangolin admin utility
4 #
5 # Copyright (C) 2012-2017 SliTaz GNU/Linux - BSD License
6 # Authors : Christophe Lincoln <pankso@slitaz.org>
7 #
9 REPOS="/home/slitaz/repos"
10 WWW="/home/vhost"
11 WEBSITE="$WWW/www.slitaz.org/website"
12 PYTHON_LIB="/usr/lib/python2.7"
13 HGUSERS="/home/slitaz/auth/hgusers"
15 usage() {
16 cat << EOT
18 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 up-pizza Update Pizza web interface pizza.slitaz.me
26 up-play Update Gamers web interface play.slitaz.me
27 up-pangolin Update pangolin.slitaz.org virtual host
28 adduser Add a new user to Hg
29 stats Display some server stats
31 EOT
32 }
34 # While libtaz.sh is not installed on Pangolin
35 #
36 newline() {
37 echo ""
38 }
40 boldify() {
41 echo -e "\\033[1m$@\\033[0m"
42 }
44 separator() {
45 echo "================================================================================"
46 }
48 #
49 # handle commands
50 #
52 case "$1" in
54 up-www)
55 # Update website from repo.
56 newline
57 boldify "Updating: www.slitaz.org..."
58 cd ${WEBSITE} && hg pull -u
59 newline ;;
61 up-forum)
62 # Update forum.slitaz.org theme
63 newline
64 boldify "Updating: forum.slitaz.org..."
65 cd ${REPOS}/slitaz-forge && hg up
66 cp -a forum/my-templates ${WWW}/forum.slitaz.org/public_html
67 newline ;;
69 up-doc)
70 # Update doc.slitaz.org theme
71 newline
72 boldify "Updating: doc.slitaz.org..."
73 cd ${REPOS}/slitaz-forge && hg up
74 cp -a doc/* ${WWW}/doc.slitaz.org/public_html
75 chown www.www ${WWW}/doc.slitaz.org/public_html/conf
76 chown www.www ${WWW}/doc.slitaz.org/public_html/conf/local.php
77 newline ;;
79 up-hg)
80 # Update hg.slitaz.org template
81 newline
82 boldify "Updating Mercurial template..."
83 cd ${REPOS}/slitaz-dev-tools && hg update
84 cp -a slitaz-mercurial-style/* ${PYTHON_LIB}/site-packages/mercurial
85 chown -R root.root ${PYTHON_LIB}/site-packages/mercurial/templates
86 newline ;;
88 up-pizza)
89 # Update pizza.slitaz.me
90 newline
91 boldify "Updating Pizza builder..."
92 cd ${REPOS}/slitaz-pizza && hg update
93 cp /etc/slitaz/pizza.conf /etc/slitaz/pizza.conf.bak
94 make install; cd ..
95 cp -f /etc/slitaz/pizza.conf.bak /etc/slitaz/pizza.conf
96 pizza up-files
97 newline ;;
99 up-play)
100 # Update play.slitaz.me
101 newline
102 boldify "Updating play.slitaz.org..."
103 cd ${REPOS}/slitaz-forge && hg update
104 cp -rf play.slitaz.me/* ${WWW}/play.slitaz.me/public_html
105 # Tazcraft
106 cd ${REPOS}/tazcraft && hg update
107 rm -rf ${WWW}/play.slitaz.me/public_html/tazcraft
108 cp -rf tazcraft/web ${WWW}/play.slitaz.me/public_html/tazcraft
109 make install-server
110 newline ;;
112 up-pangolin)
113 # Update pangolin.slitaz.org and tools
114 newline
115 boldify "Updating tool: pangolin"
116 cd ${REPOS}/slitaz-forge/pangolin && hg up
117 make install
119 newline
120 boldify "Updating tool: slitaz-release"
121 cd ${REPOS}/slitaz-dev-tools/slitaz-release && hg up
122 make install
124 newline
125 boldify "Updating: pangolin.slitaz.org..."
126 cd ${REPOS}/slitaz-forge && hg up
127 cp -a pangolin/web/* ${WWW}/pangolin.slitaz.org/public_html
128 newline ;;
130 adduser)
131 [ ! "$2" ] && echo "Missing user name arg" && exit 0
132 [ ! "$3" ] && echo "Missing password arg" && exit 0
133 htpasswd -b ${HGUSERS} "$2" "$3" ;;
135 stats)
136 # Echo some stats.
137 newline
138 boldify "Memory usage"
139 separator
140 free -m | grep ^Mem
141 newline
142 boldify "Connected users"
143 separator
144 who
145 newline
146 boldify "HG users"
147 cat ${HGUSERS} | wc -l ;;
149 *)
150 usage ;;
151 esac
152 exit 0