A small command library for your commands.conf / Kleine Befehlsammlung für die commands.conf -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Timer-controlled computer shutdown / Zeitgesteuerter Shutdown des PCs Shutdown 30 min : /usr/bin/shutdown30min.sh #!/bin/sh at -f /usr/bin/vdrshutdown.sh now + 30 minutes echo VDR Station geht in 30 Minuten schlafen ... atq | \ awk '{printf"Uhrzeit: %s\n",$3,stdout}' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- VDR restart / Startet VDR neu VDR Reboot : killall -9 vdr -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- System shutdown / Fährt den PC runter System Power Off : /sbin/poweroff 2>&1 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- System re-boot / Startet den PC neu System Reboot : /sbin/reboot 2>&1 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Some scripts to show the recording capacity using the on-screen display Verschiedene Scripte für die Kapazitätsanzeige per OSD capacity : echo -n "There are approx. "; echo -n `df | awk '/video/ { space +=$4 } END { printf "%d", space/30000, stdout;}'`; echo " minutes left for recording" capacity : df -h | grep '/video' | awk '{ print 100 - $5 "% Hard disk space available for recording"; }' capacity : df -h | awk '{print $4," ",$5," ",$6}' capacity : cd /video;du -sk *|sort -n|cut -c1-29 capacity : df -h | grep '/video' | awk '{ print 100 - $5 "% free"; }' capacity : df -m | grep /video | awk '{ hours = int($4/1650); minutes = $4/27.5 - hours*60; printf "Available: %ih %imin (%i MB, ", hours, minutes, $4; print 100-$5 "%)" }' capacity : cd /video/ ; du -m */* | sort -nr | sed -e 's/\.\///' -e 's/\...\...\././' -e 's/\/../\//' -e's/ \([^\/]\{0,20\}\)[^\/]*\/\(..\)-\(..\)-\(..\)/ \1\/\2\3\4/g' -e 's/\.rec$//' -e 's/\.del$/~/' /vtx % : [ -e /vtx ] && echo "`df -m | grep 'tmpfs' | awk '{print "/vtx "$5" use ..."}'`" || echo "directory /vtx not exist ..." -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- System Messages per OSD Messages View Messages: tail -n100 /var/log/messages -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Delete the message history / Löschen der Messages History Clear Messages : cd /var/log; cat /dev/null > /var/log/messages -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Mount a NFS drive / Einhängen von NFS Drive Mount NFS Drive Video : mount -t nfs 10.25.164.11:/video /video -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Mount SMB shares / Einhängen von SMB Shares Mount SMB /video0 : mount -t smbfs -o password=******** //Server/video /video0 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Get the status of your DSL line TDSL-Status : echo -n "Akt. IP-Adresse: "; route -n | grep UG | awk '{ print $2; }'; echo -n "Status: "; cat /etc/ppp/ppp_status DSL-Status : echo -n "Act. IP-Address: "; route -n | grep UG | awk '{ print $2; }'; echo -n "Status: "; cat /etc/ppp/ppp_status -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Start / Stop DSL connection DSL-Verbindung on : echo "DSL wird Online geschaltet"; /usr/sbin/cinternet -start; echo "PPPD gestartet" > /etc/ppp/ppp_status DSL-Connetion off : echo "DSL will be switched off"; /usr/sbin/cinternet -stop; echo "PPPD stopped" > /etc/ppp/ppp_status -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Start / Stop ISDN connection ISDN Einwahl / dial-in : isdnctrl dial ippp0 ISDN Auflegen / hangup : isdnctrl hangup ippp0 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Reboot of a different operating system / Neustart in ein anderes Betriebsystem reboot w2k : lilo -R windows| shutdown -r now -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Network Netstat : netstat -n -t TCP | grep "$*" Actual IP : route -n | grep UG | awk '{ print $2; }' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Command to show conversion progress of tosvcd / Kommando zur Fortschritt Anzeige von tosvcd view log : tail -1 -n40 /video/mpeg/*.log -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Command for news servers news : lynx -dump http://slashdot.org -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Script to control the system´s status / Script zur Systemstatus Abfrage CPU Temperatur/temperature : cat /proc/sys/dev/sensors/via686a-isa-6000/temp1 2>&1 Mainboard Temperatur/temperature : cat /proc/sys/dev/sensors/via686a-isa-6000/temp2 2>&1 Memory Info : cat /proc/meminfo -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- CPU Statics CPU Stats: vmstat 1 10 | awk '{a+=$14;b+=$15;c+=$16} END {a=a/10;b=b/10;c=c/10;printf "CPU stats:\nus\tsy\tid\n"a"\t"b"\t"c"\n"}' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- CD Copy Script Copy Files: at now -f /usr/bin/cdcopy #! /bin/sh mount /cdrom if [ -r /cdrom/*.avi ]; then cp /cdrom/*.avi /video/divx/ >/dev/null fi if [ -r /cdrom/*.mpg ]; then cp /cdrom/*.mpg /video/divx/ >/dev/null fi if [ -r /cdrom/*.mpeg ]; then cp /cdrom/*.mpeg /video/divx/ >/dev/null fi umount /cdrom eject /dev/hdc -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Simple Script to change channel lists with a pass code (the kids should not see everything) Simples Script um Channel Listen per code zu tauschen (Kids sollten ja nicht alles sehen) Primarily 2 channel lists will be generated, one for the kids, and the other for the 'super user', the same story also for the commands.conf. Zuerst werden 2 channel Listen erstellt, eine für Kids und eine für den Super User, das selbe für die commands.conf. */VDRtmp/tmp/channels.conf */VDRtmp/tmp/channels.kids.conf */VDRtmp/tmp/commands.conf */VDRtmp/tmp/commands.kids.conf The shell script: ------------------------------<*/VDRtmp/scripts/code.sh>------------------------------ #!/bin/bash # # Simple script that change the $(channels|commands).conf for kids with a pass code via commands.conf # CODE="123456789" MYPATH="/usr/local/src/VDRtmp" CMDLST="${MYPATH}/tmp/code" CH_USER="${MYPATH}/tmp/channels.conf" CH_KIDS="${MYPATH}/tmp/channels.kids.conf" CM_USER="${MYPATH}/tmp/commands.conf" CM_KIDS="${MYPATH}/tmp/commands.kids.conf" if ! [[ -e ${CM_KIDS} && -e ${CH_KIDS} && -e ${CH_USER} && -e ${CH_USER} ]] then echo "Sorry can not change, check your *.conf files !" exit fi case "$1" in view) if [ -e ${CMDLST} ] then echo "$(echo `cat ${CMDLST}` | sed -e 's/ //g')" else echo "Sorry code not found" rm ${CMDLST} fi ;; change) cat ${CH_KIDS} > ${MYPATH}/channels.conf cat ${CM_KIDS} > ${MYPATH}/commands.conf killall -9 vdr ;; run) if [ -e ${CMDLST} ] then if [ ${CODE} -eq $(echo `cat ${CMDLST}` | sed -e 's/ //g') ] then cat ${CH_USER} > ${MYPATH}/channels.conf cat ${CM_USER} > ${MYPATH}/commands.conf rm ${CMDLST} killall -9 vdr else echo "Error 'code' abort" rm ${CMDLST} fi else echo "Sorry code not found" rm ${CMDLST} fi ;; clear) if [ -e ${CMDLST} ] then rm ${CMDLST} echo "Code cleaned up" else echo "Sorry code not found" fi ;; esac -------------------------------------------------------------------------------------- Commands for the */VDRtmp/tmp/commands.kids.conf / Einträge für die */VDRtmp/tmp/commands.kids.conf -------------------------<*/VDRtmp/tmp/commands.kid.conf>----------------------------- .... -> : echo 1 >> */VDRtmp/tmp/code; */VDRtmp/scripts/code.sh view -> : echo 2 >> */VDRtmp/tmp/code; */VDRtmp/scripts/code.sh view -> : echo 3 >> */VDRtmp/tmp/code; */VDRtmp/scripts/code.sh view -> : echo 4 >> */VDRtmp/tmp/code; */VDRtmp/scripts/code.sh view -> : echo 5 >> */VDRtmp/tmp/code; */VDRtmp/scripts/code.sh view -> : echo 6 >> */VDRtmp/tmp/code; */VDRtmp/scripts/code.sh view -> : echo 7 >> */VDRtmp/tmp/code; */VDRtmp/scripts/code.sh view -> : echo 8 >> */VDRtmp/tmp/code; */VDRtmp/scripts/code.sh view -> : echo 9 >> */VDRtmp/tmp/code; */VDRtmp/scripts/code.sh view Run : */VDRtmp/scripts/code.sh run Clear : */VDRtmp/scripts/code.sh clear View : */VDRtmp/scripts/code.sh view .... -------------------------------------------------------------------------------------- Command for the */VDRtmp/commands.conf / Eintrag für die */VDRtmp/commands.conf -------------------------<*/VDRtmp/commands.conf>------------------------------------- Change channels : */VDRtmp/scripts/code.sh change -------------------------------------------------------------------------------------- The sample uses 123456789, and can be selected via the commands menu of the VDR. 1 [Enter] 2 [Enter] 3 [Enter] ...... Once all variables are integrated in the file code.sh, you need to execute "run". This will read the file code.sh, verifies the variables. Das Sample hat 123456789 stellen, kann im VDR Menü unter (commands) aufgerufen werden. 1 [Enter] 2 [Enter] 3 [Enter] ...... sind alle Variablen in der */VDRtmp/tmp/code, klickt man "Run", nun wird die */VDRtmp/tmp/code ausgelesen, Variablen überprüft If the variables are correct, the script will first delete the */VDRtmp/tmp/code and then read out the */VDRtmp/tmp/channels.conf, and adds this to the */VDRtmp/channels.conf. The same procedure happens also with the commands.conf. Finally a "kill VDR" ensures that the new list will be used by VDR after the restart. Stimmen die Variablen überein, wird als erstes die */VDRtmp/tmp/code gelöscht, dann die */VDRtmp/tmp/channels.conf ausgelesen und direct per cat && echo in die */VDRtmp/channels.conf gewritet, analog dazu das selbe mit der commands.conf. (zum Schluß ein vdr kill, damit die neue Liste von VDR geladen wird). I should be relatively complex to find out the code without knowing it. The possibilities given by 6 digits are tremendous. If we would use alpha-numerics instead of numerics the complexity would be higher. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Plugins (on|off) via commands.conf The shell script: ------------------------------<*/VDRtmp/scripts/change.sh>---------------------------- #!/bin/bash # # Simple script that set plugins entries (on/off) via commands.conf # MYPATH="/usr/local/src" VDRCONF="${MYPATH}/VDR/runvdr.conf" ORGCONF="${MYPATH}/VDRtmp/scripts/runvdr.conf" VERSION="`grep 'VDRVERSION' ${MYPATH}/VDR/config.h | cut -f 2 -d '"'`" function view () { grep "\\\\" $VDRCONF| sed -e '1d' -e 's/\\//' | awk '{print $1" "$2}' } case "$1" in view) if [ -e ${VDRCONF} ] then view else echo "Error runvdr.conf not found" fi exit 0 ;; load) if [ -e ${ORGCONF} ] then cat ${ORGCONF} > ${VDRCONF} view else echo "Error orginal runvdr.conf not found" fi exit 0 ;; *) if [ ! -f ${MYPATH}/VDR/PLUGINS/lib/libvdr-$1.so.${VERSION} ] then echo "Sorry Plugin $1 not found, can not edit the runvdr.conf !" exit 0 elif (grep "$1 \\\\" ${VDRCONF} | egrep -q 'P') then perl -p -i -e "s/-P $1 \\\/ $1 \\\/" ${VDRCONF} else perl -p -i -e "s/ $1 \\\/-P $1 \\\/" ${VDRCONF} fi if (echo `grep "$1 -m" ${VDRCONF}` | egrep -q '\-P') || (echo `grep "$1 -r" ${VDRCONF}` | egrep -q '\-P') then perl -p -i -e "s/-P'$1/'$1/" ${VDRCONF} else perl -p -i -e "s/'$1/-P'$1/" ${VDRCONF} fi view esac -------------------------------------------------------------------------------------- Sample runvdr.conf: -----------------<*/VDRtmp/scripts/runvdr.conf */VDRrunvdr.conf>---------------------- .... DVBDIR="${MYPATH}/DVB/driver" DVBREM="$DVBDIR/../apps/av7110_loadkeys" PLUGIN="${MYPATH}/VDR/PLUGINS/lib/libvdr" VDRPRG="${MYPATH}/VDR/vdr -c ${MYPATH}/VDRtmp -s ${MYPATH}/VDRtmp/scripts/vdrshutdown -L ${MYPATH}/VDR/PLUGINS/lib" VDRCMD="$VDRPRG -w 60 -t /dev/tty8 $* \ -P hello \ -P'image -m ${MYPATH}/VDRtmp/scripts/mount.sh -C ${MYPATH}/VDRtmp/scripts/convert.sh' \ -P'mp3 -m ${MYPATH}/VDRtmp/scripts/mount.sh -B /var/lib/cddb' \ -P'osdteletext -r' \ " .... -------------------------------------------------------------------------------------- Sample runvdr: ------------------------------<*/VDR/runvdr>------------------------------------------ #!/bin/bash .... # Modifikations Thu Apr 10 12:05:41 CEST 2003 createt by runvdr.func ... # Load LCDproc: LCDSTATUS="`ps -ef | grep -e LCDd | grep -c -v grep`" if [[ $LCDSTATUS -eq 0 && -x /usr/local/sbin/LCDd ]] then echo "Starting daemon LCDd" cd ${MYPATH}/lcdproc* ./server/LCDd -c /etc/LCDd.conf & fi # Load Lircd: LIRCSTATUS="`ps -ef | grep -e lircd | grep -c -v grep`" if [[ $LIRCSTATUS -eq 0 && -x /usr/local/sbin/lircd ]] then echo "Starting daemon lircd" setserial /dev/ttyS0 uart none modprobe lirc_serial /usr/local/sbin/lircd & fi VDRUSR=vdr export DVDCSS_METHOD=key # read runvdr.conf . /usr/local/src/VDR/runvdr.conf LSMOD=$(/sbin/lsmod | grep -cw '^dvb') KILL="/usr/bin/killall -q -TERM" # Load driver if it hasn't been loaded already: if [ $LSMOD -eq 0 ] then (echo "Load DVB driver"; cd $DVBDIR; make insmod) if [ -x $PLUGIN-remote* ] then $DVBREM/av7110_loadkeys $DVBREM/hauppauge.rc5 > /proc/av7110_ir fi fi while (true) do su -c "$VDRCMD" $VDRUSR if test $? -eq 0; then exit; fi date echo "restarting VDR" . /usr/local/src/VDR/runvdr.conf $KILL $VDRPRG > /dev/null 2>&1 sleep 10 (cd $DVBDIR; make rmmod; make insmod) date done -------------------------------------------------------------------------------------- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Source: VDR Mailing List, Hubertus Sandmann, my