2018-11-04 16:05:39 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
function fixperms {
|
2021-11-19 10:22:17 -05:00
|
|
|
chown -R $UID:$GID /var/log /data /opt/maubot
|
|
|
|
}
|
|
|
|
|
|
|
|
function fixconfig {
|
|
|
|
# If the DB path is the default relative path, replace it with an absolute /data path
|
|
|
|
_db_url=$(yq e '.database' /data/config.yaml)
|
|
|
|
if [[ _db_url == "sqlite:///maubot.db" ]]; then
|
|
|
|
yq e -i '.database = "sqlite:////data/maubot.db"' /data/config.yaml
|
|
|
|
fi
|
|
|
|
_log_path=$(yq e '.logging.handlers.file.filename' /data/config.yaml)
|
|
|
|
if [[ _log_path == "./maubot.log" ]]; then
|
|
|
|
yq e -i '.logging.handlers.file.filename = "/var/log/maubot.log"' /data/config.yaml
|
|
|
|
fi
|
|
|
|
# Set the correct resource paths
|
|
|
|
yq e -i '
|
|
|
|
.server.override_resource_path = "/opt/maubot/frontend" |
|
|
|
|
.plugin_directories.upload = "/data/plugins" |
|
|
|
|
.plugin_directories.load = ["/data/plugins"] |
|
|
|
|
.plugin_directories.trash = "/data/trash" |
|
|
|
|
.plugin_directories.db = "/data/dbs"
|
|
|
|
' /data/config.yaml
|
2018-11-04 16:05:39 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
cd /opt/maubot
|
|
|
|
|
2021-11-19 10:22:17 -05:00
|
|
|
mkdir -p /var/log/maubot /data/plugins /data/trash /data/dbs
|
2020-04-09 07:27:22 -04:00
|
|
|
|
2018-11-04 16:05:39 -05:00
|
|
|
if [ ! -f /data/config.yaml ]; then
|
2021-11-19 10:22:17 -05:00
|
|
|
cp example-config.yaml /data/config.yaml
|
|
|
|
# Apply some docker-specific adjustments to the config
|
2018-11-04 16:05:39 -05: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 10:22:17 -05:00
|
|
|
fixconfig
|
2018-11-04 16:05:39 -05:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2019-09-28 11:25:30 -04:00
|
|
|
alembic -x config=/data/config.yaml upgrade head
|
2018-11-04 16:05:39 -05:00
|
|
|
fixperms
|
2021-11-19 10:22:17 -05:00
|
|
|
fixconfig
|
2021-11-21 16:33:21 -05:00
|
|
|
mv -n /data/plugins/*.db /data/dbs/
|
2021-11-19 10:22:17 -05:00
|
|
|
|
|
|
|
exec su-exec $UID:$GID python3 -m maubot -c /data/config.yaml
|