From 5f9a2b987928311f58fa186028f5cec1f8c4dc1f Mon Sep 17 00:00:00 2001 From: j Date: Sat, 30 May 2020 17:44:49 +0200 Subject: [PATCH] reuse sudo code, install pandoractl --- ctl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ctl b/ctl index bd7896441..b518cddd1 100755 --- a/ctl +++ b/ctl @@ -49,15 +49,15 @@ if [ "$action" = "init" ]; then fi if [ "$action" = "manage" ]; then cd "`dirname "$self"`" - if [ `whoami` != 'root' ]; then - manage="./pandora/manage.py" - else - manage="sudo -u pandora ./pandora/manage.py" + BASE=`pwd` + SUDO="" + PANDORA_USER=`ls -l update.py | cut -f3 -d" "` + if [ `whoami` != $PANDORA_USER ]; then + SUDO="sudo -H -u $PANDORA_USER" fi shift - $manage $@ + $SUDO $BASE/pandora/manage.py $@ exit $? - fi if [ `whoami` != 'root' ]; then echo you have to be root or run $0 with sudo @@ -83,6 +83,7 @@ if [ "$action" = "install" ]; then systemctl enable ${service}.service done fi + test -e /usr/local/bin/pandoractl || ln -s /srv/pandora/ctl /usr/local/bin/pandoractl else if [ -d /etc/init ]; then cp $BASE/etc/init/* /etc/init/