Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # chkconfig: 2345 99 20
- # description: ASUS G50 OLED Daemon
- # Startup script to be installed in /etc/init.d or equivalent
- ### BEGIN INIT INFO
- # Provides: asusg50leds
- # Required-Start: $syslog $local_fs $network
- # Required-Stop: $syslog
- # Should-Start:
- # Should-Stop:
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Starts asusg50leds
- # Description: Starts the ASUS OLED daemon
- ### END INIT INFO
- # Get the position in lsmod of some module
- # @param 1 module name
- getModulePos()
- {
- lsmod | awk '{print $1}' | nl | grep "$1" | awk '{print $1}'
- }
- reloadModules()
- {
- rmmod asus_oled >/dev/null
- rmmod usbhid
- modprobe asus_oled
- modprobe usbhid
- }
- # Check if "asus_oled" is loaded _before_ "usbhid"
- checkModulesOrder(){
- usbhidpos=`getModulePos usbhid`
- asusoledpos=`getModulePos asus_oled`
- if [ -z "$usbhidpos" ]; then
- if [ -z "$asusoledpos" ]; then
- modprobe asus_oled
- fi
- else
- if [ -z "$asusoledpos" ]; then
- reloadModules
- elif [ "$asusoledpos" -lt "$usbhidpos" ]; then
- reloadModules
- fi
- fi
- }
- # Check if the kernel version requires re-arranging of the modules order
- # @return 0 if it is not required, 1 is re-arranging is required
- checkKernelVersion(){
- kernelversion=`uname -r`
- MAJ=`echo "$kernelversion" | awk -F'[-._]' '{print $1}'`
- MIN=`echo "$kernelversion" | awk -F'[-._]' '{print $2}'`
- REL=`echo "$kernelversion" | awk -F'[-._]' '{print $3}'`
- VER=$((MAJ*1000000+MIN*1000+REL))
- # if before 2.6.28 return 1 else return 0
- if [ $VER -lt 2006028 ]; then
- if [ $VER -lt 2006027 ]; then
- echo "***"
- echo "*** You should upgrade the kernel to at least 2.6.27 to take full benefit of the Asus G50/G70 hardware"
- echo "***"
- fi
- return 1
- fi
- return 0
- }
- case "$1" in
- start|restart)
- checkKernelVersion || checkModulesOrder
- # By default the value there is 0 although the led is lit
- echo 1 > "/sys/class/leds/asus::touchpad/brightness" 2>/dev/null
- /opt/leds/start.sh &
- ;;
- stop)
- /opt/leds/stop.sh
- ;;
- *)
- N=/etc/init.d/${0##*/}
- echo "Usage: $N {start|stop|restart}"
- exit 1
- ;;
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement