From e124e1c3fd90052b0f2a069ca5f776418b4ac68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louis=20V=C3=A9zina?= <5130500+morpheus65535@users.noreply.github.com> Date: Tue, 16 Oct 2018 21:15:42 -0400 Subject: [PATCH] Fix to create daemon stop and restart file in config_dir. Add a fix for automatic reloading after restart when using a reverse proxy with SSL. --- bazarr.py | 16 +++++++++++++--- bazarr/main.py | 4 ++-- views/menu.tpl | 6 ++++-- views/system.tpl | 6 ++++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/bazarr.py b/bazarr.py index 06c39ead2..44511a4b1 100644 --- a/bazarr.py +++ b/bazarr.py @@ -5,6 +5,9 @@ import os import sys import getopt +config_dir = os.path.join(os.path.dirname(__file__), 'data/') +no_update = False + arguments = [] try: opts, args = getopt.getopt(sys.argv[1:],"h:",["no-update", "config="]) @@ -13,7 +16,14 @@ except getopt.GetoptError: sys.exit(2) for opt, arg in opts: arguments.append(opt) - if arg != '': + if opt == '-h': + print 'bazarr.py -h --no-update --config ' + sys.exit() + elif opt in ("--no-update"): + no_update = True + elif opt in ("--config"): + config_dir = arg + elif arg != '': arguments.append(arg) @@ -32,8 +42,8 @@ def start_bazarr(): if __name__ == '__main__': - restartfile = os.path.normcase(os.path.join(globals()['dir_name'], 'bazarr.restart')) - stopfile = os.path.normcase(os.path.join(globals()['dir_name'], 'bazarr.stop')) + restartfile = os.path.normcase(os.path.join(config_dir, 'bazarr.restart')) + stopfile = os.path.normcase(os.path.join(config_dir, 'bazarr.stop')) try: os.remove(restartfile) diff --git a/bazarr/main.py b/bazarr/main.py index e6be41237..178bf300e 100644 --- a/bazarr/main.py +++ b/bazarr/main.py @@ -199,7 +199,7 @@ def redirect_root(): @route(base_url + 'shutdown') def shutdown(): try: - stop_file = open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "bazarr.stop"), "w") + stop_file = open(os.path.join(config_dir, "bazarr.stop"), "w") except Exception as e: logging.error('Cannot create bazarr.stop file.') else: @@ -215,7 +215,7 @@ def restart(): logging.error('Cannot stop CherryPy.') else: try: - restart_file = open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "bazarr.restart"), "w") + restart_file = open(os.path.join(config_dir, "bazarr.restart"), "w") except Exception as e: logging.error('Cannot create bazarr.restart file.') else: diff --git a/views/menu.tpl b/views/menu.tpl index 15a9f27b1..1cabb40be 100644 --- a/views/menu.tpl +++ b/views/menu.tpl @@ -190,11 +190,13 @@ public_ip = "{{ip}}"; } + protocol = window.location.protocol; + function ping() { $.ajax({ - url: 'http://' + public_ip + ':{{port}}{{base_url}}', + url: protocol + '://' + public_ip + ':{{port}}{{base_url}}', success: function(result) { - window.location.href= 'http://' + public_ip + ':{{port}}{{base_url}}'; + window.location.href= protocol + '://' + public_ip + ':{{port}}{{base_url}}'; } }); } diff --git a/views/system.tpl b/views/system.tpl index 9cd3163de..7022ee5c5 100644 --- a/views/system.tpl +++ b/views/system.tpl @@ -246,11 +246,13 @@ public_ip = "{{ip}}"; } + protocol = window.location.protocol; + function ping() { $.ajax({ - url: 'http://' + public_ip + ':{{port}}{{base_url}}', + url: protocol + '://' + public_ip + ':{{port}}{{base_url}}', success: function(result) { - window.location.href= 'http://' + public_ip + ':{{port}}{{base_url}}'; + window.location.href= protocol + '://' + public_ip + ':{{port}}{{base_url}}'; } }); }