# HG changeset patch # User Pascal Bellard # Date 1438378397 -7200 # Node ID 01f2e8c0ea7b58e957c2ffa31d1252ff004bab4d # Parent a81e49dbaf30f0a7b4630b49cb50d8ad42b130cc Add tazpanel-extra diff -r a81e49dbaf30 -r 01f2e8c0ea7b tazpanel-extra/receipt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tazpanel-extra/receipt Fri Jul 31 23:33:17 2015 +0200 @@ -0,0 +1,24 @@ +# SliTaz package receipt. + +PACKAGE="tazpanel-extra" +VERSION="1.0" +CATEGORY="system-tools" +SHORT_DESC="SliTaz administration and configuration panel extra modules." +MAINTAINER="pascal.bellard@slitaz.org" +LICENSE="BSD" +WEB_SITE="http://www.slitaz.org/" +HOST_ARCH="i486" + +DEPENDS="tazpanel" + +# Rules to gen a SliTaz package suitable for Tazpkg. +genpkg_rules() +{ + mkdir -p $fs/var/www/tazpanel/menu.d/boot $fs/usr/bin \ + $fs/var/www/tazpanel/menu.d/hardware + cp -a $stuff/bootloader $fs/usr/bin/ + cp -a $stuff/floppy.cgi $fs/var/www/tazpanel/ + ln -s ../../floppy.cgi $fs/var/www/tazpanel/menu.d/boot/floppy + cp -a $stuff/powersaving.cgi $fs/var/www/tazpanel/ + ln -s ../../powersaving.cgi $fs/var/www/tazpanel/menu.d/hardware/powersaving +} diff -r a81e49dbaf30 -r 01f2e8c0ea7b tazpanel-extra/stuff/bootloader --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tazpanel-extra/stuff/bootloader Fri Jul 31 23:33:17 2015 +0200 @@ -0,0 +1,395 @@ +#!/bin/sh +# +# This script creates a floppy image set from a linux bzImage and can merge +# a cmdline and/or one or more initramfs. +# +# (C) 2009-2015 Pascal Bellard - GNU General Public License v3. + +usage() +{ +cat < /dev/null; } + +get() +{ +echo $( od -v -j $(($1)) -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An $2 2>/dev/null || + hexdump -v -s $(($1)) -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %d\n\"" $2 ) +} + +trace() +{ + [ -n "$DEBUG" ] && printf "$@" 1>&2 && echo 1>&2 +} + +# usage: store bits offset data file +store() +{ + n=$3; for i in $(seq 8 8 $1); do + printf '\\\\x%02X' $(($n & 255)) + n=$(($n >> 8)) + done | xargs echo -en | ddq bs=1 conv=notrunc of=$4 seek=$(($2)) + s=$1; a=$2; d=$3; shift 4; c="$@" + trace "store$s(%03X) = %0$(($s/4))X $c" $a $d +} + +die() +{ + echo $@ 1>&2 + exit 1 +} +extract() +{ + shift + [ ! -s "$1" ] && die "No floppy ?" + [ $(get 0x1FE "$1") -ne 43605 ] && die "Not bootable" + [ $(get $Magic "$1" 4) != 1400005704 ] && + [ $(get 0x1F4 "$1") -gt 32768 -o $(get 0x1F6 "$1") -ne 0 ] && + die "Not linux." + FORMAT="$(($(stat -c "%s" $1)/1024))" + cat <kernel + files="kernel" + if [ "$MYBB" ]; then + store 8 $SetupSzOfs $(($n-1)) kernel "setup size $n" + store 16 0x22 0 kernel "clear cmdline" + store 16 0x1EF 0 kernel "clear info" + fi + [ $cmdline -ne 0 ] && files="$files cmdline" && + ddq bs=512 count=1 | strings | sed q > cmdline + [ $info -ne 0 ] && files="$files info" && + ddq bs=512 count=$infolen | sed \ + 's/'$(echo -en "\xff\xff$//;s/\xff/\f")'/g;s/\r/\n/g;q' > info + syssz=$(get 0x1F4 kernel 4) + ddq bs=16 count=$syssz >>kernel + [ $(($syssz % 32)) -ne 0 ] && + ddq bs=16 of=/dev/null count=$((32 - ($syssz % 32))) + if [ $(get $Magic kernel 4) == 1400005704 ]; then + ddq bs=1 count=200 skip=$((512+$(get 0x20E kernel 2))) \ + if=kernel | strings | sed q + len=$(get $RamfsLenOfs kernel 4) + if [ $len -ne 0 ]; then + adrs=$(get $RamfsAdrOfs kernel 4) + printf "--address-initrd 0x%X \n" $adrs + echo "--mem $(((($adrs+$len)/1024+512)/1024))" + ddq bs=512 count=$((($len+511)/512)) > initrd + ddq count=0 bs=1 seek=$len of=initrd + files="$files initrd" + store 64 $RamfsAdrOfs 0 kernel "reset initrd" + fi + if [ $(get 0x206 kernel) -ge 514 ]; then + store 32 0x228 0 kernel "clean cmdline32" + fi + else + len=$(get $OldRamfsLenOfs kernel) + [ $len -ne 0 ] && files="$files initrd" && + if [ -s "$2" ]; then + ddq if=$2 bs=1024 count=$len of=initrd + else + ddq if=$1 bs=1024 skip=256 count=$len of=initrd + fi + fi + ls -l $files + } + exit +} + +KERNEL="" +INITRD="" +ADRSRD="" +CMDLINE="" +PREFIX="floppy." +FORMAT="1440" +RDEV="" +VIDEO="" +FLAGS="" +TRACKS="80" +MEM="16" +HIDE="" +NOEDIT="" +QUIET="" +NOSYSSIZEFIX="" +INFOFILE="" +DEBUG="" +while [ -n "$1" ]; do + case "${1/--/-}" in + -c*) CMDLINE="$2"; shift;; + -inf*) INFOFILE="$2"; shift;; + -i*) INITRD="$INITRD $2"; shift;; + -a*) ADRSRD="$2"; shift;; + -h*) HIDE="1";; + -p*) PREFIX="$2"; shift;; + -fl*)FLAGS="$2"; shift;; # 1 read-only, 0 read-write + -f*) FORMAT="$2"; shift;; + -m*) MEM="$(echo $2 | sed 's/[^0-9]//g')"; shift;; + -r*) RDEV="$2"; shift;; + -v*) VIDEO="$2"; shift;; # -3 .. n + -t*) TRACKS="$2"; shift;; # likely 81 .. 84 + -n*) NOSYSSIZEFIX="1";; + -debug) DEBUG="1";; + -d*) NOEDIT="1";; + -q*) QUIET="1";; + -e*) extract "$@";; + *) KERNEL="$1";; + esac + shift +done +[ -n "$KERNEL" -a -f "$KERNEL" ] || usage +while [ -L "$KERNEL" ]; do KERNEL="$(readlink "$KERNEL")"; done +if [ $(( $FORMAT % $TRACKS )) -ne 0 ]; then + echo "Invalid track count for format $FORMAT." + usage +fi +[ 0$MEM -lt 2 ] && MEM=2 + +patch() +{ + echo -en $(echo ":$2" | sed 's/:/\\x/g') | \ + ddq bs=1 conv=notrunc of=$3 seek=$((0x$1)) + trace "patch $1 $2 $4" +} + +error() +{ + rm -f $bs + die $@ +} + +floppyset() +{ + # boot+setup address + SetupBase=0x90000 + + bs=/tmp/bs$$ + + # Get and patch boot sector + # See http://hg.slitaz.org/wok/raw-file/13835bce7189/syslinux/stuff/iso2exe/bootloader.S + trace "Read bootsector..." + ddq if=$KERNEL bs=512 count=1 of=$bs + + [ $(get 0x1FE $bs) -eq 43605 ] || error "Not bootable" + + uudecode <> $bs + + Version=$(get 0x206 $bs) + [ $(get $Magic $bs 4) != 1400005704 ] && Version=0 + feature="" + while read prot kern info ; do + [ $Version -lt $((0x$prot)) ] && continue + feature="features $prot starting from kernel $kern " + done < /dev/null) + store 16 $RootDevOfs $RDEV $bs RDEV + + [ $FORMAT -lt 720 ] && store 8 0x15F 40 $bs 360K + [ $FORMAT -lt 320 ] && store 8 0x158 237 $bs 160K + + extra=0 + # Store cmdline after setup for kernels >= 0.99 + if [ -n "$CMDLINE" ]; then + CmdlineOfs=$(stat -c '%s' $bs) + store 16 0x22 $CmdlineOfs $bs "Cmdline @$CmdlineOfs '$CMDLINE'" + [ $Version -ge 514 ] && + store 32 0x228 $(( $SetupBase + 0x8000 )) $bs "Cmdline32" + echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> $bs + extra=$(($extra+1)) + store 8 0x1F1 $(($setupsz+$extra)) $bs setup size + [ $Version -ge 512 ] && [ -n "$QUIET" ] && + store 8 0x211 $(($(get 0x211 $bs 1) | 32)) $bs suppress early messages + fi + + # Info text after setup + if [ -s "$INFOFILE" ]; then + InfoOfs=$(stat -c '%s' $bs) + sed -e ':a;N;$!ba;s/\r\n/\r/g;s/\n/\r/g' \ + -e 's/'$(echo -e "\f/\xff/g;s/$/\xff\xff")'/' \ + < "$INFOFILE" > $bs.infotext + ddq if=/dev/zero bs=512 count=1 >>$bs.infotext + infolen=$(($(stat -c %s $bs.infotext)/512)) + ddq if=$bs.infotext count=$infolen bs=512 >> $bs + extra=$(($extra+$infolen)) + rm -f $bs.infotext + store 8 0x1F1 $(($setupsz+$extra)) $bs setup size + store 16 0x1EF $InfoOfs $bs update infoptr + fi + + syssz=$((($(stat -c %s $KERNEL)+15)/16-32*(1+$setupsz))) + #syssz=$(get 0x1F4 $bs 4) + sysszsect=$((($syssz+31)/32)) + store 16 $OldRamfsLenOfs 0 $bs clear oldramfs + INITRD="${INITRD# }" + INITRDPAD=4 + [ -n "$INITRD" ] && + if [ $Version -lt 512 ]; then + # Compute initramfs location (protocol < 2.00) + [ $syssz -gt 32768 ] && syssz=$(get 0x1F4 $bs 2) + [ $syssz -eq 0 ] && syssz=$((0x7F00)) + sysszsect=$((($syssz+31)/32)) + INITRD="${INITRD%%,*}" + initrdlen=$(stat -c %s "$INITRD") + store 16 $OldRamfsLenOfs $(($initrdlen/1024)) $bs set oldramfs + INITRDDISKALIGN=$((0x40000)) + [ $(($initrdlen+$INITRDDISKALIGN)) -gt $(($FORMAT*1024)) -o \ + $(((512*$sysszsect) + $(stat -c %s $bs))) -gt $INITRDDISKALIGN -o \ + -n "$ADRSRD" ] && INITRDDISKALIGN=$(($FORMAT*1024)) + else +INITRDRAMALIGN=0x1000 + # Compute initramfs size (protocol >= 2.00) + initrdlen=0 + INITRDDISKALIGN=0 + for i in ${INITRD//,/ }; do + [ -s "$i" ] || continue + while [ -L "$i" ]; do i="$(readlink $i)"; done + size=$(stat -c %s "$i") + trace "initrd $i $size " + initrdlen=$(((($initrdlen + $INITRDPAD - 1) & -$INITRDPAD) + $size)) + ADRSRD2=$(( (($MEM * 0x100000) - $initrdlen) & -$INITRDRAMALIGN )) + store 32 $RamfsAdrOfs $(( ${ADRSRD:-$ADRSRD2} )) $bs initrd adrs + store 32 $RamfsLenOfs $initrdlen $bs initrdlen + done + fi + + [ -n "$NOSYSSIZEFIX" ] || store 32 0x1F4 $syssz $bs fix system size + + # Output boot sector + setup + cmdline + info + ddq if=$bs + + # Output kernel code + [ $INITRDDISKALIGN -ne 0 ] && + INITRDDISKALIGN=$(($INITRDDISKALIGN/512-$sysszsect-$extra-$setupsz-1)) + cat $KERNEL /dev/zero | ddq bs=512 skip=$(( $setupsz+1 )) \ + count=$(($sysszsect+$INITRDDISKALIGN)) conv=sync + + # Output initramfs + padding=$INITRDPAD + for i in ${INITRD//,/ }; do + [ -s "$i" ] || continue + [ $padding -eq $INITRDPAD ] || ddq if=/dev/zero bs=1 count=$padding + ddq if=$i + trace "initrd $i ($(stat -c %s $i) bytes) padding $INITRDPAD" + padding=$(( $INITRDPAD - ($(stat -c %s $i) % $INITRDPAD) )) + done + + # Cleanup + rm -f $bs +} + +if [ "$FORMAT" == "0" ]; then # unsplitted + floppyset > $PREFIX + PAD=$(( 512 - ($(stat -c %s $PREFIX) % 512) )) + [ $PAD -ne 512 ] && ddq if=/dev/zero bs=1 count=$PAD >> $PREFIX + exit +fi +floppyset | split -b ${FORMAT}k /dev/stdin floppy$$ +i=1 +ls floppy$$* 2> /dev/null | while read file ; do + output=$PREFIX$(printf "%03d" $i) + cat $file /dev/zero | ddq bs=1k count=$FORMAT conv=sync of=$output + echo $output + rm -f $file + i=$(( $i + 1 )) +done diff -r a81e49dbaf30 -r 01f2e8c0ea7b tazpanel-extra/stuff/floppy.cgi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tazpanel-extra/stuff/floppy.cgi Fri Jul 31 23:33:17 2015 +0200 @@ -0,0 +1,342 @@ +#!/bin/sh +# +# Floppy set CGI interface +# +# Copyright (C) 2015 SliTaz GNU/Linux - BSD License +# + +# Common functions from libtazpanel +. lib/libtazpanel +get_config + + +case "$1" in + menu) + TEXTDOMAIN_original=$TEXTDOMAIN + export TEXTDOMAIN='floppy' + + #which bootloader > /dev/null && + cat <$(_ 'Boot floppy') +EOT + export TEXTDOMAIN=$TEXTDOMAIN_original + exit +esac + + +# +# Commands +# + +error= +case " $(POST) " in +*\ doformat\ *) + fdformat $(POST fd) + which mkfs.$(POST fstype) > /dev/null 2>&1 && + mkfs.$(POST fstype) $(POST fd) + ;; +*\ write\ *) + if [ "$(FILE fromimage tmpname)" ]; then + dd if=$(FILE fromimage tmpname) of=$(POST tofd) + rm -f $(FILE fromimage tmpname) + else + error="$(msg err 'Broken FILE support')" + fi ;; +*\ read\ *) + dd if=$(POST fromfd) of=$(POST toimage) + ;; +*\ build\ *) + cd $(POST workdir) + cmd="" + toremove="" + while read key file ; do + [ "$(FILE $file size)" ] || continue + cmd="$cmd $key $(FILE $file tmpname)" + toremove="$toremove $(FILE $file tmpname)" + done <&1 + [ "$toremove" ] && rm -f $toremove + xhtml_footer + exit 0 + fi + ;; +esac + +listfd() +{ + echo "" +} + +TITLE="$(_ 'TazPanel - floppy')" +header +xhtml_header +echo "$error" + +cat < +EOT +[ -w /dev/fd0 ] && cat < +
+ $(_ 'Floppy disk format') +
+ + $(listfd fd) filesystem: + + + +
+
+ $(_ 'Floppy disk transfert') +
+ + + + + + + + +
+ + $(listfd tofd) <<< +
+ + $(listfd fromfd) >>> + +
+
+EOT +cat < +
+ $(_ 'Boot floppy set builder') +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
$(_ 'Linux kernel:') $(_ 'required')
$(_ 'Initramfs / Initrd:') $(_ 'optional')
$(_ 'Extra initramfs:') $(_ 'optional')
$(_ 'Boot message:') $(_ 'optional')
$(_ 'Default cmdline:') $(_ 'edit') + $(_ 'optional')
$(_ 'Root device:') +   $(_ 'Flags:') +   VESA: +
$(_ 'Output directory:')
$(_ 'Floppy size:')  + $(_ 'RAM used')   + +
+
+

