tvdinner 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -2
- data/VERSION +1 -1
- data/lib/tvdinner.rb +27 -5
- data/libexec/_jason +200 -0
- data/libexec/_log4sh +3841 -0
- data/libexec/_shflags +1012 -0
- data/libexec/_sub +60 -0
- data/libexec/compare +100 -0
- data/libexec/run +60 -0
- data/libexec/run-noop +71 -0
- data/libexec/sanitize +60 -0
- data/libexec/sanitize-log +30 -0
- data/libexec/sanitize-node +23 -0
- data/libexec/sanitize-node.rb +30 -0
- metadata +14 -3
data/README.md
CHANGED
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.4
|
data/lib/tvdinner.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
1
3
|
module TVDinner
|
|
2
4
|
end
|
|
3
5
|
|
|
@@ -5,17 +7,37 @@ class Chef
|
|
|
5
7
|
class Config
|
|
6
8
|
def self.local_config shome
|
|
7
9
|
sandbox_path platform_specific_path("#{shome}/var/chef/sandboxes")
|
|
10
|
+
ensure_mkdir sandbox_path
|
|
11
|
+
|
|
8
12
|
checksum_path platform_specific_path("#{shome}/var/chef/checksums")
|
|
13
|
+
ensure_mkdir checksum_path
|
|
14
|
+
|
|
9
15
|
file_cache_path platform_specific_path("#{shome}/var/chef/cache")
|
|
16
|
+
ensure_mkdir file_cache_path
|
|
17
|
+
|
|
10
18
|
file_backup_path platform_specific_path("#{shome}/var/chef/backup")
|
|
19
|
+
ensure_mkdir file_backup_path
|
|
20
|
+
|
|
11
21
|
node_path platform_specific_path("#{shome}/var/chef/node")
|
|
22
|
+
ensure_mkdir node_path
|
|
23
|
+
|
|
12
24
|
role_path platform_specific_path("#{shome}/var/chef/roles")
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
validation_key platform_specific_path("#{shome}/etc/chef/validation.pem")
|
|
16
|
-
signing_ca_cert platform_specific_path("#{shome}/var/chef/ca/cert.pem")
|
|
17
|
-
signing_ca_key platform_specific_path("#{shome}/var/chef/ca/key.pem")
|
|
25
|
+
ensure_mkdir role_path
|
|
26
|
+
|
|
18
27
|
cache_options({ :path => platform_specific_path("#{shome}/var/chef/cache/checksums") })
|
|
28
|
+
ensure_mkdir cache_options[:path]
|
|
29
|
+
|
|
30
|
+
#data_bag_path platform_specific_path("#{shome}/var/chef/data_bags")
|
|
31
|
+
#client_key platform_specific_path("#{shome}/etc/chef/client.pem")
|
|
32
|
+
#validation_key platform_specific_path("#{shome}/etc/chef/validation.pem")
|
|
33
|
+
#signing_ca_cert platform_specific_path("#{shome}/var/chef/ca/cert.pem")
|
|
34
|
+
#signing_ca_key platform_specific_path("#{shome}/var/chef/ca/key.pem")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def ensure_mkdir d
|
|
38
|
+
unless File.exists? d
|
|
39
|
+
FileUtils.mkdir_p d
|
|
40
|
+
end
|
|
19
41
|
end
|
|
20
42
|
|
|
21
43
|
def self.bundler_config more_paths=[]
|
data/libexec/_jason
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
if [[ -z "${shome:-}" ]]; then
|
|
4
|
+
shome="$(unset CDPATH; cd -P -- "$(dirname -- "${BASH_SOURCE}")/.." && pwd -P)"
|
|
5
|
+
fi
|
|
6
|
+
|
|
7
|
+
function check_help {
|
|
8
|
+
# taken from shocco
|
|
9
|
+
if expr -- "$*" : ".*--help" >/dev/null; then
|
|
10
|
+
display_help
|
|
11
|
+
exit 0
|
|
12
|
+
fi
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function display_help {
|
|
16
|
+
flags_help
|
|
17
|
+
echo
|
|
18
|
+
|
|
19
|
+
# taken from shocco
|
|
20
|
+
grep '^#/' <"$shome/$(basename $(dirname -- "$0"))/$(basename -- "$0")" | cut -c4-
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# Exits the script with the last error code. Servers as a marker in $0 to
|
|
24
|
+
# begin ronn documentation until end of file.
|
|
25
|
+
function __MAN__ {
|
|
26
|
+
exit "$!"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# Extracts ronn-style Markdown after __MAN__ to stdout. If a line is "MAN", it
|
|
30
|
+
# is assumed that a here document is used (for syntactical reasons).
|
|
31
|
+
#
|
|
32
|
+
# A limitation of detecting "MAN" will truncate the Markdown if "MAN" is a
|
|
33
|
+
# legimate text.
|
|
34
|
+
#
|
|
35
|
+
# __MAN__ << "MAN"
|
|
36
|
+
# raw ronn-style Markdown
|
|
37
|
+
# MAN
|
|
38
|
+
function display_man {
|
|
39
|
+
awk '/^__MAN__/,/^MAN$/ {print}' <"$0" | tail -n +2 | egrep -v '^MAN$'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function display_synopsis {
|
|
43
|
+
awk '/^#/ && !/^#!/ { print } /^[^#]/ || /^$/ { exit }' <"$0" | cut -c3-
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function which_library {
|
|
47
|
+
local library="$1"; shift
|
|
48
|
+
if [[ -r "$shome/vendor/projects/$library/libexec/_$library" ]]; then
|
|
49
|
+
echo "$shome/vendor/projects/$library/libexec/_$library"
|
|
50
|
+
elif [[ -r "$shome/libexec/_$library" ]]; then
|
|
51
|
+
echo "$shome/libexec/_$library"
|
|
52
|
+
elif [[ -r "$shome/.$library/libexec/_$library" ]]; then
|
|
53
|
+
echo "$shome/.$library/libexec/_$library"
|
|
54
|
+
else
|
|
55
|
+
local nm_library="${library%%/*}"
|
|
56
|
+
if [[ "$nm_library" != "$library" ]]; then
|
|
57
|
+
local nm_right="${library##*/}"
|
|
58
|
+
if [[ -r "$shome/vendor/projects/$nm_library/libexec/_$nm_right" ]]; then
|
|
59
|
+
echo "$shome/vendor/projects/$nm_library/libexec/_$nm_right"
|
|
60
|
+
elif [[ -r "$shome/.$nm_library/libexec/_$nm_right" ]]; then
|
|
61
|
+
echo "$shome/.$nm_library/libexec/_$nm_right"
|
|
62
|
+
fi
|
|
63
|
+
fi
|
|
64
|
+
fi
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function require {
|
|
68
|
+
local nm_library="$1"; shift
|
|
69
|
+
local pth_lib="$(which_library "$nm_library")"
|
|
70
|
+
if [[ -r "$pth_lib" ]]; then
|
|
71
|
+
if [[ "$#" == 0 ]]; then
|
|
72
|
+
set --
|
|
73
|
+
fi
|
|
74
|
+
source "$pth_lib" "$@"
|
|
75
|
+
else
|
|
76
|
+
logger_warn "library $nm_library not found"
|
|
77
|
+
fi
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function parse_command_line {
|
|
81
|
+
if [[ "$FLAGS_SUB" = "$FLAGS_TRUE" && "$@" > 0 ]]; then
|
|
82
|
+
export POSIXLY_CORRECT=1
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
if ! FLAGS "$@"; then
|
|
86
|
+
unset POSIXLY_CORRECT
|
|
87
|
+
if [[ "$flags_error" = "help requested" ]]; then
|
|
88
|
+
echo ""
|
|
89
|
+
display_help
|
|
90
|
+
exit 0
|
|
91
|
+
fi
|
|
92
|
+
|
|
93
|
+
return 4
|
|
94
|
+
fi
|
|
95
|
+
|
|
96
|
+
unset POSIXLY_CORRECT
|
|
97
|
+
return 0
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function configure_logging {
|
|
101
|
+
# load log4sh (disabling properties file warning) and clear the default
|
|
102
|
+
# configuration
|
|
103
|
+
LOG4SH_CONFIGURATION='none' require 'log4sh'
|
|
104
|
+
log4sh_resetConfiguration
|
|
105
|
+
|
|
106
|
+
# set the global logging level to INFO
|
|
107
|
+
logger_setLevel INFO
|
|
108
|
+
|
|
109
|
+
# add and configure a FileAppender that outputs to STDERR, and activate the
|
|
110
|
+
# configuration
|
|
111
|
+
logger_addAppender stderr
|
|
112
|
+
appender_setType stderr FileAppender
|
|
113
|
+
appender_file_setFile stderr STDERR
|
|
114
|
+
appender_activateOptions stderr
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function ryaml {
|
|
118
|
+
ruby -ryaml -e 'def ps x; unless x.nil?; puts (x.class == String || x.class == Fixnum) ? x : x.to_yaml; end; end; ps ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[acc.class == Array ? key.to_i : key] }' "$@" 2>&-
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function random_str {
|
|
122
|
+
echo "$(date +%s).$$.$RANDOM"
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function runmany {
|
|
126
|
+
local cpu="$1"; shift
|
|
127
|
+
local args="$1"; shift
|
|
128
|
+
local cmd="$1"; shift
|
|
129
|
+
if [[ "$#" = 0 ]]; then
|
|
130
|
+
cat
|
|
131
|
+
else
|
|
132
|
+
echo "$@"
|
|
133
|
+
fi | xargs -P $cpu -n $args -- bash -c "$cmd" ""
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function mark_log {
|
|
137
|
+
local nm_mark="$1"; shift
|
|
138
|
+
touch "$tmp_switch/wait-$nm_mark"
|
|
139
|
+
echo $tmp_switch $nm_mark
|
|
140
|
+
while [[ -f "$tmp_switch/wait-$nm_mark" ]]; do
|
|
141
|
+
sleep 1
|
|
142
|
+
done
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function marked_logger {
|
|
146
|
+
local nm_switch=""
|
|
147
|
+
while read -r a b; do
|
|
148
|
+
if [[ "$a" = "$tmp_switch" ]]; then
|
|
149
|
+
nm_switch="$b"
|
|
150
|
+
rm "$tmp_switch/wait-$nm_switch"
|
|
151
|
+
else
|
|
152
|
+
if [[ -z "$nm_switch" ]]; then
|
|
153
|
+
echo "$a $b"
|
|
154
|
+
else
|
|
155
|
+
echo "$nm_switch: $a $b"
|
|
156
|
+
fi
|
|
157
|
+
fi
|
|
158
|
+
done
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function mark_stdout {
|
|
162
|
+
if [[ -z "${tmp_switch:-}" ]]; then
|
|
163
|
+
tmp_switch="$(mktemp -d -t XXXXXXXXX)"
|
|
164
|
+
fi
|
|
165
|
+
exec 1> >(marked_logger)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function mark_stderr {
|
|
169
|
+
if [[ -z "${tmp_switch:-}" ]]; then
|
|
170
|
+
tmp_switch="$(mktemp -d -t XXXXXXXXX)"
|
|
171
|
+
fi
|
|
172
|
+
exec 2> >(marked_logger)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function mark_output {
|
|
176
|
+
if [[ -z "${tmp_switch:-}" ]]; then
|
|
177
|
+
tmp_switch="$(mktemp -d -t XXXXXXXXX)"
|
|
178
|
+
fi
|
|
179
|
+
exec 1> >(marked_logger) 2>&1
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function _main {
|
|
183
|
+
if [[ -z "$shome" ]]; then
|
|
184
|
+
shome="$(unset CDPATH; cd -P -- "$(dirname -- "${BASH_SOURCE}")/.." && pwd -P)"
|
|
185
|
+
fi
|
|
186
|
+
|
|
187
|
+
: ${__meat__:=x}
|
|
188
|
+
if [[ "$__meat__" != 'x' ]]; then
|
|
189
|
+
return 0
|
|
190
|
+
fi
|
|
191
|
+
|
|
192
|
+
__meat__='y'
|
|
193
|
+
|
|
194
|
+
require 'shflags'
|
|
195
|
+
|
|
196
|
+
configure_logging
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
_main "$@"
|
|
200
|
+
set -fue
|