-
-
Save kkurahar/7171350 to your computer and use it in GitHub Desktop.
Hubotの自動更新用スクリプト。 foreverの自動起動機能を利用して利用する想定。 $ /path/to/hubot/bin/bot start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH" | |
##export HUBOT_LOG_LEVEL="debug" | |
## HipChat | |
export HUBOT_HIPCHAT_TOKEN="" | |
export HUBOT_HIPCHAT_JID="" | |
export HUBOT_HIPCHAT_PASSWORD="" | |
##export HUBOT_HIPCHAT_ROOMS="" | |
case $1 in | |
"start") | |
sudo npm uninstall hubot-hipchat | |
sudo npm install hubot-hipchat | |
sudo npm install | |
./node_modules/forever/bin/forever $1 \ | |
-c coffee node_modules/hubot/bin/hubot -a hipchat | |
;; | |
"stop") | |
./node_modules/forever/bin/forever $1 \ | |
-c coffee node_modules/hubot/bin/hubot -a hipchat | |
* ) echo "usage: bot start|stop" ;; | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description | |
# Allows hubot to update itself using git pull and restart process | |
# | |
# Dependencies: | |
# None | |
# | |
# Configuration: | |
# None | |
# | |
# Commands: | |
# hubot update - Performs a git pull and npm udate. | |
# | |
# Author: | |
# | |
child_process = require 'child_process' | |
module.exports = (robot) -> | |
robot.respond /update( yourself)?$/i, (msg) -> | |
try | |
msg.send "git pull..." | |
child_process.exec 'git pull', (error, stdout, stderr) -> | |
if error | |
msg.send "git pull failed: " + stderr | |
else | |
output = stdout+'' | |
if not /Already up\-to\-date/.test output | |
msg.send "Hubot changed:\n" + output + "\nBegin restart..." | |
## TODO | |
process.exit() | |
else | |
msg.send "Hubot is up-to-date" | |
catch error | |
msg.send "git pull failed: " + error |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment