Skip to content

Commit

Permalink
rc
Browse files Browse the repository at this point in the history
  • Loading branch information
qiaofeng1227 committed Dec 19, 2024
2 parents a98411e + 607a06a commit 5ed7455
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions docker/apphub/script/migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,44 @@
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - start to migrate config.ini"

migrate_ini() {

# Define file paths, use template ini and syn exsit items from target ini
# Combine source_ini to target ini
export target_ini="$1"
export template_ini="$2"
export source_ini="$2"

python3 - <<EOF
import configparser
import os
import sys
target_ini = os.environ['target_ini']
template_ini = os.environ['template_ini']
source_ini = os.environ['source_ini']
# Create two config parsers
target_parser = configparser.ConfigParser()
template_parser = configparser.ConfigParser()
source_parser = configparser.ConfigParser()
try:
target_parser.read(target_ini)
template_parser.read(template_ini)
source_parser.read(source_ini)
except configparser.MissingSectionHeaderError:
print("Error: The provided files are not valid INI files.")
sys.exit(1)
# use target_parser to override template_parser
# use target_parser to override source_parser
for section in target_parser.sections():
if template_parser.has_section(section):
if source_parser.has_section(section):
for key, value in target_parser.items(section):
if template_parser.has_option(section, key):
template_parser.set(section, key, value)
if source_parser.has_option(section, key):
source_parser.set(section, key, value)
with open(target_ini, 'w') as f:
template_parser.write(f)
source_parser.write(f)
EOF
}

# special migration
# Special migration
post_migration(){
echo "$(date '+%Y-%m-%d %H:%M:%S') - INFO - Set listen_port to nginx_proxy_manager"
config_file="/websoft9/config/config.ini"
Expand Down

0 comments on commit 5ed7455

Please sign in to comment.