coreos-home-server/service/writefreely/container/run-writefreely
Alex Palaistras f877a72e83 Flatten directory structures
This commit contains a fairly large diff for a fairly small change:
moving the `config/common` directory to `host/base` to better reflect
its intended use, and promoting `config/service` to the root directory.

These changes unlock some improvements in `coreos-home-server-update`
processes, which will (assuming `/etc/coreos-home-server/base` exists)
keep host-wide systemd services in sync in addition to service-specific
ones.

Changes have been make to the `Makefile` and a few other places where
`config/common` was referenced, but most of this work is renames that
are not intended to break compatibility with new or running servers.
2022-01-15 11:43:33 +00:00

32 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# Create configuration file from collected templates.
envsubst < /etc/writefreely/config.ini.template > /etc/writefreely/config.ini
mkdir -p /var/lib/writefreely/keys
# Initialize and run migrates on database if needed. New instances of WriteFreely will have a
# default administrator be created with a random password, which is echoed back to the system. It
# is intended that both the username and password are changed by whoever manages this instance.
if ! test -f /var/lib/writefreely/writefreely.db; then
writefreely -c /etc/writefreely/config.ini db init
(
password="$(dd if=/dev/urandom | tr -dc '[:alnum:]' | head -c 50)"
writefreely -c /etc/writefreely/config.ini user add --admin "default:${password}"
echo "Created an administrator user with username 'default' and password '${password}'"
echo "Make sure to change this immediately after logging in for the first time!"
)
fi
writefreely -c /etc/writefreely/config.ini db migrate
# Generate keys, if none have already been generated.
if test -z "$(ls -A /var/lib/writefreely/keys)"; then
writefreely -c /etc/writefreely/config.ini keys generate
fi
# Correct permissions for data files.
chown -R writefreely:writefreely /var/lib/writefreely
# Run entrypoint under specific user.
gosu writefreely /bin/writefreely -c /etc/writefreely/config.ini "$@"