#!/bin/sh export PATH=/sbin:/usr/sbin:/bin:/usr/bin export RIGHT=${RIGHT-$(($(echo $(stty size 2>/dev/null || echo 37 93) | cut -d ' ' -f 2) - 10))} . /etc/rc.config failed() { touch /var/spool/failed } check_status() { status=$? if [ -n "$1" ]; then status=$1 elif [ -e /var/spool/failed ]; then status=1 fi rm -f /var/spool/failed echo -en "\\033[1A\\033[${RIGHT}G" if [ $status = 0 ]; then echo -en "\\033[1;32mdone" else if [ -n "$2" ]; then echo -en "\\033[1;37m$2" else echo -en "\\033[1;31mfailed" touch /var/spool/error fi fi echo -e "\\033[0;39m" echo $(($(cat /var/spool/bootstep 2>/dev/null || echo 0) + 1)) > /var/spool/bootstep echo 0 > /var/spool/subbootstep show_bootstep return $status } show_step() { subbootstep=$(($(cat /var/spool/subbootstep 2>/dev/null || echo 0) + 1)) echo $subbootstep > /var/spool/subbootstep echo '|/-\' | cut -b $(($subbootstep%4+1)) show_bootstep } show_bootstep() { bootstep=$(cat /var/spool/bootstep 2>/dev/null || echo 0) subbootstep=$(cat /var/spool/subbootstep 2>/dev/null || echo 0) if [ "$splash" = "silent" ]; then echo "show $((65534 * $bootstep / ${BOOTSTEPS:-100} + ($subbootstep * 100)))" 2>/dev/null > /proc/splash fi } hide_splash() { echo "verbose" 2>/dev/null >/proc/splash && { yes "" | head -n $(stty -F /dev/tty1 size | cut -d ' ' -f 1) > /dev/tty1 usleep 10000 } } show_splash() { echo "silent" 2>/dev/null >/proc/splash } #call() #{ # if [ "$splash" = "silent" ]; then # eval "echo \"\$( ($1) 2>&1 )\"" & # else # eval "$1" # fi #} tr() { export LC_ALL=$LANG export TEXTDOMAIN eval echo -n "$(gettext "$1")" } register_setting() { name=$1 value=$2 description=$3 if [ -z "`grep -e "^$name=" /etc/rc.config`" ]; then if [ -z "$registerSetting" ]; then echo >> /etc/rc.config fi if [ -n "$description" ]; then echo "# $description" >> /etc/rc.config fi echo "$name=\"$value\"" >> /etc/rc.config eval "$name=\"$value\"" fi registerSetting=1 } update_setting() { name=$1 value=$2 description=$3 register_setting "$name" "$value" "$description" sed -i -e "s|^$name=.*|$name=\"$value\"|g" /etc/rc.config eval "$name=\"$value\"" } # register_configfile() ## Config file or dir von /etc nach /usr/etc verlegen damit es nicht dauerhaft gespeichert wird # link_configdir() register_config() { search=$1 value=$2 file=$3 if grep -qs "$search" $file; then sed -ie "s|.*\($search\).*|$value|g" $file else echo -e "$value\n" >> $file fi } search_modules() { addon=$1 { pcimodules $addon; usbmodules $addon; } | /usr/bin/tr "\n" "," | sed "s/.$//" } load_modules() { name=$1 modullist=$2 status=0 if [ "$modullist" = "auto" ]; then eval "modullist=\"$(search_modules $name)\"" fi OLDIFS=$IFS IFS=, for modul in $modullist; do if [ -n "$modul" ]; then IFS=$OLDIFS modprobe $modul >>/dev/stdlog 2>&1 || status=$? IFS=, fi done echo "$modullist" > /tmp/$name.drivers return $status } unload_modules() { name=$1 status=0 OLDIFS=$IFS IFS="" modullist="$(echo -n ,$(cat /tmp/$name.drivers 2>/dev/null) | tac -bs ,)" IFS=, for modul in $modullist; do modul=${modul## } modul=${modul%% *} if [ -n "$modul" ]; then IFS=$OLDIFS modprobe -r $modul >>/dev/stdlog 2>/dev/null || status=$? IFS=, fi done return $status } setup_drivers() { name=${0##*/} name=${name%.*} values="$1" eval "driver=\"\$$(echo "$name" | /usr/bin/tr a-z- A-Z_)_DRIVER\"" auto="$(search_modules $name)" test "$driver" != "" && echo "$driver" test "$driver" != "$auto" -a -n "$auto" && echo "$auto" test "$driver" != "auto" && echo "auto" echo "-" echo "$values" } register_application() { name="$1" command="$2" grep -sq "^$name" /usr/share/xorg_autostarts || echo "$name $command" >> /usr/share/xorg_autostarts if [ -e /etc/X11/icewm/menu ]; then com="prog $name $name $command" sed "s|\(# progs\)|\1\n$com\n|" -i /etc/X11/icewm/menu fi if [ -e /etc/vdr/menu.xml -a "$name" != "VDR" ]; then com="" if grep -q "" /etc/vdr/menu.xml; then sed "s|\(.*\)|\1\n\t\t$com|" -i /etc/vdr/menu.xml else app="$(test "$LANG" = "de_DE.UTF-8" && echo "Programme" || echo "Applications")" sed "s|^\(\t\)|\t\n\t\t$com\n\t\n\1|" -i /etc/vdr/menu.xml fi fi } unregister_application() { name="$1" sed "/^$name /d" -i /usr/share/xorg_autostarts if [ -e /etc/vdr/menu.xml ]; then sed "/