Created
April 7, 2017 09:41
-
-
Save kenzo0107/9c9a302b355b250fa9acc4c7881c43c2 to your computer and use it in GitHub Desktop.
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 | |
#FOREVER=/usr/bin/forever | |
HUBOT_HOME=/home/hu/mybot | |
FOREVER=$HUBOT_HOME/node_modules/forever/bin/forever | |
who=$(whoami) | |
if [ "${who}" != "root" ]; then | |
echo "Usage: sudo bin/hubot (start|stop|restart|status). 'sudo' is requied ! Please again.\n" | |
exit 1; | |
fi | |
ARG1=$1 | |
if [ "${ARG1}" == "" ]; then | |
echo "missing param. sudo bin/hubot (start|stop|restart|status). Please again." | |
exit 1; | |
fi | |
cd $HUBOT_HOME | |
set -e | |
npm install | |
export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH" | |
# Slack | |
export HUBOT_SLACK_TOKEN=xoxb-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxx | |
# JIRA | |
export HUBOT_JIRA_URL=https://xxxxxxxxxx.atlassian.net | |
# Jenkins | |
export HUBOT_JENKINS_URL="http://ec2-xxx-xxx-xxx-xxx.ap-northeast-1.compute.amazonaws.com:8080" | |
export HUBOT_JENKINS_AUTH="hubot:xxxxxxxxxxxxxx" | |
# Grafana | |
export HUBOT_GRAFANA_HOST=http://xxxxx.xxxxxx.jp:3000 | |
export HUBOT_GRAFANA_API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" | |
export HUBOT_GRAFANA_S3_BUCKET=grafana-bucket | |
export HUBOT_GRAFANA_S3_REGION=ap-northeast-1 | |
export HUBOT_GRAFANA_S3_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxxx | |
export HUBOT_GRAFANA_S3_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | |
export HUBOT_GRAFANA_S3_PREFIX=graphs | |
export HUBOT_GRAFANA_QUERY_TIME_RANGE=1h | |
export HUBOT_LOG_LEVEL=debug | |
# port | |
export PORT=80 | |
start() { | |
$FOREVER start -c coffee node_modules/.bin/hubot -a slack | |
} | |
stop () { | |
$FOREVER stop -c coffee node_modules/.bin/hubot | |
} | |
status() { | |
$FOREVER list | |
} | |
restart() { | |
$FOREVER stop -c coffee node_modules/.bin/hubot | |
$FOREVER start -c coffee node_modules/.bin/hubot -a slack | |
} | |
case "$ARG1" in | |
"stop" ) | |
stop | |
;; | |
"restart" ) | |
restart | |
;; | |
"start" ) | |
start | |
;; | |
"status" ) | |
status | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment