fbs diff fbs @ rev 6

Add a minimal rcS boot script for example (from ARM version but usable on a desktop)
author Christophe Lincoln <pankso@slitaz.org>
date Fri May 02 14:14:56 2014 +0200 (2014-05-02)
parents
children 2736565d8cf9
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/fbs	Fri May 02 14:14:56 2014 +0200
     1.3 @@ -0,0 +1,152 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# Fbs - Graphical framebuffer boot using Busybox fbsplash applet. No use of SliTaz
     1.7 +# specific code since it may be used by other distro or emb system.
     1.8 +#
     1.9 +# (C) 2014 Christophe Lincoln - BSD License.
    1.10 +#
    1.11 +
    1.12 +sysconf="/etc/fbs.conf"
    1.13 +themes="/usr/share/fbs"
    1.14 +fifo="/fbs.fifo"
    1.15 +
    1.16 +[ -f "${sysconf}" ] && . ${sysconf}
    1.17 +[ -f "fbs.conf" ] && . fbs.conf
    1.18 +[ "$2" ] && FBTHEME="$2"
    1.19 +
    1.20 +# Functions
    1.21 +
    1.22 +boldify() { 
    1.23 +	echo -e "\033[1m$@\033[0m"
    1.24 +}
    1.25 +
    1.26 +usage() {
    1.27 +	cat << EOT
    1.28 +
    1.29 +Framebuffer Boot Splash utility
    1.30 +
    1.31 +$(boldify "Usage:") $(basename $0) [command] [theme]
    1.32 +
    1.33 +$(boldify "Commands:")
    1.34 +  on            Enable graphical boot
    1.35 +  off           Disable graphical boot
    1.36 +  test          Test a splash theme
    1.37 +  themes        List all installed themes
    1.38 +  set-theme     Change current theme
    1.39 +  pack-theme    Pack a system theme
    1.40 +  add-theme     Install a fbs-theme archive
    1.41 +
    1.42 +EOT
    1.43 +}
    1.44 +
    1.45 +check_root() {
    1.46 +	if [ $(id -u) != "0" ]; then
    1.47 +		echo "Only root adiministrator can run fbs $1" && exit 1
    1.48 +	fi
    1.49 +}
    1.50 +
    1.51 +separator() {
    1.52 +	echo "--------------------------------------"
    1.53 +}
    1.54 +
    1.55 +set_theme() {
    1.56 +	sed -i s'~FBTHEME=.*~FBTHEME=\"$new_theme\"~' /etc/fbs.conf
    1.57 +}
    1.58 +
    1.59 +start_fbsplash() {
    1.60 +	[ -x "$themes/$FBTHEME/init.sh" ] && \
    1.61 +		${themes}/${FBTHEME}/init.sh
    1.62 +	mkfifo ${fifo}
    1.63 +	fbsplash -c -f ${fifo} \
    1.64 +		-s $themes/$FBTHEME/splash.ppm.gz \
    1.65 +		-i $themes/$FBTHEME/splash.cfg &
    1.66 +}
    1.67 +
    1.68 +# Commands
    1.69 +
    1.70 +case "$1" in
    1.71 +
    1.72 +	on)
    1.73 +		# Enable graphical boot
    1.74 +		check_root
    1.75 +		echo "Enabling SliTaz graphical boot..."
    1.76 +		if ! grep -q "rcS > /dev/null 2>/dev/null" /etc/inittab; then		
    1.77 +			sed -i s'#rcS#rcS >/dev/null 2>/dev/null#' /etc/inittab
    1.78 +		fi
    1.79 +		sed -i s'/FBSPLASH=.*/FBSPLASH="on"/' /etc/fbs.conf ;;
    1.80 +		
    1.81 +	off)
    1.82 +		# Disable graphical boot
    1.83 +		check_root
    1.84 +		echo "Disabling SliTaz graphical boot..."
    1.85 +		sed -i s'#rcS >/dev/null 2>/dev/null#rcS#' /etc/inittab
    1.86 +		sed -i s'/FBSPLASH=.*/FBSPLASH="off"/' /etc/fbs.conf ;;
    1.87 +	
    1.88 +	'test')
    1.89 +		# Testsuite for fbs 
    1.90 +		reset && start_fbsplash
    1.91 +		for p in 0 10 20 30 40 50 60 70 80 90 100
    1.92 +		do
    1.93 +			echo "$p" > ${fifo} && sleep 1
    1.94 +		done #> /dev/null
    1.95 +		echo "exit" > ${fifo}
    1.96 +		clear && rm -f ${fifo};;
    1.97 +	
    1.98 +	themes)
    1.99 +		# List all themes
   1.100 +		echo ""
   1.101 +		boldify "Fbs themes list"
   1.102 +		separator
   1.103 +		cd ${themes}
   1.104 +		ls -1 && echo "" ;;
   1.105 +		
   1.106 +	set-theme)
   1.107 +		check_root
   1.108 +		new_theme="$2"
   1.109 +		[ "$new_theme" ] || exit 0
   1.110 +		[ -d "$themes/$new_theme" ] || exit 0
   1.111 +		echo -n "Enabling fbs theme: $new_theme"
   1.112 +		set_theme; status ;;
   1.113 +		
   1.114 +	pack-theme)
   1.115 +		# Pack a theme into .tar.gz
   1.116 +		theme="$2"
   1.117 +		tmp=fbs-theme-$theme
   1.118 +		if [ ! -d "$themes/$theme" ]; then
   1.119 +			echo "No theme found in: $themes/$theme"; exit 0
   1.120 +		fi
   1.121 +		echo -n "Creating fbs theme archive: $theme"
   1.122 +		mkdir -p $tmp
   1.123 +		cp -r $themes/$theme $tmp
   1.124 +		cat > $tmp/README << EOT
   1.125 +Fbs theme - Framebuffer Splash boot artwork
   1.126 +$(separator)
   1.127 +
   1.128 +
   1.129 +This is a Busybox fbsplash theme created by $USER. To use it you can copy
   1.130 +files manually to $themes or use 'fbs add-theme'
   1.131 +
   1.132 +
   1.133 +$(separator)
   1.134 +EOT
   1.135 +		busybox tar czf fbs-theme-$theme.tar.gz $tmp
   1.136 +		rm -rf $tmp; status ;;
   1.137 +		
   1.138 +	add-theme)
   1.139 +		check_root
   1.140 +		file=$2
   1.141 +		if [ ! -f "$file" ]; then
   1.142 +			echo "Missing theme archive: $file"; exit 0
   1.143 +		fi
   1.144 +		echo -n "Installing fbs theme: ${file%.tar.gz}"
   1.145 +		tar xzf $file -C /tmp
   1.146 +		rm /tmp/fbs-theme-*/README
   1.147 +		cp -r /tmp/fbs-*/* ${themes}
   1.148 +		status ;;
   1.149 +		
   1.150 +	start) start_fbsplash ;;
   1.151 +	
   1.152 +	*) usage ;;
   1.153 +	
   1.154 +esac
   1.155 +exit 0