Debian Codegraph @

bin/post

raw
1 #!/bin/bash
2
3 #*****************************************************************
4 #
5 # Organization: Lawrence Livermore National Lab (LLNL)
6 # Directorate: Computation
7 # Department: Computing Applications and Research
8 # Division: S&T Global Security
9 # Matrix: Atmospheric, Earth and Energy Division
10 # Program: PCMDI
11 # Project: Earth Systems Grid
12 # First Author: Gavin M. Bell ([email protected])
13 #
14 # Description:
15 #
16 # Simple script for pushing files from the repsitory to the website
17 # for general consumption. The motivation here was to not have
18 # people pummel our source code repository getting these files, which
19 # is slow and not what a repo is for. Web servers are made exactly
20 # for this task, so put the necessary files on one, right? :-)
21 #
22 # This file reads a manifest file by default postlist.manif
23 #
24 # The format of the manifest file is pseudo "ini" like. You can
25 # specifiy the destination directory extending from the esg_dist_url
26 # value by putting that value on a single line in []s. files must be
27 # listed with either absolute path or directory relative to the
28 # execution of the "post" script. There may be a second value after the
29 # file location that determines where this particular entry is put on
30 # the server (after the esg_dist_url value). If no destination
31 # directory value is set the default is esg_node set at the top of the
32 # script.
33 #
34 # NOTE: Because we use rsync -c files will not be pushed if they have
35 # not changed since the last push! :-) Pretty damn sweet!
36 #
37 # Ex:
38 # -----
39 #
40 # #lines starting with "#" are ignored :-)
41 # /path/file1
42 #
43 # [server_dir]
44 #
45 # path/file2
46 # path/file3 other_server_dir
47 # ../path/file4
48 #
49 # [another_path/foo]
50 #
51 # path/file4
52 #
53 # -----
54 # file1 will go to ${esg_dist_url}/esg_node (the default server dir)
55 # file2 will go to ${esg_dist_url}/server_dir
56 # file3 will to go ${esg_dist_url}/other_server_dir
57 # file4 will go to ${esg_dist_url}/server_dir
58 # file5 will go to ${esg_dist_url}/another_path/foo
59 #
60 #
61 #*****************************************************************
62
63 #uses: egrep, rsync (and thus ssh)
64
65 debug=${debug:-0}
66 noop=${noop:-0}
67
68 ((debug)) && echo "Debug is ON"
69 ((noop)) && echo "Noop is ON"
70
71 manifest_file=${manifest_file:-$0.manif}
72 esg_dist_url="rainbow.llnl.gov:/pcmdi_web/dist"
73 current_dir=${current_dir:="esg_node"}
74
75 fail=0
76 good=0
77 total=0
78
79 while read file dest_dir; do
80
81 #skip comment lines (#) and blank lines...
82 if [ -n "$(echo $file | grep ^#)" ] || [ -z "$file" ]; then
83 continue
84 fi
85
86 t=$(echo $file | egrep "[[](.*)[]]" | awk '{print substr($1,2,length($1)-2)}')
87 if [ -n "$t" ]; then
88 current_dir=$t
89 continue
90 fi
91
92
93 if [ ! -e $file ]; then
94 echo -n "x"
95 ((debug)) && echo " [FAIL] No Such File $file"
96 ((++total))
97 ((++fail))
98 continue
99 fi
100
101 dest_dir=${dest_dir:-"${current_dir}"}
102 #echo "[$file] >> [$dest_dir]"
103
104 ((debug)) && echo -n "pushing $file ---> ${esg_dist_url}/${dest_dir} " || echo -n "*"
105 ((!noop)) && md5sum $file > ${file}.md5
106 ((!noop)) && rsync -c ${file}.md5 ${esg_dist_url}/${dest_dir}/${file##*/}.md5 >& /dev/null
107 echo -n "-"
108 ((!noop)) && rsync -c ${file} ${esg_dist_url}/${dest_dir}/${file##*/} >& /dev/null
109 if [ $? != 0 ]; then
110 ((debug)) && echo "[FAIL]"
111 ((++fail))
112 else
113 ((debug)) && echo "[OK]"
114 ((++good))
115 fi
116 ((++total))
117 done < $manifest_file
118
119 echo
120 echo total=${total} good=${good} fail=${fail}
121 echo "done."
122 exit 0