diff options
author | Timo Weingärtner <timo@tiwe.de> | 2012-02-25 21:17:02 +0100 |
---|---|---|
committer | Timo Weingärtner <timo@tiwe.de> | 2012-02-25 21:17:02 +0100 |
commit | 550c2f513a05899566ca90a1e859218ee44a8ac7 (patch) | |
tree | 4a357b16b938c67463822b1394b09403e086e709 /update-openssh-known-hosts | |
parent | 4b444020fa50e4f22a427b981c582b35cdb4efb1 (diff) | |
download | openssh-known-hosts-550c2f513a05899566ca90a1e859218ee44a8ac7.tar.gz |
Imported Debian version 0.3debian/0.3
Diffstat (limited to 'update-openssh-known-hosts')
-rwxr-xr-x | update-openssh-known-hosts | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/update-openssh-known-hosts b/update-openssh-known-hosts index 136535a..63df1e3 100755 --- a/update-openssh-known-hosts +++ b/update-openssh-known-hosts @@ -1,4 +1,4 @@ -#!/bin/dash +#!/bin/bash set -euC @@ -9,18 +9,39 @@ LOCK=/var/lock/openssh-known-hosts OUTFILE=/var/lib/openssh-known-hosts/ssh_known_hosts path_search () { - if [ "${1}" != "${1#*/}" ]; then - echo $1 - else - echo "$2" | tr ':' '\n' | while read -r path; do - if [ -f "${path}/${1}" ]; then - echo "${path}/${1}" - break - fi - done + search="$1" + shift + local IFS + IFS=: + set -- $@ + if [ "${search}" != "${search#*/}" ]; then + echo "${search}" + return 0 fi + for path; do + if [ -f "${path}/${search}" ]; then + echo "${path}/${search}" + return 0 + fi + done + echo "'${search}' not found in '$@'!" >&2 + exit 127 +} + +cleanup () { + rm -f "${OUTFILE}.new" + kill "${LOCKPID}" + lockfile-remove "${LOCK}" } +if [ $# = 1 ] && [ "$1" = "-f" ]; then + fail=1 +else + fail='' +fi + +trap cleanup EXIT + lockfile-create "${LOCK}" lockfile-touch "${LOCK}" & LOCKPID="$!" @@ -47,13 +68,16 @@ run-parts --list "${CONFDIR}/sources/" | while read sourcefile; do break fi done - if [ ! "$ignore" ]; then + if [ "$ignore" != "1" -o "$fail" = "1" ]; then echo "${source} exited with code ${exitcode}, log follows:" cat log echo fi + if [ "$fail" = "1" ]; then + exit 1 + fi } - ) + ) || exit 1 if [ -e ${source}/new ]; then mv ${source}/new ${source}/current fi @@ -70,7 +94,4 @@ for d in *; do [ -e "${CONFDIR}/sources/$d" ] || rm -fr $d done -kill "${LOCKPID}" -lockfile-remove "${LOCK}" - # vim:set ft=sh: |