Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overwriting existing values in config.json in auto #418

Merged
merged 8 commits into from
May 6, 2023
1 change: 1 addition & 0 deletions services/AUTOMATIC1111/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"outdir_txt2img_samples": "/output/txt2img",
"outdir_img2img_samples": "/output/img2img",
"outdir_extras_samples": "/output/extras",
"outdir_grids": "",
wookiefriseur marked this conversation as resolved.
Show resolved Hide resolved
"outdir_txt2img_grids": "/output/txt2img-grids",
"outdir_img2img_grids": "/output/img2img-grids",
"outdir_save": "/output/saved",
Expand Down
16 changes: 15 additions & 1 deletion services/AUTOMATIC1111/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,22 @@ mkdir -p /data/config/auto/scripts/
find "${ROOT}/scripts/" -maxdepth 1 -type l -delete
cp -vrfTs /data/config/auto/scripts/ "${ROOT}/scripts/"

# config.json for auto
## Step 1: Copy default config to user config if missing
cp -n /docker/config.json /data/config/auto/config.json
jq '. * input' /data/config/auto/config.json /docker/config.json | sponge /data/config/auto/config.json
## Step 2: Put the default config and user config into vars
cfg_json_default=$(cat /docker/config.json)
cfg_json_user=$(cat /data/config/auto/config.json)
## Step 3: delete invalid entries from user.json
cfg_json_user=$(echo $cfg_json_user | jq '
. as $original
| reduce (to_entries[] | select((.key | startswith("outdir_"))
and (.value | test("^\/output(\\.)?(\/\\.?[\\w\\-\\_]+)+\/?")|not)))
as $item
($original; del(.[$item.key]))
')
## Step 4: Merge and save config
echo $cfg_json_default $cfg_json_user | jq '. * input' | sponge /data/config/auto/config.json
wookiefriseur marked this conversation as resolved.
Show resolved Hide resolved

if [ ! -f /data/config/auto/ui-config.json ]; then
echo '{}' >/data/config/auto/ui-config.json
Expand Down