SHARE
TWEET

Untitled

a guest Oct 15th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. #
  3. # Based upon work by tprelog at https://www.ixsystems.com/community/resources/fn-11-2-iocage-home-assistant-jail-plugins-for-node-red-mosquitto-amazon-dash-tasmoadmin.102/
  4. #
  5. # PROVIDE: homeassistant
  6. # REQUIRE: LOGIN
  7. # KEYWORD: shutdown
  8. #
  9. # homeassistant_enable:    Set to YES to enable the homeassistant service.
  10. #            Default: NO
  11. # homeassistant_user:    The user account used to run the homeassistant daemon.
  12. #            This is optional, however do not specifically set this to an
  13. #            empty string as this will cause the daemon to run as root.
  14. #            Default: homeassistant
  15. # homeassistant_group:    The group account used to run the homeassistant daemon.
  16. #            This is optional, however do not specifically set this to an
  17. #            empty string as this will cause the daemon to run with group wheel.
  18. #            Default: homeassistant
  19. # homeassistant_config_dir:    Directory where config files are located.
  20. #            Default: /usr/home/homeassistant/.homeassistant
  21. # homeassistant_install_dir:    Directory where Home Assistant is installed.
  22. #            Default: /usr/local/share/homeassistant
  23. #
  24. # sysrc homeassistant_enable=yes
  25. # service homeassistant start
  26.  
  27. . /etc/rc.subr
  28. name=homeassistant
  29. rcvar=${name}_enable
  30.  
  31. pidfile_child="/var/run/${name}.pid"
  32. pidfile="/var/run/${name}_daemon.pid"
  33.  
  34. load_rc_config ${name}
  35. : ${homeassistant_enable:="NO"}
  36. : ${homeassistant_user:="homeassistant"}
  37. : ${homeassistant_group:="homeassistant"}
  38. : ${homeassistant_config_dir:="/usr/home/homeassistant/.homeassistant"}
  39. : ${homeassistant_install_dir:="/usr/local/share/homeassistant"}
  40.  
  41. command="/usr/sbin/daemon"
  42. start_precmd=${name}_precmd
  43. homeassistant_precmd()
  44. {
  45.     rc_flags="-f -P ${pidfile} -p ${pidfile_child} ${homeassistant_install_dir}/bin/hass --config ${homeassistant_config_dir} ${rc_flags}"
  46.  
  47.     if [ ! -e "${pidfile_child}" ]; then
  48.             install -g ${homeassistant_group} -o ${homeassistant_user} -- /dev/null "${pidfile_child}";
  49.     fi
  50.  
  51.     if [ ! -e "${pidfile}" ]; then
  52.             install -g ${homeassistant_group} -o ${homeassistant_user} -- /dev/null "${pidfile}";
  53.     fi
  54.  
  55.     if [ ! -d "${homeassistant_config_dir}" ]; then
  56.             install -d -g ${homeassistant_group} -o ${homeassistant_user} -- "${homeassistant_config_dir}";
  57.     fi
  58.  
  59.     echo "Performing check on Home Assistant configuration:"
  60.     eval "${homeassistant_install_dir}/bin/hass" --config "${homeassistant_config_dir}" --script check_config
  61. }
  62.  
  63. stop_postcmd=${name}_postcmd
  64. homeassistant_postcmd()
  65. {
  66.     rm -f -- "${pidfile}"
  67.     rm -f -- "${pidfile_child}"
  68. }
  69.  
  70. run_rc_command "$1"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top