regenconf: sometimes ntp doesnt exist

This commit is contained in:
Alexandre Aubin 2023-02-12 17:31:01 +01:00
parent 20e8805e3b
commit 97c0128c22

View file

@ -125,12 +125,15 @@ EOF
fi
# Skip ntp if inside a container (inspired from the conf of systemd-timesyncd)
mkdir -p ${pending_dir}/etc/systemd/system/ntp.service.d/
cat >${pending_dir}/etc/systemd/system/ntp.service.d/ynh-override.conf <<EOF
if systemctl | grep -q 'ntp.service'
then
mkdir -p ${pending_dir}/etc/systemd/system/ntp.service.d/
cat >${pending_dir}/etc/systemd/system/ntp.service.d/ynh-override.conf <<EOF
[Unit]
ConditionCapability=CAP_SYS_TIME
ConditionVirtualization=!container
EOF
fi
# Make nftable conflict with yunohost-firewall
mkdir -p ${pending_dir}/etc/systemd/system/nftables.service.d/
@ -215,10 +218,13 @@ do_post_regen() {
grep -q '^sftp.app:' /etc/group || groupadd sftp.app
# Propagates changes in systemd service config overrides
[[ ! "$regen_conf_files" =~ "ntp.service.d/ynh-override.conf" ]] || {
systemctl daemon-reload
systemctl restart ntp
}
if systemctl | grep -q 'ntp.service'
then
[[ ! "$regen_conf_files" =~ "ntp.service.d/ynh-override.conf" ]] || {
systemctl daemon-reload
systemctl restart ntp
}
fi
[[ ! "$regen_conf_files" =~ "nftables.service.d/ynh-override.conf" ]] || systemctl daemon-reload
[[ ! "$regen_conf_files" =~ "login.conf.d/ynh-override.conf" ]] || {
systemctl daemon-reload