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

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