unison tuning
This commit is contained in:
parent
d312aeeaa4
commit
2cf9ce38d1
@ -3,29 +3,7 @@
|
|||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: {
|
||||||
mergeNmConnections = pkgs.writeShellApplication {
|
|
||||||
name = "merge-nmconnections";
|
|
||||||
text = ''
|
|
||||||
CURRENT1="$1"
|
|
||||||
CURRENT2="$2"
|
|
||||||
NEW="$3"
|
|
||||||
NEW1="$4"
|
|
||||||
NEW2="$5"
|
|
||||||
|
|
||||||
sed -i -E '/^(uuid|interface-name)=/d' "$CURRENT1"
|
|
||||||
sed -i -E '/^(uuid|interface-name)=/d' "$CURRENT2"
|
|
||||||
|
|
||||||
if cmp "$1" "$2"; then
|
|
||||||
mv "$CURRENT1" "$NEW"
|
|
||||||
else
|
|
||||||
mv "$CURRENT1" "$NEW1"
|
|
||||||
mv "$CURRENT2" "$NEW2"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
options.mj.services.wifibackup = with lib.types; {
|
options.mj.services.wifibackup = with lib.types; {
|
||||||
enable = lib.mkEnableOption "enable wifi code backups to M-Active";
|
enable = lib.mkEnableOption "enable wifi code backups to M-Active";
|
||||||
fromPath = lib.mkOption {
|
fromPath = lib.mkOption {
|
||||||
@ -55,18 +33,19 @@ in {
|
|||||||
Type = "oneshot";
|
Type = "oneshot";
|
||||||
User = "root";
|
User = "root";
|
||||||
SuccessExitStatus = [0 1];
|
SuccessExitStatus = [0 1];
|
||||||
ExecStart = ''
|
|
||||||
${pkgs.unison}/bin/unison \
|
|
||||||
-sshcmd ${pkgs.openssh}/bin/ssh \
|
|
||||||
-sshargs "-i /etc/ssh/ssh_host_ed25519_key" \
|
|
||||||
-batch \
|
|
||||||
-merge "Name *.nmconnection -> ${mergeNmConnections}/bin/merge-nmconnections CURRENT1 CURRENT2 NEW NEW1 NEW2" \
|
|
||||||
-backuploc local \
|
|
||||||
-backup "Name *" \
|
|
||||||
${fromPath} \
|
|
||||||
ssh://${toUser}@localhost/${toPath}/
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
script = ''
|
||||||
|
sed -i -E '/^(uuid|interface-name)=/d' ${fromPath}/*.nmconnection
|
||||||
|
|
||||||
|
exec ${pkgs.unison}/bin/unison \
|
||||||
|
-sshcmd ${pkgs.openssh}/bin/ssh \
|
||||||
|
-sshargs "-i /etc/ssh/ssh_host_ed25519_key -o KnownHostsCommand=\"${pkgs.coreutils}/bin/cat /etc/ssh/ssh_host_ed25519_key.pub\"" \
|
||||||
|
-batch \
|
||||||
|
-backuploc local \
|
||||||
|
-backup "Name *" \
|
||||||
|
${fromPath} \
|
||||||
|
ssh://${toUser}@localhost/${toPath}/
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user