Skip to content

Commit 6fd32e8

Browse files
authored
Merge pull request #35 from linuxserver/ro-tweaks
Use envs for DB config, move config.yml to /config
2 parents 6df3a72 + 658c088 commit 6fd32e8

File tree

4 files changed

+20
-27
lines changed

4 files changed

+20
-27
lines changed

readme-vars.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ common_param_env_vars_enabled: true
1616
param_container_name: "{{ project_name }}"
1717
param_usage_include_vols: true
1818
param_volumes:
19-
- { vol_path: "/config", vol_host_path: "/path/to/{{ project_name }}/config", desc: "Persistent config files" }
19+
- {vol_path: "/config", vol_host_path: "/path/to/{{ project_name }}/config", desc: "Persistent config files"}
2020
- {vol_path: "/data", vol_host_path: "/path/to/data", desc: "Where Wiki.js data is stored."}
2121
param_usage_include_ports: true
2222
param_ports:
@@ -30,6 +30,9 @@ opt_param_env_vars:
3030
- {env_var: "DB_NAME", env_value: "", desc: "DB name (postgres only)"}
3131
- {env_var: "DB_USER", env_value: "", desc: "DB username (postgres only)"}
3232
- {env_var: "DB_PASS", env_value: "", desc: "DB password (postgres only)"}
33+
34+
readonly_supported: true
35+
3336
# application setup block
3437
app_setup_block_enabled: true
3538
app_setup_block: |

root/defaults/config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ port: 3000
2121
# - sqlite = SQLite 3.9 or later
2222

2323
db:
24-
type: {{DB_TYPE}}
24+
type: $(DB_TYPE)
2525

2626
# PostgreSQL / MySQL / MariaDB / MS SQL Server only:
27-
host: {{DB_HOST}}
28-
port: {{DB_PORT}}
29-
user: {{DB_USER}}
30-
pass: {{DB_PASS}}
31-
db: {{DB_NAME}}
27+
host: '$(DB_HOST)'
28+
port: $(DB_PORT)
29+
user: '$(DB_USER)'
30+
pass: '$(DB_PASS)'
31+
db: $(DB_NAME)
3232
ssl: false
3333

3434
# Optional - PostgreSQL / MySQL / MariaDB only:
Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,19 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4-
mkdir -p /data
5-
6-
DB_TYPE=${DB_TYPE:-sqlite}
7-
DB_HOST=${DB_HOST:-mariadb}
8-
DB_PORT=${DB_PORT:-3306}
9-
DB_USER=${DB_USER:-root}
10-
DB_PASS=${DB_PASS:-root}
11-
DB_NAME=${DB_NAME:-wikijs}
4+
if [[ -z ${DB_TYPE} ]]; then
5+
printf "sqlite" > /run/s6/container_environment/DB_TYPE
6+
fi
127

138
if [[ ! -f "/config/config.yml" ]]; then
149
cp /defaults/config.yml /config/config.yml
15-
16-
sed -i "s|{{DB_TYPE}}|"${DB_TYPE}"|g" /config/config.yml
17-
sed -i "s|{{DB_HOST}}|"${DB_HOST}"|g" /config/config.yml
18-
sed -i "s|{{DB_PORT}}|"${DB_PORT}"|g" /config/config.yml
19-
sed -i "s|{{DB_USER}}|"${DB_USER}"|g" /config/config.yml
20-
sed -i "s|{{DB_PASS}}|"${DB_PASS}"|g" /config/config.yml
21-
sed -i "s|{{DB_NAME}}|"${DB_NAME}"|g" /config/config.yml
2210
fi
2311

24-
ln -sf /config/config.yml /app/wiki/config.yml
25-
2612
# permissions
2713
lsiown -R abc:abc \
28-
/app/wiki/data \
2914
/config
30-
lsiown abc:abc \
31-
/data
15+
16+
if grep -qe ' /data ' /proc/mounts; then
17+
lsiown abc:abc \
18+
/data
19+
fi
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/with-contenv bash
22
# shellcheck shell=bash
33

4+
export CONFIG_FILE="/config/config.yml"
5+
46
exec \
57
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 3000" \
68
cd /app/wiki s6-setuidgid abc /usr/bin/node server

0 commit comments

Comments
 (0)