services/tmptsync: init
This commit is contained in:
parent
1d6312c258
commit
0806e9ec72
4 changed files with 62 additions and 0 deletions
|
|
@ -30,5 +30,6 @@
|
|||
nginx
|
||||
postgres
|
||||
synapse
|
||||
tmptsync
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ in {
|
|||
./services/nginx.nix
|
||||
./services/postgres.nix
|
||||
./services/synapse.nix
|
||||
./services/tmptsync.nix
|
||||
];
|
||||
system = mkAttrsFromPaths [
|
||||
./system/audio.nix
|
||||
|
|
|
|||
30
modules/services/tmptsync.nix
Normal file
30
modules/services/tmptsync.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{ ... }:
|
||||
let
|
||||
dir = "/persist/tmptsync";
|
||||
in
|
||||
{
|
||||
systemd = {
|
||||
services = {
|
||||
tmptsync-load = {
|
||||
before = [ "basic.target" ];
|
||||
after = [ "local-fs.target" "sysinit.target" ];
|
||||
unitConfig.DefaultDependencies = false;
|
||||
|
||||
script = "${../../scripts/tmptsync.sh} load";
|
||||
wantedBy = [ "basic.target" ];
|
||||
};
|
||||
|
||||
tmptsync-save = {
|
||||
script = "${../../scripts/tmptsync.sh} load";
|
||||
wantedBy = [ "basic.target" ];
|
||||
};
|
||||
};
|
||||
timers.tmptsync-save = {
|
||||
timerConfig = {
|
||||
Unit = "tmptsync-save.service";
|
||||
OnBootSec = "30mn";
|
||||
OnUnitActiveSec = "2h";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
30
scripts/tmptsync.sh
Executable file
30
scripts/tmptsync.sh
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env sh
|
||||
#
|
||||
# Super simple script that saves clock to file and reads from it later
|
||||
# Something like fake-hwclock from debian
|
||||
# CC0-1.0
|
||||
|
||||
CMD="${1:-save}"
|
||||
|
||||
if [ ! -v FILE ]; then
|
||||
echo 'missing $FILE'
|
||||
exit 64
|
||||
fi
|
||||
|
||||
case $CMD in
|
||||
save)
|
||||
date -u '+%Y-%m-%d %H:%M:%S' > $FILE
|
||||
;;
|
||||
load)
|
||||
if [ ! -e $FILE ]; then
|
||||
echo "attempted to load from nonexistent file"
|
||||
exit 65
|
||||
fi
|
||||
NEW=$(cat $FILE)
|
||||
date -u -s "$NEW"
|
||||
;;
|
||||
*)
|
||||
echo "unknown subcommand"
|
||||
exit 66
|
||||
;;
|
||||
esac
|
||||
Loading…
Add table
Add a link
Reference in a new issue