Last active
December 2, 2015 16:53
-
-
Save declan/4b7cc4fb4926df16f54c to your computer and use it in GitHub Desktop.
ThinkingSphinx start-up script for Ubuntu 14.04
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/bash | |
# | |
# This script goes in /etc/init.d/thinking_sphinx | |
# Make sure the file is executable: | |
# | |
# chmod 755 /etc/init.d/thinking_sphinx | |
# | |
# | |
# Once the file is in place, you need to add it to the list | |
# of scripts that get executed when the system comes up or | |
# goes down. | |
# | |
# update-rc.d thinking_sphinx defaults | |
# | |
# | |
# If you later want to disable this script, you can say | |
# | |
# update-rc.d -f thinking_sphinx remove | |
# | |
set -e | |
# Feel free to change any of the following variables for your app: | |
APP_ROOT=/var/www/purplebinder/current | |
AS_USER=rails | |
RUBY_VERSION="2.0.0" | |
CMD="export HOME; true "${HOME:=$(getent passwd "$AS_USER" | cut -d: -f6;)}" ; cd $APP_ROOT && /usr/local/rvm/bin/rvm $RUBY_VERSION do bundle exec rake ts" # :(stop|start|index) | |
set -u | |
run () { | |
if [ "$(id -un)" = "$AS_USER" ]; then | |
eval $1 | |
else | |
su -c "$1" - $AS_USER | |
fi | |
} | |
case "$1" in | |
start) | |
run "$CMD:start" | |
;; | |
stop) | |
run "$CMD:stop" | |
;; | |
*) | |
echo >&2 "Usage: $0 <start|stop>" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment