Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- ### BEGIN INIT INFO
- # Provides: coolercontrold
- # Required-Start: $network $local_fs $remote_fs
- # Required-Stop: $network $local_fs $remote_fs
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: CoolerControl Daemon
- # Description: CoolerControl Daemon for managing cooling systems.
- ### END INIT INFO
- # Source function library.
- . /etc/init.d/functions
- # Path to the coolercontrold executable
- DAEMON=/usr/bin/coolercontrold
- NAME=coolercontrold
- DESC="CoolerControl Daemon"
- PIDFILE=/var/run/$NAME.pid
- LOGFILE=/var/log/$NAME.log
- # Environment variables
- export COOLERCONTROL_LOG=INFO
- # Start the service
- start() {
- echo -n $"Starting $DESC: "
- if [ -f $PIDFILE ]; then
- if kill -0 $(cat $PIDFILE) > /dev/null 2>&1; then
- echo "$NAME is already running."
- exit 1
- else
- rm -f $PIDFILE
- fi
- fi
- $DAEMON >> $LOGFILE 2>&1 &
- echo $! > $PIDFILE
- echo "$NAME."
- }
- # Stop the service
- stop() {
- echo -n $"Stopping $DESC: "
- if [ -f $PIDFILE ]; then
- kill $(cat $PIDFILE) > /dev/null 2>&1
- rm -f $PIDFILE
- echo "$NAME."
- else
- echo "$NAME is not running."
- fi
- }
- # Restart the service
- restart() {
- stop
- sleep 1
- start
- }
- # Reload the service (not applicable for this service)
- reload() {
- echo "Reloading $DESC: Not supported."
- }
- # Check the status of the service
- status() {
- if [ -f $PIDFILE ]; then
- if kill -0 $(cat $PIDFILE) > /dev/null 2>&1; then
- echo "$NAME is running."
- else
- echo "$NAME is not running but PID file exists."
- fi
- else
- echo "$NAME is not running."
- fi
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- restart
- ;;
- reload)
- reload
- ;;
- status)
- status
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|reload|status}"
- exit 1
- ;;
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement