那个智能家庭中枢

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
头像
aiikii
帖子: 268
注册时间: 2008-03-05 23:45

那个智能家庭中枢

#1

帖子 aiikii » 2017-08-17 21:23

https://post.smzdm.com/p/553097/
我按这个贴子安装到

sudo chmod +x /etc/init.d/hass-daemon
sudo update-rc.d hass-daemon defaults
sudo service hass-daemon install

时,前两步执行完了,第三步执行时显示
env: '/etc/init.d/hass-daemon': No such file or directory

请问怎么处理?
头像
aiikii
帖子: 268
注册时间: 2008-03-05 23:45

Re: 那个智能家庭中枢

#2

帖子 aiikii » 2017-08-17 22:01

android@localhost:/etc/init.d$ sudo service hass-daemon install
: not found/hass-daemon: 1: /etc/init.d/hass-daemon: #!/bin/sh
/etc/init.d/hass-daemon: 62: /etc/init.d/hass-daemon: Syntax error: word unexpected (expecting "in")
头像
aiikii
帖子: 268
注册时间: 2008-03-05 23:45

Re: 那个智能家庭中枢

#3

帖子 aiikii » 2017-08-17 22:04

#!/bin/sh
### BEGIN INIT INFO
# Provides: hass
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Home\ Assistant
### END INIT INFO
# /etc/init.d Service Script for Home Assistant
# Created with: https://gist.github.com/naholyr/4275302 ... service-sh
PRE_EXEC="source /srv/homeassistant/bin/activate;"
RUN_AS="homeassistant"
PID_FILE="/var/run/hass.pid"
CONFIG_DIR="/var/opt/homeassistant"
FLAGS="-v --config $CONFIG_DIR --pid-file $PID_FILE --daemon"
REDIRECT="> $CONFIG_DIR/home-assistant.log 2>&1"
start() {
if [ -f $PID_FILE ] && kill -0 $(cat $PID_FILE) 2> /dev/null; then
echo 'Service already running' >&2
return 1
fi
echo 'Starting service…' >&2
local CMD="$PRE_EXEC hass $FLAGS $REDIRECT;"
su -c "$CMD" $RUN_AS
echo 'Service started' >&2
}

stop() {
if [ ! -f "$PID_FILE" ] || ! kill -0 $(cat "$PID_FILE") 2> /dev/null; then
echo 'Service not running' >&2
return 1
fi
echo 'Stopping service…' >&2
kill $(cat "$PID_FILE")
while ps -p $(cat "$PID_FILE") > /dev/null 2>&1; do sleep 1;done;
echo 'Service stopped' >&2
}

install() {
echo "Installing Home Assistant Daemon (hass-daemon)"
echo "999999" > $PID_FILE
chown $RUN_AS $PID_FILE
mkdir -p $CONFIG_DIR
chown $RUN_AS $CONFIG_DIR
}

uninstall() {
echo -n "Are you really sure you want to uninstall this service? That cannot be undone. [yes|No] "
local SURE
read SURE
if [ "$SURE" = "yes" ]; then
stop
rm -fv "$PID_FILE"
echo "Notice: The config directory has not been removed"
echo $CONFIG_DIR
update-rc.d -f hass-daemon remove
rm -fv "$0"
echo "Home Assistant Daemon has been removed. Home Assistant is still installed."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
install)
install
;;
uninstall)
uninstall
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|install|uninstall}"
esac
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: 那个智能家庭中枢

#4

帖子 vickycq » 2017-08-17 22:24

那篇教程说“无法使用 systemctl 的方式”,不会吧,官方文档里有 systemd 的说明
https://home-assistant.io/docs/autostart/systemd/

你用的什么版本 Ubuntu,现在都是 systemd 了
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
头像
aiikii
帖子: 268
注册时间: 2008-03-05 23:45

Re: 那个智能家庭中枢

#5

帖子 aiikii » 2017-08-17 22:57

vickycq 写了:那篇教程说“无法使用 systemctl 的方式”,不会吧,官方文档里有 systemd 的说明
https://home-assistant.io/docs/autostart/systemd/

你用的什么版本 Ubuntu,现在都是 systemd 了
用的是Ubuntu 16.04 LTS \n \l
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: 那个智能家庭中枢

#6

帖子 vickycq » 2017-08-17 23:42

aiikii 写了:用的是Ubuntu 16.04 LTS \n \l
那用的是 Upstart
https://home-assistant.io/docs/autostart/upstart/
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
回复