Hi,
every (updated) model railroad content is now on:
https://launchpad.net/mrsd
.
Have fun!
electronics – linux – model railroad
Hi,
every (updated) model railroad content is now on:
https://launchpad.net/mrsd
.
Have fun!
Hello,
I’ve set up a print server with auto shutdown capability.
It checks if an idle timeout is reached, if there are active print jobs and if the idle timeout is greater than the uptime the server shuts down.
It also has a lock option if you want to have the server online (You could enable the lock with the ~/.xsession and/or the ~/.bashrc file).
#!/bin/bash IDLE=30 #idle time in min echo "Shutdown script" echo "#########################################" echo "" if [[ "$1" == "lock" ]]; then touch /var/lock/shutdown.sh.lock fi if [[ "$1" == "unlock" ]]; then rm -f /var/lock/shutdown.sh.lock echo "Lock file removed, exiting" exit 0 fi if [ -f /var/lock/shutdown.sh.lock ]; then LOCK=1 echo "Lock file exists, exiting" exit 0 else LOCK=0 fi MODTIME=`stat -c %Y /var/log/cups/page_log | awk '{ printf $1 "n"}'` TIME=`date +%s` SECS=$(echo "$IDLE*60" | bc) TEMP=`echo "$MODTIME+$SECS" | bc` UPTIME=$(cat /proc/uptime | awk '{ printf $1 }') UPTIME=$(echo $UPTIME / 1 | bc) lpstat -t | grep -q "now printing" PRINTING=$? echo "Uhrzeit $TIME" echo "Uptime $UPTIME" echo "Idle secs $SECS" echo "Temp $TEMP" echo "Printing $PRINTING" if (( ( "$TEMP" < "$TIME" ) && ( "$UPTIME" > "$SECS" ) &! $LOCK && $PRINTING )); then echo "Printer spooler system shutdown because of idle timeout." | wall #echo $TEMP "<" $TIME /sbin/halt -p else echo "Printer spooler system: Timeout not reached" fi
Have fun!