Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- cd `dirname $0`
- which java &>/dev/null
- if [ $? != 0 ]; then
- echo "You don't seem to have java installed, or it cannot be found in the PATH"
- echo "Please correct this and try again"
- exit 1
- fi
- if [ `id -u` != 0 ]; then
- echo "You should run this script as root, so it is able to make the required changes to /etc/acpi"
- exit 1
- fi
- lsmod | grep -q asus_oled
- if [ $? != 0 ]; then
- echo ""
- echo " ERROR: You have not loaded asus_oled kernel module!"
- echo ""
- echo " The daemon will not work without the module, so please go to"
- echo " http://lapsus.berlios.de/asus_oled.html"
- echo " and grab the latest (SVN!) version of the module. Then run this script again."
- echo ""
- exit 1
- fi
- # install ACPI event handlers for ASUS G50
- export WHERE=`cd ..; pwd`
- # Copy one of the scripts, replacing "/opt/leds" with the real location where the program resides
- # @param 1 script to install
- # @param 2 destination file name
- # @return nothing
- function cpScript(){
- SCRIPT="$1"
- TARGET="$2"
- sed "s#/opt/leds#$WHERE#g" < "$SCRIPT" > "$TARGET"
- chmod +x "$TARGET"
- }
- ACPID=""
- if [ -f /etc/init.d/acpid ]; then
- ACPID=/etc/init.d/acpid
- elif [ -f /etc/rc.d/init.d/acpid ]; then
- ACPID=/etc/rc.d/init.d/acpid
- fi
- if [ -z "$ACPID" ]; then
- echo "acpid cannot be located in either /etc/init.d or /etc/rc.d/init.d"
- echo "I will not install the ACPI event handlers"
- else
- echo "Found acpid as $ACPID, installing event handlers in /etc/acpi"
- mkdir -p /etc/acpi/events &>/dev/null
- cp acpi/events/* /etc/acpi/events/
- cpScript acpi/asus-g50-games.sh /etc/acpi/asus-g50-games.sh
- for script in asus-g50-lid.sh asus-g50-run.sh; do
- cp acpi/$script /etc/acpi
- chmod +x /etc/acpi/$script
- done
- $ACPID reload
- fi
- # install startup script
- if [ -d /etc/init ]; then
- echo "Installing Upstart configuration in /etc/init"
- cpScript asusg50leds.conf /etc/init/asusg50leds.conf
- chmod a-x /etc/init/asusg50leds.conf
- fi
- if [ -d /etc/event.d ]; then
- echo "Installing Upstart configuration in /etc/event.d"
- cpScript asusg50leds.conf /etc/event.d/asusg50leds.conf
- chmod a-x /etc/event.d/asusg50leds.conf
- fi
- which update-rc.d &>/dev/null
- if [ $? = 0 ]; then
- echo "Installing Ubuntu/Debian startup script"
- cpScript asusg50leds.sh /etc/init.d/asusg50leds.sh
- update-rc.d asusg50leds.sh defaults 80 20
- exit 0
- fi
- which chkconfig &>/dev/null
- if [ $? = 0 ]; then
- echo -n "Installing RedHat/SuSE startup script "
- if [ -d /etc/rc.d/init.d ]; then
- echo "in /etc/rc.d/init.d"
- cpScript asusg50leds.sh /etc/rc.d/init.d/asusg50leds.sh
- elif [ -d /etc/init.d ]; then
- echo "in /etc/init.d"
- cpScript asusg50leds.sh /etc/init.d/asusg50leds.sh
- else
- echo "Sorry, neither /etc/rc.d/init.d or /etc/init.d are present. I don't know what to do."
- exit 1
- fi
- chkconfig --add asusg50leds.sh
- exit 0
- fi
- which rc-update &>/dev/null
- if [ $? = 0 ]; then
- echo "Installing Gentoo startup script"
- cpScript gentoo/asusg50leds /etc/init.d/asusg50leds
- rc-update add asusg50leds default
- exit 0
- fi
- echo "I don't know how to install the startup script on your system!"
- echo "It should be very simple to adapt asusg50leds.sh on your system too."
- exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement