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

Update local-mirror script. Add on and off options. Put if statement of WWW and for loop of REPOS into functions.
author Christopher Rogers <slaxemulator@gmail.com>
date Mon Feb 28 14:49:41 2011 +0000 (2011-02-28)
parents afc5e1a66639
children 1dd991f59195
line source
1 #!/bin/sh
3 source /usr/lib/slitaz/libtaz
4 source_lib commons
5 check_root
7 . /etc/local-mirror.conf
9 VERSION="0.1"
10 COMMAND="$1"
12 usage() {
13 echo "$0 $VERSION"
14 echo "$0 [on|off]"
15 exit 1
16 }
18 [ -d $REPOS_DIR ] || continue
19 [ -d $WWW_DIR ] || mkdir -p $WWW_DIR
20 [ -L /var/www/vhosts ] || ln -sf $WWW_DIR /var/www/vhosts
22 www() {
23 b=$1
24 if [ "$b" = "website" ]; then
25 [ -d $REPOS_DIR/$b ] && ln -s $REPOS_DIR/$b $WWW_DIR
26 fi
27 if [ "$b" = "people" ]; then
28 [ -d $REPOS_DIR/slitaz-forge/people ] && ln -s $REPOS_DIR/slitaz-forge/people $WWW_DIR/people
29 fi
30 if [ "$b" = "doc" ]; then
31 [ -d $REPOS_DIR/slitaz-forge/doc ] && cp -a $REPOS_DIR/slitaz-forge/doc $WWW_DIR/doc
32 [ -d /var/www/dokuwiki ] && cp -a /var/www/dokuwiki/* $WWW_DIR/doc
33 VAR="index media pages"
34 for i in $VAR; do
35 [ -d $REPOS_DIR/slitaz-doc-wiki-data ] && cp -a $REPOS_DIR/slitaz-doc-wiki-data/$i $WWW_DIR/doc/data
36 done
37 [ -d $REPOS_DIR/slitaz-doc-wiki-data/plugins ] && cp -a $REPOS_DIR/slitaz-doc-wiki-data/plugins $WWW_DIR/doc/lib
38 chown root.root -R $WWW_DIR/doc
39 chmod 777 -R $WWW_DIR/doc
40 fi
41 if [ "$b" = "bb" ]; then
42 [ -d /usr/share/slitaz/web-bb ] && cp -a /usr/share/slitaz/web-bb $WWW_DIR/bb
43 [ -d /usr/share/slitaz/web ] && cp -a /usr/share/slitaz/web $WWW_DIR/bb/web
44 [ -d $REPOS_DIR/website/pics ] && ln -sf $REPOS_DIR/website/pics $WWW_DIR/bb/pics
45 fi
46 if [ "$b" = "pkgs" ]; then
47 [ -d $wWW_DIR/pkgs ] || mkdir -p $WWW_DIR/pkgs
48 [ -d /var/lib/tazpkg-web/style ] && cp -a /var/lib/tazpkg-web/style/* $WWW_DIR/pkgs
49 [ -f /var/lib/tazpkg-web/search.cgi ] && cp -a /var/lib/tazpkg-web/search.cgi $WWW_DIR/pkgs
50 [ -d $COOKING ] || mkdir -p $COOKING
51 [ -d $STABLE ] || mkdir -p $STABLE
52 [ -d $COOKING/wok ] || ln -sf $REPOS_DIR/wok $COOKING/clean-wok
53 [ -d $STABLE/wok ] || ln -sf $REPOS_DIR/wok-stable $STABLE/clean-wok
54 [ -d /boot/packages ] && ln -sf /boot/packages /home/slitaz/$(cat /etc/slitaz-release)/packages
55 [ -d /boot/src ] && ln -sf /boot/src /home/slitaz/$(cat /etc/slitaz-release)/src
56 fi
57 if [ "$b" = "mirror" ]; then
58 [ -d $REPOS_DIR/slitaz-dev-tools/mirror-tools/mirror-info ] && cp -a $REPOS_DIR/slitaz-dev-tools/mirror-tools/mirror-info $WWW_DIR
59 [ -d $REPOS_DIR/slitaz-dev-tools/mirror-tools/slitaz ] && cp -a $REPOS_DIR/slitaz-dev-tools/mirror-tools/slitaz $WWW_DIR
60 [ -d $WWW_DIR/slitaz/mirror/packages ] || mkdir -p $WWW_DIR/slitaz/mirror/packages
61 [ -d /boot/packages ] && ln -sf /boot/packages $WWW_DIR/slitaz/mirror/packages/$(cat /etc/slitaz-release)
62 if [ -d /boot/src ]; then
63 for i in $(ls /boot/src); do
64 [ -d $WWW_DIR/slitaz/mirror/sources/packages/${i:0:1} ] || mkdir -p $WWW_DIR/slitaz/mirror/sources/packages/${i:0:1}
65 ln -sf /boot/src/$i $WWW_DIR/slitaz/mirror/sources/packages/${i:0:1}/$i
66 done
67 fi
68 fi
69 if [ "$b" = "tank" ]; then
70 [ -d $REPOS_DIR/slitaz-forge/$b/web ] && ln -sf $REPOS_DIR/slitaz-forge/$b/web $WWW_DIR/$b
71 [ -f /usr/share/awstats/extras/update ] && ln -sf /usr/share/awstats/extras/update /usr/sbin/awsupdate_all
72 [ -d $REPOS_DIR/slitaz-forge/$b/root/etc/awstats ] && cp -a $REPOS_DIR/slitaz-forge/$b/root/etc/awstats/* /etc/awstats
73 fi
74 if [ "$b" = "hg" ]; then
75 [ -d $WWW_DIR/hg ] || mkdir -p $WWW_DIR/hg
76 [ -f /usr/share/examples/mercurial/hgwebdir.cgi ] && ln -sf /usr/share/examples/mercurial/hgwebdir.cgi $WWW_DIR/hg
77 [ -f $REPOS_DIR/slitaz-forge/tank/files/etc/mercurial/hgweb.config ] && ln -sf $REPOS_DIR/slitaz-forge/tank/files/etc/mercurial/hgweb.config /etc/mercurial/hgweb.config
78 fi
79 }
81 repos() {
82 for repo in $REPOS; do
83 [ -d $REPOS_DIR/$repo ] || continue
84 if [ "$repo" = "flavors" ]; then
85 [ -d $COOKING ] || mkdir -p $COOKING
86 [ -d $REPOS_DIR/$repo ] && ln -sf $REPOS_DIR/$repo $COOKING/$repo
87 fi
88 if [ "$repo" = "flavors-stable" ]; then
89 [ -d $STABLE ] || mkdir -p $STABLE
90 [ -d $REPOS_DIR/$repo ] && ln -sf $REPOS_DIR/$repo $STABLE/$repo
91 fi
92 if [ ! -f $REPOS_DIR/$repo/.hg/hgrc-web ]; then
93 [ -d $REPOS_DIR/$repo/.hg ] && touch $REPOS_DIR/$repo/.hg/hgrc-web
94 [ -d $REPOS_DIR/$repo/.hg ] && echo "[web]" >> $REPOS_DIR/$repo/.hg/hgrc-web
95 [ -d $REPOS_DIR/$repo/.hg ] && echo "style = slitaz" >> $REPOS_DIR/$repo/.hg/hgrc-web
96 [ -d $REPOS_DIR/$repo/.hg ] && echo "push_ssl = false" >> $REPOS_DIR/$repo/.hg/hgrc-web
97 [ -d $REPOS_DIR/$repo/.hg ] && echo "allow_push = *" >> $REPOS_DIR/$repo/.hg/hgrc-web
98 [ ! -f $REPOS_DIR/$repo/.hg/hgrc-pull ] && mv $REPOS_DIR/$repo/.hg/hgrc $REPOS_DIR/$repo/.hg/hgrc-pull
99 [ ! -f $REPOS_DIR/$repo/.hg/hgrc ] && cp -a $REPOS_DIR/$repo/.hg/hgrc-web $REPOS_DIR/$repo/.hg/hgrc
100 fi
102 if [ ! $(grep -l 'name = ' $REPOS_DIR/$repo/.hg/hgrc ) ]; then
103 echo "name = $repo" >> $REPOS_DIR/$repo/.hg/hgrc
104 fi
106 if [ ! $(grep -l 'contact = ' $REPOS_DIR/$repo/.hg/hgrc ) ]; then
107 [ "$repo" = "flavors" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
108 [ "$repo" = "flavors-stable" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
109 [ "$repo" = "slitaz-base-files" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
110 [ "$repo" = "slitaz-boot-scripts" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
111 [ "$repo" = "slitaz-configs" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
112 [ "$repo" = "slitaz-dev-tools" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
113 [ "$repo" = "slitaz-doc" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
114 [ "$repo" = "slitaz-doc-wiki-data" ] && echo "contact = Christopher Rogers" >> $REPOS_DIR/$repo/.hg/hgrc
115 [ "$repo" = "slitaz-forge" ] && echo "contact = Eric Joseph-Alexandre" >> $REPOS_DIR/$repo/.hg/hgrc
116 [ "$repo" = "slitaz-modular" ] && echo "contact = Christopher Rogers" >> $REPOS_DIR/$repo/.hg/hgrc
117 [ "$repo" = "slitaz-pizza" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
118 [ "$repo" = "slitaz-tools" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
119 [ "$repo" = "tazlito" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
120 [ "$repo" = "tazpkg" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
121 [ "$repo" = "tazusb" ] && echo "contact = Eric Joseph-Alexandre" >> $REPOS_DIR/$repo/.hg/hgrc
122 [ "$repo" = "tazwok" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
123 [ "$repo" = "website" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
124 [ "$repo" = "wok" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
125 [ "$repo" = "wok-stable" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
126 [ "$repo" = "wok-tiny" ] && echo "contact = Pascal Bellard" >> $REPOS_DIR/$repo/.hg/hgrc
127 [ "$repo" = "wok-undigest" ] && echo "contact = Christophe Lincoln" >> $REPOS_DIR/$repo/.hg/hgrc
128 fi
130 if [ ! $(grep -l 'description = ' $REPOS_DIR/$repo/.hg/hgrc) ]; then
131 [ "$repo" = "flavors" ] && echo "description = SliTaz Cooking flavors" >> $REPOS_DIR/$repo/.hg/hgrc
132 [ "$repo" = "flavors-stable" ] && echo "description = SliTaz Stable flavors" >> $REPOS_DIR/$repo/.hg/hgrc
133 [ "$repo" = "slitaz-base-files" ] && echo "description = SliTaz base files" >> $REPOS_DIR/$repo/.hg/hgrc
134 [ "$repo" = "slitaz-boot-scripts" ] && echo "description = SliTaz boot scripts" >> $REPOS_DIR/$repo/.hg/hgrc
135 [ "$repo" = "slitaz-configs" ] && echo "description = SliTaz configuration files" >> $REPOS_DIR/$repo/.hg/hgrc
136 [ "$repo" = "slitaz-dev-tools" ] && echo "description = SliTaz Developers Tools" >> $REPOS_DIR/$repo/.hg/hgrc
137 [ "$repo" = "slitaz-doc" ] && echo "description = SliTaz system doc" >> $REPOS_DIR/$repo/.hg/hgrc
138 [ "$repo" = "slitaz-doc-wiki-data" ] && echo "description = SliTaz documentation wiki content" >> $REPOS_DIR/$repo/.hg/hgrc
139 [ "$repo" = "slitaz-forge" ] && echo "description = SliTaz Forge Config" >> $REPOS_DIR/$repo/.hg/hgrc
140 [ "$repo" = "slitaz-modular" ] && echo "description = Scripts to make SliTaz Modular" >> $REPOS_DIR/$repo/.hg/hgrc
141 [ "$repo" = "slitaz-pizza" ] && echo "description = SliTaz Online flavor builder" >> $REPOS_DIR/$repo/.hg/hgrc
142 [ "$repo" = "slitaz-tools" ] && echo "description = SliTaz Tools and Tinyutils" >> $REPOS_DIR/$repo/.hg/hgrc
143 [ "$repo" = "tazlito" ] && echo "description = SliTaz Live Tool" >> $REPOS_DIR/$repo/.hg/hgrc
144 [ "$repo" = "tazpkg" ] && echo "description = SliTaz Packages manager" >> $REPOS_DIR/$repo/.hg/hgrc
145 [ "$repo" = "tazusb" ] && echo "description = SliTaz LiveUSB utility" >> $REPOS_DIR/$repo/.hg/hgrc
146 [ "$repo" = "tazwok" ] && echo "description = Slitaz Packages builder" >> $REPOS_DIR/$repo/.hg/hgrc
147 [ "$repo" = "website" ] && echo "description = SliTaz Website" >> $REPOS_DIR/$repo/.hg/hgrc
148 [ "$repo" = "wok" ] && echo "description = SliTaz Cooking wok" >> $REPOS_DIR/$repo/.hg/hgrc
149 [ "$repo" = "wok-stable" ] && echo "description = SliTaz Stable wok" >> $REPOS_DIR/$repo/.hg/hgrc
150 [ "$repo" = "wok-tiny" ] && echo "description = Tiny SliTaz wok" >> $REPOS_DIR/$repo/.hg/hgrc
151 [ "$repo" = "wok-undigest" ] && echo "description = SliTaz Undigest wok" >> $REPOS_DIR/$repo/.hg/hgrc
152 fi
153 done
154 }
156 case "$COMMAND" in
157 on)
158 for c in $WWW; do
159 if [ ! -d $WWW_DIR/$c ]; then
160 www $c
161 fi
162 [ "$c" = "hg" ] && repos
163 done
164 for hostname in $ADDRESS; do
165 END_IP=$(($END_IP+1))
166 for i in $END_IP; do
167 if [ ! $(grep -l "${BASE_IP}.$i $hostname" /etc/hosts) ]; then
168 echo "${BASE_IP}.$i $hostname" >> /etc/hosts
169 fi
170 done
171 done
173 [ -f $VHOST_FILE ] && ln -sf $VHOST_FILE /etc/lighttpd/vhosts.conf
174 chown -R www.www /home/slitaz/www
175 [ -f /etc/init.d/lighttpd ] && /etc/init.d/lighttpd start
176 ;;
177 off)
178 [ -f /etc/init.d/lighttpd ] && /etc/init.d/lighttpd stop
179 echo "127.0.0.1 localhost $(cat /etc/hostname)" > /etc/hosts
180 exit 1
181 ;;
182 *)
183 usage
184 ;;
185 esac