File: post

package info (click to toggle)
drslib 0.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,596 kB
  • sloc: python: 6,119; xml: 988; makefile: 128; sh: 121
file content (122 lines) | stat: -rwxr-xr-x 3,450 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash

#*****************************************************************
#
# Organization: Lawrence Livermore National Lab (LLNL)
#  Directorate: Computation
#   Department: Computing Applications and Research
#     Division: S&T Global Security
#       Matrix: Atmospheric, Earth and Energy Division
#      Program: PCMDI
#      Project: Earth Systems Grid
# First Author: Gavin M. Bell (gavin@llnl.gov)
#
#  Description:
#
#  Simple script for pushing files from the repsitory to the website
#  for general consumption.  The motivation here was to not have
#  people pummel our source code repository getting these files, which
#  is slow and not what a repo is for.  Web servers are made exactly
#  for this task, so put the necessary files on one, right? :-)
#
#  This file reads a manifest file by default postlist.manif
# 
# The format of the manifest file is pseudo "ini" like.  You can
# specifiy the destination directory extending from the esg_dist_url
# value by putting that value on a single line in []s.  files must be
# listed with either absolute path or directory relative to the
# execution of the "post" script.  There may be a second value after the
# file location that determines where this particular entry is put on
# the server (after the esg_dist_url value).  If no destination
# directory value is set the default is esg_node set at the top of the
# script.
#
# NOTE: Because we use rsync -c files will not be pushed if they have
# not changed since the last push! :-) Pretty damn sweet!
# 
# Ex: 
# -----
# 
# #lines starting with "#" are ignored :-)
# /path/file1
# 
# [server_dir]
# 
# path/file2
# path/file3 other_server_dir
# ../path/file4
# 
# [another_path/foo]
# 
# path/file4
# 
# -----
# file1 will go to ${esg_dist_url}/esg_node (the default server dir)
# file2 will go to ${esg_dist_url}/server_dir
# file3 will to go ${esg_dist_url}/other_server_dir
# file4 will go to ${esg_dist_url}/server_dir
# file5 will go to ${esg_dist_url}/another_path/foo
# 
#
#*****************************************************************

#uses: egrep, rsync (and thus ssh)

debug=${debug:-0}
noop=${noop:-0}

((debug)) && echo "Debug is ON"
((noop)) && echo "Noop is ON"

manifest_file=${manifest_file:-$0.manif}
esg_dist_url="rainbow.llnl.gov:/pcmdi_web/dist"
current_dir=${current_dir:="esg_node"}

fail=0
good=0
total=0

while read file dest_dir; do
    
    #skip comment lines (#) and blank lines...
    if [ -n "$(echo $file | grep ^#)" ] || [ -z "$file" ]; then
    	continue
    fi
    
    t=$(echo $file | egrep "[[](.*)[]]" | awk '{print substr($1,2,length($1)-2)}')
    if [ -n "$t" ]; then
	current_dir=$t
	continue
    fi


    if [ ! -e $file ]; then
	echo -n "x"
	((debug)) && echo " [FAIL] No Such File $file"
	((++total))
	((++fail))
	continue
    fi

    dest_dir=${dest_dir:-"${current_dir}"}
    #echo "[$file] >> [$dest_dir]"
    
    ((debug)) && echo -n "pushing $file ---> ${esg_dist_url}/${dest_dir} " || echo -n "*"
    ((!noop))  && md5sum $file > ${file}.md5
    ((!noop))  && rsync -c ${file}.md5 ${esg_dist_url}/${dest_dir}/${file##*/}.md5 >& /dev/null
    echo -n "-"
    ((!noop))  && rsync -c ${file} ${esg_dist_url}/${dest_dir}/${file##*/} >& /dev/null
    if [ $? != 0 ]; then
	((debug)) && echo "[FAIL]"
	((++fail))
    else
	((debug)) && echo "[OK]" 
	((++good))
    fi
    ((++total))
done < $manifest_file

echo 
echo total=${total} good=${good} fail=${fail}
echo "done."
exit 0