2020-07-24 23:33:53 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-02-20 21:39:06 +01:00
|
|
|
set -eu
|
|
|
|
|
2020-07-24 23:33:53 +02:00
|
|
|
app=__APP__
|
|
|
|
service_config_file=/etc/matrix-$app/conf.d/app_service.yaml
|
|
|
|
|
|
|
|
# Backup the previous config file
|
|
|
|
cp $service_config_file /tmp/app_service_backup.yaml
|
|
|
|
|
2023-05-25 12:38:09 +02:00
|
|
|
if [ -n "$(ls /etc/matrix-$app/app-service/)" ]; then
|
|
|
|
echo "app_service_config_files:" > $service_config_file
|
2023-06-06 08:48:53 +02:00
|
|
|
else
|
|
|
|
echo "" > $service_config_file
|
2023-05-25 12:38:09 +02:00
|
|
|
fi
|
2020-07-24 23:33:53 +02:00
|
|
|
for f in $(ls /etc/matrix-$app/app-service/); do
|
2020-08-06 23:11:52 +02:00
|
|
|
echo " - /etc/matrix-$app/app-service/$f" >> $service_config_file
|
2020-07-24 23:33:53 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
# Set permissions
|
|
|
|
chown matrix-$app $service_config_file
|
2020-10-13 22:29:45 +02:00
|
|
|
chown matrix-$app /etc/matrix-$app/app-service/*
|
2020-07-24 23:33:53 +02:00
|
|
|
chmod 600 $service_config_file
|
2020-10-13 22:29:45 +02:00
|
|
|
chmod 600 /etc/matrix-$app/app-service/*
|
2020-07-24 23:33:53 +02:00
|
|
|
|
2024-02-06 20:42:00 +01:00
|
|
|
systemctl restart $app.service
|
2020-07-24 23:33:53 +02:00
|
|
|
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
rm /tmp/app_service_backup.yaml
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "Failed to restart synapse with the new config file. Restore the old config file !!"
|
|
|
|
cp /tmp/app_service_backup.yaml $service_config_file
|
|
|
|
fi
|