2018-11-04 21:05:39 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
function fixperms {
|
2022-03-25 17:45:48 +00:00
|
|
|
chown -R $UID:$GID /var/log /data
|
2021-11-19 15:22:17 +00:00
|
|
|
}
|
|
|
|
|
2022-01-06 22:05:07 +00:00
|
|
|
function fixdefault {
|
|
|
|
_value=$(yq e "$1" /data/config.yaml)
|
|
|
|
if [[ "$_value" == "$2" ]]; then
|
|
|
|
yq e -i "$1 = "'"'"$3"'"' /data/config.yaml
|
2021-11-19 15:22:17 +00:00
|
|
|
fi
|
2022-01-06 22:05:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function fixconfig {
|
|
|
|
# Change relative default paths to absolute paths in /data
|
|
|
|
fixdefault '.database' 'sqlite:///maubot.db' 'sqlite:////data/maubot.db'
|
|
|
|
fixdefault '.plugin_directories.upload' './plugins' '/data/plugins'
|
|
|
|
fixdefault '.plugin_directories.load[0]' './plugins' '/data/plugins'
|
|
|
|
fixdefault '.plugin_directories.trash' './trash' '/data/trash'
|
2022-03-26 11:59:49 +00:00
|
|
|
fixdefault '.plugin_databases.sqlite' './plugins' '/data/dbs'
|
|
|
|
fixdefault '.plugin_databases.sqlite' './dbs' '/data/dbs'
|
2022-01-06 22:05:07 +00:00
|
|
|
fixdefault '.logging.handlers.file.filename' './maubot.log' '/var/log/maubot.log'
|
|
|
|
# This doesn't need to be configurable
|
2022-01-07 14:17:47 +00:00
|
|
|
yq e -i '.server.override_resource_path = "/opt/maubot/frontend"' /data/config.yaml
|
2018-11-04 21:05:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cd /opt/maubot
|
|
|
|
|
2021-11-19 15:22:17 +00:00
|
|
|
mkdir -p /var/log/maubot /data/plugins /data/trash /data/dbs
|
2020-04-09 11:27:22 +00:00
|
|
|
|
2018-11-04 21:05:39 +00:00
|
|
|
if [ ! -f /data/config.yaml ]; then
|
2021-11-19 15:22:17 +00:00
|
|
|
cp example-config.yaml /data/config.yaml
|
|
|
|
# Apply some docker-specific adjustments to the config
|
2018-11-04 21:05:39 +00:00
|
|
|
echo "Config file not found. Example config copied to /data/config.yaml"
|
|
|
|
echo "Please modify the config file to your liking and restart the container."
|
|
|
|
fixperms
|
2021-11-19 15:22:17 +00:00
|
|
|
fixconfig
|
2018-11-04 21:05:39 +00:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2019-09-28 15:25:30 +00:00
|
|
|
alembic -x config=/data/config.yaml upgrade head
|
2018-11-04 21:05:39 +00:00
|
|
|
fixperms
|
2021-11-19 15:22:17 +00:00
|
|
|
fixconfig
|
2022-01-07 14:20:50 +00:00
|
|
|
if ls /data/plugins/*.db > /dev/null 2>&1; then
|
|
|
|
mv -n /data/plugins/*.db /data/dbs/
|
|
|
|
fi
|
2021-11-19 15:22:17 +00:00
|
|
|
|
|
|
|
exec su-exec $UID:$GID python3 -m maubot -c /data/config.yaml
|