Skip to content

Commit

Permalink
Merge pull request #35 from linuxserver/ro-tweaks
Browse files Browse the repository at this point in the history
Use envs for DB config, move config.yml to /config
  • Loading branch information
Roxedus authored Jul 7, 2024
2 parents 6df3a72 + 658c088 commit 6fd32e8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 27 deletions.
5 changes: 4 additions & 1 deletion readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ common_param_env_vars_enabled: true
param_container_name: "{{ project_name }}"
param_usage_include_vols: true
param_volumes:
- { vol_path: "/config", vol_host_path: "/path/to/{{ project_name }}/config", desc: "Persistent config files" }
- {vol_path: "/config", vol_host_path: "/path/to/{{ project_name }}/config", desc: "Persistent config files"}
- {vol_path: "/data", vol_host_path: "/path/to/data", desc: "Where Wiki.js data is stored."}
param_usage_include_ports: true
param_ports:
Expand All @@ -30,6 +30,9 @@ opt_param_env_vars:
- {env_var: "DB_NAME", env_value: "", desc: "DB name (postgres only)"}
- {env_var: "DB_USER", env_value: "", desc: "DB username (postgres only)"}
- {env_var: "DB_PASS", env_value: "", desc: "DB password (postgres only)"}

readonly_supported: true

# application setup block
app_setup_block_enabled: true
app_setup_block: |
Expand Down
12 changes: 6 additions & 6 deletions root/defaults/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ port: 3000
# - sqlite = SQLite 3.9 or later

db:
type: {{DB_TYPE}}
type: $(DB_TYPE)

# PostgreSQL / MySQL / MariaDB / MS SQL Server only:
host: {{DB_HOST}}
port: {{DB_PORT}}
user: {{DB_USER}}
pass: {{DB_PASS}}
db: {{DB_NAME}}
host: '$(DB_HOST)'
port: $(DB_PORT)
user: '$(DB_USER)'
pass: '$(DB_PASS)'
db: $(DB_NAME)
ssl: false

# Optional - PostgreSQL / MySQL / MariaDB only:
Expand Down
28 changes: 8 additions & 20 deletions root/etc/s6-overlay/s6-rc.d/init-wikijs-config/run
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

mkdir -p /data

DB_TYPE=${DB_TYPE:-sqlite}
DB_HOST=${DB_HOST:-mariadb}
DB_PORT=${DB_PORT:-3306}
DB_USER=${DB_USER:-root}
DB_PASS=${DB_PASS:-root}
DB_NAME=${DB_NAME:-wikijs}
if [[ -z ${DB_TYPE} ]]; then
printf "sqlite" > /run/s6/container_environment/DB_TYPE
fi

if [[ ! -f "/config/config.yml" ]]; then
cp /defaults/config.yml /config/config.yml

sed -i "s|{{DB_TYPE}}|"${DB_TYPE}"|g" /config/config.yml
sed -i "s|{{DB_HOST}}|"${DB_HOST}"|g" /config/config.yml
sed -i "s|{{DB_PORT}}|"${DB_PORT}"|g" /config/config.yml
sed -i "s|{{DB_USER}}|"${DB_USER}"|g" /config/config.yml
sed -i "s|{{DB_PASS}}|"${DB_PASS}"|g" /config/config.yml
sed -i "s|{{DB_NAME}}|"${DB_NAME}"|g" /config/config.yml
fi

ln -sf /config/config.yml /app/wiki/config.yml

# permissions
lsiown -R abc:abc \
/app/wiki/data \
/config
lsiown abc:abc \
/data

if grep -qe ' /data ' /proc/mounts; then
lsiown abc:abc \
/data
fi
2 changes: 2 additions & 0 deletions root/etc/s6-overlay/s6-rc.d/svc-wikijs/run
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/with-contenv bash
# shellcheck shell=bash

export CONFIG_FILE="/config/config.yml"

exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 3000" \
cd /app/wiki s6-setuidgid abc /usr/bin/node server

0 comments on commit 6fd32e8

Please sign in to comment.