slackbuilds

Personal Slackbuilds in the style of slackbuilds.org
git clone git://git.danielmoch.com/slackbuilds.git
Log | Files | Refs

rc.throttled (1022B)


      1 #!/bin/sh
      2 #
      3 # Start/Stop/Restart the throttle daemon.
      4 #
      5 
      6 # Start
      7 throttled_start() {
      8   if [ -x /usr/sbin/lenovo_fix.py ]; then
      9     if pgrep -a python3 | grep lenovo_fix.py > /dev/null 2>&1; then
     10       echo "Throttle daemon already started!"
     11     else
     12       echo "Starting Throttle daemon..."
     13       /usr/sbin/lenovo_fix.py > /dev/null 2>&1 &
     14     fi
     15   fi
     16 }
     17 
     18 # Stop
     19 throttled_stop() {
     20   echo "Stopping Throttle daemon..."
     21   if pgrep -a python3 | grep lenovo_fix.py > /dev/null 2>&1; then
     22       kill -9 $(pgrep -a python3 | grep lenovo_fix.py | awk '{ print $1 }')
     23   fi
     24 }
     25 
     26 # Restart
     27 throttled_restart() {
     28   throttled_stop
     29   sleep 3
     30   throttled_start
     31 }
     32 
     33 # Status
     34 throttled_status() {
     35   if pgrep -a python3 | grep lenovo_fix.py > /dev/null 2>&1; then
     36     echo "throttled is running."
     37   else
     38     echo "throttled is stopped."
     39   fi
     40 }
     41 
     42 case "$1" in
     43 'start')
     44   throttled_start
     45   ;;
     46 'stop')
     47   throttled_stop
     48   ;;
     49 'restart')
     50   throttled_restart
     51   ;;
     52 'status')
     53   throttled_status
     54   ;;
     55 *)
     56   echo "usage: $0 start|stop|restart|status"
     57 esac