Advertisement
Guest User

Untitled

a guest
Jan 30th, 2025
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.06 KB | None | 0 0
  1. #!/bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          coolercontrold
  4. # Required-Start:    $network $local_fs $remote_fs
  5. # Required-Stop:     $network $local_fs $remote_fs
  6. # Default-Start:     2 3 4 5
  7. # Default-Stop:      0 1 6
  8. # Short-Description: CoolerControl Daemon
  9. # Description:       CoolerControl Daemon for managing cooling systems.
  10. ### END INIT INFO
  11.  
  12. # Source function library.
  13. . /etc/init.d/functions
  14.  
  15. # Path to the coolercontrold executable
  16. DAEMON=/usr/bin/coolercontrold
  17. NAME=coolercontrold
  18. DESC="CoolerControl Daemon"
  19. PIDFILE=/var/run/$NAME.pid
  20. LOGFILE=/var/log/$NAME.log
  21.  
  22. # Environment variables
  23. export COOLERCONTROL_LOG=INFO
  24.  
  25. # Start the service
  26. start() {
  27.     echo -n $"Starting $DESC: "
  28.     if [ -f $PIDFILE ]; then
  29.         if kill -0 $(cat $PIDFILE) > /dev/null 2>&1; then
  30.             echo "$NAME is already running."
  31.             exit 1
  32.         else
  33.             rm -f $PIDFILE
  34.         fi
  35.     fi
  36.     $DAEMON >> $LOGFILE 2>&1 &
  37.     echo $! > $PIDFILE
  38.     echo "$NAME."
  39. }
  40.  
  41. # Stop the service
  42. stop() {
  43.     echo -n $"Stopping $DESC: "
  44.     if [ -f $PIDFILE ]; then
  45.         kill $(cat $PIDFILE) > /dev/null 2>&1
  46.         rm -f $PIDFILE
  47.         echo "$NAME."
  48.     else
  49.         echo "$NAME is not running."
  50.     fi
  51. }
  52.  
  53. # Restart the service
  54. restart() {
  55.     stop
  56.     sleep 1
  57.     start
  58. }
  59.  
  60. # Reload the service (not applicable for this service)
  61. reload() {
  62.     echo "Reloading $DESC: Not supported."
  63. }
  64.  
  65. # Check the status of the service
  66. status() {
  67.     if [ -f $PIDFILE ]; then
  68.         if kill -0 $(cat $PIDFILE) > /dev/null 2>&1; then
  69.             echo "$NAME is running."
  70.         else
  71.             echo "$NAME is not running but PID file exists."
  72.         fi
  73.     else
  74.         echo "$NAME is not running."
  75.     fi
  76. }
  77.  
  78. case "$1" in
  79.     start)
  80.         start
  81.         ;;
  82.     stop)
  83.         stop
  84.         ;;
  85.     restart)
  86.         restart
  87.         ;;
  88.     reload)
  89.         reload
  90.         ;;
  91.     status)
  92.         status
  93.         ;;
  94.     *)
  95.         echo $"Usage: $0 {start|stop|restart|reload|status}"
  96.         exit 1
  97.         ;;
  98. esac
  99.  
  100. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement