From fa5cf7cf60d205be2849e35bf183f4b96f530574 Mon Sep 17 00:00:00 2001 From: j Date: Sat, 30 May 2020 13:01:44 +0200 Subject: [PATCH 1/3] make manage.py accessible via ctl, install pandoractl --- ctl | 29 ++++++++++++++++++++++++++--- vm/pandora_install.sh | 5 +++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ctl b/ctl index 1b93c214..bd789644 100755 --- a/ctl +++ b/ctl @@ -1,13 +1,17 @@ #!/bin/sh SERVICES="pandora pandora-tasks pandora-encoding pandora-cron pandora-websocketd" if [ -z "$1" ]; then - echo "Usage: $0 (start|stop|restart|reload)" + echo "Usage: $0 (start|stop|restart|reload|status)" exit 1 else action="$1" fi +self=`readlink "$0"` +if [ -z $self ]; then + self="$0" +fi if [ "$action" = "init" ]; then - cd "`dirname "$0"`" + cd "`dirname "$self"`" BASE=`pwd` SUDO="" PANDORA_USER=`ls -l update.py | cut -f3 -d" "` @@ -43,6 +47,18 @@ if [ "$action" = "init" ]; then fi exit 0 fi +if [ "$action" = "manage" ]; then + cd "`dirname "$self"`" + if [ `whoami` != 'root' ]; then + manage="./pandora/manage.py" + else + manage="sudo -u pandora ./pandora/manage.py" + fi + shift + $manage $@ + exit $? + +fi if [ `whoami` != 'root' ]; then echo you have to be root or run $0 with sudo exit 1 @@ -74,6 +90,13 @@ if [ "$action" = "install" ]; then fi exit 0 fi +if [ "status" = "$action" ]; then + export SYSTEMD_PAGER= +fi for service in $SERVICES; do - service $service $action + if [ -x /bin/systemctl ]; then + /bin/systemctl $action $service + else + service $service $action + fi done diff --git a/vm/pandora_install.sh b/vm/pandora_install.sh index 65d776c2..ec77d3b0 100755 --- a/vm/pandora_install.sh +++ b/vm/pandora_install.sh @@ -12,7 +12,7 @@ NGINX=${NGINX-local} BRANCH=${BRANCH-stable} # add a pandora user -echo Installing pandora with user: $PANDORA +echo Installing pandora with user: $PANDORA branch: $BRANCH getent passwd $PANDORA > /dev/null 2>&1 || adduser --disabled-password --gecos "" $PANDORA # @@ -197,8 +197,9 @@ fi if [ "$NGINX" == "local" ]; then cp "/srv/pandora/etc/nginx/pandora" "/etc/nginx/sites-available/pandora" -rm -f /etc/nginx/sites-enabled/default +rm -f /etc/nginx/sites-enabled/default /etc/nginx/sites-enabled/pandora ln -s ../sites-available/pandora /etc/nginx/sites-enabled/pandora +ln -s /srv/pandora/ctl /usr/local/bin/pandoractl read -r -d '' GZIP < Date: Sat, 30 May 2020 13:57:34 +0200 Subject: [PATCH 2/3] fix exception --- pandora/user/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandora/user/utils.py b/pandora/user/utils.py index 808aaa69..86a21ae1 100644 --- a/pandora/user/utils.py +++ b/pandora/user/utils.py @@ -1,4 +1,4 @@ -from django.contrib.gis.geoip2 import GeoIP2 +from django.contrib.gis.geoip2 import GeoIP, GeoIP2Exception2 import ox @@ -22,7 +22,7 @@ def get_location(ip): else: try: location = g.city(ip) - except django.contrib.gis.geoip2.GeoIP2Exception: + except GeoIP2Exception: try: location = g.country(s.ip) except: From d82cd9b6a7ffe40b9934c5031b0caae841afd7ca Mon Sep 17 00:00:00 2001 From: j Date: Sat, 30 May 2020 14:00:08 +0200 Subject: [PATCH 3/3] get current revno before switch --- update.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/update.py b/update.py index 2c1de756..bfa0a019 100755 --- a/update.py +++ b/update.py @@ -297,7 +297,7 @@ if __name__ == "__main__": ]: run_sql(sql) run(join(base, 'pandora/manage.py'), 'migrate', 'system') - + run(join(base, 'pandora/manage.py'), 'update_geoip') else: if len(sys.argv) == 1: branch = get_branch() @@ -316,13 +316,13 @@ if __name__ == "__main__": if exists(path): os.chdir(path) current_branch = get_branch(path) - if current_branch != branch: - run('git', 'remote', 'set-branches', 'origin', '*') - run('git', 'fetch', 'origin') - run('git', 'checkout', branch) - revno = get_version(path) if repo == 'pandora': pandora_old_revno = revno + if current_branch != branch: + run('git', 'remote', 'set-branches', 'origin', '*') + run('git', 'fetch', 'origin') + run('git', 'checkout', branch) + revno = get_version(path) current += revno url = repos[repo]['url'] print('Checking', repo)