From 3b51220148f640c81773cc08438d6715d9d94231 Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Sat, 13 Feb 2010 18:06:02 -0600 Subject: [PATCH] sbin/saveconfig: force running as root; save cpios relative to / --- src/overlay/sbin/saveconfig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/overlay/sbin/saveconfig b/src/overlay/sbin/saveconfig index 835a810..c109df4 100755 --- a/src/overlay/sbin/saveconfig +++ b/src/overlay/sbin/saveconfig @@ -1,5 +1,7 @@ #!/bin/sh +[ "$(id -u)" -ne 0 ] && exec /usr/local/bin/sudo "${0}" "${@}" + echo -n "Saving configuration... " if [ ! -f /etc/diskless ] @@ -10,14 +12,14 @@ fi # Find all files newer than /etc/diskless and print them out find_newer_files() { - [ -d "/${1}" ] || return 1 - ( cd /; find "${1}" -type f -not -regex '.*/tmp/*.' -newer /etc/diskless -print ) + [ -d "${1}" ] || return 1 + find "${1}" -type f -not -regex '.*/tmp/*.' -newer /etc/diskless -print } # Archive all newer files into a gzipped cpio archive archive_cpio() { [ -f "${2}" ] && return 1 - find_newer_files "${1}" | cpio -o --quiet | gzip -9 > "${2}" || return 1 + ( cd /; find_newer_files "${1}" | cpio -o --quiet | gzip -9 > "${2}" ) || return 1 } # Archive specified files to named target -- 2.42.0