diff options
Diffstat (limited to 'etc/sh')
-rwxr-xr-x | etc/sh/check.sh | 9 | ||||
-rwxr-xr-x | etc/sh/cronjob.sh | 70 | ||||
-rw-r--r-- | etc/sh/rc | 14 |
3 files changed, 85 insertions, 8 deletions
diff --git a/etc/sh/check.sh b/etc/sh/check.sh index 102fcd0..07e9e66 100755 --- a/etc/sh/check.sh +++ b/etc/sh/check.sh @@ -51,10 +51,11 @@ cd -- "$(dirname -- "$0")" cd -- "$(git rev-parse --show-toplevel)" shellcheck -xe 1090,1091 \ - "$XDG_CONFIG_HOME"/sh/rc \ - "$XDG_CONFIG_HOME"/sh/vcs-ps1.sh \ - "$XDG_CONFIG_HOME"/sh/check.sh \ - "$XDG_CONFIG_HOME"/sh/privrc.sh \ + "$XDG_CONFIG_HOME"/sh/rc \ + "$XDG_CONFIG_HOME"/sh/vcs-ps1.sh \ + "$XDG_CONFIG_HOME"/sh/check.sh \ + "$XDG_CONFIG_HOME"/sh/privrc.sh \ + "$XDG_CONFIG_HOME"/sh/cronjob.sh \ "$XDG_CONFIG_HOME"/notmuch/default/hooks/post-new if git grep FIXME -- ":(exclude)$XDG_CONFIG_HOME/bash/check.sh"; then diff --git a/etc/sh/cronjob.sh b/etc/sh/cronjob.sh new file mode 100755 index 0000000..950430f --- /dev/null +++ b/etc/sh/cronjob.sh @@ -0,0 +1,70 @@ +#!/bin/sh +set -eu + +usage() { + cat <<-'EOF' + Usage: + cronjob COMMAND... + cronjob -h + EOF +} + +help() { + cat <<-'EOF' + + Options: + -h, --help show this message + + COMMAND the command to be executed + + + Execute the given command, and send the output to email, with + special treatment to the status code. + + It loads the appropriate files, so that the actual cron + declaration is smaller. + + + Examples: + + Run a backup: + + $ cronjob backup cron + EOF +} + + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +while getopts 'h' flag; do + case "$flag" in + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + + +. ~/.usr/etc/sh/rc +CMD="$@" +with-email -s "$CMD" -- "$@" 1>>"$XDG_LOG_HOME"/euandreh/mcron.log 2>&1 @@ -38,7 +38,7 @@ idempotent_path_add() { esac } export A="$HOME${A:+:}${A:-}" -idempotent_path_add B "$HOME" +# idempotent_path_add B "$HOME" export XDG_DATA_DIRS="$XDG_DATA_HOME/flatpak/exports/share:/var/lib/flatpak/exports/share${XDG_DATA_DIRS:+:}${XDG_DATA_DIRS:-}" # idempotent_path_add XDG_DATA_DIRS "$XDG_DATA_HOME/flatpak/exports/share" @@ -241,7 +241,7 @@ fi # SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) -GPG_TTY=$(tty) +GPG_TTY=$(tty ||:) export GPG_TTY SSH_AUTH_SOCK gpgconf --launch gpg-agent gpg --export-ssh-key eu@euandre.org > "$XDG_CONFIG_HOME"/ssh/id_rsa.pub @@ -253,11 +253,17 @@ $HOME/dev/libre/package-repository/EuAndreh.key $HOME/dev/published/euandre.org/public.asc " for f in $PUB_GPG_FILES; do - gpg --armour --export eu@euandre.org > $f + gpg --armour --export eu@euandre.org > "$f" done -stty -ixon # Disable C-s/C-q mode +case $- in + *i*) + stty -ixon # Disable C-s/C-q mode + ;; + *) + ;; +esac F="$XDG_CONFIG_HOME"/sh/privrc.sh if [ -e "$F" ]; then |