cookutils rev 163

Add init script and doc hwoto used it
author Christophe Lincoln <pankso@slitaz.org>
date Sun May 15 15:21:18 2011 +0200 (2011-05-15)
parents f1c83137e788
children cd039ff446c4
files Makefile doc/cookutils.en.html init.d/cooker
line diff
     1.1 --- a/Makefile	Sun May 15 00:19:54 2011 +0200
     1.2 +++ b/Makefile	Sun May 15 15:21:18 2011 +0200
     1.3 @@ -7,14 +7,17 @@
     1.4  all:
     1.5  
     1.6  install:
     1.7 +	install -m 0777 -d $(DESTDIR)/etc/slitaz
     1.8 +	install -m 0777 -d $(DESTDIR)$(PREFIX)/bin
     1.9 +	install -m 0777 -d $(DESTDIR)/var/www/cgi-bin/cooker
    1.10 +	install -m 0777 -d $(DESTDIR)$(PREFIX)/share/cook
    1.11  	install -m 0777 cook $(DESTDIR)$(PREFIX)/bin
    1.12  	install -m 0777 cooker $(DESTDIR)$(PREFIX)/bin
    1.13  	install -m 0644 cook.conf $(DESTDIR)/etc/slitaz
    1.14  	install -m 0644 cook.site $(DESTDIR)/etc/slitaz
    1.15 -	install -m 0777 -d $(DESTDIR)/var/www/cgi-bin/cooker
    1.16 -	install -m 0777 -d $(DESTDIR)$(PREFIX)/share/cook
    1.17  	install -m 0644 web/* $(DESTDIR)/var/www/cgi-bin/cooker
    1.18  	cp -r data/* $(DESTDIR)$(PREFIX)/share/cook
    1.19 +	cp -r init.d $(DESTDIR)/etc
    1.20  
    1.21  uninstall:
    1.22  	rm -rf \
     2.1 --- a/doc/cookutils.en.html	Sun May 15 00:19:54 2011 +0200
     2.2 +++ b/doc/cookutils.en.html	Sun May 15 15:21:18 2011 +0200
     2.3 @@ -352,7 +352,22 @@
     2.4  	to run the Cooker every 2 hours:
     2.5  </p>
     2.6  <pre>
     2.7 -*/2 * * * * /usr/bin/cooker
     2.8 +* */2 * * * /usr/bin/cooker
     2.9 +</pre>
    2.10 +
    2.11 +<h3>Cooker BB started at boot</h3>
    2.12 +<p>
    2.13 +	The Cooker environment and deamon can automaticaly started at boot time. You
    2.14 +	must have cookutils installed on the host and use standard SliTaz to make it
    2.15 +	work properly (cooking goes in /home/slitaz/cooking). The deamon script will
    2.16 +	mount virtual filesystems if needed as well as source and packages. Sources
    2.17 +	files are in /home/slitaz/src and binded into the chroot so you can share
    2.18 +	packages source between several version (stable, cooking, undiguest). To
    2.19 +	start the daemon you must have a cron file definition for root in the chroot,
    2.20 +	the deamon script work like all other system daemon and can be handled with:
    2.21 +</p>
    2.22 +<pre>
    2.23 +# /etc/init.d/cooker [start|stop|restart]
    2.24  </pre>
    2.25  
    2.26  <!-- End content -->
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/init.d/cooker	Sun May 15 15:21:18 2011 +0200
     3.3 @@ -0,0 +1,49 @@
     3.4 +#!/bin/sh
     3.5 +# /etc/init.d/cooker: Start, stop or restart Cooker daemon.
     3.6 +#
     3.7 +. /etc/slitaz/cook.conf
     3.8 +
     3.9 +case "$i" in
    3.10 +	start)
    3.11 +		# When 4.0: for version in stable cooking undigest
    3.12 +		for version in cooking
    3.13 +		do
    3.14 +			if [ -d "$SLITAZ/$version/chroot" ]; then
    3.15 +				echo "Starting $version cooker..."
    3.16 +				rootfs=$SLITAZ/$version/chroot
    3.17 +				if [ ! -d $rootfs/proc/1 ]; then
    3.18 +					mount -t proc proc $rootfs/proc
    3.19 +					mount -t sysfs sysfs $rootfs/sys
    3.20 +					mount -t devpts devpts $rootfs/dev/pts
    3.21 +					mount -t tmpfs shm $rootfs/dev/shm
    3.22 +				fi
    3.23 +				if [ ! $(mount | grep -q ${roots}$SLITAZ/src) ]
    3.24 +					mount -o bind $SLITAZ/src ${rootfs}$SLITAZ/src
    3.25 +					mount -o bind $SLITAZ/$version/packages \
    3.26 +						${rootfs}$SLITAZ/packages
    3.27 +				fi
    3.28 +				# Start cron in chroot.
    3.29 +				chroot $rootfs /etc/init.d/cron start
    3.30 +			fi
    3.31 +		done ;;
    3.32 +	stop)
    3.33 +		for version in cooking
    3.34 +		do
    3.35 +			rootfs=$SLITAZ/$version/chroot
    3.36 +			if [ -d "$SLITAZ/$version/chroot" ]; then
    3.37 +				echo "Stoping $version cooker..."
    3.38 +				# Stop cron in chroot.
    3.39 +				chroot $rootfs /etc/init.d/cron stop
    3.40 +				for i in /dev/shm /dev/pts /sys /proc $SLITAZ/src $SLITAZ/packages
    3.41 +				do
    3.42 +					umount ${rootfs}$i
    3.43 +				done
    3.44 +			fi
    3.45 +		done ;;
    3.46 +	restart)
    3.47 +		$0 stop && sleep 2 && $0 start ;;
    3.48 +	*)
    3.49 +		echo "Usage: $0 [start|stop|restart]" ;;
    3.50 +esac
    3.51 +
    3.52 +exit 0