summaryrefslogtreecommitdiffstats
path: root/krebs
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2016-02-18 17:07:49 +0100
committerlassulus <lass@aidsballs.de>2016-02-18 17:07:49 +0100
commit0f225385758ebb156d49d05f03fe76c15023e200 (patch)
tree80a66df538e3c25f37cba726ef27669bbefdc18e /krebs
parente1a77d240eaedafbb58a387da94c863118533574 (diff)
parentffc47bf80d521635021b3f7a0122092708ebd2bf (diff)
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'krebs')
-rw-r--r--krebs/3modules/backup.nix23
-rw-r--r--krebs/3modules/build.nix9
-rw-r--r--krebs/3modules/tv/default.nix2
-rw-r--r--krebs/3modules/urlwatch.nix69
4 files changed, 68 insertions, 35 deletions
diff --git a/krebs/3modules/backup.nix b/krebs/3modules/backup.nix
index 0aa86dec..97082f56 100644
--- a/krebs/3modules/backup.nix
+++ b/krebs/3modules/backup.nix
@@ -117,6 +117,14 @@ let
"$dst_user@$dst_host" \
-T "$with_dst_path_lock_script"
}
+ rsh="ssh -F /dev/null -i $identity ''${dst_port:+-p $dst_port}"
+ local_rsync() {
+ rsync "$@"
+ }
+ remote_rsync=${shell.escape (concatStringsSep " && " [
+ "mkdir -m 0700 -p ${shell.escape plan.dst.path}/current"
+ "exec flock -n ${shell.escape plan.dst.path} rsync"
+ ])}
'';
pull = ''
identity=${shell.escape plan.dst.host.ssh.privkey.path}
@@ -131,6 +139,12 @@ let
dst_shell() {
eval "$with_dst_path_lock_script"
}
+ rsh="ssh -F /dev/null -i $identity ''${src_port:+-p $src_port}"
+ local_rsync() {
+ mkdir -m 0700 -p ${shell.escape plan.dst.path}/current
+ flock -n ${shell.escape plan.dst.path} rsync "$@"
+ }
+ remote_rsync=rsync
'';
}}
# Note that this only works because we trust date +%s to produce output
@@ -140,13 +154,10 @@ let
with_dst_path_lock_script="exec env start_date=$(date +%s) "${shell.escape
"flock -n ${shell.escape plan.dst.path} /bin/sh"
}
- rsync >&2 \
+ local_rsync >&2 \
-aAXF --delete \
- -e "ssh -F /dev/null -i $identity ''${dst_port:+-p $dst_port}" \
- --rsync-path ${shell.escape (concatStringsSep " && " [
- "mkdir -m 0700 -p ${shell.escape plan.dst.path}/current"
- "exec flock -n ${shell.escape plan.dst.path} rsync"
- ])} \
+ --rsh="$rsh" \
+ --rsync-path="$remote_rsync" \
--link-dest="$dst_path/current" \
"$src/" \
"$dst/.partial"
diff --git a/krebs/3modules/build.nix b/krebs/3modules/build.nix
index c700fbc5..b8ea34ae 100644
--- a/krebs/3modules/build.nix
+++ b/krebs/3modules/build.nix
@@ -42,12 +42,13 @@ let
set -eu
verbose() {
- printf '+%s\n' "$(printf ' %q' "$@")" >&2
+ printf '%s%s\n' "$PS5$(printf ' %q' "$@")" >&2
"$@"
}
- echo ${shell.escape git-script} \
- | ssh -p ${shell.escape target-port} \
+ { printf 'PS5=%q%q\n' @ "$PS5"
+ echo ${shell.escape git-script}
+ } | verbose ssh -p ${shell.escape target-port} \
${shell.escape "${target-user}@${target-host}"} -T
unset tmpdir
@@ -86,7 +87,7 @@ let
set -efu
verbose() {
- printf '+%s\n' "$(printf ' %q' "$@")" >&2
+ printf '%s%s\n' "$PS5$(printf ' %q' "$@")" >&2
"$@"
}
diff --git a/krebs/3modules/tv/default.nix b/krebs/3modules/tv/default.nix
index f8d3d867..300fce01 100644
--- a/krebs/3modules/tv/default.nix
+++ b/krebs/3modules/tv/default.nix
@@ -352,7 +352,7 @@ with config.krebs.lib;
pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGer9e2+Lew7vnisgBbsFNECEIkpNJgEaqQqgb9inWkQ mv@vod";
};
tv = {
- mail = "tv@wu.retiolum";
+ mail = "tv@nomic.retiolum";
pubkey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAEAQDFR//RnCvEZAt0F6ExDsatKZ/DDdifanuSL360mqOhaFieKI34RoOwfQT9T+Ga52Vh5V2La6esvlph686EdgzeKLvDoxEwFM9ZYFBcMrNzu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lWfcgHxTf17d/4tl6z4DTcLpCCk8Da77JouSHgvtcRbRlFV1OfhWZLXUsrlfpaQTiItv6TGIr3k7+7b66o3Qw/GQVs5GmYifaIZIz8n8my4XjkaMBd0SZfBzzvFjHMq6YUP9+SbjvReqofuoO+5tW1wTYZXitFFBfwuHlXm6w77K5QDBW6olT7pat41/F5eGxLcz tv@wu";
};
tv-nomic = {
diff --git a/krebs/3modules/urlwatch.nix b/krebs/3modules/urlwatch.nix
index cd4976a2..ed1a2126 100644
--- a/krebs/3modules/urlwatch.nix
+++ b/krebs/3modules/urlwatch.nix
@@ -3,7 +3,6 @@
# TODO multiple users
# TODO inform about unused caches
# cache = url: "${cfg.dataDir}/.urlwatch/cache/${hashString "sha1" url}"
-# TODO hooks.py
with config.krebs.lib;
let
@@ -32,6 +31,14 @@ let
Content of the From: header of the generated mails.
'';
};
+ # TODO hooks :: attrsOf hook
+ hooksFile = mkOption {
+ type = with types; nullOr path;
+ default = null;
+ description = ''
+ File to use as hooks.py module.
+ '';
+ };
mailto = mkOption {
type = types.str;
default = config.krebs.build.user.mail;
@@ -48,7 +55,7 @@ let
'';
};
urls = mkOption {
- type = with types; listOf str;
+ type = with types; listOf (either str subtypes.job);
default = [];
description = "URL to watch.";
example = [
@@ -56,7 +63,10 @@ let
];
apply = map (x: getAttr (typeOf x) {
set = x;
- string.url = x;
+ string = {
+ url = x;
+ filter = null;
+ };
});
};
verbose = mkOption {
@@ -68,9 +78,12 @@ let
};
};
- urlsFile = toFile "urls" (concatMapStringsSep "\n---\n" toJSON cfg.urls);
+ urlsFile = pkgs.writeText "urls"
+ (concatMapStringsSep "\n---\n" toJSON cfg.urls);
+
+ hooksFile = cfg.hooksFile;
- configFile = toFile "urlwatch.yaml" (toJSON {
+ configFile = pkgs.writeText "urlwatch.yaml" (toJSON {
display = {
error = true;
new = true;
@@ -127,10 +140,10 @@ let
User = user.name;
PermissionsStartOnly = "true";
PrivateTmp = "true";
+ SyslogIdentifier = "urlwatch";
Type = "oneshot";
ExecStartPre =
- pkgs.writeScript "urlwatch-prestart" ''
- #! /bin/sh
+ pkgs.writeDash "urlwatch-prestart" ''
set -euf
dataDir=$HOME
@@ -140,31 +153,29 @@ let
chown ${user.name}: "$dataDir"
fi
'';
- ExecStart = pkgs.writeScript "urlwatch" ''
- #! /bin/sh
+ ExecStart = pkgs.writeDash "urlwatch" ''
set -euf
- from=${escapeShellArg cfg.from}
- mailto=${escapeShellArg cfg.mailto}
- urlsFile=${escapeShellArg urlsFile}
- configFile=${escapeShellArg configFile}
cd /tmp
urlwatch \
${optionalString cfg.verbose "-v"} \
- --urls="$urlsFile" \
- --config="$configFile" \
+ --config=${shell.escape configFile} \
+ ${optionalString (hooksFile != null)
+ "--hooks=${shell.escape hooksFile}"
+ } \
+ --urls=${shell.escape urlsFile} \
> changes || :
if test -s changes; then
- date=$(date -R)
- subject=$(sed -n 's/^\(CHANGED\|ERROR\|NEW\): //p' changes \
- | tr \\n \ )
{
- echo "Date: $date"
- echo "From: $from"
- echo "Subject: $subject"
- echo "To: $mailto"
+ echo Date: $(date -R)
+ echo From: ${shell.escape cfg.from}
+ echo Subject: $(
+ sed -n 's/^\(CHANGED\|ERROR\|NEW\): //p' changes \
+ | tr '\n' ' '
+ )
+ echo To: ${shell.escape cfg.mailto}
echo
cat changes
} | /var/setuid-wrappers/sendmail -t
@@ -181,5 +192,15 @@ let
name = "urlwatch";
uid = genid name;
};
-in
-out
+
+ subtypes.job = types.submodule {
+ options = {
+ url = mkOption {
+ type = types.str;
+ };
+ filter = mkOption {
+ type = with types; nullOr str; # TODO nullOr subtypes.filter
+ };
+ };
+ };
+in out