-
Notifications
You must be signed in to change notification settings - Fork 0
/
only.sh
executable file
·133 lines (120 loc) · 3.29 KB
/
only.sh
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
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
## -----------------------------------------------------------------------
## Intent: Commands to apply
## -----------------------------------------------------------------------
declare -a cmd=()
# cmd=("/home/joey/etc/emacs.sh")
cmd=('rsync' '--checksum')
# cmd=('sdiff' '--width=200' '--ignore-all-space')
# cmd=('diff')
# cmd=('/bin/rm')
## -----------------------------------------------------------------------
## Intent: Display a mesage then exit with error status
## -----------------------------------------------------------------------
function error()
{
echo "$0::${FUNCNAME[1]}: ERROR $*"
exit 1
}
## -----------------------------------------------------------------------
## Intent: A list of files to edit
## -----------------------------------------------------------------------
declare -a fyls=()
fyls+=("artifacts")
fyls+=("bin/edit-charts.sh")
fyls+=("bin/gen_branch.sh")
fyls+=("bin/links.sh")
fyls+=("bin/maven-artifacts.sh")
fyls+=("bin/README.md")
fyls+=("bin/stage.sh")
fyls+=("bin/triage-build")
fyls+=("bin/triage-build.sh")
fyls+=("bin/voltha-helm-charts.sh")
fyls+=("bin/wait-4-artifact.sh")
fyls+=("bttb")
fyls+=("bttb.log")
fyls+=("bttb.sh")
fyls+=("ci-management")
fyls+=("conf")
fyls+=("config")
fyls+=("config.mk")
fyls+=("cookbook")
fyls+=("copyrights")
fyls+=("docker")
fyls+=("doit.sh")
fyls+=("edit.sh")
fyls+=("fixes.sh")
fyls+=("fix.sh")
fyls+=("gomod")
fyls+=("hierarchy")
fyls+=("lf")
fyls+=("lib")
fyls+=("license")
fyls+=("logs")
fyls+=("markdown")
fyls+=("notes")
fyls+=("onos")
fyls+=("post-release")
fyls+=("repo-deps")
fyls+=("repos")
fyls+=("repositories")
fyls+=("review.log")
fyls+=("sandbox.sh")
fyls+=("security")
fyls+=("snapshot")
fyls+=("tmp")
fyls+=("todo.safe")
fyls+=("todo/voltha-openolt-adapter")
fyls+=("todo/wip")
fyls+=("triage-build.sh")
fyls+=("typescript")
fyls+=("versions-chart")
fyls+=("voltha")
fyls+=("voltha-lib-go")
fyls+=("voltha-protos")
fyls+=("wip")
fyls+=("yEd")
[[ ${#fyls[@]} -eq 0 ]] && error "fyls= uncomment an entry"
## -----------------------------------------------------------------------
## Intent: Apply action to a single file
## -----------------------------------------------------------------------
function doit()
{
local fyl="$1"; shift
declare src="/sandbox/triage/voltha-release"
declare dst="/sandbox/voltha-release"
# declare -i -g copy_src_dst=1
# declare -i -g copy_dst_src=1
declare -a args=()
args+=("$src/$fyl")
args+=("$dst/$fyl")
declare -a raw=("${cmd[@]}")
if [[ ${#cmd[@]} -gt 0 ]]; then
if [ -d "$src/$fyl" ]; then
raw+=('--recursive')
mkdir -p "$dst/$fyl"
raw+=("$src/$fyl/.")
raw+=("$dst/$fyl/.")
else
raw+=("$src/$fyl")
[ -e "$dst" ] && raw+=("$dst/$fyl")
fi
elif [[ -v copy_src_dst ]]; then
raw=('rsync' '-v' '--checksum' "${args[@]}")
elif [[ -v copy_dst_src ]]; then
raw=('rsync' '-v' '--checksum' "$dst/$fyl" "$src/$fyl")
else
error "Detected invalid cmd="
fi
echo "RUNNING: ${raw[@]}"
"${raw[@]}"
return
}
## -----------------------------------------------------------------------
## Intent: Iterate over file list and apply an action
## -----------------------------------------------------------------------
for fyl in "${fyls[@]}";
do
doit "$fyl"
done
# [EOF]