-
Notifications
You must be signed in to change notification settings - Fork 0
/
puppetcbsd
executable file
·108 lines (88 loc) · 2.96 KB
/
puppetcbsd
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
#!/bin/sh
export LANG="C.UTF-8"
name="ldconfig"
ldconfig_command="/sbin/ldconfig"
err () {
exitval=$1
shift
echo "$*"
exit $exitval
}
init_ruby_path()
{
FIND_PATH="${DIR}/lib/ruby"
[ ! -d "${FIND_PATH}" ] && err 1 "Unable to find ${FIND_PATH}"
RUBY_DIR=$( find ${FIND_PATH}/*.*/ -type f -name json.rb -depth 1 -maxdepth 1 -exec dirname {} \; 2>/dev/null )
[ -z "${RUBY_DIR}" ] && err 1 "Unable to locate json.rb"
RUBY_PLATFORM_DIR=$( find ${RUBY_DIR}/*-freebsd*/ -type f -name rbconfig.rb -depth 1 -maxdepth 1 -exec dirname {} \; )
[ -z "${RUBY_PLATFORM_DIR}" ] && err 1 "Unable to locate rbconfig.rb"
RUBY_VER=$( basename ${RUBY_DIR} )
[ -z "${RUBY_VER}" ] && err 1 "Unable to determine ruby ver by dir path"
}
ldconfig_start()
{
local _files _ins
_ins=
ldconfig=${ldconfig_command}
if [ -x "${ldconfig_command}" ]; then
_LDC="/lib /usr/lib"
for i in ${ldconfig_local_dirs}; do
if [ -d "${i}" ]; then
_files=$( find ${i} -type f )
if [ -n "${_files}" ]; then
ldconfig_paths="${ldconfig_paths} `cat ${_files} | sort -u`"
fi
fi
done
for i in ${ldconfig_paths} /etc/ld-elf.so.conf; do
if [ -r "${i}" ]; then
_LDC="${_LDC} ${i}"
fi
done
${ldconfig} -elf ${_ins} ${_LDC}
fi
}
#### OLD method ###
if [ "${1}" = "debug" ]; then
shift
debug_args="debug"
else
debug_args="err"
fi
DIR="/tmp/puppet"
if [ -x /usr/local/bin/puppet ]; then
PUPPET_CMD=/usr/local/bin/puppet
local_puppet=1
else
PUPPET_CMD="${DIR}/bin/puppet"
init_ruby_path
GEM_PATH="${DIR}/lib/ruby/${RUBY_VER}/:${DIR}/:${DIR}/bin/:${RUBY_PLATFORM_DIR}/:${DIR}/lib/ruby/site_ruby/${RUBY_VER}/:${DIR}/PPP/lib/ruby/vendor_ruby"
GEM_HOME="${DIR}/lib/ruby/${RUBY_VER}/:${RUBY_PLATFORM_DIR}/:${DIR}/lib/ruby/site_ruby/${RUBY_VER}/:${DIR}/PPP/lib/ruby/vendor_ruby"
ldconfig_paths="${DIR}/lib /usr/local/lib"
ldconfig_start
local_puppet=0
export PATH=${DIR}/bin:${DIR}/sbin:$PATH
fi
modulepath="/tmp/cbsdpuppet/modules/public"
echo "Module path: ${modulepath}"
ret=0
case ${local_puppet} in
1)
${PUPPET_CMD} apply $@ --show_diff --hiera_config=/tmp/cbsdpuppet/hiera.yaml --modulepath=${modulepath} --log_level=${debug_args}
ret=$?
;;
0)
# echo "${DIR}/bin/ruby -I${DIR}/lib/ruby/vendor_ruby -I \
# \"${DIR}/lib/ruby/${RUBY_VER}/\" -I \"${DIR}/bin/\" -I \"${RUBY_PLATFORM_DIR}\" \
# -I \"${DIR}/lib/ruby/site_ruby/${RUBY_VER}/\" \
# ${PUPPET_CMD} apply $@ --show_diff --hiera_config=/tmp/cbsdpuppet/hiera.yaml --modulepath=${modulepath} --log_level=${debug_args}"
${DIR}/bin/ruby -I${DIR}/lib/ruby/vendor_ruby -I \
"${DIR}/lib/ruby/${RUBY_VER}/" -I "${DIR}/bin/" -I "${RUBY_PLATFORM_DIR}" \
-I "${DIR}/lib/ruby/site_ruby/${RUBY_VER}/" \
${PUPPET_CMD} apply $@ --show_diff --hiera_config=/tmp/cbsdpuppet/hiera.yaml --modulepath=${modulepath} --log_level=${debug_args}
ret=$?
;;
esac
echo "${PUPPET_CMD} apply $@ --show_diff --hiera_config=/tmp/cbsdpuppet/hiera.yaml --modulepath=${modulepath} --log_level=${debug_args}"
[ "${debug_args}" = "debug" ] && read p
exit ${ret}