Subversion Repositories DevTools

Rev

Rev 1038 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1038 dpurdie 1
#
2
#   Receive a file and save is locally
3
#   Script run by ssh to receive a compressed file and to save it
4
#
5
#   Assumes that gzip output as stdin
6
#
7
#set -x
8
set -e
9
 
10
function error {
11
    echo ERROR: $*
12
    exit 1;
13
}
14
 
15
# User options
16
while getopts D arg ; do
17
    case $arg in
18
        D) set -x ;;
19
        *) error Unknown option: $arg ;;
20
    esac
21
done
22
shift $(($OPTIND - 1))
23
 
24
# User arguments
25
fname=${1:?Need file name}
26
 
27
dpkg="dpkg_archive"
28
[ -d $dpkg ] || error dpkg_archive not found
29
 
30
#
31
#   Names of working directories
32
#
33
metadir="$dpkg/.dpkg_archive"
34
tmpfile="$metadir/${fname}.NEWTMP"
35
newfile="$metadir/${fname}"
36
 
37
#
38
#   Create package metadata directory
39
#   Ensure its writable
40
mkdir -p "$metadir"
41
chmod u+w "$metadir"
42
 
43
#
44
#   unzip the file into a temp name
45
gunzip -c -d -- > "$tmpfile"
46
 
47
#
48
#   Now that the new file has arrived error free
49
#   Rename the temp file to the new file
50
#
51
 
52
chmod a+w "$newfile" || true
53
rm -f "$newfile"
54
mv "$tmpfile" "$newfile"
55
 
56
# Fix up permissions on the file and directory
57
chmod a-w "$newfile"
1042 dpurdie 58
chmod go-w "$metadir"
59
chmod a+rx "$metadir"
1038 dpurdie 60