diff options
author | Gareth Rees <gareth@mysociety.org> | 2015-02-23 13:27:00 +0000 |
---|---|---|
committer | Gareth Rees <ADD_EMAIL_HERE> | 2015-03-09 09:52:07 +0000 |
commit | 59b58f107902b8e04abb2a6727be77e1ad6bfea4 (patch) | |
tree | 2a5d4976e696004ebb27b5aefda2669d9cfd97aa | |
parent | 4bb6fc418e97b53205221955120f8f43244277c7 (diff) |
Improve checking whether the daemon can run
Only `su` to the app user if the app user is not running the script.
If the app user is running the script, its unlikely they'll have sudo
permissions so the `su` call prompts for a password.
-rwxr-xr-x | config/sysvinit-thin.ugly | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/config/sysvinit-thin.ugly b/config/sysvinit-thin.ugly index b333f3738..0155ff8c3 100755 --- a/config/sysvinit-thin.ugly +++ b/config/sysvinit-thin.ugly @@ -22,7 +22,13 @@ RAILS_ENV=!!(*= $rails_env *)!! set -e # Check that the Daemon can be run -su -l -c "cd $SITE_HOME && bundle exec thin --version &> /dev/null || exit 0" $USER +CURRENT_USER=$(whoami) +if [ "$CURRENT_USER" = "$USER" ] + then + cd $SITE_HOME && bundle exec thin --version > /dev/null 2>&1 || exit 0 + else + su -l -c "cd $SITE_HOME && bundle exec thin --version &> /dev/null || exit 0" $USER +fi start_daemon() { echo -n "Starting $DESC: " |