Falln87 commited on
Commit
e1558bd
·
verified ·
1 Parent(s): bde1b49

Create entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +85 -0
entrypoint.sh ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ set -Eeuo pipefail
4
+
5
+ # TODO: move all mkdir -p ?
6
+ mkdir -p /data/config/auto/scripts/
7
+ # mount scripts individually
8
+
9
+ echo $ROOT
10
+ ls -lha $ROOT
11
+
12
+ find "${ROOT}/scripts/" -maxdepth 1 -type l -delete
13
+ cp -vrfTs /data/config/auto/scripts/ "${ROOT}/scripts/"
14
+
15
+ # Set up config file
16
+ python /docker/config.py /data/config/auto/config.json
17
+
18
+ if [ ! -f /data/config/auto/ui-config.json ]; then
19
+ echo '{}' >/data/config/auto/ui-config.json
20
+ fi
21
+
22
+ if [ ! -f /data/config/auto/styles.csv ]; then
23
+ touch /data/config/auto/styles.csv
24
+ fi
25
+
26
+ # copy models from original models folder
27
+ mkdir -p /data/models/VAE-approx/ /data/models/karlo/
28
+
29
+ rsync -a --info=NAME ${ROOT}/models/VAE-approx/ /data/models/VAE-approx/
30
+ rsync -a --info=NAME ${ROOT}/models/karlo/ /data/models/karlo/
31
+
32
+ declare -A MOUNTS
33
+
34
+ MOUNTS["/root/.cache"]="/data/.cache"
35
+ MOUNTS["${ROOT}/models"]="/data/models"
36
+
37
+ MOUNTS["${ROOT}/embeddings"]="/data/embeddings"
38
+ MOUNTS["${ROOT}/config.json"]="/data/config/auto/config.json"
39
+ MOUNTS["${ROOT}/ui-config.json"]="/data/config/auto/ui-config.json"
40
+ MOUNTS["${ROOT}/styles.csv"]="/data/config/auto/styles.csv"
41
+ MOUNTS["${ROOT}/extensions"]="/data/config/auto/extensions"
42
+ MOUNTS["${ROOT}/config_states"]="/data/config/auto/config_states"
43
+
44
+ # extra hacks
45
+ MOUNTS["${ROOT}/repositories/CodeFormer/weights/facelib"]="/data/.cache"
46
+
47
+ for to_path in "${!MOUNTS[@]}"; do
48
+ set -Eeuo pipefail
49
+ from_path="${MOUNTS[${to_path}]}"
50
+ rm -rf "${to_path}"
51
+ if [ ! -f "$from_path" ]; then
52
+ mkdir -vp "$from_path"
53
+ fi
54
+ mkdir -vp "$(dirname "${to_path}")"
55
+ ln -sT "${from_path}" "${to_path}"
56
+ echo Mounted $(basename "${from_path}")
57
+ done
58
+
59
+ echo "Installing extension dependencies (if any)"
60
+
61
+ # because we build our container as root:
62
+ chown -R root ~/.cache/
63
+ chmod 766 ~/.cache/
64
+
65
+ shopt -s nullglob
66
+ # For install.py, please refer to https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Developing-extensions#installpy
67
+ list=(./extensions/*/install.py)
68
+ for installscript in "${list[@]}"; do
69
+ EXTNAME=$(echo $installscript | cut -d '/' -f 3)
70
+ # Skip installing dependencies if extension is disabled in config
71
+ if $(jq -e ".disabled_extensions|any(. == \"$EXTNAME\")" config.json); then
72
+ echo "Skipping disabled extension ($EXTNAME)"
73
+ continue
74
+ fi
75
+ PYTHONPATH=${ROOT} python "$installscript"
76
+ done
77
+
78
+ if [ -f "/data/config/auto/startup.sh" ]; then
79
+ pushd ${ROOT}
80
+ echo "Running startup script"
81
+ . /data/config/auto/startup.sh
82
+ popd
83
+ fi
84
+
85
+ exec "$@"