Created
July 24, 2015 16:32
-
-
Save zonywhoop/08c720e80018670eac25 to your computer and use it in GitHub Desktop.
start-stop-hubot
This file contains hidden or 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/bash | |
### Basic bot params ### | |
BOTPATH="/opt/botdir/" | |
BOTADAPTER="hipchat" | |
BOTNAME="botname" | |
BOTUSER="unix_username" | |
BOTALIAS='bot_alias_name' | |
### Additional Adapter / Plugin bot params ### | |
# HipChat Config | |
export HUBOT_HIPCHAT_JID="[email protected]" | |
export HUBOT_HIPCHAT_PASSWORD="my_password" | |
### No changes below here are necessary ### | |
PIDFILE="${BOTPATH}/run/${BOTNAME}.pid" | |
LOCKFILE="${BOTPATH}/run/${BOTNAME}.lock" | |
LOGFILE="${BOTPATH}/log/${BOTNAME}.log" | |
ERRFILE="${BOTPATH}/log/${BOTNAME}.err" | |
. /etc/rc.d/init.d/functions | |
cd "${BOTPATH}" | |
if [ ! -d "${BOTPATH}/run" ]; then | |
mkdir -p "${BOTPATH}/run" | |
chown ${BOTUSER} "${BOTPATH}/run" | |
fi | |
if [ ! -d "${BOTPATH}/log" ]; then | |
mkdir -p "${BOTPATH}/log" | |
chown ${BOTUSER} "${BOTPATH}/log" | |
fi | |
RETVAL=0 | |
# set -x | |
case "$1" in | |
start) | |
echo -n $"Starting bot: ${BOTNAME}" | |
/usr/sbin/daemonize -E PATH=${PATH} -c "${BOTPATH}" -e "${ERRFILE}" -o "${LOGFILE}" -p "${PIDFILE}" -u ${BOTUSER} -l "${LOCKFILE}" "${BOTPATH}/bin/hubot" -a ${BOTADAPTER} --alias ${BOTALIAS} | |
RETVAL=$? | |
echo | |
;; | |
stop) | |
echo -n "Stopping bot: ${BOTNAME}" | |
killproc -p ${PIDFILE} | |
RETVAL=$? | |
rm -f "${LOCKFILE}" | |
echo | |
;; | |
*) | |
echo "Usage: start-stop-bot (start|stop)" | |
exit 1 | |
;; | |
esac | |
exit ${REVAL} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment