nixos/zerotierone: clean up local.conf symlinks unconditionally

This commit is contained in:
Jörg Thalheim 2024-07-01 13:33:28 +02:00
parent 0e4209dd43
commit f09ab69a7e

View File

@ -60,14 +60,16 @@ in
mkdir -p /var/lib/zerotier-one/networks.d
chmod 700 /var/lib/zerotier-one
chown -R root:root /var/lib/zerotier-one
# cleans up old symlinks also if we unset localConf
if [[ -L "${localConfFilePath}" && "$(readlink "${localConfFilePath}")" =~ ^${builtins.storeDir}.* ]]; then
rm ${localConfFilePath}
fi
'' + (concatMapStrings (netId: ''
touch "/var/lib/zerotier-one/networks.d/${netId}.conf"
'') cfg.joinNetworks) + optionalString (cfg.localConf != {}) ''
if [ -L "${localConfFilePath}" ]
then
rm ${localConfFilePath}
elif [ -f "${localConfFilePath}" ]
then
'') cfg.joinNetworks) + lib.optionalString (cfg.localConf != {}) ''
# in case the user has applied manual changes to the local.conf, we backup the file
if [ -f "${localConfFilePath}" ]; then
mv ${localConfFilePath} ${localConfFilePath}.bak
fi
ln -s ${localConfFile} ${localConfFilePath}