Rev 1042 | Blame | Compare with Previous | Last modification | View Log | RSS feed
## Receive a file and save is locally# Script run by ssh to receive a compressed file and to save it# Works in bash and dash## Assumes that gzip output as stdin##set -xset -eerror() {echo ERROR: $*exit 1;}# User optionswhile getopts D arg ; docase $arg inD) set -x ;;*) error Unknown option: $arg ;;esacdoneshift $(($OPTIND - 1))# User argumentsfname=${1:?Need file name}dpkg="dpkg_archive"[ -d $dpkg ] || error dpkg_archive not found## Names of working directories#metadir="$dpkg/.dpkg_archive"tmpfile="$metadir/${fname}.NEWTMP"newfile="$metadir/${fname}"## Create package metadata directory# Ensure its writablemkdir -p "$metadir"chmod u+w "$metadir"## unzip the file into a temp namegunzip -c -d -- > "$tmpfile"## Now that the new file has arrived error free# Rename the temp file to the new file#chmod a+w "$newfile" || truerm -f "$newfile"mv "$tmpfile" "$newfile"# Fix up permissions on the file and directorychmod a-w "$newfile"chmod go-w "$metadir"chmod a+rx "$metadir"