wok rev 18245

Add tazpanel-extra
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jul 31 23:33:17 2015 +0200 (2015-07-31)
parents a81e49dbaf30
children 1970bb96ea6c
files tazpanel-extra/receipt tazpanel-extra/stuff/bootloader tazpanel-extra/stuff/floppy.cgi tazpanel-extra/stuff/powersaving.cgi
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tazpanel-extra/receipt	Fri Jul 31 23:33:17 2015 +0200
     1.3 @@ -0,0 +1,24 @@
     1.4 +# SliTaz package receipt.
     1.5 +
     1.6 +PACKAGE="tazpanel-extra"
     1.7 +VERSION="1.0"
     1.8 +CATEGORY="system-tools"
     1.9 +SHORT_DESC="SliTaz administration and configuration panel extra modules."
    1.10 +MAINTAINER="pascal.bellard@slitaz.org"
    1.11 +LICENSE="BSD"
    1.12 +WEB_SITE="http://www.slitaz.org/"
    1.13 +HOST_ARCH="i486"
    1.14 +
    1.15 +DEPENDS="tazpanel"
    1.16 +
    1.17 +# Rules to gen a SliTaz package suitable for Tazpkg.
    1.18 +genpkg_rules()
    1.19 +{
    1.20 +	mkdir -p $fs/var/www/tazpanel/menu.d/boot $fs/usr/bin \
    1.21 +		 $fs/var/www/tazpanel/menu.d/hardware
    1.22 +	cp -a $stuff/bootloader $fs/usr/bin/
    1.23 +	cp -a $stuff/floppy.cgi $fs/var/www/tazpanel/
    1.24 +	ln -s ../../floppy.cgi $fs/var/www/tazpanel/menu.d/boot/floppy
    1.25 +	cp -a $stuff/powersaving.cgi $fs/var/www/tazpanel/
    1.26 +	ln -s ../../powersaving.cgi $fs/var/www/tazpanel/menu.d/hardware/powersaving
    1.27 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tazpanel-extra/stuff/bootloader	Fri Jul 31 23:33:17 2015 +0200
     2.3 @@ -0,0 +1,395 @@
     2.4 +#!/bin/sh
     2.5 +#
     2.6 +# This script creates a floppy image set from a linux bzImage and can merge
     2.7 +# a cmdline and/or one or more initramfs.
     2.8 +#
     2.9 +# (C) 2009-2015 Pascal Bellard - GNU General Public License v3.
    2.10 +
    2.11 +usage()
    2.12 +{
    2.13 +cat <<EOT
    2.14 +Usage: $0 bzImage [--prefix image_prefix] [--info file] [--quiet]
    2.15 +       [--format 1200|1440|1680|1920|2880|...] [--mem mb] [--tracks cnt]
    2.16 +       [--rdev device] [--video mode] [--flags rootflags] [--no-syssize-fix]
    2.17 +       [--dont-edit-cmdline] [--cmdline 'args'] [--hide-version-string]
    2.18 +       [--address-initrd address] [--initrd initrdfile]...
    2.19 +
    2.20 +Default values: --format 1440 --tracks 80 --rdev /dev/fd0 --prefix floppy. --mem 16
    2.21 +
    2.22 +Example:
    2.23 +$0 /boot/bzImage --rdev /dev/ram0 --video -3 --cmdline 'rw lang=fr_FR kmap=fr-latin1 laptop autologin' --initrd /boot/rootfs.gz --initrd ./myconfig.gz
    2.24 +
    2.25 +or: $0 --extract floppy*
    2.26 +
    2.27 +Create kernel and maybe cmdline, initrd and info files from a floppy images set 
    2.28 +EOT
    2.29 +exit 1
    2.30 +}
    2.31 +
    2.32 +# bzImage offsets
    2.33 +SetupSzOfs=497
    2.34 +FlagsOfs=498
    2.35 +OldRamfsLenOfs=504
    2.36 +VideoModeOfs=506
    2.37 +RootDevOfs=508
    2.38 +Magic=0x202
    2.39 +RamfsAdrOfs=0x218
    2.40 +RamfsLenOfs=0x21C
    2.41 +
    2.42 +ddq() { dd $@ 2> /dev/null; }
    2.43 +
    2.44 +get()
    2.45 +{
    2.46 +echo $( od -v -j $(($1)) -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An $2 2>/dev/null ||
    2.47 +	hexdump -v -s $(($1)) -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %d\n\"" $2 )
    2.48 +}
    2.49 +
    2.50 +trace()
    2.51 +{
    2.52 +	[ -n "$DEBUG" ] && printf "$@" 1>&2 && echo 1>&2
    2.53 +}
    2.54 +
    2.55 +# usage: store bits offset data file
    2.56 +store()
    2.57 +{
    2.58 +	n=$3; for i in $(seq 8 8 $1); do
    2.59 +		printf '\\\\x%02X' $(($n & 255))
    2.60 +		n=$(($n >> 8))
    2.61 +	done | xargs echo -en | ddq bs=1 conv=notrunc of=$4 seek=$(($2))
    2.62 +	s=$1; a=$2; d=$3; shift 4; c="$@"
    2.63 +	trace "store$s(%03X) = %0$(($s/4))X	$c" $a $d
    2.64 +}
    2.65 +
    2.66 +die()
    2.67 +{
    2.68 +	echo $@ 1>&2
    2.69 +	exit 1
    2.70 +}
    2.71 +extract()
    2.72 +{
    2.73 +	shift
    2.74 +	[ ! -s "$1" ] && die "No floppy ?"
    2.75 +	[ $(get 0x1FE "$1") -ne 43605 ] && die "Not bootable"
    2.76 +	[ $(get $Magic "$1" 4) != 1400005704 ] &&
    2.77 +	[ $(get 0x1F4 "$1") -gt 32768 -o $(get 0x1F6 "$1") -ne 0 ] &&
    2.78 +	die "Not linux."
    2.79 +	FORMAT="$(($(stat -c "%s" $1)/1024))"
    2.80 +	cat <<EOT
    2.81 +--format $FORMAT
    2.82 +--rdev $(printf "0x%04X" $(get $RootDevOfs $1))
    2.83 +--video $(get $VideoModeOfs $1)
    2.84 +--flags $(get $FlagsOfs $1)
    2.85 +EOT
    2.86 +	MYBB="$(ddq if=$1 bs=512 count=1 | strings | grep "Insert disk 00")"
    2.87 +	cmdline=0
    2.88 +	info=0
    2.89 +	if [ "$MYBB" ]; then
    2.90 +		cmdline=$(get 0x22 $1)
    2.91 +		info=$(get 0x1EF $1)
    2.92 +		[ $(get 0x75 $1) -eq $((0xDB0)) ] && echo "--dont-edit-cmdline"
    2.93 +		[ $(get 0x58 $1) -eq $((0x9090)) ] && echo "--hide-version-string"
    2.94 +	fi
    2.95 +	n=$(($(get $SetupSzOfs $1 1)+1))
    2.96 +	[ $n -eq 1 ] && n=5
    2.97 +	[ $info -ne 0 ] && infolen=$(($n-$info/512)) && n=$(($info/512))
    2.98 +	[ $cmdline -ne 0 ] && n=$(($cmdline/512))
    2.99 +	cat "$@" | {
   2.100 +		ddq bs=512 count=$n >kernel
   2.101 +		files="kernel"
   2.102 +		if [ "$MYBB" ]; then
   2.103 +			store 8 $SetupSzOfs $(($n-1)) kernel "setup size $n"
   2.104 +			store 16 0x22 0 kernel "clear cmdline"
   2.105 +			store 16 0x1EF 0 kernel "clear info"
   2.106 +		fi
   2.107 +		[ $cmdline -ne 0 ] && files="$files cmdline" &&
   2.108 +		ddq bs=512 count=1 | strings | sed q > cmdline
   2.109 +		[ $info -ne 0 ] && files="$files info" &&
   2.110 +		ddq bs=512 count=$infolen | sed \
   2.111 +		 's/'$(echo -en "\xff\xff$//;s/\xff/\f")'/g;s/\r/\n/g;q' > info
   2.112 +		syssz=$(get 0x1F4 kernel 4)
   2.113 +		ddq bs=16 count=$syssz >>kernel
   2.114 +		[ $(($syssz % 32)) -ne 0 ] &&
   2.115 +		ddq bs=16 of=/dev/null count=$((32 - ($syssz % 32)))
   2.116 +		if [ $(get $Magic kernel 4) == 1400005704 ]; then
   2.117 +	  		ddq bs=1 count=200 skip=$((512+$(get 0x20E kernel 2))) \
   2.118 +	  			if=kernel | strings | sed q
   2.119 +			len=$(get $RamfsLenOfs kernel 4)
   2.120 +			if [ $len -ne 0 ]; then
   2.121 +				adrs=$(get $RamfsAdrOfs kernel 4)
   2.122 +				printf "--address-initrd 0x%X \n" $adrs
   2.123 +				echo "--mem $(((($adrs+$len)/1024+512)/1024))"
   2.124 +				ddq bs=512 count=$((($len+511)/512)) > initrd
   2.125 +				ddq count=0 bs=1 seek=$len of=initrd
   2.126 +				files="$files initrd"
   2.127 +				store 64 $RamfsAdrOfs 0 kernel "reset initrd"
   2.128 +			fi
   2.129 +			if [ $(get 0x206 kernel) -ge 514 ]; then
   2.130 +				store 32 0x228 0 kernel "clean cmdline32"
   2.131 +			fi
   2.132 +		else
   2.133 +			len=$(get $OldRamfsLenOfs kernel)
   2.134 +			[ $len -ne 0 ] && files="$files initrd" &&
   2.135 +			if [ -s "$2" ]; then
   2.136 +				ddq if=$2 bs=1024 count=$len of=initrd
   2.137 +			else
   2.138 +				ddq if=$1 bs=1024 skip=256 count=$len of=initrd
   2.139 +			fi
   2.140 +		fi
   2.141 +		ls -l $files
   2.142 +	}
   2.143 +	exit
   2.144 +}
   2.145 +
   2.146 +KERNEL=""
   2.147 +INITRD=""
   2.148 +ADRSRD=""
   2.149 +CMDLINE=""
   2.150 +PREFIX="floppy."
   2.151 +FORMAT="1440"
   2.152 +RDEV=""
   2.153 +VIDEO=""
   2.154 +FLAGS=""
   2.155 +TRACKS="80"
   2.156 +MEM="16"
   2.157 +HIDE=""
   2.158 +NOEDIT=""
   2.159 +QUIET=""
   2.160 +NOSYSSIZEFIX=""
   2.161 +INFOFILE=""
   2.162 +DEBUG=""
   2.163 +while [ -n "$1" ]; do
   2.164 +	case "${1/--/-}" in
   2.165 +	-c*) CMDLINE="$2"; shift;;
   2.166 +	-inf*) INFOFILE="$2"; shift;;
   2.167 +	-i*) INITRD="$INITRD $2"; shift;;
   2.168 +	-a*) ADRSRD="$2"; shift;;
   2.169 +	-h*) HIDE="1";;
   2.170 +	-p*) PREFIX="$2"; shift;;
   2.171 +	-fl*)FLAGS="$2"; shift;;	# 1 read-only, 0 read-write
   2.172 +	-f*) FORMAT="$2"; shift;;
   2.173 +	-m*) MEM="$(echo $2 | sed 's/[^0-9]//g')"; shift;;
   2.174 +	-r*) RDEV="$2"; shift;;
   2.175 +	-v*) VIDEO="$2"; shift;;	# -3 .. n
   2.176 +	-t*) TRACKS="$2"; shift;;	# likely 81 .. 84
   2.177 +	-n*) NOSYSSIZEFIX="1";;
   2.178 +	-debug) DEBUG="1";;
   2.179 +	-d*) NOEDIT="1";;
   2.180 +	-q*) QUIET="1";;
   2.181 +	-e*) extract "$@";;
   2.182 +	*) KERNEL="$1";;
   2.183 +	esac
   2.184 +	shift
   2.185 +done
   2.186 +[ -n "$KERNEL" -a -f "$KERNEL" ] || usage
   2.187 +while [ -L "$KERNEL" ]; do KERNEL="$(readlink "$KERNEL")"; done
   2.188 +if [ $(( $FORMAT % $TRACKS )) -ne 0 ]; then
   2.189 +	echo "Invalid track count for format $FORMAT."
   2.190 +	usage
   2.191 +fi
   2.192 +[ 0$MEM -lt 2  ] && MEM=2
   2.193 +
   2.194 +patch()
   2.195 +{
   2.196 +	echo -en $(echo ":$2" | sed 's/:/\\x/g') | \
   2.197 +		ddq bs=1 conv=notrunc of=$3 seek=$((0x$1))
   2.198 +	trace "patch $1 $2		$4"
   2.199 +}
   2.200 +
   2.201 +error()
   2.202 +{
   2.203 +	rm -f $bs
   2.204 +	die $@
   2.205 +}
   2.206 +
   2.207 +floppyset()
   2.208 +{
   2.209 +	# boot+setup address
   2.210 +	SetupBase=0x90000
   2.211 +
   2.212 +	bs=/tmp/bs$$
   2.213 +
   2.214 +	# Get and patch boot sector
   2.215 +	# See http://hg.slitaz.org/wok/raw-file/13835bce7189/syslinux/stuff/iso2exe/bootloader.S
   2.216 +	trace "Read bootsector..."
   2.217 +	ddq if=$KERNEL bs=512 count=1 of=$bs
   2.218 +
   2.219 +	[ $(get 0x1FE $bs) -eq 43605 ] || error "Not bootable"
   2.220 +	
   2.221 +	uudecode <<EOT | ddq of=$bs conv=notrunc
   2.222 +begin-base64 644 -
   2.223 +v8adaACQF4n8FgcxwLk7APOqWx+g8X1AD6H6xXd4XwZXvQAAsQbzpRYfZGaP
   2.224 +R3jGRfg/l1hB6CQBMfYLNu8BdAzoggF0B+hgATwbdfS+AAKBTBAggMZEJZvo
   2.225 +ZwEx9gt3G3Q6x0cZP6PoWwGwIOgtASwYc/lO6DEBmDwIdAOIBK05dxt08OgV
   2.226 +ATwKdd+IfP4WB78AgIn+h3cbtQLzpFuJ5v9IEMdAFAiTgPMIdfO79AGxBaEV
   2.227 +AmaLH2ZLZtPrZkOJRBtmv4AAAABmKfuccwIB31BTVjHbaACAB+hwAF5bjMG0
   2.228 +hxYHzRVYBQABEEwfnXfPuQkCuxwCOE/+che0iM0VPQCwcgaIbB+Ib/+hGQLT
   2.229 +b+J1o5fNE+oAACCQWjjBdzRgzRP56HMAYVJQKMh3ArABOfhyAon4ULQCzRNa
   2.230 +WHLclQHRjukA1wDXKddadE2M6ZU4wXXUiMixATDOdcz+xYD9UHXFtQBgvtEB
   2.231 +U7sPAIAg8Ev+AIA4OXf16EwAW4n16CkAdRVSmM0TuAECzRNa0NQ6Zv516kVI
   2.232 +debrjbAxHAO0DrsHAM0QPA1088O/bARkxgWmuA0BZDoldArNFnT0mM0WjudH
   2.233 +wwN0DrAN6NL/rDwAf/jDSW5zZXJ0IGRpc2sgMDAxIGFuZCBFbnRlci4HDQAA
   2.234 +AAA=
   2.235 +====
   2.236 +EOT
   2.237 +	# Get setup
   2.238 +	setupsz=$(get $SetupSzOfs $bs 1)
   2.239 +	if [ $setupsz -eq 0 ]; then
   2.240 +		setupsz=4
   2.241 +		store 8 $SetupSzOfs $setupsz $bs "setup size $setupsz"
   2.242 +	fi
   2.243 +	trace "Read setup ($setupsz sectors) ..."
   2.244 +	ddq if=$KERNEL bs=512 skip=1 count=$setupsz >> $bs
   2.245 +
   2.246 +	Version=$(get 0x206 $bs)
   2.247 +	[ $(get $Magic $bs 4) != 1400005704 ] && Version=0
   2.248 +	feature=""
   2.249 +	while read prot kern info ; do
   2.250 +		[ $Version -lt $((0x$prot)) ] && continue
   2.251 +		feature="features $prot starting from kernel $kern "
   2.252 +	done <<EOT
   2.253 +200	1.3.73	kernel_version, bzImage, initrd, loadflags/type_of_loader
   2.254 +201	1.3.76	heap_end_ptr
   2.255 +202	2.4.0	new cmdline + relocatable setup
   2.256 +204	2.6.14	long syssize
   2.257 +206	2.6.22	cmdline maxsize $(get 0x238 $bs 4)
   2.258 +EOT
   2.259 +	trace "Protocol %X $feature" $Version
   2.260 +	
   2.261 +	# Old kernels need bootsector patches to disable rescent features
   2.262 +	while read minversion maxversion offset bytes rem; do
   2.263 +		[ $Version -gt $(( 0x$maxversion )) ] && continue
   2.264 +		[ $Version -lt $(( 0x$minversion )) ] && continue
   2.265 +		patch $offset $bytes $bs "$rem"
   2.266 +	done <<EOT
   2.267 +000 1FF 0B2	B8:00:01			force zImage (movw \$0x100, %ax)
   2.268 +000 1FF 0F9	EB				skip initrd code 
   2.269 +000 1FF 059	90:90:90			no kernel version
   2.270 +000 1FF 050	90:90:90:90:90			type_of_loader
   2.271 +000 200 055	90:90:90:90			heap_end_ptr
   2.272 +000 203 1F6	00:00 				syssize32
   2.273 +EOT
   2.274 +	[ -n "$CMDLINE" ] || patch 061 EB $bs "No cmdline"
   2.275 +	[ -n "$HIDE" ] && patch 058 90 90 90 $bs "Hide version"
   2.276 +	[ -n "$NOEDIT" ] && patch 075 B0:0D:90 $bs 'mov CR,%al ; nop'
   2.277 +	[ 1$TRACKS -ne 180 ] &&	store	8	0x15F		$TRACKS $bs TRACKS
   2.278 +	
   2.279 +	[ -n "$FLAGS" ] &&	store	16	$FlagsOfs	$FLAGS $bs FLAGS
   2.280 +	[ -n "$VIDEO" ] &&	store	16	$VideoModeOfs	$VIDEO $bs VIDEO
   2.281 +	[ -n "$RDEV" ] || case "$FORMAT" in
   2.282 +		1200)	RDEV=0x0208 ;;
   2.283 +		1440)	RDEV=0x021C ;;
   2.284 +		2880)	RDEV=0x0220 ;;
   2.285 +		*)	RDEV=0x0200 ;;
   2.286 +	esac
   2.287 +	while [ -L "$RDEV" ]; do RDEV="$(readlink "$RDEV")"; done
   2.288 +	[ -b "$RDEV" ] && RDEV=$(stat -c '0x%02t%02T' $RDEV 2> /dev/null)
   2.289 +	store 16 $RootDevOfs $RDEV $bs RDEV
   2.290 +
   2.291 +	[ $FORMAT -lt 720  ] && store 8 0x15F 40	 $bs	360K
   2.292 +	[ $FORMAT -lt 320  ] && store 8 0x158 237	 $bs	160K
   2.293 +	
   2.294 +	extra=0
   2.295 +	# Store cmdline after setup for kernels >= 0.99
   2.296 +	if [ -n "$CMDLINE" ]; then
   2.297 +		CmdlineOfs=$(stat -c '%s' $bs)
   2.298 +		store 16 0x22 $CmdlineOfs $bs "Cmdline @$CmdlineOfs '$CMDLINE'"
   2.299 +		[ $Version -ge 514 ] &&
   2.300 +		store 32 0x228 $(( $SetupBase + 0x8000 )) $bs "Cmdline32"
   2.301 +		echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> $bs
   2.302 +		extra=$(($extra+1))
   2.303 +		store 8 0x1F1  $(($setupsz+$extra))	 $bs	setup size
   2.304 +		[ $Version -ge 512 ] && [ -n "$QUIET" ] &&
   2.305 +		store 8 0x211 $(($(get 0x211 $bs 1) | 32)) $bs suppress early messages
   2.306 +	fi
   2.307 +
   2.308 +	# Info text after setup
   2.309 +	if [ -s "$INFOFILE" ]; then
   2.310 +		InfoOfs=$(stat -c '%s' $bs)
   2.311 +		sed -e ':a;N;$!ba;s/\r\n/\r/g;s/\n/\r/g' \
   2.312 +		    -e 's/'$(echo -e "\f/\xff/g;s/$/\xff\xff")'/' \
   2.313 +			< "$INFOFILE" > $bs.infotext
   2.314 +		ddq if=/dev/zero bs=512 count=1 >>$bs.infotext
   2.315 +		infolen=$(($(stat -c %s $bs.infotext)/512))
   2.316 +		ddq if=$bs.infotext count=$infolen bs=512 >> $bs
   2.317 +		extra=$(($extra+$infolen))
   2.318 +		rm -f $bs.infotext
   2.319 +		store 8 0x1F1  $(($setupsz+$extra))	$bs	setup size
   2.320 +		store 16 0x1EF  $InfoOfs $bs	update infoptr
   2.321 +	fi
   2.322 +
   2.323 +	syssz=$((($(stat -c %s $KERNEL)+15)/16-32*(1+$setupsz)))
   2.324 +	#syssz=$(get 0x1F4 $bs 4)
   2.325 +	sysszsect=$((($syssz+31)/32))
   2.326 +	store 16 $OldRamfsLenOfs 0 $bs clear oldramfs
   2.327 +	INITRD="${INITRD# }"
   2.328 +	INITRDPAD=4
   2.329 +	[ -n "$INITRD" ] &&
   2.330 +	if [ $Version -lt 512 ]; then
   2.331 +		# Compute initramfs location (protocol < 2.00)
   2.332 +		[ $syssz -gt 32768 ] && syssz=$(get 0x1F4 $bs 2)
   2.333 +		[ $syssz -eq 0 ] && syssz=$((0x7F00))
   2.334 +		sysszsect=$((($syssz+31)/32))
   2.335 +		INITRD="${INITRD%%,*}"
   2.336 +		initrdlen=$(stat -c %s "$INITRD")
   2.337 +		store 16 $OldRamfsLenOfs $(($initrdlen/1024)) $bs set oldramfs
   2.338 +		INITRDDISKALIGN=$((0x40000))
   2.339 +		[ $(($initrdlen+$INITRDDISKALIGN)) -gt $(($FORMAT*1024)) -o \
   2.340 +		  $(((512*$sysszsect) + $(stat -c %s $bs))) -gt $INITRDDISKALIGN -o \
   2.341 +		  -n "$ADRSRD" ] && INITRDDISKALIGN=$(($FORMAT*1024))
   2.342 +	else
   2.343 +INITRDRAMALIGN=0x1000
   2.344 +		# Compute initramfs size (protocol >= 2.00)
   2.345 +		initrdlen=0
   2.346 +		INITRDDISKALIGN=0
   2.347 +		for i in ${INITRD//,/ }; do
   2.348 +			[ -s "$i" ] || continue
   2.349 +			while [ -L "$i" ]; do i="$(readlink $i)"; done
   2.350 +			size=$(stat -c %s "$i")
   2.351 +			trace "initrd $i $size "
   2.352 +			initrdlen=$(((($initrdlen + $INITRDPAD - 1) & -$INITRDPAD) + $size))
   2.353 +			ADRSRD2=$(( (($MEM * 0x100000) - $initrdlen) & -$INITRDRAMALIGN ))
   2.354 +			store 32 $RamfsAdrOfs $(( ${ADRSRD:-$ADRSRD2} )) $bs initrd adrs
   2.355 +			store 32 $RamfsLenOfs $initrdlen $bs initrdlen
   2.356 +		done
   2.357 +	fi
   2.358 +
   2.359 +	[ -n "$NOSYSSIZEFIX" ] || store 32 0x1F4 $syssz $bs fix system size
   2.360 +
   2.361 +	# Output boot sector + setup + cmdline + info
   2.362 +	ddq if=$bs
   2.363 +
   2.364 +	# Output kernel code
   2.365 +	[ $INITRDDISKALIGN -ne 0 ] &&
   2.366 +	INITRDDISKALIGN=$(($INITRDDISKALIGN/512-$sysszsect-$extra-$setupsz-1))
   2.367 +	cat $KERNEL /dev/zero | ddq bs=512 skip=$(( $setupsz+1 )) \
   2.368 +		count=$(($sysszsect+$INITRDDISKALIGN)) conv=sync
   2.369 +
   2.370 +	# Output initramfs
   2.371 +	padding=$INITRDPAD
   2.372 +	for i in ${INITRD//,/ }; do
   2.373 +		[ -s "$i" ] || continue
   2.374 +		[ $padding -eq $INITRDPAD ] || ddq if=/dev/zero bs=1 count=$padding
   2.375 +		ddq if=$i
   2.376 +		trace "initrd $i ($(stat -c %s $i) bytes) padding $INITRDPAD"
   2.377 +		padding=$(( $INITRDPAD - ($(stat -c %s $i) % $INITRDPAD) ))
   2.378 +	done
   2.379 +
   2.380 +	# Cleanup
   2.381 +	rm -f $bs
   2.382 +}
   2.383 +
   2.384 +if [ "$FORMAT" == "0" ]; then # unsplitted
   2.385 +	floppyset > $PREFIX
   2.386 +	PAD=$(( 512 - ($(stat -c %s $PREFIX) % 512) ))
   2.387 +	[ $PAD -ne 512 ] && ddq if=/dev/zero bs=1 count=$PAD >> $PREFIX
   2.388 +	exit
   2.389 +fi
   2.390 +floppyset | split -b ${FORMAT}k /dev/stdin floppy$$
   2.391 +i=1
   2.392 +ls floppy$$* 2> /dev/null | while read file ; do
   2.393 +	output=$PREFIX$(printf "%03d" $i)
   2.394 +	cat $file /dev/zero | ddq bs=1k count=$FORMAT conv=sync of=$output
   2.395 +	echo $output
   2.396 +	rm -f $file
   2.397 +	i=$(( $i + 1 ))
   2.398 +done
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tazpanel-extra/stuff/floppy.cgi	Fri Jul 31 23:33:17 2015 +0200
     3.3 @@ -0,0 +1,342 @@
     3.4 +#!/bin/sh
     3.5 +#
     3.6 +# Floppy set CGI interface
     3.7 +#
     3.8 +# Copyright (C) 2015 SliTaz GNU/Linux - BSD License
     3.9 +#
    3.10 +
    3.11 +# Common functions from libtazpanel
    3.12 +. lib/libtazpanel
    3.13 +get_config
    3.14 +
    3.15 +
    3.16 +case "$1" in
    3.17 +	menu)
    3.18 +		TEXTDOMAIN_original=$TEXTDOMAIN
    3.19 +		export TEXTDOMAIN='floppy'
    3.20 +
    3.21 +		#which bootloader > /dev/null &&
    3.22 +		cat <<EOT
    3.23 +<li><a data-icon="slitaz" href="floppy.cgi">$(_ 'Boot floppy')</a></li>
    3.24 +EOT
    3.25 +		export TEXTDOMAIN=$TEXTDOMAIN_original
    3.26 +		exit
    3.27 +esac
    3.28 +
    3.29 +
    3.30 +#
    3.31 +# Commands
    3.32 +#
    3.33 +
    3.34 +error=
    3.35 +case " $(POST) " in
    3.36 +*\ doformat\ *)
    3.37 +	fdformat $(POST fd)
    3.38 +	which mkfs.$(POST fstype) > /dev/null 2>&1 &&
    3.39 +	mkfs.$(POST fstype) $(POST fd)
    3.40 +	;;
    3.41 +*\ write\ *)
    3.42 +	if [ "$(FILE fromimage tmpname)" ]; then
    3.43 +		dd if=$(FILE fromimage tmpname) of=$(POST tofd)
    3.44 +		rm -f $(FILE fromimage tmpname)
    3.45 +	else
    3.46 +		error="$(msg err 'Broken FILE support')"
    3.47 +	fi ;;
    3.48 +*\ read\ *)
    3.49 +	dd if=$(POST fromfd) of=$(POST toimage)
    3.50 +	;;
    3.51 +*\ build\ *)
    3.52 +	cd $(POST workdir)
    3.53 +	cmd=""
    3.54 +	toremove=""
    3.55 +	while read key file ; do
    3.56 +		[ "$(FILE $file size)" ] || continue
    3.57 +		cmd="$cmd $key $(FILE $file tmpname)"
    3.58 +		toremove="$toremove $(FILE $file tmpname)"
    3.59 +	done <<EOT
    3.60 +bootloader	kernel
    3.61 +--initrd	initrd
    3.62 +--initrd	initrd2
    3.63 +--info		info
    3.64 +EOT
    3.65 +	error="$(msg err 'Broken FILE support !')
    3.66 +		<pre>$(httpinfo)</pre>"
    3.67 +	if [ "$cmd" ]; then
    3.68 +		for key in cmdline rdev video format mem ; do
    3.69 +			[ "$(POST $key)" ] || continue
    3.70 +			cmd="$cmd --$key '$(POST $key)'"
    3.71 +		done 
    3.72 +		[ "$(POST edit)" ] || cmd="$cmd --dont-edit-cmdline"
    3.73 +		TITLE="$(_ 'TazPanel - floppy')"
    3.74 +		header
    3.75 +		xhtml_header
    3.76 +		eval $cmd 2>&1
    3.77 +		[ "$toremove" ] && rm -f $toremove
    3.78 +		xhtml_footer
    3.79 +		exit 0
    3.80 +	fi
    3.81 +	;;
    3.82 +esac
    3.83 +
    3.84 +listfd()
    3.85 +{
    3.86 +	echo "<select name=\"$1\">"
    3.87 +	ls /dev/fd[0-9]* | sed 's|.*|<option>&</option>|'
    3.88 +	echo "</select>"
    3.89 +}
    3.90 +
    3.91 +TITLE="$(_ 'TazPanel - floppy')"
    3.92 +header
    3.93 +xhtml_header
    3.94 +echo "$error"
    3.95 +
    3.96 +cat <<EOT
    3.97 +<form method="post" enctype="multipart/form-data">
    3.98 +EOT
    3.99 +[ -w /dev/fd0 ] && cat <<EOT
   3.100 +<section>
   3.101 +	<header>
   3.102 +		$(_ 'Floppy disk format')
   3.103 +	</header>
   3.104 +	<button type="submit" name="doformat" data-icon="start" >$(_ 'Format disk'  )</button>
   3.105 +	$(listfd fd) filesystem:
   3.106 +	<select name "fstype">
   3.107 +		<option>$(_ 'none')</option>
   3.108 +		$(ls /sbin/mkfs.* | sed '/dev/d;s|.*/mkfs.\(.*\)|<option>\1</option>|')
   3.109 +	</select>
   3.110 +</section>
   3.111 +
   3.112 +<section>
   3.113 +	<header>
   3.114 +		$(_ 'Floppy disk transfert')
   3.115 +	</header>
   3.116 +<table>
   3.117 +	<tbody>
   3.118 +	<tr>
   3.119 +	<td>
   3.120 +	<button type="submit" name="write" data-icon="start" >$(_ 'Write image'  )</button>
   3.121 +	$(listfd tofd) &lt;&lt;&lt; <input name="fromimage" type="file">
   3.122 +	</td>
   3.123 +	</tr>
   3.124 +	<tr>
   3.125 +	<td>
   3.126 +	<button type="submit" name="read" data-icon="start" >$(_ 'Read image'  )</button>
   3.127 +	$(listfd fromfd) &gt;&gt;&gt; <input name="toimage" type="text" value="/tmp/floppy.img">
   3.128 +	<td>
   3.129 +	</tr>
   3.130 +	</tbody>
   3.131 +</table>
   3.132 +</section>
   3.133 +EOT
   3.134 +cat <<EOT
   3.135 +<section>
   3.136 +	<header>
   3.137 +		$(_ 'Boot floppy set builder')
   3.138 +	</header>
   3.139 +
   3.140 +<table>
   3.141 +	<tbody><tr>
   3.142 +	<td>$(_ 'Linux kernel:')</td>
   3.143 +	<td><input name="kernel" size="37" type="file"> <i>$(_ 'required')</i></td>
   3.144 +	</tr>
   3.145 +	<tr>
   3.146 +	<td>$(_ 'Initramfs / Initrd:')</td>
   3.147 +	<td><input name="initrd" size="37" type="file"> <i>$(_ 'optional')</i></td>
   3.148 +	</tr>
   3.149 +	<tr>
   3.150 +	<td>$(_ 'Extra initramfs:')</td>
   3.151 +	<td><input name="initrd2" size="37" type="file"> <i>$(_ 'optional')</i></td>
   3.152 +	</tr>
   3.153 +	<tr>
   3.154 +	<td>$(_ 'Boot message:')</td>
   3.155 +	<td><input name="info" size="37" type="file"> <i>$(_ 'optional')</i></td>
   3.156 +	</tr>
   3.157 +	<tr>
   3.158 +	<td>$(_ 'Default cmdline:')</td>
   3.159 +	<td id="cmdline"><input name="cmdline" size="36" type="text"> <input name="edit" checked="checked" type="checkbox">$(_ 'edit')
   3.160 +	<i>$(_ 'optional')</i></td>
   3.161 +	</tr>
   3.162 +	<tr>
   3.163 +	<td>$(_ 'Root device:')</td>
   3.164 +	<td><input name="rdev" size="8" value="/dev/fd0" type="text">
   3.165 +	&nbsp;&nbsp;$(_ 'Flags:') <select name="flags">
   3.166 +		<option selected="selected" value="1">R/O</option>
   3.167 +		<option value="0">R/W</option>
   3.168 +	</select>
   3.169 +	&nbsp;&nbsp;VESA: <select name="video">
   3.170 +		<option value="-3">Ask</option>
   3.171 +<option value="-2">Extended</option>
   3.172 +<option value="-1" selected="selected">Standard</option>
   3.173 +<option value="0">0</option>
   3.174 +<option value="1">1</option>
   3.175 +<option value="2">2</option>
   3.176 +<option value="3">3</option>
   3.177 +<option value="4">4</option>
   3.178 +<option value="5">5</option>
   3.179 +<option value="6">6</option>
   3.180 +<option value="7">7</option>
   3.181 +<option value="8">8</option>
   3.182 +<option value="9">9</option>
   3.183 +<option value="10">10</option>
   3.184 +<option value="11">11</option>
   3.185 +<option value="12">12</option>
   3.186 +<option value="13">13</option>
   3.187 +<option value="14">14</option>
   3.188 +<option value="15">15</option>
   3.189 +<option value="3840">80x25</option>
   3.190 +<option value="3841">80x50</option>
   3.191 +<option value="3842">80x43</option>
   3.192 +<option value="3843">80x28</option>
   3.193 +<option value="3845">80x30</option>
   3.194 +<option value="3846">80x34</option>
   3.195 +<option value="3847">80x60</option>
   3.196 +<option value="778">132x43</option>
   3.197 +<option value="777">132x25</option>
   3.198 +<option value="824">320x200x8</option>
   3.199 +<option value="781">320x200x15</option>
   3.200 +<option value="782">320x200x16</option>
   3.201 +<option value="783">320x200x24</option>
   3.202 +<option value="800">320x200x32</option>
   3.203 +<option value="818">896x672x24</option>
   3.204 +<option value="915">320x240x15</option>
   3.205 +<option value="821">320x240x16</option>
   3.206 +<option value="917">320x240x24</option>
   3.207 +<option value="918">320x240x32</option>
   3.208 +<option value="819">896x672x32</option>
   3.209 +<option value="931">400x300x15</option>
   3.210 +<option value="822">400x300x16</option>
   3.211 +<option value="933">400x300x24</option>
   3.212 +<option value="934">400x300x32</option>
   3.213 +<option value="820">512x384x8</option>
   3.214 +<option value="947">512x384x15</option>
   3.215 +<option value="823">512x384x16</option>
   3.216 +<option value="949">512x384x24</option>
   3.217 +<option value="950">512x384x32</option>
   3.218 +<option value="962">640x350x8</option>
   3.219 +<option value="963">640x350x15</option>
   3.220 +<option value="964">640x350x16</option>
   3.221 +<option value="965">640x350x24</option>
   3.222 +<option value="966">640x350x32</option>
   3.223 +<option value="768">640x400x8</option>
   3.224 +<option value="899">640x400x15</option>
   3.225 +<option value="825">640x400x16</option>
   3.226 +<option value="901">640x400x24</option>
   3.227 +<option value="902">640x400x32</option>
   3.228 +<option value="769">640x480x8</option>
   3.229 +<option value="784">640x480x15</option>
   3.230 +<option value="785">640x480x16</option>
   3.231 +<option value="786">640x480x24</option>
   3.232 +<option value="826">640x480x32</option>
   3.233 +<option value="879">800x500x8</option>
   3.234 +<option value="880">800x500x15</option>
   3.235 +<option value="881">800x500x16</option>
   3.236 +<option value="882">800x500x24</option>
   3.237 +<option value="883">800x500x32</option>
   3.238 +<option value="771">800x600x8</option>
   3.239 +<option value="787">800x600x15</option>
   3.240 +<option value="788">800x600x16</option>
   3.241 +<option value="789">800x600x24</option>
   3.242 +<option value="827">800x600x32</option>
   3.243 +<option value="815">896x672x8</option>
   3.244 +<option value="816">1600x1200x8</option>
   3.245 +<option value="817">1600x1200x16</option>
   3.246 +<option value="874">1024x640x8</option>
   3.247 +<option value="875">1024x640x15</option>
   3.248 +<option value="876">1024x640x16</option>
   3.249 +<option value="877">1024x640x24</option>
   3.250 +<option value="878">1024x640x32</option>
   3.251 +<option value="773">1024x768x8</option>
   3.252 +<option value="790">1024x768x15</option>
   3.253 +<option value="791">1024x768x16</option>
   3.254 +<option value="792">1024x768x24</option>
   3.255 +<option value="828">1024x768x32</option>
   3.256 +<option value="869">1152x720x8</option>
   3.257 +<option value="870">1152x720x15</option>
   3.258 +<option value="871">1152x720x16</option>
   3.259 +<option value="872">1152x720x24</option>
   3.260 +<option value="873">1152x720x32</option>
   3.261 +<option value="775">1280x1024x8</option>
   3.262 +<option value="793">1280x1024x15</option>
   3.263 +<option value="794">1280x1024x16</option>
   3.264 +<option value="795">1280x1024x24</option>
   3.265 +<option value="829">1280x1024x32</option>
   3.266 +<option value="835">1400x1050x8</option>
   3.267 +<option value="837">1400x1050x16</option>
   3.268 +<option value="838">1400x1040x24</option>
   3.269 +<option value="864">1440x900x15</option>
   3.270 +<option value="866">1440x900x16</option>
   3.271 +<option value="867">1440x900x24</option>
   3.272 +<option value="868">1440x900x32</option>
   3.273 +<option value="893">1920x1200x8</option>
   3.274 +	</select>
   3.275 +	</td>
   3.276 +	</tr>
   3.277 +	<tr>
   3.278 +	<td>$(_ 'Output directory:')</td>
   3.279 +	<td id="workdir"><input name="workdir" size="36" type="text" value="/tmp"></td>
   3.280 +	</tr>
   3.281 +	<tr>
   3.282 +	<td>$(_ 'Floppy size:')</td>
   3.283 +	<td><select name="format">
   3.284 +		<optgroup label="5&frac14; SD">
   3.285 +		<option value="360">360 KB</option>
   3.286 +		</optgroup>
   3.287 +		<optgroup label="3&frac12; SD">
   3.288 +		<option value="720">720 KB</option>
   3.289 +		</optgroup>
   3.290 +		<optgroup label="5&frac14; HD">
   3.291 +		<option value="1200">1.20 MB</option>
   3.292 +		</optgroup>
   3.293 +		<optgroup label="3&frac12; HD">
   3.294 +		<option value="1440" selected="selected">1.44 MB</option>
   3.295 +		<option value="1600">1.60 MB</option>
   3.296 +		<option value="1680">1.68 MB</option>
   3.297 +		<option value="1722">1.72 MB</option>
   3.298 +		<option value="1743">1.74 MB</option>
   3.299 +		<option value="1760">1.76 MB</option>
   3.300 +		<option value="1840">1.84 MB</option>
   3.301 +		<option value="1920">1.92 MB</option>
   3.302 +		<option value="1968">1.96 MB</option>
   3.303 +		</optgroup>
   3.304 +		<optgroup label="3&frac12; ED">
   3.305 +		<option value="2880">2.88 MB</option>
   3.306 +		<option value="3360">3.36 MB</option>
   3.307 +		<option value="3444">3.44 MB</option>
   3.308 +		<option value="3840">3.84 MB</option>
   3.309 +		<option value="3936">3.92 MB</option>
   3.310 +		</optgroup>
   3.311 +		<option value="0">$(_ 'no limit')</option>
   3.312 +	</select>&nbsp;
   3.313 +	$(_ 'RAM used')&nbsp;<select name="mem">
   3.314 +		<option selected="selected" value="16">16 MB</option>
   3.315 +		<option value="15">15 MB</option>
   3.316 +		<option value="14">14 MB</option>
   3.317 +		<option value="13">13 MB</option>
   3.318 +		<option value="12">12 MB</option>
   3.319 +		<option value="11">11 MB</option>
   3.320 +		<option value="10">10 MB</option>
   3.321 +		<option value="9">9 MB</option>
   3.322 +		<option value="8">8 MB</option>
   3.323 +		<option value="7">7 MB</option>
   3.324 +		<option value="6">6 MB</option>
   3.325 +		<option value="5">5 MB</option>
   3.326 +		<option value="4">4 MB</option>
   3.327 +	</select>&nbsp;
   3.328 +	<button type="submit" name="build" data-icon="start" >$(_ 'Build floppy set'  )</button>
   3.329 +	</td>
   3.330 +	</tr>
   3.331 +</tbody></table>
   3.332 +<footer>
   3.333 +<p>
   3.334 +$(_ 'Note') 1: $(_ 'the extra initramfs may be useful to add your own configuration files.')
   3.335 +</p>
   3.336 +<p>
   3.337 +$(_ 'Note') 2: $(_ 'the keyboard is read for ESC or ENTER on every form feed (ASCII 12) in the boot message.')
   3.338 +</p>
   3.339 +</footer>
   3.340 +</section>
   3.341 +</form>
   3.342 +EOT
   3.343 +
   3.344 +xhtml_footer
   3.345 +exit 0
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tazpanel-extra/stuff/powersaving.cgi	Fri Jul 31 23:33:17 2015 +0200
     4.3 @@ -0,0 +1,177 @@
     4.4 +#!/bin/sh
     4.5 +#
     4.6 +# Hardware / power saving
     4.7 +#
     4.8 +# Copyright (C) 2011-2015 SliTaz GNU/Linux - BSD License
     4.9 +#
    4.10 +
    4.11 +# Common functions from libtazpanel
    4.12 +. lib/libtazpanel
    4.13 +get_config
    4.14 +
    4.15 +case "$1" in
    4.16 +	menu)
    4.17 +		cat <<EOT
    4.18 +<li><a data-icon="display" href="powersaving.cgi" data-root>$(_ 'Power saving')</a></li>
    4.19 +EOT
    4.20 +		exit
    4.21 +esac
    4.22 +
    4.23 +header
    4.24 +
    4.25 +TITLE=$(_ 'Hardware')
    4.26 +
    4.27 +xhtml_header "$(_ 'Power saving')"
    4.28 +
    4.29 +## DPMS ##
    4.30 +cat <<EOT
    4.31 +<section>
    4.32 +	<header>
    4.33 +		<span data-icon="display">DPMS (Display Power Management Signaling)</span>
    4.34 +	</header>
    4.35 +
    4.36 +	<div>$(_ "DPMS enables power saving behaviour of monitors when the computer is not in use.")</div>
    4.37 +	<form method="post" class="wide">
    4.38 +		<input type="hidden" name="powersaving" value="set"/>
    4.39 +EOT
    4.40 +
    4.41 +monitor_conf='/etc/X11/xorg.conf.d/50-Monitor.conf'
    4.42 +if [ ! -s "$monitor_conf" ]; then
    4.43 +	# Config is absent, so create it
    4.44 +	cat > "$monitor_conf" <<EOT
    4.45 +Section "Monitor"
    4.46 +	Identifier   "Monitor0"
    4.47 +	VendorName   "Monitor Vendor"
    4.48 +	ModelName    "Monitor Model"
    4.49 +	Option "DPMS" "true"
    4.50 +EndSection
    4.51 +EOT
    4.52 +fi
    4.53 +
    4.54 +cat <<EOT
    4.55 +		<table class="wide zebra">
    4.56 +			<thead>
    4.57 +				<tr><td>$(_ 'Identifier')</td>
    4.58 +					<td>$(_ 'Vendor name')</td>
    4.59 +					<td>$(_ 'Model name')</td>
    4.60 +					<td>$(_ 'DPMS enabled')</td>
    4.61 +				</tr>
    4.62 +			</thead>
    4.63 +EOT
    4.64 +
    4.65 +awk -F\" '{
    4.66 +	if ($1 ~ /^Section/) { I = V = M = D = ""; }
    4.67 +	if ($1 ~ /Identifier/) { I = $2; }
    4.68 +	if ($1 ~ /VendorName/) { V = $2; }
    4.69 +	if ($1 ~ /ModelName/)  { M = $2; }
    4.70 +	if ($1 ~ /Option/ && $2 ~ /DPMS/) { D = $4; }
    4.71 +	if ($1 ~ /EndSection/) {
    4.72 +		if (D == "false") { D = ""; } else { D = "checked"; }
    4.73 +		printf "<tr><td data-icon=\"display\">%s</td><td>%s</td><td>%s</td><td>", I, V, M;
    4.74 +		printf "<label><input type=\"checkbox\" name=\"%s\" %s/>DPMS</label>", I, D;
    4.75 +		printf "</td></tr>\n";
    4.76 +	}
    4.77 +}' $monitor_conf
    4.78 +
    4.79 +layout_conf='/etc/X11/xorg.conf.d/10-ServerLayout.conf'
    4.80 +
    4.81 +cat <<EOT
    4.82 +		</table>
    4.83 +		<input type="hidden" name="ids" value="$(
    4.84 +			awk -F\" '$1 ~ /Identifier/ { printf "%s ", $2; }' $monitor_conf)"/>
    4.85 +
    4.86 +		<table>
    4.87 +			<tr><td>
    4.88 +					<fieldset>
    4.89 +						<legend>$(_ 'DPMS times (in minutes):')</legend>
    4.90 +						<table>
    4.91 +							<tr><td>Standby Time</td>
    4.92 +								<td><input type="number" name="StandbyTime" value="10"/></td></tr>
    4.93 +							<tr><td>Suspend Time</td>
    4.94 +								<td><input type="number" name="SuspendTime" value="20"/></td></tr>
    4.95 +							<tr><td>Off Time</td>
    4.96 +								<td><input type="number" name="OffTime"     value="30"/></td></tr>
    4.97 +						</table>
    4.98 +					</fieldset>
    4.99 +				</td>
   4.100 +				<td style="vertical-align: top">
   4.101 +					<fieldset>
   4.102 +						<legend>$(_ 'Manual edit')</legend>
   4.103 +						<a data-icon="conf" href="index.cgi?file=$monitor_conf">$(basename $monitor_conf)</a><br/>
   4.104 +						<a data-icon="conf" href="index.cgi?file=$layout_conf">$(basename $layout_conf)</a>
   4.105 +					</fieldset>
   4.106 +					<pre>$(for i in $(POST); do echo "$i: " $(POST $i); done)</pre>
   4.107 +				</td>
   4.108 +			</tr>
   4.109 +		</table>
   4.110 +		<footer>
   4.111 +			<button type="submit" data-icon="ok">$(_ 'Change')</button>
   4.112 +		</footer>
   4.113 +	</form>
   4.114 +</section>
   4.115 +EOT
   4.116 +
   4.117 +
   4.118 +## CPU ##
   4.119 +
   4.120 +cpu=$(awk -F: '$1 ~ "model name" {
   4.121 +	gsub(/\(TM\)/,"™",$2); gsub(/\(R\)/,"®",$2);
   4.122 +	split($2,c,"@");
   4.123 +	print "<span data-icon=\"cpu\">" c[1] "</span>";
   4.124 +}' /proc/cpuinfo)
   4.125 +multiplier=$(echo "$cpu" | wc -l)
   4.126 +[ "$multiplier" -ne 1 ] && cpu="$multiplier × $(echo "$cpu" | head -n1)"
   4.127 +
   4.128 +freq=$(awk -F: 'BEGIN{N=0}$1~"MHz"{printf "%d:<b>%s</b>MHz ",N,$2; N++}' /proc/cpuinfo)
   4.129 +
   4.130 +cat <<EOT
   4.131 +<section>
   4.132 +	<header><span data-icon="cpu">$(_ 'CPU')</span></header>
   4.133 +
   4.134 +	<div>$(_ "CPU frequency scaling enables the operating system to scale the \
   4.135 +CPU frequency up or down in order to save power. CPU frequencies can be scaled \
   4.136 +automatically depending on the system load, in responce to ACPI events, or \
   4.137 +manually by userspace programs.")</div>
   4.138 +
   4.139 +	<table class="wide zebra">
   4.140 +		<tr><td>$(_ 'Model name')</td><td>$cpu</td></tr>
   4.141 +		<tr><td>$(_ 'Current frequency')</td><td>$freq</td></tr>
   4.142 +		<tr><td>$(_ 'Current driver')</td><td>$(cat '/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver')
   4.143 +		<tr><td>$(_ 'Current governor')</td><td>$(cat '/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor')
   4.144 +	</table>
   4.145 +</section>
   4.146 +EOT
   4.147 +
   4.148 +# As of Kernel 3.4, the native CPU module is loaded automatically.
   4.149 +if [ -d "/lib/modules/$(uname -r)/kernel/drivers/cpufreq" ]; then
   4.150 +	cd /lib/modules/$(uname -r)/kernel/drivers/cpufreq
   4.151 +	cat <<EOT
   4.152 +<section>
   4.153 +	<header>$(_ 'Kernel modules')</header>
   4.154 +	<table class="wide zebra summary">
   4.155 +		<thead>
   4.156 +			<tr><td>$(_ 'Module')</td>
   4.157 +				<td>$(_ 'Description')</td>
   4.158 +			</tr>
   4.159 +		</thead>
   4.160 +EOT
   4.161 +	lsmod="$(lsmod | awk '{printf "%s " $1}') "
   4.162 +
   4.163 +	for module in $(ls | grep -v 'mperf\|speedstep-lib'); do
   4.164 +		module="${module%.ko.xz}"; module="${module//-/_}"
   4.165 +		if echo $lsmod | grep -q " $module "; then icon='ok'; else icon='cancel'; fi
   4.166 +		echo "<tr><td><span data-icon=\"$icon\">$module</span></td><td>"
   4.167 +		modinfo $module | awk -F: '$1=="description"{
   4.168 +			gsub(/\(TM\)/,"™",$2); gsub(/\(R\)/,"®",$2);
   4.169 +			gsub(/VIA|C7|Cyrix|MediaGX|NatSemi|Geode|Transmeta|Crusoe|Efficeon|Pentium™ 4|Xeon™|AMD|K6-2\+|K6-3\+|K7|Athlon 64|Opteron|Intel/,"<b>&</b>",$2);
   4.170 +			print $2}'
   4.171 +		echo "</td></tr>"
   4.172 +	done
   4.173 +	cat <<EOT
   4.174 +	</table>
   4.175 +</section>
   4.176 +EOT
   4.177 +fi
   4.178 +
   4.179 +xhtml_footer
   4.180 +exit 0