node.jsの導入、hubotの雛形の生成、Raspberry Piの起動時に…の通り
sudo apt install -y nodejs npm
sudo npm cache clean
sudo npm install npm n -g
sudo n lts
sudo npm install -g yo generator-hubot
mkdir homebot; cd homebot
yo hubot
? Owner (User <user@example.com>) [Enter]
? Bot name (homebot) [Enter]
? Description (A simple helpful robot for your Company) [Enter]
? Bot adapter (campfire) slack[Enter]
sudo apt install redis-server
npm install coffee-script@^1.12.6
rm hubot-scripts.json
vi hubot-scripts.json “hubot-heroku-keepalive”,を削除
npm install hubot-broadlink-rm
vi external-scripts.json “hubot-broadlink-rm”,を追加
vi bin/hubot
#!/bin/sh
set -e
npm install
export PATH=”node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH”
export HUBOT_SLACK_TOKEN=xxx…
exec node_modules/.bin/hubot –name “homebot” “$@”
vi bin/homebot.sh
#!/bin/sh
cd /home/pi/homebot
sudo -u pi bin/hubot –adapter slack
chmod +x bin/homebot.sh
vi /etc/systemd/system/homebot.service
[Unit]
Description = hubot for smart home
[Service]
ExecStart=/home/pi/homebot/bin/homebot.sh
Restart=always
Type=simple
[Install]
WantedBy=multi-user.target
systemctl list-unit-files –type=service
sudo systemctl enable homebot
sudo reboot
systemctl status homebot