slitaz-modular view initramfs/usr/bin/local-mirror @ rev 171

initramfs: Update local-mirror script and lighttpd config files. Support new /lib/libtaz.sh script.
author Christopher Rogers <slaxemulator@gmail.com>
date Tue Apr 24 18:55:39 2012 +0000 (2012-04-24)
parents d1ce26b3493b
children b227f5995c89
line source
1 #!/bin/sh
3 source /usr/lib/slitaz/libtaz
4 source_lib commons
5 check_root
6 . /etc/slitaz/slitaz.conf
8 . /etc/local-mirror.conf
10 COMMAND="$1"
11 VERSION="0.1"
12 usage() {
13 echo "$0 $VERSION"
14 echo "$0 [on|off|update-repos|tank-only|mirror-only]"
15 echo "$0 [backup-mirror|up-src-links]"
16 exit 1
17 }
19 #[ -d /mnt/live/memory/mirror/packages ] && PKGDIR="/mnt/live/memory/mirror/packages"
20 #[ -d /mnt/live/memory/mirror/src ] && SRCDIR="/mnt/live/memory/mirror/src"
21 sync_mirror=$(find /mnt/live -maxdepth 3 -name "mirror" -type d | head -1)
23 COOKORDER="$(find /mnt/live/mnt/* -maxdepth 1 -name "cookorder.list")"
24 CUR_PWD="$PWD"
25 version="$SLITAZ_RELEASE"
27 [ -d $SLITAZ_HOME/$version ] || mkdir -p $SLITAZ_HOME/$version
28 [ -d $SLITAZ_HOME/repos ] || ln -sf $REPOS_DIR $SLITAZ_HOME/repos
29 [ -d $SLITAZ_HOME/repos ] && REPOS_DIR="$SLITAZ_HOME/repos"
30 PYTHON_LIB="/usr/lib/python2.7"
32 if [ -d $PKGDIR ]; then
33 [ -d $SLITAZ_HOME/$version/packages ] || ln -sf $PKGDIR $SLITAZ_HOME/$version/packages
34 [ -d $SLITAZ_HOME/packages ] || ln -sf $PKGDIR $SLITAZ_HOME/packages
35 fi
36 if [ -d $SRCDIR ]; then
37 [ -d $SLITAZ_HOME/$version/src ] || ln -sf $SRCDIR $SLITAZ_HOME/$version/src
38 [ -d $SLITAZ_HOME/src ] || ln -sf $SRCDIR $SLITAZ_HOME/src
39 fi
41 #repos folders for website
42 PEOPLE_WWW_DIR="$REPOS_DIR/slitaz-forge/people"
43 MIRROR_WWW_DIR="$REPOS_DIR/slitaz-forge/mirror/root"
44 MIRROR_INFO_WWW_DIR="$REPOS_DIR/slitaz-forge/mirror/info"
45 PKGS_WWW_DIR="$REPOS_DIR/slitaz-forge/pkgs"
46 DOC_WWW_DIR="$REPOS_DIR/slitaz-forge/doc"
47 PIZZA_WWW_DIR="$REPOS_DIR/slitaz-pizza/php"
48 BOOT_WWW_DIR="$REPOS_DIR/slitaz-forge/boot"
49 TANK_WWW_DIR="$REPOS_DIR/slitaz-forge/tank/web"
50 USBKEY_WWW_DIR="$REPOS_DIR/slitaz-forge/usbkey"
51 ROADMAP_WWW_DIR="$REPOS_DIR/slitaz-forge/roadmap"
52 PRO_WWW_DIR="$REPOS_DIR/slitaz-forge/pro"
54 if [ "$COMMAND" = "tank-only" ]; then
55 WWW="${WWW/mirror/}"
56 ADDRESS="${ADDRESS/mirror.slitaz.org/}"
57 VHOST_FILE="$VHOST_TANK_FILE"
58 fi
60 if [ "$COMMAND" = "mirror-only" ]; then
61 WWW="${WWW/tank/}"
62 ADDRESS="mirror.slitaz.org"
63 VHOST_FILE="$VHOST_MIRROR_FILE"
64 fi
66 if [ ! -d $PKGDIR ]; then
67 WWW="${WWW/pkg/}"
68 ADDRESS="${ADDRESS/pkg.slitaz.org}"
69 fi
70 [ -d $REPOS_DIR ] || continue
72 INCOMING_REPOSITORY="$COOKING/packages-incoming"
73 INCOMING="$SLITAZ_HOME/$version/incoming"
74 CRON_FILE="/var/spool/cron/crontabs/root"
76 www() {
77 b=$1
78 [ -d $(dirname $CRON_FILE) ] || mkdir -p $(dirname $CRON_FILE)
79 [ -f $CRON_FILE ] || touch $CRON_FILE
80 [ -d $MAIN_WWW_DIR ] || mkdir -p $MAIN_WWW_DIR
81 [ -L /var/www/vhosts ] || ln -sf $MAIN_WWW_DIR /var/www/vhosts
83 if [ -d $REPOS_DIR/wok-tank ]; then
84 REPO_WOK=$REPOS_DIR/wok-tank
85 if [ -x /usr/bin/hg ]; then
86 cd $REPO_WOK
87 if [ ! "$(hg branch)" = "cooking" ]; then
88 hg update cooking
89 fi
90 cd $CUR_PWD
91 fi
92 elif [ -d $REPOS_DIR/wok ]; then
93 REPO_WOK=$REPOS_DIR/wok
94 fi
95 [ -d $STABLE ] || mkdir -p $STABLE
96 [ -d $COOKING ] || mkdir -p $COOKING
97 [ -d $MAIN_WWW_DIR/pics/rrd ] || mkdir -p $MAIN_WWW_DIR/pics/rrd
99 case "$b" in
100 website)
101 #cd $REPOS_DIR/$b
102 #hg update testing
103 #cd $CUR_DIR
104 [ -d $REPOS_DIR/$b ] && ln -s $REPOS_DIR/$b $MAIN_WWW_DIR
105 if [ -f $MAIN_WWW_DIR/$b/libs/get-feeds.sh ]; then
106 if [ ! $(grep -l "$MAIN_WWW_DIR/$b/libs/get-feeds.sh" $CRON_FILE) ]; then
107 echo "#Update SliTaz stuff" >> $CRON_FILE
108 echo "*/20 * * * * $MAIN_WWW_DIR/$b/libs/get-feeds.sh" >> $CRON_FILE
109 fi
110 fi
111 ;;
112 people)
113 [ -d $PEOPLE_WWW_DIR ] && ln -s $PEOPLE_WWW_DIR $MAIN_WWW_DIR/people
114 ;;
115 doc)
116 [ -d $DOC_WWW_DIR ] && cp -a $DOC_WWW_DIR $MAIN_WWW_DIR/doc
117 [ -d /var/www/dokuwiki ] && cp -a /var/www/dokuwiki/* $MAIN_WWW_DIR/doc
118 VAR="index attic meta media pages"
119 for i in $VAR; do
120 [ -d $REPOS_DIR/slitaz-doc-wiki-data ] && cp -a $REPOS_DIR/slitaz-doc-wiki-data/$i $MAIN_WWW_DIR/doc/data
121 done
122 #[ -d $REPOS_DIR/slitaz-doc-wiki-data/plugins ] && cp -a $REPOS_DIR/slitaz-doc-wiki-data/plugins $MAIN_WWW_DIR/doc/lib
123 chown root.root -R $MAIN_WWW_DIR/doc
124 chmod 777 -R $MAIN_WWW_DIR/doc
125 ;;
126 bugs)
127 [ -d $SLITAZ_HOME/bugs ] || mkdir -p $SLITAZ_HOME/bugs
128 [ -d $MAIN_WWW_DIR/bugs ] || mkdir -p $MAIN_WWW_DIR/bugs
129 [ -d $REPOS_DIR/slitaz-forge/bugs ] && cp -a $REPOS_DIR/slitaz-forge/bugs/roundup.wsgi $SLITAZ_HOME/bugs/roundup.wsgi
130 [ -d $REPOS_DIR/slitaz-forge/bugs ] && cp -a $REPOS_DIR/slitaz-forge/bugs/server.ini $SLITAZ_HOME/bugs/server.ini
131 [ -d $REPOS_DIR/slitaz-forge/bugs/templates/slitaz ] && cp -a $REPOS_DIR/slitaz-forge/bugs/templates/slitaz/* $SLITAZ_HOME/bugs
132 [ -f /usr/share/roundup/cgi-bin/roundup.cgi ] && ln -sf /usr/share/roundup/cgi-bin/roundup.cgi $MAIN_WWW_DIR/bugs/roundup.cgi
133 ;;
134 pizza)
135 [ -d $PIZZA_WWW_DIR ] && ln -sf $PIZZA_WWW_DIR $MAIN_WWW_DIR/pizza
136 ;;
137 bb)
138 [ -d /usr/share/slitaz/web-bb ] && cp -a /usr/share/slitaz/web-bb $MAIN_WWW_DIR/bb
139 #[ -d /usr/share/slitaz/web ] && cp -a /usr/share/slitaz/web $MAIN_WWW_DIR/bb/web
140 [ -d $REPOS_DIR/website/images ] && ln -sf $REPOS_DIR/website/images $MAIN_WWW_DIR/bb/images
141 [ -d $INCOMING_REPOSITORY ] || mkdir -p $INCOMING_REPOSITORY
142 [ -f $INCOMING_REPOSITORY/packages.desc ] || touch $INCOMING_REPOSITORY/packages.desc
143 [ -f $INCOMING_REPOSITORY/packages.equiv ] || touch $INCOMING_REPOSITORY/packages.equiv
144 [ -f $INCOMING_REPOSITORY/packages.list ] || touch $INCOMING_REPOSITORY/packages.list
145 [ -f $INCOMING_REPOSITORY/packages.md5 ] || touch $INCOMING_REPOSITORY/packages.md5
146 [ -f $INCOMING_REPOSITORY/packages.txt ] || touch $INCOMING_REPOSITORY/packages.txt
147 [ -d $PKGDIR ] && ln -sf $PKGDIR $COOKING/packages
148 [ -d $SRCDIR ] && ln -sf $SRCDIR $COOKING/src
149 if [ "$CUSTOM_WOK" = "yes" ]; then
150 tazwok gen-wok-db --WOK=$REPO_WOK
151 if [ -f $COOKORDER ]; then
152 [ -d $COOKING/wok ] || mkdir -p $COOKING/wok
153 [ -d $COOKING/clean-wok ] || mkdir -p $COOKING/clean-wok
154 cat $COOKORDER | while read pkg; do
155 rwanted=$(grep $'\t'$pkg$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1)
156 for i in $rwanted; do
157 [ -f $COOKING/clean-wok/$i/receipt ] || cp -a $REPO_WOK/$i $COOKING/clean-wok/$i
158 [ -f $COOKING/wok/$i/receipt ] || cp -a $REPO_WOK/$i $COOKING/wok/$i
159 done
160 [ -f $COOKING/clean-wok/$pkg/receipt ] || cp -a $REPO_WOK/$pkg $COOKING/clean-wok/$pkg
161 [ -f $COOKING/wok/$pkg/receipt ] || cp -a $REPO_WOK/$pkg $COOKING/wok/$pkg
162 done
163 unset i
164 tazwok gen-wok-db --WOK=$COOKING/clean-wok
165 fi
166 else
167 [ -d $COOKING/clean-wok ] || ln -sf $REPO_WOK $COOKING/clean-wok
168 [ -d $COOKING/wok ] || ln -sf $REPO_WOK $COOKING/wok
169 fi
170 [ -d $STABLE/clean-wok ] || ln -sf $REPOS_DIR/wok-stable $STABLE/clean-wok
171 [ -d $STABLE/wok ] || ln -sf $REPOS_DIR/wok-stable $STABLE/wok
172 [ -f $SRCDIR/sources.list ] || tazwok gen-src $SRCDIR --WOK=$REPO_WOK
173 [ -d $REPOS_DIR/slitaz-modular ] && ln -sf $REPOS_DIR/slitaz-modular $COOKING/slitaz-modular
174 echo -e "$MAIN_WWW_DIR/bb" | tazwok webserver on
175 ;;
176 cook)
177 #pwd=$(pwd)
178 #if [ -d $REPOS_DIR/my-cookutils ]; then
179 # cd $REPOS_DIR/my-cookutils
180 # if [ "$(hg branch)" != "testing" ]; then
181 # hg update testing
182 # fi
183 # make install
184 # cd $pwd
185 #fi
186 echo "$SLITAZ_HOME/$version/packages" > $LOCALSTATE/mirror
187 [ -d $LOCALSTATE/undigest/incoming ] || mkdir -p $LOCALSTATE/undigest/incoming
188 [ -f $LOCALSTATE/undigest/incoming/mirror ] || echo "$INCOMING" > $LOCALSTATE/undigest/incoming/mirror
189 echo "incoming" > $LOCALSTATE/priority
190 [ -d $SLITAZ_HOME/$version/incoming ] || mkdir -p $SLITAZ_HOME/$version/incoming
191 [ -d /var/www/cooker ] && cp -a /var/www/cooker $MAIN_WWW_DIR/$b
192 [ -f /usr/share/$b/header.html ] && cp -a /usr/share/$b/header.html $MAIN_WWW_DIR/$b/header.html
193 [ -f /etc/slitaz/$b.conf ] && cp -a /etc/slitaz/$b.conf $MAIN_WWW_DIR/$b/$b.conf
194 if [ "$MKCHROOT" = "yes" ]; then
195 if [ -d $PKGDIR ]; then
196 tazpkg recharge
197 tazdev gen-chroot $version
198 [ -d $SLITAZ_HOME/$version/chroot ] && mkdir -p $SLITAZ_HOME/$version/chroot$(dirname $CRON_FILE)
199 [ -d $SLITAZ_HOME/$version/chroot ] && echo "0 */2 * * * /usr/bin/cooker" > $SLITAZ_HOME/$version/chroot${CRON_FILE}
200 [ -d $SLITAZ_HOME/$version/chroot ] && echo "$SLITAZ_HOME/$version/packages" > $SLITAZ_HOME/$version/chroot${LOCALSTATE}/mirror
201 mkdir -p $SLITAZ_HOME/$version/chroot${LOCALSTATE}/undigest/incoming
202 echo "$SLITAZ_HOME/$version/incoming" > $SLITAZ_HOME/$version/chroot${LOCALSTATE}/undigest/incoming/mirror
203 fi
204 fi
205 [ -d $REPOS_DIR/wok-tank ] && ln -sf $REPOS_DIR/wok-tank $SLITAZ_HOME/$version/wok-hg
206 #[ -d $REPOS_DIR/wok-tank ] && ln -sf $REPOS_DIR/wok-tank $SLITAZ_HOME/$version/wok
207 [ -d $MAIN_WWW_DIR/$b/packages ] || ln -sf $SLITAZ_HOME/$version/packages $MAIN_WWW_DIR/$b/packages
208 [ -d $MAIN_WWW_DIR/$b/incoming ] || ln -sf $SLITAZ_HOME/$version/incoming $MAIN_WWW_DIR/$b/incoming
209 ;;
210 try)
211 [ -d $MAIN_WWW_DIR/tinycm ] || ln -sf $REPOS_DIR/tinycm $MAIN_WWW_DIR/tinycm ;;
212 pkgs)
213 pwd=$(pwd)
214 if [ -d $PKGS_WWW_DIR ]; then
215 cd $PKGS_WWW_DIR
216 make install-msg
217 cd $pwd
218 fi
219 [ -d $MAIN_WWW_DIR/pkgs ] || ln -sf $PKGS_WWW_DIR $MAIN_WWW_DIR/pkgs
220 [ -d $REPOS_DIR/flavors ] && ln -sf $REPOS_DIR/flavors $COOKING/flavors
221 ;;
222 usbkey)
223 [ -d $USBKEY_WWW_DIR ] && ln -sf $USBKEY_WWW_DIR $MAIN_WWW_DIR/usbkey ;;
224 pro)
225 [ -d $PRO_WWW_DIR ] && ln -sf $PRO_WWW_DIR $MAIN_WWW_DIR/pro ;;
226 roadmap)
227 [ -d $ROADMAP_WWW_DIR ] && ln -sf $ROADMAP_WWW_DIR $MAIN_WWW_DIR/roadmap ;;
228 mirror)
229 [ -d $MIRROR_INFO_WWW_DIR ] && cp -a $MIRROR_INFO_WWW_DIR $MAIN_WWW_DIR/mirror-info
230 [ -d $MIRROR_WWW_DIR ] && cp -a $MIRROR_WWW_DIR $MAIN_WWW_DIR/mirror
231 [ -d $MAIN_WWW_DIR/mirror/packages ] || mkdir -p $MAIN_WWW_DIR/mirror/packages
232 [ -d $PKGDIR ] && ln -sf $PKGDIR $MAIN_WWW_DIR/mirror/packages/$version
233 [ -d /var/www/slitaz ] || mkdir -p /var/www/slitaz
234 [ -d /var/www/slitaz/mirror ] || ln -sf $MAIN_WWW_DIR/mirror /var/www/slitaz/mirror
235 [ -d /var/www/mirror ] || ln -sf $MAIN_WWW_DIR/mirror /var/www/mirror
236 [ -d /var/www/mirror-info ] || ln -sf $MAIN_WWW_DIR/mirror-info /var/www/mirror-info
237 [ -d $MAIN_WWW_DIR/mirror-info/pics ] || mkdir -p $MAIN_WWW_DIR/mirror-info/pics
238 [ -d $MAIN_WWW_DIR/mirror-info/pics/rrd ] || ln -sf $MAIN_WWW_DIR/pics/rrd $MAIN_WWW_DIR/mirror-info/pics/rrd
239 [ -f $REPOS_DIR/slitaz-forge/mirror/files/etc/rsyncd.conf ] && cp -a $REPOS_DIR/slitaz-forge/mirror/files/etc/rsyncd.conf /etc/rsyncd.conf
240 [ -f $REPOS_DIR/slitaz-forge/mirror/files/etc/rsyncd.motd ] && cp -a $REPOS_DIR/slitaz-forge/mirror/files/etc/rsyncd.motd /etc/rsyncd.motd
241 [ -f $REPOS_DIR/slitaz-forge/mirror/files/usr/bin/chkfilelist ] && cp -a $REPOS_DIR/slitaz-forge/mirror/files/usr/bin/chkfilelist /usr/bin/chkfilelist
242 if [ -f /usr/bin/makegraphs ]; then
243 [ -f $MAIN_WWW_DIR/pics/makegraphs ] || cp -a /usr/bin/makegraphs $MAIN_WWW_DIR/pics/makegraphs
244 if [ ! $(grep -l "$MAIN_WWW_DIR/pics/makegraphs" $CRON_FILE) ]; then
245 echo "# Update system load graphics" >> $CRON_FILE
246 echo "*/5 * * * * $MAIN_WWW_DIR/pics/makegraphs" >> $CRON_FILE
247 fi
248 fi
249 ;;
250 boot)
251 [ -d $BOOT_WWW_DIR ] && cp -a $BOOT_WWW_DIR $MAIN_WWW_DIR/$b
252 #[ -d $REPOS_DIR/website/pics ] && ln -sf $REPOS_DIR/website/images $MAIN_WWW_DIR/$b/images
253 ;;
254 tank)
255 [ -d $TANK_WWW_DIR ] && cp -a $TANK_WWW_DIR $MAIN_WWW_DIR/$b
256 [ -f /usr/share/awstats/extras/update ] && ln -sf /usr/share/awstats/extras/update /usr/sbin/awsupdate_all
257 [ -d $REPOS_DIR/slitaz-forge/$b/files/etc/awstats ] && cp -a $REPOS_DIR/slitaz-forge/$b/files/etc/awstats/* /etc/awstats
258 for i in $ADDRESS; do
259 if [ -f /etc/awstats/awstats.$i.conf ]; then
260 dirlog=$(grep ^DirData= /etc/awstats/awstats.$i.conf | cut -d "=" -f2 | sed -e 's/"//g')
261 mkdir -p $dirlog
262 fi
263 done
264 [ -d $MAIN_WWW_DIR/$b/images ] || mkdir -p $MAIN_WWW_DIR/$b/images
265 [ -d $MAIN_WWW_DIR/$b/graphs/rrd ] || ln -sf $MAIN_WWW_DIR/graphs/rrd $MAIN_WWW_DIR/$b/images/rrd
266 if [ -f /usr/share/awstats/extras/update ]; then
267 if [ ! $(grep -l "/usr/share/awstats/extras/update" $CRON_FILE) ]; then
268 echo "# Update Web stats" >> $CRON_FILE
269 echo "*/5 * * * * /usr/share/awstats/extras/update" >> $CRON_FILE
270 fi
271 fi
272 if [ -f /usr/bin/makegraphs ]; then
273 [ -f $MAIN_WWW_DIR/pics/makegraphs ] || cp -a /usr/bin/makegraphs $MAIN_WWW_DIR/pics/makegraphs
274 if [ ! $(grep -l "$MAIN_WWW_DIR/pics/makegraphs" $CRON_FILE) ]; then
275 echo "# Update system load graphics" >> $CRON_FILE
276 echo "*/5 * * * * $MAIN_WWW_DIR/pics/makegraphs" >> $CRON_FILE
277 fi
278 fi
279 ;;
280 hg)
281 [ -d $MAIN_WWW_DIR/hg ] || mkdir -p $MAIN_WWW_DIR/hg
282 [ -d $REPOS_DIR/slitaz-dev-tools/slitaz-mercurial-style ] && cp -a $REPOS_DIR/slitaz-dev-tools/slitaz-mercurial-style/* $PYTHON_LIB/site-packages/mercurial
283 [ -f /usr/share/examples/mercurial/hgwebdir.cgi ] && cp -a /usr/share/examples/mercurial/hgwebdir.cgi $MAIN_WWW_DIR/hg
284 [ -f /usr/share/examples/mercurial/hgwebdir.cgi ] && cp -a /usr/share/examples/mercurial/hgwebdir.cgi $MAIN_WWW_DIR/hg/hgwebdir.py
285 [ -f $REPOS_DIR/slitaz-forge/tank/files/etc/mercurial/hgweb.config ] && cp -a $REPOS_DIR/slitaz-forge/tank/files/etc/mercurial/hgweb.config /etc/mercurial
286 [ -f $REPOS_DIR/slitaz-forge/tank/files/etc/mercurial/hgweb.config-mirror ] && cp -a $REPOS_DIR/slitaz-forge/tank/files/etc/mercurial/hgweb.config-mirror /etc/mercurial
287 sed -i 's|/etc/mercurial/hgweb.config|/etc/mercurial/hgweb.config-mirror|g' $MAIN_WWW_DIR/hg/hgwebdir.py
288 #[ -f /etc/mercurial/hgweb.conf ] && sed -i 's|style = slitaz|style = gitweb|g' /etc/mercurial/hgweb.config
289 ;;
290 lfs)
291 #[ -d $MAIN_WWW_DIR/lfs ] || ln -sf /usr/share/doc/lfs-book $MAIN_WWW_DIR/lfs ;;
292 fake-website /usr/share/doc/lfs-book lfs.slitaz.org ;;
293 hgbook)
294 #if [ -d /usr/share/hgbook ]; then
295 # [ -d $MAIN_WWW_DIR/hgbook ] || ln -sf /usr/share/hgbook $MAIN_WWW_DIR/hgbook
296 #fi ;;
297 fake-website /usr/share/hgbook hgbook.slitaz.org ;;
298 absguide)
299 #if [ -d /usr/share/absguide ]; then
300 # [ -d $MAIN_WWW_DIR/absguide ] || ln -sf /usr/share/absguide $MAIN_WWW_DIR/absguide
301 #fi ;;
302 fake-website /usr/share/absguide absguide.slitaz.org ;;
303 man-html)
304 #if [ -d /usr/share/man-html ]; then
305 # [ -d $MAIN_WWW_DIR/man-html ] || ln -sf /usr/share/man-html $MAIN_WWW_DIR/man-html
306 #fi ;;
307 fake-website /usr/share/man-html man-html.slitaz.org ;;
308 gimp.en)
309 #if [ -d /usr/share/gimp/2.0/help/en ]; then
310 # [ -d $MAIN_WWW_DIR/gimp_en ] || ln -sf /usr/share/gimp/2.0/help/en $MAIN_WWW_DIR/gimp_en
311 #fi ;;
312 fake-website /usr/share/gimp/2.0/help/en gimp.en.slitaz.org ;;
313 gimp.fr)
314 #if [ -d /usr/share/gimp/2.0/help/fr ]; then
315 # [ -d $MAIN_WWW_DIR/gimp_fr ] || ln -sf /usr/share/gimp/2.0/help/fr $MAIN_WWW_DIR/gimp_fr
316 #fi ;;
317 fake-website /usr/share/gimp/2.0/help/fr gimp.fr.slitaz.org ;;
318 gimp.es)
319 #if [ -d /usr/share/gimp/2.0/help/es ]; then
320 # [ -d $MAIN_WWW_DIR/gimp_es ] || ln -sf /usr/share/gimp/2.0/help/es $MAIN_WWW_DIR/gimp_es
321 #fi ;;
322 fake-website /usr/share/gimp/2.0/help/es gimp.es.slitaz.org ;;
323 piratebox)
324 cd $REPOS_DIR/piratebox
325 hg update lighttpd
326 cd $CUR_PWD
327 if [ -d $REPOS_DIR/piratebox/piratebox/www ]; then
328 cp -a $REPOS_DIR/piratebox/piratebox/www $MAIN_WWW_DIR/piratebox
329 fi
330 if [ -f $MAIN_WWW_DIR/piratebox/cgi-bin/data.pso ]; then
331 chmod -R 777 $MAIN_WWW_DIR/piratebox/cgi-bin/data.pso
332 fi
333 if [ ! -d $MAIN_WWW_DIR/piratebox/share ]; then
334 mkdir -p $MAIN_WWW_DIR/piratebox/share
335 chmod -R 777 $MAIN_WWW_DIR/piratebox/share
336 fi
337 echo "<date>00:00:00</date>&nbsp;&nbsp;<name>PirateBox:</name>&nbsp;&nbsp;&nbsp;<data class='def'>Chat and share files anonymously!</data><br>" > $MAIN_WWW_DIR/piratebox/cgi-bin/data.pso
338 ;;
339 linuxgazette)
340 #if [ -d /repos/linuxgazette ]; then
341 # [ -d $MAIN_WWW_DIR/linuxgazette ] || ln -sf /repos/linuxgazette $MAIN_WWW_DIR/linuxgazette
342 #fi ;;
343 fake-website /repos/linuxgazette linuxgazette.net ;;
344 esac
345 }
347 repos() {
348 for repo in $REPOS; do
349 [ -d $REPOS_DIR/$repo ] || continue
350 if [ -d $REPOS_DIR/$repo/.hg ]; then
351 mkdir -p $REPOS_WEB_DIR/$repo
352 [ -d $REPOS_WEB_DIR/$repo/.hg ] || ln -s $REPOS_DIR/$repo/.hg $REPOS_WEB_DIR/$repo/.hg
353 if [ ! $(grep -l "$REPOS_WEB_DIR" /etc/mercurial/hgweb.config) ]; then
354 [ -f /etc/mercurial/hgweb.config ] && sed -i "s|$REPOS_DIR|$REPOS_WEB_DIR|g" /etc/mercurial/hgweb.config
355 fi
356 fi
357 if [ ! -f $REPOS_DIR/$repo/.hg/hgrc-web ]; then
358 touch $REPOS_DIR/$repo/.hg/hgrc-web
359 cat "$REPOS_DIR/$repo/.hg/hgrc" >> $REPOS_DIR/$repo/.hg/hgrc-web
360 echo "[web]" >> $REPOS_DIR/$repo/.hg/hgrc-web
361 #[ -d $REPOS_DIR/$repo/.hg ] && echo "style = slitaz" >> $REPOS_DIR/$repo/.hg/hgrc-web
362 echo "staticurl = http://hg.slitaz.org/static/" >> $REPOS_DIR/$repo/.hg/hgrc-web
363 echo "push_ssl = false" >> $REPOS_DIR/$repo/.hg/hgrc-web
364 echo "allow_push = *" >> $REPOS_DIR/$repo/.hg/hgrc-web
365 #[ ! -f $REPOS_DIR/$repo/.hg/hgrc-pull ] && mv $REPOS_DIR/$repo/.hg/hgrc $REPOS_DIR/$repo/.hg/hgrc-pull
366 cp -a $REPOS_DIR/$repo/.hg/hgrc-web $REPOS_DIR/$repo/.hg/hgrc
367 fi
369 if [ ! $(grep -l 'name = ' $REPOS_DIR/$repo/.hg/hgrc ) ]; then
370 echo "name = $repo" >> $REPOS_DIR/$repo/.hg/hgrc
371 fi
373 if [ ! $(grep -l 'contact = ' $REPOS_DIR/$repo/.hg/hgrc ) ]; then
374 [ "$repo" = "cookutils" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
375 [ "$repo" = "my-cookutils" ] && echo "contact = Christopher Rogers" >> $REPOS_DIR/$repo/.hg/hgrc
376 [ "$repo" = "flavors" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
377 [ "$repo" = "flavors-stable" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
378 [ "$repo" = "slitaz-base-files" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
379 [ "$repo" = "slitaz-boot-scripts" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
380 [ "$repo" = "slitaz-configs" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
381 [ "$repo" = "slitaz-dev-tools" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
382 [ "$repo" = "slitaz-doc" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
383 [ "$repo" = "slitaz-doc-wiki-data" ] && echo "contact = Christopher Rogers" >> $REPOS_DIR/$repo/.hg/hgrc
384 [ "$repo" = "slitaz-forge" ] && echo "contact = Eric Joseph-Alexandre" >> $REPOS_DIR/$repo/.hg/hgrc
385 [ "$repo" = "slitaz-modular" ] && echo "contact = Christopher Rogers" >> $REPOS_DIR/$repo/.hg/hgrc
386 [ "$repo" = "slitaz-pizza" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
387 [ "$repo" = "slitaz-tools" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
388 [ "$repo" = "slitaz-vz" ] && echo "contact = Eric Joseph-Alexandre" >> $REPOS_DIR/$repo/.hg/hgrc
389 [ "$repo" = "ssfs" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
390 [ "$repo" = "tazlito" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
391 [ "$repo" = "tazpanel" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
392 [ "$repo" = "tazpkg" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
393 [ "$repo" = "tazusb" ] && echo "contact = Eric Joseph-Alexandre" >> $REPOS_DIR/$repo/.hg/hgrc
394 [ "$repo" = "tazwok" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
395 [ "$repo" = "website" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
396 [ "$repo" = "wok" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
397 [ "$repo" = "wok-stable" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
398 [ "$repo" = "wok-tank" ] && echo "contact = Christopher Rogers" >> $REPOS_DIR/$repo/.hg/hgrc
399 [ "$repo" = "wok-tiny" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
400 [ "$repo" = "wok-undigest" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
401 fi
403 if [ ! $(grep -l 'description = ' $REPOS_DIR/$repo/.hg/hgrc) ]; then
404 [ "$repo" = "cookutils" ] && echo "description = Utils to cook SliTaz packages" >> $REPOS_DIR/$repo/.hg/hgrc
405 [ "$repo" = "my-cookutils" ] && echo "description = More powerful version of cookutils" >> $REPOS_DIR/$repo/.hg/hgrc
406 [ "$repo" = "flavors" ] && echo "description = SliTaz Cooking flavors" >> $REPOS_DIR/$repo/.hg/hgrc
407 [ "$repo" = "flavors-stable" ] && echo "description = SliTaz Stable flavors" >> $REPOS_DIR/$repo/.hg/hgrc
408 [ "$repo" = "slitaz-base-files" ] && echo "description = SliTaz base files" >> $REPOS_DIR/$repo/.hg/hgrc
409 [ "$repo" = "slitaz-boot-scripts" ] && echo "description = SliTaz boot scripts" >> $REPOS_DIR/$repo/.hg/hgrc
410 [ "$repo" = "slitaz-configs" ] && echo "description = SliTaz configuration files" >> $REPOS_DIR/$repo/.hg/hgrc
411 [ "$repo" = "slitaz-dev-tools" ] && echo "description = SliTaz Developers Tools" >> $REPOS_DIR/$repo/.hg/hgrc
412 [ "$repo" = "slitaz-doc" ] && echo "description = SliTaz system doc" >> $REPOS_DIR/$repo/.hg/hgrc
413 [ "$repo" = "slitaz-doc-wiki-data" ] && echo "description = SliTaz documentation wiki content" >> $REPOS_DIR/$repo/.hg/hgrc
414 [ "$repo" = "slitaz-forge" ] && echo "description = SliTaz Forge Config" >> $REPOS_DIR/$repo/.hg/hgrc
415 [ "$repo" = "slitaz-modular" ] && echo "description = Scripts to make SliTaz Modular" >> $REPOS_DIR/$repo/.hg/hgrc
416 [ "$repo" = "slitaz-pizza" ] && echo "description = SliTaz Online flavor builder" >> $REPOS_DIR/$repo/.hg/hgrc
417 [ "$repo" = "slitaz-tools" ] && echo "description = SliTaz Tools and Tinyutils" >> $REPOS_DIR/$repo/.hg/hgrc
418 [ "$repo" = "slitaz-vz" ] && echo "description = SliTaz OpenVZ integration" >> $REPOS_DIR/$repo/.hg/hgrc
419 [ "$repo" = "ssfs" ] && echo "description = SliTaz Secure File Storage" >> $REPOS_DIR/$repo/.hg/hgrc
420 [ "$repo" = "tazlito" ] && echo "description = SliTaz Live Tool" >> $REPOS_DIR/$repo/.hg/hgrc
421 [ "$repo" = "tazpanel" ] && echo "description = Slitaz Administration Panel" >> $REPOS_DIR/$repo/.hg/hgrc
422 [ "$repo" = "tazpkg" ] && echo "description = SliTaz Packages manager" >> $REPOS_DIR/$repo/.hg/hgrc
423 [ "$repo" = "tazusb" ] && echo "description = SliTaz LiveUSB utility" >> $REPOS_DIR/$repo/.hg/hgrc
424 [ "$repo" = "tazwok" ] && echo "description = SliTaz Packages builder" >> $REPOS_DIR/$repo/.hg/hgrc
425 [ "$repo" = "website" ] && echo "description = SliTaz Website" >> $REPOS_DIR/$repo/.hg/hgrc
426 [ "$repo" = "wok" ] && echo "description = SliTaz Cooking wok" >> $REPOS_DIR/$repo/.hg/hgrc
427 [ "$repo" = "wok-stable" ] && echo "description = SliTaz Stable wok" >> $REPOS_DIR/$repo/.hg/hgrc
428 [ "$repo" = "wok-tank" ] && echo "description = SliTaz Tank Mirror wok" >> $REPOS_DIR/$repo/.hg/hgrc
429 [ "$repo" = "wok-tiny" ] && echo "description = Tiny SliTaz wok" >> $REPOS_DIR/$repo/.hg/hgrc
430 [ "$repo" = "wok-undigest" ] && echo "description = SliTaz Undigest wok" >> $REPOS_DIR/$repo/.hg/hgrc
431 fi
432 done
433 }
435 up_src_links() {
436 local i
437 if [ -d $SRCDIR ]; then
438 [ -d $MAIN_WWW_DIR/mirror/sources/packages ] && rm -rf $MAIN_WWW_DIR/mirror/sources/packages
439 for i in $(ls $SRCDIR); do
440 [ -d $MAIN_WWW_DIR/mirror/sources/packages/${i:0:1} ] || mkdir -p $MAIN_WWW_DIR/mirror/sources/packages/${i:0:1}
441 [ -f $MAIN_WWW_DIR/mirror/sources/packages/${i:0:1}/$i ] || ln -sf $SRCDIR/$i $MAIN_WWW_DIR/mirror/sources/packages/${i:0:1}/$i
442 done
443 fi
444 [ -f /usr/bin/chkfilelist ] && /usr/bin/chkfilelist
445 }
447 case "$COMMAND" in
448 start|on|tank-only|mirror-only)
449 [ -d $MAIN_WWW_DIR/mirror-info ] && WWW="${WWW/mirror /}"
450 for c in $WWW; do
451 if [ ! -d $MAIN_WWW_DIR/$c ]; then
452 www $c
453 [ "$c" = "hg" ] && repos
454 fi
455 done
456 #echo "127.0.0.1 localhost $(cat /etc/hostname)" > /etc/hosts
457 [ "$IP_ADDR" == "127.0.0.1" ] && echo "127.0.0.1 tazpanel.slitaz.org" >> /etc/hosts
458 for hostname in $ADDRESS; do
459 if [ "$hostname" = "www.slitaz.org" ]; then
460 echo "$IP_ADDR $hostname slitaz.org" >> /etc/hosts
461 elif [ "$hostname" = "pro.slitaz.org" ]; then
462 echo "$IP_ADDR $hostname slitaz.pro" >> /etc/hosts
463 else
464 echo "$IP_ADDR $hostname" >> /etc/hosts
465 fi
466 done
467 if [ ! -L /usr/share/awstats/icon/other/slitaz-spider-48x48.png ]; then
468 ln -s $REPOS_DIR/website/images/artwork/slitaz-spider-48x48.png /usr/share/awstats/icon/other/slitaz-spider-48x48.png
469 fi
470 if [ "$IP_ADDR" != "127.0.0.1" ]; then
471 if [ ! $(grep -l "dhcp-option=option:router,$ROUTER_IP" /etc/dnsmasq.conf) ]; then
472 echo "$IP_ADDR tazpanel tazpanel.slitaz.org" >> /etc/hosts
473 echo "dhcp-option=option:router,$ROUTER_IP" >> /etc/dnsmasq.conf
474 fi
475 fi
476 if [ -d "$SLITAZ_HOME/$version/packages" ]; then
477 echo "$SLITAZ_HOME/$version/packages" > $LOCALSTATE/mirror
478 fi
479 if [ "$COMMAND" = "tank-only" ]; then
480 [ -f $VHOST_TANK_FILE ] && ln -sf $VHOST_TANK_FILE /etc/lighttpd/vhosts.conf
481 elif [ "$COMMAND" = "mirror-only" ]; then
482 [ -f $VHOST_MIRROR_FILE ] && ln -sf $VHOST_MIRROR_FILE /etc/lighttpd/vhosts.conf
483 else
484 [ -f $VHOST_FILE ] && ln -sf $VHOST_FILE /etc/lighttpd/vhosts.conf
485 fi
486 [ -d $MAIN_WWW_DIR/pics/rrd ] || mkdir -p $MAIN_WWW_DIR/pics/rrd
487 chown -R www.www $MAIN_WWW_DIR
488 up_src_links
489 [ -x /etc/init.d/lighttpd ] && /etc/init.d/lighttpd start
490 [ -x /etc/init.d/crond ] && /etc/init.d/crond start
491 ;;
492 update-repos)
493 pwd=$(pwd)
494 for i in $(ls $REPOS_DIR); do
495 if [ -d $REPOS_DIR/$i/.hg ]; then
496 cd $REPOS_DIR/$i
497 echo "Updaing $i repo..."
498 hg pull -u
499 fi
500 done
501 cd $pwd
502 ;;
503 up-src-links)
504 up_src_links
505 ;;
506 backup-mirror|-bm)
507 case "$2" in
508 pkgs-dry-push)
509 rsync -avrtlz --delete --dry-run $PKGDIR ${sync_mirror} ;;
510 src-dry-push)
511 rsync -avrtlz --delete --dry-run $SRCDIR ${sync_mirror} ;;
512 repos-dry-push)
513 rsync -avrtlz --delete --dry-run $REPOS_DIR ${sync_mirror} ;;
514 pkgs-push)
515 rsync -avrtlz --delete $PKGDIR ${sync_mirror} ;;
516 src-push)
517 rsync -avrtlz --delete $SRCDIR ${sync_mirror} ;;
518 repos-push)
519 rsync -avrtlz --delete $REPOS_DIR ${sync_mirror} ;;
520 pkgs-dry-pull)
521 rsync -avrtlz --delete --dry-run ${sync_mirror}${PKGDIR} $(dirname ${PKGDIR}) ;;
522 src-dry-pull)
523 rsync -avrtlz --delete --dry-run ${sync_mirror}${SRCDIR} $(dirname ${SRCDIR}) ;;
524 repos-dry-pull)
525 rsync -avrtlz --delete --dry-run ${sync_mirror}${REPOS_DIR} $(dirname ${REPOS_DIR}) ;;
526 pkgs-pull)
527 rsync -avrtlz --delete ${sync_mirror}${PKGDIR} $(dirname ${PKGDIR}) ;;
528 src-pull)
529 rsync -avrtlz --delete ${sync_mirror}${SRCDIR} $(dirname ${SRCDIR}) ;;
530 repos-pull)
531 rsync -avrtlz --delete ${sync_mirror}${REPOS_DIR} $(dirname ${REPOS_DIR}) ;;
532 *)
533 echo "$0 backup-mirror pkgs-dry-{push|pull}"
534 echo "$0 backup-mirorr pkgs-{push|pull}"
535 echo "$0 backup-mirror src-dry-{push|pull}"
536 echo "$0 backup-mirror src-{push|pull}"
537 echo "$0 backup-mirror repos-dry-{push|pull}"
538 echo "$0 backup-mirror repos-{push|pull}" ;;
539 esac ;;
540 off|stop)
541 [ -x /etc/init.d/lighttpd ] && /etc/init.d/lighttpd stop
542 [ -x /etc/init.d/crond ] && /etc/init.d/crond stop
543 echo "127.0.0.1 localhost $(cat /etc/hostname) tazpanel" > /etc/hosts
544 exit 1
545 ;;
546 *)
547 usage
548 ;;
549 esac