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

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