Skip to content

Commit

Permalink
add apply_config
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Jan 1, 2023
1 parent ed2e2df commit c204c0d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
14 changes: 6 additions & 8 deletions admin_ui/admin_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <br>"+
Expand All @@ -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={
Expand Down
2 changes: 2 additions & 0 deletions apply_configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
DO_NOT_INSTALL=true ./install.sh
9 changes: 5 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c204c0d

Please sign in to comment.