tb-scripts: add pushover-send
This commit is contained in:
@@ -78,6 +78,20 @@
|
|||||||
identityFile = tb1;
|
identityFile = tb1;
|
||||||
forwardAgent = true;
|
forwardAgent = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Git Services
|
||||||
|
"github.com" = {
|
||||||
|
user = "git";
|
||||||
|
identityFile = tb1;
|
||||||
|
};
|
||||||
|
"bitbucket.org" = {
|
||||||
|
user = "git";
|
||||||
|
identityFile = tb1;
|
||||||
|
};
|
||||||
|
"gitlab.com" = {
|
||||||
|
user = "git";
|
||||||
|
identityFile = tb1;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,5 +25,10 @@ pkgs.symlinkJoin {
|
|||||||
runtimeInputs = [ pkgs.coreutils ];
|
runtimeInputs = [ pkgs.coreutils ];
|
||||||
text = builtins.readFile ./split-1G;
|
text = builtins.readFile ./split-1G;
|
||||||
})
|
})
|
||||||
|
(pkgs.writeShellApplication {
|
||||||
|
name = ",pushover-send";
|
||||||
|
runtimeInputs = [ pkgs.curl ];
|
||||||
|
text = builtins.readFile ./pushover-send;
|
||||||
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
47
pkgs/tb-scripts/pushover-send
Executable file
47
pkgs/tb-scripts/pushover-send
Executable file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Send a pushover notification.
|
||||||
|
# Usage: pushover-send [--pid <pid>] [message]
|
||||||
|
# --pid <pid> Wait for process to finish before sending
|
||||||
|
# message Optional message (default: "Job done.")
|
||||||
|
|
||||||
|
pid=""
|
||||||
|
message=""
|
||||||
|
|
||||||
|
# Parse arguments
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--pid)
|
||||||
|
pid="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
message="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Default message
|
||||||
|
if [ -z "$message" ]; then
|
||||||
|
message="Job done."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Wait for PID if specified
|
||||||
|
if [ -n "$pid" ]; then
|
||||||
|
if ! [[ "$pid" =~ ^[0-9]+$ ]]; then
|
||||||
|
echo "Error: PID must be a number" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! -d "/proc/$pid" ]; then
|
||||||
|
echo "Error: Process $pid does not exist" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
tail --pid="$pid" -f /dev/null 2>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl \
|
||||||
|
https://api.pushover.net/1/messages.json \
|
||||||
|
--data-urlencode "token=ak8z7cbxim2t7eksvj7dtudo6cdxgj" \
|
||||||
|
--data-urlencode "user=u8hjgdf1hquocmy682w9xfmpf3479u" \
|
||||||
|
--data-urlencode "priority=1" \
|
||||||
|
--data-urlencode "message=$message"
|
||||||
Reference in New Issue
Block a user