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

Add tazpanel and slitaz-vz into local-mirror script.
author Christopher Rogers <slaxemulator@gmail.com>
date Sat Apr 16 18:30:51 2011 +0000 (2011-04-16)
parents c1a6007116b3
children 51467048ef4f
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 VERSION="0.1"
11 COMMAND="$1"
13 usage() {
14 echo "$0 $VERSION"
15 echo "$0 [on|off|update-repos|tank-only|mirror-only]"
16 exit 1
17 }
19 if [ "$COMMAND" = "tank-only" ]; then
20 WWW="${WWW/mirror/}"
21 ADDRESS="${ADDRESS/mirror.slitaz.org/}"
22 VHOST_FILE="$VHOST_TANK_FILE"
23 fi
25 if [ "$COMMAND" = "mirror-only" ]; then
26 WWW="${WWW/tank/}"
27 ADDRESS="mirror.slitaz.org"
28 VHOST_FILE="$VHOST_MIRROR_FILE"
29 fi
31 [ -d $REPOS_DIR ] || continue
32 [ -d $MAIN_WWW_DIR ] || mkdir -p $MAIN_WWW_DIR
33 [ -L /var/www/vhosts ] || ln -sf $MAIN_WWW_DIR /var/www/vhosts
35 www() {
36 b=$1
37 case "$b" in
38 website)
39 [ -d $REPOS_DIR/$b ] && ln -s $REPOS_DIR/$b $MAIN_WWW_DIR
40 ;;
41 people)
42 [ -d $REPOS_DIR/slitaz-forge/people ] && ln -s $REPOS_DIR/slitaz-forge/people $MAIN_WWW_DIR/people
43 ;;
44 doc)
45 [ -d $DOC_WWW_DIR ] && cp -a $DOC_WWW_DIR $MAIN_WWW_DIR/doc
46 [ -d /var/www/dokuwiki ] && cp -a /var/www/dokuwiki/* $MAIN_WWW_DIR/doc
47 VAR="index media pages"
48 for i in $VAR; do
49 [ -d $REPOS_DIR/slitaz-doc-wiki-data ] && cp -a $REPOS_DIR/slitaz-doc-wiki-data/$i $MAIN_WWW_DIR/doc/data
50 done
51 [ -d $REPOS_DIR/slitaz-doc-wiki-data/plugins ] && cp -a $REPOS_DIR/slitaz-doc-wiki-data/plugins $MAIN_WWW_DIR/doc/lib
52 chown root.root -R $MAIN_WWW_DIR/doc
53 chmod 777 -R $MAIN_WWW_DIR/doc
54 ;;
55 pizza)
56 [ -d $PIZZA_WWW_DIR ] && ln -sf $PIZZA_WWW_DIR $MAIN_WWW_DIR/pizza
57 ;;
58 bb)
59 [ -d /usr/share/slitaz/web-bb ] && cp -a /usr/share/slitaz/web-bb $MAIN_WWW_DIR/bb
60 #[ -d /usr/share/slitaz/web ] && cp -a /usr/share/slitaz/web $MAIN_WWW_DIR/bb/web
61 [ -d $REPOS_DIR/website/pics ] && ln -sf $REPOS_DIR/website/pics $MAIN_WWW_DIR/bb/pics
62 [ -d $COOKING/wok ] || ln -sf $REPOS_DIR/wok $COOKING/clean-wok
63 [ -d $COOKING/wok ] || ln -sf $REPOS_DIR/wok $COOKING/wok
64 [ -d $STABLE/wok ] || ln -sf $REPOS_DIR/wok-stable $STABLE/clean-wok
65 [ -d $STABLE/wok ] || ln -sf $REPOS_DIR/wok-stable $STABLE/wok
66 [ -f $SRCDIR/sources.list ] || tazwok gen-src $SRCDIR
67 [ -d $REPOS_DIR/slitaz-modular ] && ln -sf $REPOS_DIR/slitaz-modular $COOKING/slitaz-modular
68 echo -e "$MAIN_WWW_DIR/bb" | tazwok webserver on
69 ;;
70 pkgs)
71 [ -d $MAIN_WWW_DIR/pkgs ] || mkdir -p $MAIN_WWW_DIR/pkgs
73 #[ -d /var/lib/tazpkg-web/style ] && cp -a /var/lib/tazpkg-web/style/* $MAIN_WWW_DIR/pkgs
74 #[ -f /var/lib/tazpkg-web/search.cgi ] && cp -a /var/lib/tazpkg-web/search.cgi $MAIN_WWW_DIR/pkgs
75 [ -d $REPOS_DIR/slitaz-dev-tools/tazpkg-web/style ] && cp -a $REPOS_DIR/slitaz-dev-tools/tazpkg-web/style/* $MAIN_WWW_DIR/pkgs
76 [ -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
77 [ -d $COOKING ] || mkdir -p $COOKING
78 [ -d $STABLE ] || mkdir -p $STABLE
79 [ -d $REPOS_DIR/flavors ] && ln -sf $REPOS_DIR/flavors $COOKING/flavors
80 [ -d $REPOS_DIR/flavors-stable ] && ln -sf $REPOS_DIR/flavors-stable $STABLE/flavors
81 [ -d $COOKING/wok ] || ln -sf $REPOS_DIR/wok $COOKING/clean-wok
82 [ -d $STABLE/wok ] || ln -sf $REPOS_DIR/wok-stable $STABLE/clean-wok
83 [ -d $PKGDIR ] && ln -sf $PKGDIR $LOCAL_REPOSITORY/packages
84 [ -d $SRCDIR ] && ln -sf $SRCDIR $LOCAL_REPOSITORY/src
85 ;;
86 mirror)
87 [ -d $REPOS_DIR/slitaz-dev-tools/mirror-tools/mirror-info ] && cp -a $REPOS_DIR/slitaz-dev-tools/mirror-tools/mirror-info $MAIN_WWW_DIR
88 [ -d $REPOS_DIR/slitaz-dev-tools/mirror-tools/slitaz ] && cp -a $REPOS_DIR/slitaz-dev-tools/mirror-tools/slitaz $MAIN_WWW_DIR
89 [ -d $MAIN_WWW_DIR/slitaz/mirror/packages ] || mkdir -p $MAIN_WWW_DIR/slitaz/mirror/packages
90 [ -d $PKGDIR ] && ln -sf $PKGDIR $MAIN_WWW_DIR/slitaz/mirror/packages/$(cat /etc/slitaz-release)
91 if [ -d $SRCDIR ]; then
92 for i in $(ls $SRCDIR); do
93 [ -d $MAIN_WWW_DIR/slitaz/mirror/sources/packages/${i:0:1} ] || mkdir -p $MAIN_WWW_DIR/slitaz/mirror/sources/packages/${i:0:1}
94 [ -f $MAIN_WWW_DIR/slitaz/mirror/sources/packages/${i:0:1}/$i ] || ln -s $SRCDIR/$i $MAIN_WWW_DIR/slitaz/mirror/sources/packages/${i:0:1}/$i
95 done
96 fi
97 [ -d /var/www/slitaz ] || ln -sf $MAIN_WWW_DIR/slitaz /var/www/slitaz
98 ;;
99 boot)
100 [ -d $BOOT_WWW_DIR ] && cp -a $BOOT_WWW_DIR $MAIN_WWW_DIR/$b
101 [ -d $REPOS_DIR/website/pics ] && ln -sf $REPOS_DIR/website/pics $MAIN_WWW_DIR/$b/pics
102 ;;
103 tank)
104 [ -d $TANK_WWW_DIR ] && ln -sf $TANK_WWW_DIR $MAIN_WWW_DIR/$b
105 [ -f /usr/share/awstats/extras/update ] && ln -sf /usr/share/awstats/extras/update /usr/sbin/awsupdate_all
106 [ -d $REPOS_DIR/slitaz-forge/$b/files/etc/awstats ] && cp -a $REPOS_DIR/slitaz-forge/$b/files/etc/awstats/* /etc/awstats
107 for i in $ADDRESS; do
108 if [ -f /etc/awstats/awstats.$i.conf ]; then
109 dirlog=$(grep ^DirData= /etc/awstats/awstats.$i.conf | cut -d "=" -f2 | sed -e 's/"//g')
110 mkdir -p $dirlog
111 fi
112 done
113 ;;
114 hg)
115 [ -d $MAIN_WWW_DIR/hg ] || mkdir -p $MAIN_WWW_DIR/hg
116 [ -f /usr/share/examples/mercurial/hgwebdir.cgi ] && cp -a /usr/share/examples/mercurial/hgwebdir.cgi $MAIN_WWW_DIR/hg
117 [ -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/hgweb.config
118 #[ -f /etc/mercurial/hgweb.conf ] && sed -i 's|style = slitaz|style = gitweb|g' /etc/mercurial/hgweb.config
119 ;;
120 lfs)
121 [ -d $MAIN_WWW_DIR/lfs ] || ln -sf /usr/share/doc/lfs-book $MAIN_WWW_DIR/lfs
122 ;;
123 esac
124 }
126 repos() {
127 for repo in $REPOS; do
128 [ -d $REPOS_DIR/$repo ] || continue
129 if [ -d $REPOS_DIR/$repo/.hg ]; then
130 mkdir -p $REPOS_WEB_DIR/$repo
131 [ -d $REPOS_WEB_DIR/$repo/.hg ] || ln -s $REPOS_DIR/$repo/.hg $REPOS_WEB_DIR/$repo/.hg
132 if [ ! $(grep -l "$REPOS_WEB_DIR" /etc/mercurial/hgweb.config) ]; then
133 [ -f /etc/mercurial/hgweb.config ] && sed -i "s|$REPOS_DIR|$REPOS_WEB_DIR|g" /etc/mercurial/hgweb.config
134 fi
135 fi
136 if [ ! -f $REPOS_DIR/$repo/.hg/hgrc-web ]; then
137 touch $REPOS_DIR/$repo/.hg/hgrc-web
138 echo "[paths]" >> $REPOS_DIR/$repo/.hg/hgrc-web
139 echo "default = http://hg.slitaz.org/$repo/" >> $REPOS_DIR/$repo/.hg/hgrc-web
140 echo "[web]" >> $REPOS_DIR/$repo/.hg/hgrc-web
141 #[ -d $REPOS_DIR/$repo/.hg ] && echo "style = slitaz" >> $REPOS_DIR/$repo/.hg/hgrc-web
142 echo "staticurl = http://hg.slitaz.org/static/" >> $REPOS_DIR/$repo/.hg/hgrc-web
143 echo "push_ssl = false" >> $REPOS_DIR/$repo/.hg/hgrc-web
144 echo "allow_push = *" >> $REPOS_DIR/$repo/.hg/hgrc-web
145 #[ ! -f $REPOS_DIR/$repo/.hg/hgrc-pull ] && mv $REPOS_DIR/$repo/.hg/hgrc $REPOS_DIR/$repo/.hg/hgrc-pull
146 cp -a $REPOS_DIR/$repo/.hg/hgrc-web $REPOS_DIR/$repo/.hg/hgrc
147 fi
149 if [ ! $(grep -l 'name = ' $REPOS_DIR/$repo/.hg/hgrc ) ]; then
150 echo "name = $repo" >> $REPOS_DIR/$repo/.hg/hgrc
151 fi
153 if [ ! $(grep -l 'contact = ' $REPOS_DIR/$repo/.hg/hgrc ) ]; then
154 [ "$repo" = "flavors" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
155 [ "$repo" = "flavors-stable" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
156 [ "$repo" = "slitaz-base-files" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
157 [ "$repo" = "slitaz-boot-scripts" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
158 [ "$repo" = "slitaz-configs" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
159 [ "$repo" = "slitaz-dev-tools" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
160 [ "$repo" = "slitaz-doc" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
161 [ "$repo" = "slitaz-doc-wiki-data" ] && echo "contact = Christopher Rogers" >> $REPOS_DIR/$repo/.hg/hgrc
162 [ "$repo" = "slitaz-forge" ] && echo "contact = Eric Joseph-Alexandre" >> $REPOS_DIR/$repo/.hg/hgrc
163 [ "$repo" = "slitaz-modular" ] && echo "contact = Christopher Rogers" >> $REPOS_DIR/$repo/.hg/hgrc
164 [ "$repo" = "slitaz-pizza" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
165 [ "$repo" = "slitaz-tools" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
166 [ "$repo" = "slitaz-vz" ] && echo "contact = Eric Joseph-Alexandre" >> $REPOS_DIR/$repo/.hg/hgrc
167 [ "$repo" = "tazlito" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
168 [ "$repo" = "tazpanel" ] && echo "contact = Christophe Lincoln" >> $REPO_DIR/$repo/.hg/hgrc
169 [ "$repo" = "tazpkg" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
170 [ "$repo" = "tazusb" ] && echo "contact = Eric Joseph-Alexandre" >> $REPOS_DIR/$repo/.hg/hgrc
171 [ "$repo" = "tazwok" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
172 [ "$repo" = "website" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
173 [ "$repo" = "wok" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
174 [ "$repo" = "wok-stable" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
175 [ "$repo" = "wok-tiny" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
176 [ "$repo" = "wok-undigest" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
177 fi
179 if [ ! $(grep -l 'description = ' $REPOS_DIR/$repo/.hg/hgrc) ]; then
180 [ "$repo" = "flavors" ] && echo "description = SliTaz Cooking flavors" >> $REPOS_DIR/$repo/.hg/hgrc
181 [ "$repo" = "flavors-stable" ] && echo "description = SliTaz Stable flavors" >> $REPOS_DIR/$repo/.hg/hgrc
182 [ "$repo" = "slitaz-base-files" ] && echo "description = SliTaz base files" >> $REPOS_DIR/$repo/.hg/hgrc
183 [ "$repo" = "slitaz-boot-scripts" ] && echo "description = SliTaz boot scripts" >> $REPOS_DIR/$repo/.hg/hgrc
184 [ "$repo" = "slitaz-configs" ] && echo "description = SliTaz configuration files" >> $REPOS_DIR/$repo/.hg/hgrc
185 [ "$repo" = "slitaz-dev-tools" ] && echo "description = SliTaz Developers Tools" >> $REPOS_DIR/$repo/.hg/hgrc
186 [ "$repo" = "slitaz-doc" ] && echo "description = SliTaz system doc" >> $REPOS_DIR/$repo/.hg/hgrc
187 [ "$repo" = "slitaz-doc-wiki-data" ] && echo "description = SliTaz documentation wiki content" >> $REPOS_DIR/$repo/.hg/hgrc
188 [ "$repo" = "slitaz-forge" ] && echo "description = SliTaz Forge Config" >> $REPOS_DIR/$repo/.hg/hgrc
189 [ "$repo" = "slitaz-modular" ] && echo "description = Scripts to make SliTaz Modular" >> $REPOS_DIR/$repo/.hg/hgrc
190 [ "$repo" = "slitaz-pizza" ] && echo "description = SliTaz Online flavor builder" >> $REPOS_DIR/$repo/.hg/hgrc
191 [ "$repo" = "slitaz-tools" ] && echo "description = SliTaz Tools and Tinyutils" >> $REPOS_DIR/$repo/.hg/hgrc
192 [ "$repo" = "slitaz-vz" ] && echo "description = SliTaz OpenVZ integration" >> $REPOS_DIR/$repo/.hg/hgrc
193 [ "$repo" = "tazlito" ] && echo "description = SliTaz Live Tool" >> $REPOS_DIR/$repo/.hg/hgrc
194 [ "$repo" = "tazpanel" ] && echo "description = Slitaz Administration Panel" >> $REPOS_DIR/$repo/.hg/hgrc
195 [ "$repo" = "tazpkg" ] && echo "description = SliTaz Packages manager" >> $REPOS_DIR/$repo/.hg/hgrc
196 [ "$repo" = "tazusb" ] && echo "description = SliTaz LiveUSB utility" >> $REPOS_DIR/$repo/.hg/hgrc
197 [ "$repo" = "tazwok" ] && echo "description = SliTaz Packages builder" >> $REPOS_DIR/$repo/.hg/hgrc
198 [ "$repo" = "website" ] && echo "description = SliTaz Website" >> $REPOS_DIR/$repo/.hg/hgrc
199 [ "$repo" = "wok" ] && echo "description = SliTaz Cooking wok" >> $REPOS_DIR/$repo/.hg/hgrc
200 [ "$repo" = "wok-stable" ] && echo "description = SliTaz Stable wok" >> $REPOS_DIR/$repo/.hg/hgrc
201 [ "$repo" = "wok-tiny" ] && echo "description = Tiny SliTaz wok" >> $REPOS_DIR/$repo/.hg/hgrc
202 [ "$repo" = "wok-undigest" ] && echo "description = SliTaz Undigest wok" >> $REPOS_DIR/$repo/.hg/hgrc
203 fi
204 done
205 }
207 case "$COMMAND" in
208 on|tank-only|mirror-only)
209 [ -d $MAIN_WWW_DIR/mirror-info ] && WWW="${WWW/mirror /}"
210 for c in $WWW; do
211 if [ ! -d $MAIN_WWW_DIR/$c ]; then
212 www $c
213 [ "$c" = "hg" ] && repos
214 fi
215 done
216 echo "127.0.0.1 localhost $(cat /etc/hostname) tazpanel" > /etc/hosts
217 for hostname in $ADDRESS; do
218 #if [ ! $(grep -l "${BASE_IP}.$i $hostname" /etc/hosts) ]; then
219 echo "$IP_ADDR $hostname" >> /etc/hosts
220 #fi
221 done
222 if [ "$IP_ADDR" != "127.0.0.1" ]; then
223 if [ ! $(grep -l 'dhcp-option=option:router' /etc/dnsmasq.conf) ]; then
224 echo "dhcp-option=option:router,$ROUTER_IP" >> /etc/dnsmasq.conf
225 fi
226 fi
227 echo "$PKGDIR" > $LOCALSTATE/mirror
228 if [ "$COMMAND" = "tank-only" ]; then
229 [ -f $VHOST_TANK_FILE ] && ln -sf $VHOST_TANK_FILE /etc/lighttpd/vhosts.conf
230 elif [ "$COMMAND" = "mirror-only" ]; then
231 [ -f $VHOST_MIRROR_FILE ] && ln -sf $VHOST_MIRROR_FILE /etc/lighttpd/vhosts.conf
232 else
233 [ -f $VHOST_FILE ] && ln -sf $VHOST_FILE /etc/lighttpd/vhosts.conf
234 fi
235 chown -R www.www $SLITAZ_DIR/www
236 [ -f /etc/init.d/lighttpd ] && /etc/init.d/lighttpd start
237 ;;
238 update-repos)
239 for i in $(ls $REPOS_DIR); do
240 if [ -d $REPOS_DIR/$i/.hg ]; then
241 cd $REPOS_DIR/$i
242 echo "Updaing $i repo..."
243 hg pull -u
244 fi
245 done
246 ;;
247 off)
248 [ -f /etc/init.d/lighttpd ] && /etc/init.d/lighttpd stop
249 echo "127.0.0.1 localhost $(cat /etc/hostname)" > /etc/hosts
250 exit 1
251 ;;
252 *)
253 usage
254 ;;
255 esac