~couchNerd ~serialOutrager ~puts2In42 ~makesPigsFly

Shutdown Script For Asus WL-500W With Oleg Firmware

If you have an Asus WL-500W, the DIYers’ favourite wireless router, and have installed the Oleg custom firmware on it, then you would have set up a shutdown script for it, that allows your router to shut down gracefully. This is especially important if you have a USB hard disk attached to it. There are many such scripts available in Oleg’s firmware that you can tweak. All of these reside in “/usr/local/sbin/”. The one that we are going to talk about today is named “pre-shutdown” and it is exceuted just before the router is about to shutdown. Here is my script that will stop all the programs that have been started, finalizes all data accesses for the hard drive, unmounts all the partitions and if they can’t be unmounted, then mounts them as read only to reduce the risks, and then allows the router to continue shutdown. Although this script is written for Asus WL-500W but it will work with most other routers that use oleg or unslung firmware (like Linksys NSLU2, Asus WL-500G, WL-500gP etc):

#! /bin/sh

/opt/etc/init.d/rc.unslung stop

sleep 5s
sync
sleep 5s

for i in `cat /proc/mounts | awk '/ext3/{print($1)}'` ; do
  umount $i
  if [ $? != 0 ] ; then
    echo "Could not unmount $i. Mounting as read only"
    mount -oremount,ro $i
  else
    echo "Unmount $i."
  fi
done
  
swapoff -a
  
sleep 1s

Comments