diff options
author | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2017-05-03 17:23:35 +0000 |
---|---|---|
committer | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2017-05-03 17:23:35 +0000 |
commit | ba136dc8fab14931c0f7cb75462945496a61626c (patch) | |
tree | e44d75c2d347fbbc361f41eb6270d27d2444c8ff | |
parent | 9a07302014cc63b4ec1316d33b2428308569585b (diff) |
Output explicit error messages for:
- trying to install files mounted on a remote FS (diskless clients etc.)
- read-only FS
- not enough space on FS
These were all properly catched before (syspatch would refuse to do anything)
but the error message was a bit cryptic.
-rw-r--r-- | usr.sbin/syspatch/syspatch.sh | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/usr.sbin/syspatch/syspatch.sh b/usr.sbin/syspatch/syspatch.sh index 56fae099a2d..b48685520b4 100644 --- a/usr.sbin/syspatch/syspatch.sh +++ b/usr.sbin/syspatch/syspatch.sh @@ -1,6 +1,6 @@ #!/bin/ksh # -# $OpenBSD: syspatch.sh,v 1.96 2017/05/03 12:26:52 ajacoutot Exp $ +# $OpenBSD: syspatch.sh,v 1.97 2017/05/03 17:23:34 ajacoutot Exp $ # # Copyright (c) 2016 Antoine Jacoutot <ajacoutot@openbsd.org> # @@ -69,7 +69,7 @@ apply_patch() trap exit INT } -# quick-and-dirty size check: +# quick-and-dirty filesystem status and size checks: # - assume old files are about the same size as new ones # - ignore new (nonexistent) files # - compute total size of all files per fs, simpler and less margin for error @@ -78,7 +78,7 @@ apply_patch() # - /bsd.syspatchXX is not present (create_rollback will copy it from /bsd) checkfs() { - local _d _df _dev _files="${@}" _sz + local _d _dev _df _files="${@}" _sz [[ -n ${_files} ]] if echo "${_files}" | grep -qw bsd; then @@ -86,13 +86,18 @@ checkfs() _files="bsd ${_files}" fi + set +e # ignore errors due to: + # - nonexistent files (i.e. syspatch is installing new files) + # - broken interpolation due to bogus devices like remote filesystems eval $(cd / && stat -qf "_dev=\"\${_dev} %Sd\" %Sd=\"\${%Sd:+\${%Sd}\+}%Uz\"" \ - ${_files}) || true # ignore nonexistent files + ${_files}) 2>/dev/null + set -e + [[ -z ${_dev} && -n ${_files} ]] && sp_err "Remote filesystem, aborting" for _d in $(printf '%s\n' ${_dev} | sort -u); do mount | grep -v read-only | grep -q "^/dev/${_d} " || - sp_err "Remote or read-only filesystem, aborting" + sp_err "Read-only filesystem, aborting" _df=$(df -Pk | grep "^/dev/${_d} " | tr -s ' ' | cut -d ' ' -f4) _sz=$(($((_d))/1024)) ((_df > _sz)) || sp_err "No space left on ${_d}, aborting" |