+$(_ 'Note') 1: $(_ 'the extra initramfs may be useful to add your own configuration files.') +

+

+$(_ 'Note') 2: $(_ 'the keyboard is read for ESC or ENTER on every form feed (ASCII 12) in the boot message.') +

+
+ + +EOT + +xhtml_footer +exit 0 diff -r a81e49dbaf30 -r 01f2e8c0ea7b tazpanel-extra/stuff/powersaving.cgi --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tazpanel-extra/stuff/powersaving.cgi Fri Jul 31 23:33:17 2015 +0200 @@ -0,0 +1,177 @@ +#!/bin/sh +# +# Hardware / power saving +# +# Copyright (C) 2011-2015 SliTaz GNU/Linux - BSD License +# + +# Common functions from libtazpanel +. lib/libtazpanel +get_config + +case "$1" in + menu) + cat <$(_ 'Power saving') +EOT + exit +esac + +header + +TITLE=$(_ 'Hardware') + +xhtml_header "$(_ 'Power saving')" + +## DPMS ## +cat < +
+ DPMS (Display Power Management Signaling) +
+ +
$(_ "DPMS enables power saving behaviour of monitors when the computer is not in use.")
+
+ +EOT + +monitor_conf='/etc/X11/xorg.conf.d/50-Monitor.conf' +if [ ! -s "$monitor_conf" ]; then + # Config is absent, so create it + cat > "$monitor_conf" < + + $(_ 'Identifier') + $(_ 'Vendor name') + $(_ 'Model name') + $(_ 'DPMS enabled') + + +EOT + +awk -F\" '{ + if ($1 ~ /^Section/) { I = V = M = D = ""; } + if ($1 ~ /Identifier/) { I = $2; } + if ($1 ~ /VendorName/) { V = $2; } + if ($1 ~ /ModelName/) { M = $2; } + if ($1 ~ /Option/ && $2 ~ /DPMS/) { D = $4; } + if ($1 ~ /EndSection/) { + if (D == "false") { D = ""; } else { D = "checked"; } + printf "%s%s%s", I, V, M; + printf "", I, D; + printf "\n"; + } +}' $monitor_conf + +layout_conf='/etc/X11/xorg.conf.d/10-ServerLayout.conf' + +cat < + + + + + + +
+
+ $(_ 'DPMS times (in minutes):') + + + + + + + +
Standby Time
Suspend Time
Off Time
+
+
+
+ $(_ 'Manual edit') + $(basename $monitor_conf)
+ $(basename $layout_conf) +
+
$(for i in $(POST); do echo "$i: " $(POST $i); done)
+
+
+ +
+ + +EOT + + +## CPU ## + +cpu=$(awk -F: '$1 ~ "model name" { + gsub(/\(TM\)/,"™",$2); gsub(/\(R\)/,"®",$2); + split($2,c,"@"); + print "" c[1] ""; +}' /proc/cpuinfo) +multiplier=$(echo "$cpu" | wc -l) +[ "$multiplier" -ne 1 ] && cpu="$multiplier × $(echo "$cpu" | head -n1)" + +freq=$(awk -F: 'BEGIN{N=0}$1~"MHz"{printf "%d:%sMHz ",N,$2; N++}' /proc/cpuinfo) + +cat < +
$(_ 'CPU')
+ +
$(_ "CPU frequency scaling enables the operating system to scale the \ +CPU frequency up or down in order to save power. CPU frequencies can be scaled \ +automatically depending on the system load, in responce to ACPI events, or \ +manually by userspace programs.")
+ + + + +
$(_ 'Model name')$cpu
$(_ 'Current frequency')$freq
$(_ 'Current driver')$(cat '/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver') +
$(_ 'Current governor')$(cat '/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor') +
+ +EOT + +# As of Kernel 3.4, the native CPU module is loaded automatically. +if [ -d "/lib/modules/$(uname -r)/kernel/drivers/cpufreq" ]; then + cd /lib/modules/$(uname -r)/kernel/drivers/cpufreq + cat < +
$(_ 'Kernel modules')
+ + + + + + +EOT + lsmod="$(lsmod | awk '{printf "%s " $1}') " + + for module in $(ls | grep -v 'mperf\|speedstep-lib'); do + module="${module%.ko.xz}"; module="${module//-/_}" + if echo $lsmod | grep -q " $module "; then icon='ok'; else icon='cancel'; fi + echo "" + done + cat < + +EOT +fi + +xhtml_footer +exit 0
$(_ 'Module')$(_ 'Description')
$module" + modinfo $module | awk -F: '$1=="description"{ + gsub(/\(TM\)/,"™",$2); gsub(/\(R\)/,"®",$2); + gsub(/VIA|C7|Cyrix|MediaGX|NatSemi|Geode|Transmeta|Crusoe|Efficeon|Pentium™ 4|Xeon™|AMD|K6-2\+|K6-3\+|K7|Athlon 64|Opteron|Intel/,"&",$2); + print $2}' + echo "