From: martin f. krafft Date: Mon, 15 Jan 2018 21:07:47 +0000 (+1300) Subject: add idiotheke download script X-Git-Url: https://git.madduck.net/etc/zsh.git/commitdiff_plain/b0b97fc4ff5979996658d86faf08000478fa45ce?hp=e25239284d7361795d6f0073c6f73fc0ddabc4b8 add idiotheke download script --- diff --git a/.gitignore.d/zsh b/.gitignore.d/zsh index ef3e741..54fe9b9 100644 --- a/.gitignore.d/zsh +++ b/.gitignore.d/zsh @@ -1,9 +1,6 @@ * -!/.var -!/.var/zsh +!/.gitignore.d/zsh !/.var/zsh/.gitignore -!/.zsh -!/.zsh/aliases !/.zsh/aliases/bofh !/.zsh/aliases/chp !/.zsh/aliases/curl @@ -26,18 +23,18 @@ !/.zsh/aliases/px !/.zsh/aliases/Q !/.zsh/aliases/rrsh +!/.zsh/aliases/uc !/.zsh/aliases/w3m !/.zsh/aliases/wget !/.zsh/aliases/zstyle !/.zsh/dircolors -!/.zsh/dirhashes !/.zsh/dirhashes/debs !/.zsh/dirhashes/doc !/.zsh/dirhashes/log !/.zshenv -!/.zsh/func !/.zsh/func/gitpub !/.zsh/func/giturl +!/.zsh/func/idiotheke !/.zsh/func/old-getpw !/.zsh/func/p !/.zsh/func/svngit @@ -48,25 +45,20 @@ !/.zsh/oh-my-zsh !/.zsh/rcsstub !/.zsh/sourcedir -!/.zsh/themes !/.zsh/themes/prompt_madduck_setup !/.zsh/util -!/.zsh/zlogin !/.zsh/.zlogin !/.zsh/zlogin/00-reset_shlvl_to_1 !/.zsh/zlogin/.gitignore -!/.zsh/zlogout !/.zsh/.zlogout !/.zsh/zlogout/00-clear_sudo_cache !/.zsh/zlogout/99-clear_screen !/.zsh/zlogout/.gitignore -!/.zsh/zprofile !/.zsh/.zprofile !/.zsh/zprofile/00-disable-core-dumps !/.zsh/zprofile/10-locales !/.zsh/zprofile/10-umask !/.zsh/zprofile/.gitignore -!/.zsh/zshenv !/.zsh/.zshenv !/.zsh/zshenv/00-apath !/.zsh/zshenv/00-dhpath @@ -75,7 +67,6 @@ !/.zsh/zshenv/00-tmpdir !/.zsh/zshenv/00-zvardir !/.zsh/zshenv/.gitignore -!/.zsh/zshrc !/.zsh/.zshrc !/.zsh/zshrc/00-autoload_executables_in_fpath !/.zsh/zshrc/01-background_job_options @@ -109,7 +100,6 @@ !/.zsh/zshrc/83-reporttime !/.zsh/zshrc/85-direnv !/.zsh/zshrc/85-mime-integration -!/.zsh/zshrc/90_cleanfiles.disabled !/.zsh/zshrc/90-ls_on_chdir !/.zsh/zshrc/90-run-help !/.zsh/zshrc/95-watch-users diff --git a/.zsh/func/idiotheke b/.zsh/func/idiotheke new file mode 100755 index 0000000..5a0d5d6 --- /dev/null +++ b/.zsh/func/idiotheke @@ -0,0 +1,32 @@ +#!/bin/sh +set -u + +if [ -n "${ZSH_VERSION:-}" ]; then + # don't execute trap on return from functions + setopt local_options posix_traps no_warn_create_global +fi + +RESOURCE=idiotheke.de +PASSWORD="$(pass $RESOURCE)" +LOGIN="$(echo "$PASSWORD" | sed -rne 's/login: //p')" +URL="$(echo "$PASSWORD" | sed -rne 's/url: //p')" +PASSWORD="${PASSWORD%% +*}" #first line only + +if [ -n "${1:-}" ]; then + ASKPASS="$(tempfile --prefix=askpass --mode=700)" + cleanup() { rm -f $ASKPASS; trap - 0; } + trap cleanup 0 + + echo '#!/bin/sh' >> $ASKPASS + echo "echo ${LOGIN}:${PASSWORD}" >> $ASKPASS + + wget --continue --use-askpass="$ASKPASS" "$@" + + cleanup + ! command -v unfunction >/dev/null || unfunction cleanup +else + LFTP_PASSWORD="$PASSWORD" lftp -e "open -u $LOGIN --env-password $URL" +fi + +unset RESOURCE LOGIN PASSWORD URL ASKPASS