Advertisement
Skedar

Linux G50vt Oled install.sh

Jan 26th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.39 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. cd `dirname $0`
  4.  
  5. which java &>/dev/null
  6.  
  7. if [ $? != 0 ]; then
  8. echo "You don't seem to have java installed, or it cannot be found in the PATH"
  9. echo "Please correct this and try again"
  10. exit 1
  11. fi
  12.  
  13. if [ `id -u` != 0 ]; then
  14. echo "You should run this script as root, so it is able to make the required changes to /etc/acpi"
  15. exit 1
  16. fi
  17.  
  18. lsmod | grep -q asus_oled
  19.  
  20. if [ $? != 0 ]; then
  21. echo ""
  22. echo " ERROR: You have not loaded asus_oled kernel module!"
  23. echo ""
  24. echo " The daemon will not work without the module, so please go to"
  25. echo " http://lapsus.berlios.de/asus_oled.html"
  26. echo " and grab the latest (SVN!) version of the module. Then run this script again."
  27. echo ""
  28. exit 1
  29. fi
  30.  
  31.  
  32. # install ACPI event handlers for ASUS G50
  33. export WHERE=`cd ..; pwd`
  34.  
  35. # Copy one of the scripts, replacing "/opt/leds" with the real location where the program resides
  36. # @param 1 script to install
  37. # @param 2 destination file name
  38. # @return nothing
  39. function cpScript(){
  40. SCRIPT="$1"
  41. TARGET="$2"
  42.  
  43. sed "s#/opt/leds#$WHERE#g" < "$SCRIPT" > "$TARGET"
  44.  
  45. chmod +x "$TARGET"
  46. }
  47.  
  48. ACPID=""
  49.  
  50. if [ -f /etc/init.d/acpid ]; then
  51. ACPID=/etc/init.d/acpid
  52. elif [ -f /etc/rc.d/init.d/acpid ]; then
  53. ACPID=/etc/rc.d/init.d/acpid
  54. fi
  55.  
  56. if [ -z "$ACPID" ]; then
  57. echo "acpid cannot be located in either /etc/init.d or /etc/rc.d/init.d"
  58. echo "I will not install the ACPI event handlers"
  59. else
  60. echo "Found acpid as $ACPID, installing event handlers in /etc/acpi"
  61.  
  62. mkdir -p /etc/acpi/events &>/dev/null
  63.  
  64. cp acpi/events/* /etc/acpi/events/
  65.  
  66. cpScript acpi/asus-g50-games.sh /etc/acpi/asus-g50-games.sh
  67.  
  68. for script in asus-g50-lid.sh asus-g50-run.sh; do
  69. cp acpi/$script /etc/acpi
  70. chmod +x /etc/acpi/$script
  71. done
  72.  
  73. $ACPID reload
  74. fi
  75.  
  76. # install startup script
  77. if [ -d /etc/init ]; then
  78. echo "Installing Upstart configuration in /etc/init"
  79. cpScript asusg50leds.conf /etc/init/asusg50leds.conf
  80. chmod a-x /etc/init/asusg50leds.conf
  81. fi
  82.  
  83. if [ -d /etc/event.d ]; then
  84. echo "Installing Upstart configuration in /etc/event.d"
  85. cpScript asusg50leds.conf /etc/event.d/asusg50leds.conf
  86. chmod a-x /etc/event.d/asusg50leds.conf
  87. fi
  88.  
  89.  
  90. which update-rc.d &>/dev/null
  91.  
  92. if [ $? = 0 ]; then
  93. echo "Installing Ubuntu/Debian startup script"
  94. cpScript asusg50leds.sh /etc/init.d/asusg50leds.sh
  95. update-rc.d asusg50leds.sh defaults 80 20
  96. exit 0
  97. fi
  98.  
  99. which chkconfig &>/dev/null
  100.  
  101. if [ $? = 0 ]; then
  102. echo -n "Installing RedHat/SuSE startup script "
  103.  
  104. if [ -d /etc/rc.d/init.d ]; then
  105. echo "in /etc/rc.d/init.d"
  106. cpScript asusg50leds.sh /etc/rc.d/init.d/asusg50leds.sh
  107. elif [ -d /etc/init.d ]; then
  108. echo "in /etc/init.d"
  109. cpScript asusg50leds.sh /etc/init.d/asusg50leds.sh
  110. else
  111. echo "Sorry, neither /etc/rc.d/init.d or /etc/init.d are present. I don't know what to do."
  112. exit 1
  113. fi
  114.  
  115. chkconfig --add asusg50leds.sh
  116. exit 0
  117. fi
  118.  
  119. which rc-update &>/dev/null
  120.  
  121. if [ $? = 0 ]; then
  122. echo "Installing Gentoo startup script"
  123. cpScript gentoo/asusg50leds /etc/init.d/asusg50leds
  124. rc-update add asusg50leds default
  125. exit 0
  126. fi
  127.  
  128. echo "I don't know how to install the startup script on your system!"
  129. echo "It should be very simple to adapt asusg50leds.sh on your system too."
  130.  
  131. exit 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement