slitaz-modular rev 89

Add up-src-links so sources can be updated after build. Add some of crond commands into local-mirror if file exists. crond is now started after lighttpd. Add bugs option for setting up bugs.slitaz.org (needs to be fix).
author Christopher Rogers <slaxemulator@gmail.com>
date Fri May 06 01:25:52 2011 +0000 (2011-05-06)
parents 2355dbaf4051
children f6369bbaf51b
files initramfs/usr/bin/local-mirror
line diff
     1.1 --- a/initramfs/usr/bin/local-mirror	Fri May 06 01:13:05 2011 +0000
     1.2 +++ b/initramfs/usr/bin/local-mirror	Fri May 06 01:25:52 2011 +0000
     1.3 @@ -19,11 +19,30 @@
     1.4  COOKORDER="$(find /mnt/live/mnt/* -name "cookorder.list" -maxdepth 1)"
     1.5  CUR_PWD="$PWD"
     1.6  
     1.7 +[ -d $SLITAZ_DIR ] || mkdir -p $SLITAZ_DIR
     1.8 +if [ "$(cat /proc/cmdline | grep 'home=')" ]; then
     1.9 +	[ -d $SLITAZ_DIR/repos ] || cp -a $REPOS_DIR $SLITAZ_DIR/repos
    1.10 +	rm -rf $REPOS_DIR
    1.11 +else
    1.12 +	[ -d $SLITAZ_DIR/repos ] || ln -sf $REPOS_DIR $SLITAZ_DIR/repos
    1.13 +fi
    1.14 +
    1.15 +[ -d $SLITAZ_DIR/repos ] && REPOS_DIR="$SLITAZ_DIR/repos"
    1.16 +
    1.17 +#repos folders for website
    1.18 +PEOPLE_WWW_DIR="$REPOS_DIR/slitaz-forge/people"
    1.19 +DOC_WWW_DIR="$REPOS_DIR/slitaz-forge/doc"
    1.20 +PIZZA_WWW_DIR="$REPOS_DIR/slitaz-pizza/php"
    1.21 +BOOT_WWW_DIR="$REPOS_DIR/slitaz-forge/boot"
    1.22 +TANK_WWW_DIR="$REPOS_DIR/slitaz-forge/tank/web"
    1.23 +
    1.24  if [ -d $REPOS_DIR/my-wok ]; then
    1.25  	REPO_WOK=$REPOS_DIR/my-wok
    1.26  	if [ -x /usr/bin/hg ]; then
    1.27  		cd $REPO_WOK
    1.28 -		hg update cooking
    1.29 +		if [ ! "$(hg branch)" = "cooking" ]; then
    1.30 +			hg update cooking
    1.31 +		fi
    1.32  		cd $CUR_PWD
    1.33  	fi
    1.34  elif [ -d $REPOS_DIR/wok ]; then
    1.35 @@ -47,12 +66,22 @@
    1.36  [ -L /var/www/vhosts ] || ln -sf $MAIN_WWW_DIR /var/www/vhosts
    1.37  
    1.38  INCOMING_REPOSITORY="$LOCAL_REPOSITORY/packages-incoming"
    1.39 +CRON_FILE="/var/spool/cron/crontabs/root"
    1.40 +
    1.41 +[ -d $(dirname $CRON_FILE) ] || mkdir -p $(dirname $CRON_FILE)
    1.42 +[ -f $CRON_FILE ] || touch $CRON_FILE
    1.43  
    1.44  www() {
    1.45  	b=$1
    1.46  	case "$b" in
    1.47  		website)
    1.48  			[ -d $REPOS_DIR/$b ] && ln -s $REPOS_DIR/$b $MAIN_WWW_DIR
    1.49 +			if [ -f $MAIN_WWW_DIR/$b/libs/get-latest.sh ]; then
    1.50 +				if [ ! $(grep -l "$MAIN_WWW_DIR/$b/libs/get-latest.sh" $CRON_FILE) ]; then
    1.51 +					echo "#Update SliTaz stuff" >> $CRON_FILE
    1.52 +					echo "*/20 * * * * $MAIN_WWW_DIR/$b/libs/get-latest.sh" >> $CRON_FILE
    1.53 +				fi
    1.54 +			fi
    1.55  		;;
    1.56  		people)
    1.57  			[ -d $REPOS_DIR/slitaz-forge/people ] && ln -s $REPOS_DIR/slitaz-forge/people $MAIN_WWW_DIR/people
    1.58 @@ -60,7 +89,7 @@
    1.59  		doc)
    1.60  			[ -d $DOC_WWW_DIR ] && cp -a $DOC_WWW_DIR $MAIN_WWW_DIR/doc
    1.61  			[ -d /var/www/dokuwiki ] && cp -a /var/www/dokuwiki/* $MAIN_WWW_DIR/doc
    1.62 -			VAR="index media pages"
    1.63 +			VAR="index meta media pages"
    1.64  			for i in $VAR; do
    1.65  				[ -d $REPOS_DIR/slitaz-doc-wiki-data ] && cp -a $REPOS_DIR/slitaz-doc-wiki-data/$i $MAIN_WWW_DIR/doc/data
    1.66  			done
    1.67 @@ -68,34 +97,44 @@
    1.68  			chown root.root -R $MAIN_WWW_DIR/doc
    1.69  			chmod 777 -R $MAIN_WWW_DIR/doc
    1.70  		;;
    1.71 +		bugs)
    1.72 +			[ -d $SLITAZ_DIR/bugs ] || mkdir -p $SLITAZ_DIR/bugs
    1.73 +			[ -d $MAIN_WWW_DIR/bugs ] || mkdir -p $MAIN_WWW_DIR/bugs
    1.74 +			[ -d $REPOS_DIR/slitaz-forge/bugs ] && cp -a $REPOS_DIR/slitaz-forge/bugs/roundup.wsgi $SLITAZ_DIR/bugs/roundup.wsgi
    1.75 +			[ -d $REPOS_DIR/slitaz-forge/bugs ] && cp -a $REPOS_DIR/slitaz-forge/bugs/server.ini $SLITAZ_DIR/bugs/server.ini
    1.76 +			[ -d $REPOS_DIR/slitaz-forge/bugs/templates/slitaz ] && cp -a $REPOS_DIR/slitaz-forge/bugs/templates/slitaz/* $SLITAZ_DIR/bugs
    1.77 +			[ -f /usr/share/roundup/cgi-bin/roundup.cgi ] && ln -sf /usr/share/roundup/cgi-bin/roundup.cgi $MAIN_WWW_DIR/bugs/roundup.cgi
    1.78 +		;;
    1.79  		pizza)
    1.80  			[ -d $PIZZA_WWW_DIR ] && ln -sf $PIZZA_WWW_DIR $MAIN_WWW_DIR/pizza
    1.81  		;;
    1.82  		bb)
    1.83  			[ -d /usr/share/slitaz/web-bb ] && cp -a /usr/share/slitaz/web-bb $MAIN_WWW_DIR/bb
    1.84  			#[ -d /usr/share/slitaz/web ] && cp -a /usr/share/slitaz/web $MAIN_WWW_DIR/bb/web
    1.85 -			[ -d $REPOS_DIR/website/pics ] && ln -sf $REPOS_DIR/website/pics $MAIN_WWW_DIR/bb/pics
    1.86 +			[ -d $REPOS_DIR/website/images ] && ln -sf $REPOS_DIR/website/images $MAIN_WWW_DIR/bb/images
    1.87  			[ -d $INCOMING_REPOSITORY ] || mkdir -p $INCOMING_REPOSITORY
    1.88  			[ -f $INCOMING_REPOSITORY/packages.desc ] || touch $INCOMING_REPOSITORY/packages.desc
    1.89  			[ -f $INCOMING_REPOSITORY/packages.equiv ] || touch $INCOMING_REPOSITORY/packages.equiv
    1.90  			[ -f $INCOMING_REPOSITORY/packages.list ] || touch $INCOMING_REPOSITORY/packages.list
    1.91  			[ -f $INCOMING_REPOSITORY/packages.md5 ] || touch $INCOMING_REPOSITORY/packages.md5
    1.92  			[ -f $INCOMING_REPOSITORY/packages.txt ] || touch $INCOMING_REPOSITORY/packages.txt
    1.93 -			tazwok gen-wok-db --WOK=$REPO_WOK
    1.94 -			if [ -f $COOKORDER ]; then
    1.95 -				[ -d $COOKING/wok ] || mkdir -p $COOKING/wok
    1.96 -				[ -d $COOKING/clean-wok ] || mkdir -p $COOKING/clean-wok
    1.97 -				cat $COOKORDER | while read pkg; do
    1.98 -					rwanted=$(grep $'\t'$pkg$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1)
    1.99 -					for i in $rwanted; do
   1.100 -						[ -f $COOKING/clean-wok/$i/receipt ] || cp -a $REPO_WOK/$i $COOKING/clean-wok/$i
   1.101 -						[ -f $COOKING/wok/$i/receipt ] || cp -a $REPO_WOK/$i $COOKING/wok/$i
   1.102 +			if [ "$CUSTOM_WOK" = "yes" ]; then
   1.103 +				tazwok gen-wok-db --WOK=$REPO_WOK
   1.104 +				if [ -f $COOKORDER ]; then
   1.105 +					[ -d $COOKING/wok ] || mkdir -p $COOKING/wok
   1.106 +					[ -d $COOKING/clean-wok ] || mkdir -p $COOKING/clean-wok
   1.107 +					cat $COOKORDER | while read pkg; do
   1.108 +						rwanted=$(grep $'\t'$pkg$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1)
   1.109 +						for i in $rwanted; do
   1.110 +							[ -f $COOKING/clean-wok/$i/receipt ] || cp -a $REPO_WOK/$i $COOKING/clean-wok/$i
   1.111 +							[ -f $COOKING/wok/$i/receipt ] || cp -a $REPO_WOK/$i $COOKING/wok/$i
   1.112 +						done
   1.113 +						[ -f $COOKING/clean-wok/$pkg/receipt ] || cp -a $REPO_WOK/$pkg $COOKING/clean-wok/$pkg
   1.114 +						[ -f $COOKING/wok/$pkg/receipt ] || cp -a $REPO_WOK/$pkg $COOKING/wok/$pkg
   1.115  					done
   1.116 -					[ -f $COOKING/clean-wok/$pkg/receipt ] || cp -a $REPO_WOK/$pkg $COOKING/clean-wok/$pkg
   1.117 -					[ -f $COOKING/wok/$pkg/receipt ] || cp -a $REPO_WOK/$pkg $COOKING/wok/$pkg
   1.118 -				done
   1.119 -				unset i
   1.120 -				tazwok gen-wok-db --WOK=$COOKING/clean-wok
   1.121 +					unset i
   1.122 +					tazwok gen-wok-db --WOK=$COOKING/clean-wok
   1.123 +				fi
   1.124  			else
   1.125  				[ -d $COOKING/clean-wok ] || ln -sf $REPO_WOK $COOKING/clean-wok
   1.126  				[ -d $COOKING/wok ] || ln -sf $REPO_WOK $COOKING/wok
   1.127 @@ -138,7 +177,7 @@
   1.128  		;;
   1.129  		boot)
   1.130  			[ -d $BOOT_WWW_DIR ] && cp -a $BOOT_WWW_DIR $MAIN_WWW_DIR/$b
   1.131 -			[ -d $REPOS_DIR/website/pics ] && ln -sf $REPOS_DIR/website/pics $MAIN_WWW_DIR/$b/pics
   1.132 +			#[ -d $REPOS_DIR/website/pics ] && ln -sf $REPOS_DIR/website/images $MAIN_WWW_DIR/$b/images
   1.133  		;;
   1.134  		tank)
   1.135  			[ -d $TANK_WWW_DIR ] && ln -sf $TANK_WWW_DIR $MAIN_WWW_DIR/$b
   1.136 @@ -245,7 +284,7 @@
   1.137  }
   1.138  
   1.139  case "$COMMAND" in 
   1.140 -	on|tank-only|mirror-only)
   1.141 +	start|on|tank-only|mirror-only)
   1.142  		[ -d $MAIN_WWW_DIR/mirror-info ] && WWW="${WWW/mirror /}"
   1.143  		for c in $WWW; do
   1.144  			if [ ! -d $MAIN_WWW_DIR/$c ]; then
   1.145 @@ -253,14 +292,36 @@
   1.146  				[ "$c" = "hg" ] && repos
   1.147  			fi
   1.148  		done
   1.149 -		echo "127.0.0.1 localhost $(cat /etc/hostname) tazpanel" > /etc/hosts
   1.150 +		echo "127.0.0.1 localhost $(cat /etc/hostname)" > /etc/hosts
   1.151 +		[ "$IP_ADDR" == "127.0.0.1" ] && echo "127.0.0.1 tazpanel tazpanel.slitaz.org" >> /etc/hosts
   1.152  		for hostname in $ADDRESS; do 
   1.153 -				#if [ ! $(grep -l "${BASE_IP}.$i $hostname" /etc/hosts) ]; then
   1.154 +				if [ "$hostname" = "www.slitaz.org" ]; then
   1.155 +					echo "$IP_ADDR $hostname slitaz.org"
   1.156 +				else
   1.157  					echo "$IP_ADDR $hostname" >> /etc/hosts
   1.158 -				#fi
   1.159 -		done
   1.160 +				fi
   1.161 +		done		
   1.162 +		if [ -f /usr/share/awstats/extras/update ]; then
   1.163 +			if [ ! $(grep -l "/usr/share/awstats/extras/update" $CRON_FILE) ]; then
   1.164 +				echo "# Update Web stats" >> $CRON_FILE
   1.165 +				echo "*/5 * * * /usr/share/awstats/extras/update" >> $CRON_FILE
   1.166 +			fi
   1.167 +		fi
   1.168 +		if [ -f $MAIN_WWW_DIR/tank/bin/makegraphs ]; then
   1.169 +			if [ ! $(grep -l "$MAIN_WWW_DIR/tank/bin/makegraphs" $CRON_FILE) ]; then
   1.170 +				echo "# Update system load graphics" >> $CRON_FILE
   1.171 +				echo "*/5 * * * * $MAIN_WWW_DIR/tank/bin/makegraphs" >> $CRON_FILE
   1.172 +			fi
   1.173 +		fi
   1.174 +		if [ -f "/usr/bin/tazpkg-web" ]; then
   1.175 +			if [ ! $(grep -l "/usr/bin/tazpkg-web cooking" $CRON_FILE) ]; then
   1.176 +				echo "# Update pkgs.slitaz.org pages" >> $CRON_FILE
   1.177 +				echo "20 02 * * * /usr/bin/tazpkg-web cooking" >> $CRON_FILE
   1.178 +			fi
   1.179 +		fi
   1.180  		if [ "$IP_ADDR" != "127.0.0.1" ]; then
   1.181 -			if [ ! $(grep -l 'dhcp-option=option:router' /etc/dnsmasq.conf) ]; then
   1.182 +			if [ ! $(grep -l "dhcp-option=option:router,$ROUTER_IP" /etc/dnsmasq.conf) ]; then
   1.183 +				echo "$IP_ADDR tazpanel tazpanel.slitaz.org" >> /etc/hosts
   1.184  				echo "dhcp-option=option:router,$ROUTER_IP" >> /etc/dnsmasq.conf
   1.185  			fi
   1.186  		fi
   1.187 @@ -273,7 +334,8 @@
   1.188  			[ -f $VHOST_FILE ] && ln -sf $VHOST_FILE /etc/lighttpd/vhosts.conf
   1.189  		fi
   1.190  		chown -R www.www $SLITAZ_DIR/www
   1.191 -		[ -f /etc/init.d/lighttpd ] && /etc/init.d/lighttpd start
   1.192 +		[ -x /etc/init.d/lighttpd ] && /etc/init.d/lighttpd start
   1.193 +		[ -x /etc/init.d/crond ] && /etc/init.d/crond start
   1.194  		;;
   1.195  	update-repos)
   1.196  		for i in $(ls $REPOS_DIR); do
   1.197 @@ -284,9 +346,20 @@
   1.198  			fi
   1.199  		done
   1.200  		;;
   1.201 +	up-src-links)
   1.202 +		if [ -d $SRCDIR ]; then
   1.203 +			[ -d $MAIN_WWW_DIR/slitaz/mirror/sources/packages ] && rm -rf $MAIN_WWW_DIR/slitaz/mirror/sources/packages
   1.204 +			for i in $(ls $SRCDIR); do
   1.205 +				[ -d $MAIN_WWW_DIR/slitaz/mirror/sources/packages/${i:0:1} ] || mkdir -p $MAIN_WWW_DIR/slitaz/mirror/sources/packages/${i:0:1}
   1.206 +				[ -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
   1.207 +			done
   1.208 +			unset i
   1.209 +		fi
   1.210 +		;;
   1.211  	off)
   1.212 -		[ -f /etc/init.d/lighttpd ] && /etc/init.d/lighttpd stop
   1.213 -		echo "127.0.0.1 localhost $(cat /etc/hostname)" > /etc/hosts
   1.214 +		[ -x /etc/init.d/lighttpd ] && /etc/init.d/lighttpd stop
   1.215 +		[ -x /etc/init.d/crond ] && /etc/init.d/crond stop
   1.216 +		echo "127.0.0.1 localhost $(cat /etc/hostname) tazpanel" > /etc/hosts
   1.217  		exit 1
   1.218  		;;
   1.219  	*)