Skip to content

Commit

Permalink
Add server_runas option to run server as specific user
Browse files Browse the repository at this point in the history
  • Loading branch information
klightspeed committed Aug 5, 2018
1 parent c8c0f9a commit 0715b87
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions tools/arkmanager
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,24 @@ doRunBG(){
[[ $fd -gt 2 && $fd != 255 ]] && exec {fd}<&-
done
doRun "$@" > >(while read -r l; do printf "%s: [%s] %s\n" "$(timestamp)" "${instance}" "${l}"; done) 2>&1
if [ -n "$server_runas" ]; then
sudo -u "$server_runas" "$0" --run-instance "$instance" <(cat "${arkstGlobalCfgFile}" "${HOME}/${arkstUserCfgFile}" 2>/dev/null; if [ -z "arkSingleInstance" && -n "$configfile" ]; then cat "$configfile" 2>/dev/null; fi) > >(while read -r l; do printf "%s: [%s] %s\n" "$(timestamp)" "${instance}" "${l}"; done) 2>&1
else
doRun "$@" > >(while read -r l; do printf "%s: [%s] %s\n" "$(timestamp)" "${instance}" "${l}"; done) 2>&1
fi
}
doRunInstance(){
instance="$1"
if [[ -n "$2" && -r "$2" ]]; then
. "$2"
fi
shift
shift
doRun "$@"
}
#
Expand Down Expand Up @@ -3067,11 +3084,11 @@ useConfig() {
loadGlobalConfig() {
if [ -f "${arkstGlobalCfgFile}" ]; then
source "${arkstGlobalCfgFile}"
source "${arkstGlobalCfgFile}"
fi
if [ -f "${HOME}/${arkstUserCfgFile}" ]; then
source "${HOME}/${arkstUserCfgFile}"
source "${HOME}/${arkstUserCfgFile}"
fi
lsof=lsof
Expand Down Expand Up @@ -3243,6 +3260,13 @@ EOE
#---------------------
main(){
# Handle special --run-instance command
if [ "$1" == "--run-instance" ]; then
shift
doRunInstance "$@"
exit
fi
# Global variables
loadGlobalConfig
Expand Down

0 comments on commit 0715b87

Please sign in to comment.