From c204c0d5983fb0fa8c60a1aa226e26fd84913067 Mon Sep 17 00:00:00 2001 From: Hiddify <114227601+hiddify@users.noreply.github.com> Date: Sun, 1 Jan 2023 16:59:41 +0000 Subject: [PATCH] add apply_config --- admin_ui/admin_ui.py | 14 ++++++-------- apply_configs.sh | 2 ++ install.sh | 9 +++++---- 3 files changed, 13 insertions(+), 12 deletions(-) create mode 100755 apply_configs.sh diff --git a/admin_ui/admin_ui.py b/admin_ui/admin_ui.py index 5aa4faed1..119dc288e 100755 --- a/admin_ui/admin_ui.py +++ b/admin_ui/admin_ui.py @@ -36,16 +36,13 @@ def apply_configs(): @route('/reinstall') def reinstall(complete_install=True): configs=read_configs() - cwd = os.getcwd() - + + file="install.sh" if complete_install else "apply_configs.sh" - for name in configs: - if name in os.environ: - del os.environ[name] - env="DO_NOT_INSTALL="+("false" if complete_install else "true") # subprocess.Popen(f"{config_dir}/update.sh",env=my_env,cwd=f"{config_dir}") - os.system(f'cd {config_dir};{env} ./install.sh &') + # os.system(f'cd {config_dir};{env} ./install.sh &') + rc = subprocess.call(f"cd {config_dir};./{file} &",shell=True) return template("result",data={ "out-type":"success", "out-msg":f"Success! Please wait around {6 if complete_install else 2} minutes to make sure everything is updated. Then, please save your proxy links which are
"+ @@ -65,7 +62,8 @@ def update(): del os.environ[name] # os.chdir(config_dir) # rc = subprocess.call(f"./install.sh &",shell=True) - os.system(f'cd {config_dir};./update.sh &') + rc = subprocess.call(f"cd {config_dir};./update.sh &",shell=True) + # os.system(f'cd {config_dir};./update.sh &') # subprocess.Popen(f"{config_dir}/update.sh",env=my_env,cwd=f"{config_dir}") return template("result",data={ diff --git a/apply_configs.sh b/apply_configs.sh new file mode 100755 index 000000000..7ae329453 --- /dev/null +++ b/apply_configs.sh @@ -0,0 +1,2 @@ +#!/bin/bash +DO_NOT_INSTALL=true ./install.sh \ No newline at end of file diff --git a/install.sh b/install.sh index 1e4ef7c97..ec25060d1 100755 --- a/install.sh +++ b/install.sh @@ -9,12 +9,13 @@ fi function set_env_if_empty(){ + echo "applying configs from $1=========================================" for line in $(sed 's/\#.*//g' $1 | grep '=');do IFS=\= read k v <<< $line - if [[ ! -z $k && -z "${!k}" ]]; then +# if [[ ! -z $k && -z "${!k}" ]]; then export $k="$v" echo $k="$v" - fi +# fi done @@ -139,9 +140,9 @@ function replace_empty_env() { } function main(){ - - set_env_if_empty config.env set_env_if_empty config.env.default + set_env_if_empty config.env + cd /opt/$GITHUB_REPOSITORY git pull