Skip to content

Commit

Permalink
Merge pull request #3752 from PeterDaveHello/upstart.tpl
Browse files Browse the repository at this point in the history
Improve upstart.tpl shell script syntax
  • Loading branch information
wallet77 committed Jul 4, 2018
2 parents d147868 + d0a4c02 commit d4e66e3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/templates/init-scripts/upstart.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ MAX_OPEN_FILES=

# overwrite settings from default file
if [ -f "$DEFAULT" ]; then
. "$DEFAULT"
. "$DEFAULT"
fi

# set maximum open files if set
Expand All @@ -33,7 +33,8 @@ if [ -n "$MAX_OPEN_FILES" ]; then
fi

get_user_shell() {
local shell=$(getent passwd ${1:-`whoami`} | cut -d: -f7 | sed -e 's/[[:space:]]*$//')
local shell
shell=$(getent passwd "${1:-$(whoami)}" | cut -d: -f7 | sed -e 's/[[:space:]]*$//')

if [[ $shell == *"/sbin/nologin" ]] || [[ $shell == "/bin/false" ]] || [[ -z "$shell" ]];
then
Expand All @@ -44,8 +45,9 @@ get_user_shell() {
}

super() {
local shell=$(get_user_shell $USER)
su - $USER -s $shell -c "PATH=$PATH; PM2_HOME=$PM2_HOME $*"
local shell
shell=$(get_user_shell $USER)
su - "$USER" -s "$shell" -c "PATH=$PATH; PM2_HOME=$PM2_HOME $*"
}

start() {
Expand Down

0 comments on commit d4e66e3

Please sign in to comment.