1#!/bin/sh
2set -e
3
4ROOT=/var/www/html
5
6quote() {
7 printf "%s" "$1" | sed "s/\\\\/\\\\\\\\/g; s/'/\\\\'/g"
8}
9
10cat > "$ROOT/config.local.php" <<PHP
11<?php
12/**
13 * Written by the ZnoteX Docker entrypoint on every container start.
14 * Edit docker-compose.yml environment values, not this file - it is
15 * regenerated each time the container boots.
16 */
17
18\$config['sqlHost'] = '$(quote "${ZNOTE_DB_HOST:-db}")';
19\$config['sqlUser'] = '$(quote "${ZNOTE_DB_USER:-znotex}")';
20\$config['sqlPassword'] = '$(quote "${ZNOTE_DB_PASSWORD:-znotex}")';
21\$config['sqlDatabase'] = '$(quote "${ZNOTE_DB_NAME:-znotex}")';
22
23\$config['ServerEngine'] = '$(quote "${ZNOTE_SERVER_ENGINE:-TFS_10}")';
24\$config['site_title'] = '$(quote "${ZNOTE_SITE_TITLE:-ZnoteX}")';
25\$config['site_url'] = '$(quote "${ZNOTE_SITE_URL:-http://localhost:8080}")';
26
27\$config['mailserver'] = array(
28 'register' => true,
29 'accountRecovery' => true,
30 'myaccount_verify_email' => true,
31 'verify_email_points' => 0,
32 'host' => 'mailpit',
33 'securityType' => '',
34 'port' => 1025,
35 'email' => 'noreply@znotex.local',
36 'username' => '',
37 'password' => '',
38 'debug' => false,
39 'fromName' => \$config['site_title'],
40);
41
42// Admin access is granted by account name (not character name).
43\$config['page_admin_access'] = array(
44 '$(quote "${ZNOTE_ADMIN_ACCOUNT:-demo}")',
45);
46PHP
47
48mkdir -p "$ROOT/install"
49if [ ! -f "$ROOT/install/installed.lock" ]; then
50 printf "Installed by the ZnoteX Docker entrypoint on %s\nDelete this file only if you mean to run the installer again.\n" "$(date '+%Y-%m-%d %H:%M:%S')" > "$ROOT/install/installed.lock"
51fi
52
53mkdir -p "$ROOT/engine/cache" "$ROOT/engine/img/theme"
54chown -R www-data:www-data "$ROOT/engine/cache" "$ROOT/engine/img/theme" "$ROOT/config.local.php" 2>/dev/null || true
55
56exec "$@"
57