Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #
- # 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/
- #
- # PROVIDE: homeassistant
- # REQUIRE: LOGIN
- # KEYWORD: shutdown
- #
- # homeassistant_enable: Set to YES to enable the homeassistant service.
- # Default: NO
- # homeassistant_user: The user account used to run the homeassistant daemon.
- # This is optional, however do not specifically set this to an
- # empty string as this will cause the daemon to run as root.
- # Default: homeassistant
- # homeassistant_group: The group account used to run the homeassistant daemon.
- # This is optional, however do not specifically set this to an
- # empty string as this will cause the daemon to run with group wheel.
- # Default: homeassistant
- # homeassistant_config_dir: Directory where config files are located.
- # Default: /usr/home/homeassistant/.homeassistant
- # homeassistant_install_dir: Directory where Home Assistant is installed.
- # Default: /usr/local/share/homeassistant
- #
- # sysrc homeassistant_enable=yes
- # service homeassistant start
- . /etc/rc.subr
- name=homeassistant
- rcvar=${name}_enable
- pidfile_child="/var/run/${name}.pid"
- pidfile="/var/run/${name}_daemon.pid"
- load_rc_config ${name}
- : ${homeassistant_enable:="NO"}
- : ${homeassistant_user:="homeassistant"}
- : ${homeassistant_group:="homeassistant"}
- : ${homeassistant_config_dir:="/usr/home/homeassistant/.homeassistant"}
- : ${homeassistant_install_dir:="/usr/local/share/homeassistant"}
- command="/usr/sbin/daemon"
- start_precmd=${name}_precmd
- homeassistant_precmd()
- {
- rc_flags="-f -P ${pidfile} -p ${pidfile_child} ${homeassistant_install_dir}/bin/hass --config ${homeassistant_config_dir} ${rc_flags}"
- if [ ! -e "${pidfile_child}" ]; then
- install -g ${homeassistant_group} -o ${homeassistant_user} -- /dev/null "${pidfile_child}";
- fi
- if [ ! -e "${pidfile}" ]; then
- install -g ${homeassistant_group} -o ${homeassistant_user} -- /dev/null "${pidfile}";
- fi
- if [ ! -d "${homeassistant_config_dir}" ]; then
- install -d -g ${homeassistant_group} -o ${homeassistant_user} -- "${homeassistant_config_dir}";
- fi
- echo "Performing check on Home Assistant configuration:"
- eval "${homeassistant_install_dir}/bin/hass" --config "${homeassistant_config_dir}" --script check_config
- }
- stop_postcmd=${name}_postcmd
- homeassistant_postcmd()
- {
- rm -f -- "${pidfile}"
- rm -f -- "${pidfile_child}"
- }
- run_rc_command "$1"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement