Initial import.
This commit is contained in:
@@ -0,0 +1,140 @@
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
# Variables
|
||||
vars = import ../vars;
|
||||
in
|
||||
{
|
||||
# Services
|
||||
systemd.services = {
|
||||
|
||||
"notify-email@" = {
|
||||
path = with pkgs; [ systemd system-sendmail ];
|
||||
scriptArgs = "%I";
|
||||
script = ''
|
||||
UNIT=$(systemd-escape $1)
|
||||
TO="${vars.smtp.from}"
|
||||
FROM="${vars.smtp.from}"
|
||||
SUBJECT="$UNIT Failed"
|
||||
HEADERS="To:$TO\nFrom:$FROM\nSubject: $SUBJECT\n"
|
||||
BODY=$(systemctl status --no-pager $UNIT || true)
|
||||
echo -e "$HEADERS\n$BODY" | sendmail -t
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
};
|
||||
};
|
||||
|
||||
"usr-cloud-sync" = {
|
||||
script = ''
|
||||
$HOME/.local/bin/pva nextcloud sync \
|
||||
> $HOME/.local/log/cloud-sync.log
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "${vars.user.username}";
|
||||
};
|
||||
onFailure = [ "notify-email@%n.service" ];
|
||||
};
|
||||
|
||||
"usr-cloud-sync-force" = {
|
||||
script = ''
|
||||
$HOME/.local/bin/pva nextcloud kill && \
|
||||
$HOME/.local/bin/pva nextcloud sync \
|
||||
> $HOME/.local/log/cloud-sync-force.log
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "${vars.user.username}";
|
||||
};
|
||||
onFailure = [ "notify-email@%n.service" ];
|
||||
};
|
||||
|
||||
"usr-email-bkg" = {
|
||||
script = ''
|
||||
$HOME/.local/bin/pva email tb-background \
|
||||
> $HOME/.local/log/email-bkg.log
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "${vars.user.username}";
|
||||
};
|
||||
onFailure = [ "notify-email@%n.service" ];
|
||||
};
|
||||
|
||||
"usr-theme" = {
|
||||
script = ''
|
||||
$HOME/.local/bin/pva theme text \
|
||||
> $HOME/.local/log/theme.log
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "${vars.user.username}";
|
||||
};
|
||||
onFailure = [ "notify-email@%n.service" ];
|
||||
};
|
||||
|
||||
"sys-purge" = {
|
||||
script = ''
|
||||
/root/.local/bin/sys-purge.sh \
|
||||
> /root/.local/log/sys-purge.log
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "root";
|
||||
};
|
||||
onFailure = [ "notify-email@%n.service" ];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
# Timers
|
||||
# DayOfWeek Year-Month-Day Hour:Minute:Second
|
||||
systemd.timers = {
|
||||
|
||||
"usr-cloud-sync" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
Unit = "usr-cloud-sync.service";
|
||||
OnCalendar = "*-*-* 00..22:0/5:00";
|
||||
Persistent = true;
|
||||
};
|
||||
};
|
||||
|
||||
"usr-cloud-sync-force" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
Unit = "usr-cloud-sync-force.service";
|
||||
OnCalendar = "*-*-* 23:23:23";
|
||||
};
|
||||
};
|
||||
|
||||
"usr-email-bkg" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "*-*-* 01:20:00";
|
||||
Unit = "usr-email-bkg.service";
|
||||
};
|
||||
};
|
||||
|
||||
"usr-theme" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
Unit = "usr-theme.service";
|
||||
OnBootSec = "15m";
|
||||
OnUnitActiveSec = "15m";
|
||||
};
|
||||
};
|
||||
|
||||
"sys-purge" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "*-*-* 02:18:18";
|
||||
Unit = "sys-purge.service";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user