mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Update services.yml in yunohost conf_regen and update its content
This commit is contained in:
parent
0bacf65d9c
commit
dcdf852602
2 changed files with 78 additions and 8 deletions
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
services_path="/etc/yunohost/services.yml"
|
||||||
|
|
||||||
do_init_regen() {
|
do_init_regen() {
|
||||||
if [[ $EUID -ne 0 ]]; then
|
if [[ $EUID -ne 0 ]]; then
|
||||||
echo "You must be root to run this script" 1>&2
|
echo "You must be root to run this script" 1>&2
|
||||||
|
@ -16,22 +18,85 @@ do_init_regen() {
|
||||||
[[ -f /etc/yunohost/current_host ]] \
|
[[ -f /etc/yunohost/current_host ]] \
|
||||||
|| echo "yunohost.org" > /etc/yunohost/current_host
|
|| echo "yunohost.org" > /etc/yunohost/current_host
|
||||||
|
|
||||||
# copy default firewall and services
|
# copy default services and firewall
|
||||||
# TODO: update them as needed with upgrades
|
[[ -f $services_path ]] \
|
||||||
|
|| cp services.yml "$services_path"
|
||||||
[[ -f /etc/yunohost/firewall.yml ]] \
|
[[ -f /etc/yunohost/firewall.yml ]] \
|
||||||
|| cp firewall.yml /etc/yunohost/firewall.yml
|
|| cp firewall.yml /etc/yunohost/firewall.yml
|
||||||
[[ -f /etc/yunohost/services.yml ]] \
|
|
||||||
|| cp services.yml /etc/yunohost/services.yml
|
|
||||||
|
|
||||||
# allow users to access /media directory
|
# allow users to access /media directory
|
||||||
[[ -d /etc/skel/media ]] \
|
[[ -d /etc/skel/media ]] \
|
||||||
|| (mkdir -p /media && ln -s /media /etc/skel/media)
|
|| (mkdir -p /media && ln -s /media /etc/skel/media)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_pre_regen() {
|
||||||
|
pending_dir=$1
|
||||||
|
|
||||||
|
cd /usr/share/yunohost/templates/yunohost
|
||||||
|
|
||||||
|
# update services.yml
|
||||||
|
if [[ -f $services_path ]]; then
|
||||||
|
tmp_services_path="${services_path}-tmp"
|
||||||
|
new_services_path="${services_path}-new"
|
||||||
|
sudo cp "$services_path" "$tmp_services_path"
|
||||||
|
_update_services "$new_services_path" || {
|
||||||
|
sudo mv "$tmp_services_path" "$services_path"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
if [[ -f $new_services_path ]]; then
|
||||||
|
# replace services.yml with new one
|
||||||
|
sudo mv "$new_services_path" "$services_path"
|
||||||
|
sudo mv "$tmp_services_path" "${services_path}-old"
|
||||||
|
else
|
||||||
|
sudo rm -f "$tmp_services_path"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
sudo cp services.yml /etc/yunohost/services.yml
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_update_services() {
|
||||||
|
sudo python2 - << EOF
|
||||||
|
import yaml
|
||||||
|
with open('services.yml') as f:
|
||||||
|
new_services = yaml.load(f)
|
||||||
|
with open('/etc/yunohost/services.yml') as f:
|
||||||
|
services = yaml.load(f)
|
||||||
|
updated = False
|
||||||
|
for service, conf in new_services.items():
|
||||||
|
# remove service with empty conf
|
||||||
|
if not conf:
|
||||||
|
if service in services:
|
||||||
|
print("removing '{0}' from services".format(service))
|
||||||
|
del services[service]
|
||||||
|
updated = True
|
||||||
|
# add new service
|
||||||
|
elif not services.get(service, None):
|
||||||
|
print("adding '{0}' to services".format(service))
|
||||||
|
services[service] = conf
|
||||||
|
updated = True
|
||||||
|
# update service conf
|
||||||
|
else:
|
||||||
|
conffiles = services[service].pop('conffiles', {})
|
||||||
|
if services[service] != conf:
|
||||||
|
print("update '{0}' service".format(service))
|
||||||
|
services[service].update(conf)
|
||||||
|
updated = True
|
||||||
|
if conffiles:
|
||||||
|
services[service]['conffiles'] = conffiles
|
||||||
|
if updated:
|
||||||
|
with open('/etc/yunohost/services.yml-new', 'w') as f:
|
||||||
|
yaml.safe_dump(services, f, default_flow_style=False)
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
FORCE=$2
|
FORCE=$2
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
pre|post)
|
pre)
|
||||||
|
do_pre_regen $3
|
||||||
|
;;
|
||||||
|
post)
|
||||||
;;
|
;;
|
||||||
init)
|
init)
|
||||||
do_init_regen
|
do_init_regen
|
||||||
|
|
|
@ -15,8 +15,13 @@ postfix:
|
||||||
log: [/var/log/mail.log,/var/log/mail.err]
|
log: [/var/log/mail.log,/var/log/mail.err]
|
||||||
rmilter:
|
rmilter:
|
||||||
status: systemctl status rmilter.socket
|
status: systemctl status rmilter.socket
|
||||||
|
log: /var/log/mail.log
|
||||||
rspamd:
|
rspamd:
|
||||||
status: systemctl status rspamd.socket
|
status: systemctl status rspamd.socket
|
||||||
|
log: /var/log/mail.log
|
||||||
|
redis-server:
|
||||||
|
status: service
|
||||||
|
log: /var/log/redis/redis-server.log
|
||||||
mysql:
|
mysql:
|
||||||
status: service
|
status: service
|
||||||
log: [/var/log/mysql.log,/var/log/mysql.err]
|
log: [/var/log/mysql.log,/var/log/mysql.err]
|
||||||
|
@ -39,9 +44,6 @@ yunohost-api:
|
||||||
log: /var/log/yunohost/yunohost-api.log
|
log: /var/log/yunohost/yunohost-api.log
|
||||||
yunohost-firewall:
|
yunohost-firewall:
|
||||||
status: service
|
status: service
|
||||||
postgrey:
|
|
||||||
status: service
|
|
||||||
log: /var/log/mail.log
|
|
||||||
nslcd:
|
nslcd:
|
||||||
status: service
|
status: service
|
||||||
log: /var/log/syslog
|
log: /var/log/syslog
|
||||||
|
@ -49,3 +51,6 @@ nsswitch:
|
||||||
status: service
|
status: service
|
||||||
udisks2:
|
udisks2:
|
||||||
status: service
|
status: service
|
||||||
|
amavis: null
|
||||||
|
postgrey: null
|
||||||
|
spamassassin: null
|
||||||
|
|
Loading…
Add table
Reference in a new issue