Skip to content

Instantly share code, notes, and snippets.

@morriq
Last active December 16, 2020 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morriq/0ddf52d1a29913c516a0ee21a691363e to your computer and use it in GitHub Desktop.
Save morriq/0ddf52d1a29913c516a0ee21a691363e to your computer and use it in GitHub Desktop.
fan
#!/bin/bash
# /etc/init.d/fan
### BEGIN INIT INFO
# Provides:fan
# Required-Start:$remote_fs $syslog
# Required-Stop:$remote_fs $syslog
# Default-Start:2 3 4 5
# Default-Stop:0 1 6
# Short-Description: fan
# Description: Fan controller auto start after boot
### END INIT INFO
case "$1" in
start)
echo "Starting Fan"
python3 /home/pi/Scripts/fan.py &
;;
stop)
echo "Stopping Fan"
#killall ledblink.py
kill $(ps aux | grep -m 1 'python3 /home/pi/Scripts/fan.py' | awk '{ print $2 }')
;;
*)
echo "Usage: service fan start|stop"
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment