Compare commits

...

12 commits

Author SHA1 Message Date
Darko Poljak
ecc1dccd03 quoting; posix sed; 2018-09-30 14:45:47 +02:00
Darko Poljak
9e0cfd5df5 Fix vim typo. 2018-09-30 14:45:47 +02:00
Darko Poljak
4bec22d726 Revert changes in for loop because param value is changed. 2018-09-30 14:45:47 +02:00
Darko Poljak
33a0e05e3d Revert changes in for loop because param value is changed. 2018-09-30 14:45:47 +02:00
Darko Poljak
1388487199 Clean quotes; su - -> su -l 2018-09-30 14:45:47 +02:00
Darko Poljak
62f1e1db00 Applying uqam-fob's suggestions. 2018-09-30 14:43:39 +02:00
Darko Poljak
b55520e987 Applying uqam-fob's suggestions. 2018-09-30 14:43:39 +02:00
Darko Poljak
775d3dfc2c shellcheck fixes 2018-09-30 14:43:07 +02:00
Darko Poljak
309315910e Add shellcheck makefile target. 2018-09-30 14:42:38 +02:00
Darko Poljak
6d0e1a2e73 --tmpdir -> TMPDIR env var 2018-09-30 14:42:38 +02:00
Darko Poljak
3759a37fbd Fix tr reading from file. 2018-09-30 14:42:38 +02:00
Darko Poljak
b371c42d53 shellcheck 2018-09-30 14:42:37 +02:00
125 changed files with 412 additions and 379 deletions

View file

@ -39,6 +39,8 @@ PYTHON_VERSION=cdist/version.py
SPHINXM=make -C $(DOCS_SRC_DIR) man SPHINXM=make -C $(DOCS_SRC_DIR) man
SPHINXH=make -C $(DOCS_SRC_DIR) html SPHINXH=make -C $(DOCS_SRC_DIR) html
SPHINXC=make -C $(DOCS_SRC_DIR) clean SPHINXC=make -C $(DOCS_SRC_DIR) clean
SHELLCHECKCMD=shellcheck -s sh -f gcc -x -e SC2154,SC1091
################################################################################ ################################################################################
# Manpages # Manpages
# #
@ -253,3 +255,22 @@ test-remote:
pep8: pep8:
$(helper) $@ $(helper) $@
shellcheck-global-explorers:
@find cdist/conf/explorer -type f -exec $(SHELLCHECKCMD) {} + || exit 0
shellcheck-manifests:
@find cdist/conf/type -type f -name manifest -exec $(SHELLCHECKCMD) {} + || exit 0
shellcheck-local-gencodes:
@find cdist/conf/type -type f -name gencode-local -exec $(SHELLCHECKCMD) {} + || exit 0
shellcheck-remote-gencodes:
@find cdist/conf/type -type f -name gencode-remote -exec $(SHELLCHECKCMD) {} + || exit 0
shellcheck-gencodes: shellcheck-local-gencodes shellcheck-remote-gencodes
shellcheck-types: shellcheck-manifests shellcheck-gencodes
shellcheck: shellcheck-global-explorers shellcheck-types

View file

@ -25,13 +25,13 @@
os=$("$__explorer/os") os=$("$__explorer/os")
case "$os" in case "$os" in
"macosx") "macosx")
echo "$(sysctl -n hw.physicalcpu)" sysctl -n hw.physicalcpu
;; ;;
*) *)
if [ -r /proc/cpuinfo ]; then if [ -r /proc/cpuinfo ]; then
cores="$(grep "core id" /proc/cpuinfo | sort | uniq | wc -l)" cores="$(grep "core id" /proc/cpuinfo | sort | uniq | wc -l)"
if [ ${cores} -eq 0 ]; then if [ "${cores}" -eq 0 ]; then
cores="1" cores="1"
fi fi
echo "$cores" echo "$cores"

View file

@ -25,14 +25,14 @@
os=$("$__explorer/os") os=$("$__explorer/os")
case "$os" in case "$os" in
"macosx") "macosx")
echo "$(system_profiler SPHardwareDataType | grep "Number of Processors" | awk -F': ' '{print $2}')" system_profiler SPHardwareDataType | grep "Number of Processors" | awk -F ': ' '/Number of Processors/ {print $2}'
;; ;;
*) *)
if [ -r /proc/cpuinfo ]; then if [ -r /proc/cpuinfo ]; then
sockets="$(grep "physical id" /proc/cpuinfo | sort | uniq | wc -l)" sockets=$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)
if [ ${sockets} -eq 0 ]; then if [ "${sockets}" -eq 0 ]; then
sockets="$(cat /proc/cpuinfo | grep "processor" | wc -l)" sockets=$(grep -cE "^processor\s+:" /proc/cpuinfo)
fi fi
echo "${sockets}" echo "${sockets}"
fi fi

View file

@ -1,2 +1,2 @@
cd /dev cd /dev || exit 0
echo sd? hd? vd? echo sd? hd? vd?

View file

@ -20,7 +20,7 @@
# #
set +e set +e
case "$($__explorer/os)" in case "$("${__explorer}"/os)" in
openwrt) openwrt)
(. /etc/openwrt_release && echo "$DISTRIB_CODENAME") (. /etc/openwrt_release && echo "$DISTRIB_CODENAME")
;; ;;

View file

@ -20,7 +20,7 @@
# #
set +e set +e
case "$($__explorer/os)" in case "$("${__explorer}"/os)" in
openwrt) openwrt)
(. /etc/openwrt_release && echo "$DISTRIB_DESCRIPTION") (. /etc/openwrt_release && echo "$DISTRIB_DESCRIPTION")
;; ;;

View file

@ -20,7 +20,7 @@
# #
set +e set +e
case "$($__explorer/os)" in case "$("${__explorer}"/os)" in
openwrt) openwrt)
(. /etc/openwrt_release && echo "$DISTRIB_ID") (. /etc/openwrt_release && echo "$DISTRIB_ID")
;; ;;

View file

@ -20,7 +20,7 @@
# #
set +e set +e
case "$($__explorer/os)" in case "$("${__explorer}"/os)" in
openwrt) openwrt)
(. /etc/openwrt_release && echo "$DISTRIB_RELEASE") (. /etc/openwrt_release && echo "$DISTRIB_RELEASE")
;; ;;

View file

@ -22,6 +22,6 @@
# #
# #
if command -v uname 2>&1 >/dev/null; then if command -v uname > /dev/null 2>&1; then
uname -m uname -m
fi fi

View file

@ -22,13 +22,13 @@
# FIXME: other system types (not linux ...) # FIXME: other system types (not linux ...)
if [ -d "/proc/vz" -a ! -d "/proc/bc" ]; then if [ -d "/proc/vz" ] && [ ! -d "/proc/bc" ]; then
echo openvz echo openvz
exit exit
fi fi
if [ -e "/proc/1/environ" ] && if [ -e "/proc/1/environ" ] &&
cat "/proc/1/environ" | tr '\000' '\n' | grep -Eiq '^container='; then tr '\000' '\n' < "/proc/1/environ" | grep -Eiq '^container='; then
echo lxc echo lxc
exit exit
fi fi

View file

@ -22,7 +22,7 @@
# #
# #
case "$($__explorer/os)" in case "$("${__explorer}"/os)" in
amazon) amazon)
cat /etc/system-release cat /etc/system-release
;; ;;

View file

@ -34,9 +34,9 @@ fi
case "$state_should" in case "$state_should" in
present) present)
keyserver="$(cat "$__object/parameter/keyserver")" keyserver="$(cat "$__object/parameter/keyserver")"
echo "apt-key adv --keyserver \"$keyserver\" --recv-keys \"$keyid\"" echo "apt-key adv --keyserver '$keyserver' --recv-keys '$keyid'"
;; ;;
absent) absent)
echo "apt-key del \"$keyid\"" echo "apt-key del '$keyid'"
;; ;;
esac esac

View file

@ -29,9 +29,9 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo add-apt-repository \"$name\" echo "add-apt-repository '$name'"
;; ;;
absent) absent)
echo remove-apt-repository \"$name\" echo "remove-apt-repository '$name'"
;; ;;
esac esac

View file

@ -18,7 +18,7 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>. # along with cdist. If not, see <http://www.gnu.org/licenses/>.
# #
name="$__object_id" # name="$__object_id"
__package software-properties-common __package software-properties-common

View file

@ -19,7 +19,7 @@
# #
file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")" # file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")"
prefix=$(cat "$__object/parameter/prefix" 2>/dev/null || echo "#cdist:__block/$__object_id") prefix=$(cat "$__object/parameter/prefix" 2>/dev/null || echo "#cdist:__block/$__object_id")
suffix=$(cat "$__object/parameter/suffix" 2>/dev/null || echo "#/cdist:__block/$__object_id") suffix=$(cat "$__object/parameter/suffix" 2>/dev/null || echo "#/cdist:__block/$__object_id")
text=$(cat "$__object/parameter/text") text=$(cat "$__object/parameter/text")

View file

@ -42,21 +42,20 @@ get_current_value() {
} }
set_group() { set_group() {
echo chgrp \"$1\" \"$destination\" echo "chgrp '$1' '$destination'"
echo chgrp $1 >> "$__messages_out" echo "chgrp $1" >> "$__messages_out"
} }
set_owner() { set_owner() {
echo chown \"$1\" \"$destination\" echo "chown '$1' '$destination'"
echo chown $1 >> "$__messages_out" echo "chown $1" >> "$__messages_out"
} }
set_mode() { set_mode() {
echo chmod \"$1\" \"$destination\" echo "chmod '$1' '$destination'"
echo chmod $1 >> "$__messages_out" echo "chmod $1" >> "$__messages_out"
} }
set_attributes=
case "$state_should" in case "$state_should" in
present|exists) present|exists)
# Note: Mode - needs to happen last as a chown/chgrp can alter mode by # Note: Mode - needs to happen last as a chown/chgrp can alter mode by
@ -67,11 +66,11 @@ case "$state_should" in
# change 0xxx format to xxx format => same as stat returns # change 0xxx format to xxx format => same as stat returns
if [ "$attribute" = mode ]; then if [ "$attribute" = mode ]; then
value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')" value_should="$(echo "$value_should" | sed 's/^0\(...\)/\1/')"
fi fi
value_is="$(get_current_value "$attribute" "$value_should")" value_is="$(get_current_value "$attribute" "$value_should")"
if [ -f "$__object/files/set-attributes" -o "$value_should" != "$value_is" ]; then if [ -f "$__object/files/set-attributes" ] || [ "$value_should" != "$value_is" ]; then
"set_$attribute" "$value_should" "set_$attribute" "$value_should"
fi fi
fi fi
@ -81,7 +80,7 @@ case "$state_should" in
absent) absent)
if [ "$type" = "file" ]; then if [ "$type" = "file" ]; then
echo rm -f \"$destination\" echo "rm -f '$destination'"
echo remove >> "$__messages_out" echo remove >> "$__messages_out"
fi fi
;; ;;

View file

@ -22,7 +22,7 @@ name="$__object_id"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"
source="$(cat "$__object/parameter/source")" source="$(cat "$__object/parameter/source")"
destination="$(cat "$__object/parameter/destination")" destination="$(cat "$__object/parameter/destination")"
ccollectconf="$(cat "$__object/parameter/ccollectconf" | sed 's,/$,,')" ccollectconf="$(sed -E 's,/+$,,' "$__object/parameter/ccollectconf")"
sourcedir="$ccollectconf/sources" sourcedir="$ccollectconf/sources"
basedir="$sourcedir/$name" basedir="$sourcedir/$name"

View file

@ -66,7 +66,7 @@ require="__directory/etc/consul" \
__directory "$conf_dir" \ __directory "$conf_dir" \
--owner root --group "$group" --mode 750 --state "$state" --owner root --group "$group" --mode 750 --state "$state"
if [ -f "$__object/parameter/ca-file-source" -o -f "$__object/parameter/cert-file-source" -o -f "$__object/parameter/key-file-source" ]; then if [ -f "$__object/parameter/ca-file-source" ] || [ -f "$__object/parameter/cert-file-source" ] || [ -f "$__object/parameter/key-file-source" ]; then
# create directory for ssl certs # create directory for ssl certs
require="__directory/etc/consul" \ require="__directory/etc/consul" \
__directory /etc/consul/ssl \ __directory /etc/consul/ssl \

View file

@ -40,7 +40,7 @@ if [ ! -f "$__object/parameter/interval" ]; then
fi fi
done done
fi fi
if [ -f "$__object/parameter/docker-container-id" -a ! -f "$__object/parameter/script" ]; then if [ -f "$__object/parameter/docker-container-id" ] && [ ! -f "$__object/parameter/script" ]; then
echo "When using --docker-container-id you must also define --script." >&2 echo "When using --docker-container-id you must also define --script." >&2
exit 1 exit 1
fi fi

View file

@ -24,15 +24,15 @@ conf_file="service_${name}.json"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"
# Sanity checks # Sanity checks
if [ -f "$__object/parameter/check-script" -a -f "$__object/parameter/check-ttl" ]; then if [ -f "$__object/parameter/check-script" ] && [ -f "$__object/parameter/check-ttl" ]; then
echo "Use either --check-script together with --check-interval OR --check-ttl, but not both" >&2 echo "Use either --check-script together with --check-interval OR --check-ttl, but not both" >&2
exit 1 exit 1
fi fi
if [ -f "$__object/parameter/check-script" -a ! -f "$__object/parameter/check-interval" ]; then if [ -f "$__object/parameter/check-script" ] && [ ! -f "$__object/parameter/check-interval" ]; then
echo "When using --check-script you must also define --check-interval" >&2 echo "When using --check-script you must also define --check-interval" >&2
exit 1 exit 1
fi fi
if [ -f "$__object/parameter/check-http" -a ! -f "$__object/parameter/check-interval" ]; then if [ -f "$__object/parameter/check-http" ] && [ ! -f "$__object/parameter/check-interval" ]; then
echo "When using --check-http you must also define --check-interval" >&2 echo "When using --check-http you must also define --check-interval" >&2
exit 1 exit 1
fi fi

View file

@ -26,11 +26,11 @@ template_dir="/etc/consul-template/template"
require="" require=""
# Sanity checks # Sanity checks
if [ -f "$__object/parameter/source" -a -f "$__object/parameter/source-file" ]; then if [ -f "$__object/parameter/source" ] && [ -f "$__object/parameter/source-file" ]; then
echo "Use either --source OR --source-file, but not both." >&2 echo "Use either --source OR --source-file, but not both." >&2
exit 1 exit 1
fi fi
if [ ! -f "$__object/parameter/source" -a ! -f "$__object/parameter/source-file" ]; then if [ ! -f "$__object/parameter/source" ] && [ ! -f "$__object/parameter/source-file" ]; then
echo "Either --source OR --source-file must be given." >&2 echo "Either --source OR --source-file must be given." >&2
exit 1 exit 1
fi fi

View file

@ -25,7 +25,7 @@ conf_file="watch_${watch_type}_${__object_id}.json"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"
# Sanity checks # Sanity checks
if [ -f "$__object/parameter/filter-service" -a -f "$__object/parameter/filter-state" ]; then if [ -f "$__object/parameter/filter-service" ] && [ -f "$__object/parameter/filter-state" ]; then
echo "Use either --filter-service or --filter-state but not both." >&2 echo "Use either --filter-service or --filter-state but not both." >&2
exit 1 exit 1
fi fi

View file

@ -24,7 +24,7 @@ user="$(cat "$__object/parameter/user")"
if [ -f "$__object/parameter/raw_command" ]; then if [ -f "$__object/parameter/raw_command" ]; then
command="$(cat "$__object/parameter/command")" command="$(cat "$__object/parameter/command")"
crontab -u $user -l 2>/dev/null | grep "^$command\$" || true crontab -u "$user" -l 2>/dev/null | grep "^$command\$" || true
else else
crontab -u $user -l 2>/dev/null | grep "# $name\$" || true crontab -u "$user" -l 2>/dev/null | grep "# $name\$" || true
fi fi

View file

@ -60,7 +60,7 @@ prefix="#cdist:__cron/$__object_id"
suffix="#/cdist:__cron/$__object_id" suffix="#/cdist:__cron/$__object_id"
filter="^# DO NOT EDIT THIS FILE|^# \(.* installed on |^# \(Cron version V|^# \(Cronie version .\..\)$" filter="^# DO NOT EDIT THIS FILE|^# \(.* installed on |^# \(Cron version V|^# \(Cronie version .\..\)$"
cat << DONE cat << DONE
crontab -u $user -l 2>/dev/null | grep -v -E "$filter" | awk -v prefix="$prefix" -v suffix="$suffix" ' crontab -u '$user' -l 2>/dev/null | grep -v -E "$filter" | awk -v prefix="$prefix" -v suffix="$suffix" '
{ {
if (index(\$0,prefix)) { if (index(\$0,prefix)) {
triggered=1 triggered=1
@ -73,24 +73,30 @@ crontab -u $user -l 2>/dev/null | grep -v -E "$filter" | awk -v prefix="$prefix"
print print
} }
} }
' | crontab -u $user - ' | crontab -u '$user' -
DONE DONE
case "$state_should" in case "$state_should" in
present) present)
# if we insert new entry, filter also all entrys out with the same id # if we insert new entry, filter also all entrys out with the same id
echo "(" cat <<EOF
echo "crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" | grep -v \"# $name\\$\" 2>/dev/null || true" (
echo "echo '$entry'" crontab -u '$user' -l 2>/dev/null | grep -v -E '$filter' | grep -v '# $name\\$' 2>/dev/null || true
echo ") | crontab -u $user -" echo '$entry'
) | crontab -u '$user' -
EOF
;; ;;
absent) absent)
if [ -f "$__object/parameter/raw_command" ]; then if [ -f "$__object/parameter/raw_command" ]; then
echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\" cat <<EOF
echo "grep -v \"^$entry\\$\" | crontab -u $user -" ( crontab -u '$user' -l 2>/dev/null | grep -v -E '$filter' 2>/dev/null || true ) | \\
grep -v '^$entry\\$' | crontab -u '$user' -
EOF
else else
echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\" cat <<EOF
echo "grep -v \"# $name\\$\" | crontab -u $user -" ( crontab -u '$user' -l 2>/dev/null | grep -v -E '$filter' 2>/dev/null || true ) | \\
grep -v '# $name\\$' | crontab -u '$user' -
EOF
fi fi
;; ;;
esac esac

View file

@ -3,8 +3,8 @@
pkg=$(cat "$__object/parameter/from-package") pkg=$(cat "$__object/parameter/from-package")
servicedir=$(cat "$__object/parameter/servicedir") servicedir=$(cat "$__object/parameter/servicedir")
__package $pkg __package "$pkg"
__directory $servicedir --mode 700 __directory "$servicedir" --mode 700
os=$(cat "$__global/explorer/os") os=$(cat "$__global/explorer/os")
init=$(cat "$__global/explorer/init") init=$(cat "$__global/explorer/init")

View file

@ -25,14 +25,14 @@ badusage() {
[ -z "$run$runfile" ] && badusage [ -z "$run$runfile" ] && badusage
[ -n "$run" ] && [ -n "$runfile" ] && badusage [ -n "$run" ] && [ -n "$runfile" ] && badusage
__directory $servicedir/$name/log/main --parents __directory "$servicedir/$name/log/main" --parents
echo "$RUN_PREFIX$run" | require="__directory/$servicedir/$name/log/main" __config_file "$servicedir/$name/run" \ echo "$RUN_PREFIX$run" | require="__directory/$servicedir/$name/log/main" __config_file "$servicedir/$name/run" \
--onchange "svc -t '$servicedir/$name' 2>/dev/null" \ --onchange "svc -t '$servicedir/$name' 2>/dev/null" \
--mode 755 \ --mode 755 \
--source "${runfile:--}" --source "${runfile:--}"
echo "$RUN_PREFIX$logrun" | require="__directory/$servicedir/$name/log/main" __config_file $servicedir/$name/log/run \ echo "$RUN_PREFIX$logrun" | require="__directory/$servicedir/$name/log/main" __config_file "$servicedir/$name/log/run" \
--onchange "svc -t '$servicedir/$name/log' 2>/dev/null" \ --onchange "svc -t '$servicedir/$name/log' 2>/dev/null" \
--mode 755 \ --mode 755 \
--source "-" --source "-"

View file

@ -57,18 +57,18 @@ get_current_value() {
} }
set_group() { set_group() {
echo chgrp $recursive \"$1\" \"$destination\" echo "chgrp '$recursive' '$1' '$destination'"
echo chgrp $recursive $1 >> "$__messages_out" echo "chgrp $recursive $1" >> "$__messages_out"
} }
set_owner() { set_owner() {
echo chown $recursive \"$1\" \"$destination\" echo "chown '$recursive' '$1' '$destination'"
echo chown $recursive $1 >> "$__messages_out" echo "chown $recursive $1" >> "$__messages_out"
} }
set_mode() { set_mode() {
echo chmod $recursive \"$1\" \"$destination\" echo "chmod '$recursive' '$1' '$destination'"
echo chmod $recursive $1 >> "$__messages_out" echo "chmod $recursive $1" >> "$__messages_out"
} }
case "$state_should" in case "$state_should" in
@ -78,10 +78,10 @@ case "$state_should" in
if [ "$type" != "none" ]; then if [ "$type" != "none" ]; then
# our destination is not a directory, remove whatever is there # our destination is not a directory, remove whatever is there
# and then create our directory and set all attributes # and then create our directory and set all attributes
echo rm -f "\"$destination\"" echo "rm -f '$destination'"
echo "remove non directory" >> "$__messages_out" echo "remove non directory" >> "$__messages_out"
fi fi
echo "mkdir $mkdiropt \"$destination\"" echo "mkdir $mkdiropt '$destination'"
echo "create" >> "$__messages_out" echo "create" >> "$__messages_out"
fi fi
@ -94,7 +94,7 @@ case "$state_should" in
# change 0xxx format to xxx format => same as stat returns # change 0xxx format to xxx format => same as stat returns
if [ "$attribute" = mode ]; then if [ "$attribute" = mode ]; then
value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')" value_should="$(echo "$value_should" | sed 's/^0\(...\)/\1/')"
fi fi
if [ "$set_attributes" = 1 ] || [ "$value_should" != "$value_is" ]; then if [ "$set_attributes" = 1 ] || [ "$value_should" != "$value_is" ]; then
@ -105,7 +105,7 @@ case "$state_should" in
;; ;;
absent) absent)
if [ "$type" = "directory" ]; then if [ "$type" = "directory" ]; then
echo rm -rf \"$destination\" echo "rm -rf '$destination'"
echo remove >> "$__messages_out" echo remove >> "$__messages_out"
fi fi
;; ;;

View file

@ -22,10 +22,10 @@
version="$(cat "$__object/parameter/version")" version="$(cat "$__object/parameter/version")"
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"
if [ ${state} = "present" ]; then if [ "${state}" = "present" ]; then
# Download docker-compose file # Download docker-compose file
echo 'curl -L "https://github.com/docker/compose/releases/download/'${version}'/docker-compose-$(uname -s)-$(uname -m)" -o /tmp/docker-compose' echo "curl -L 'https://github.com/docker/compose/releases/download/${version}/docker-compose-$(uname -s)-$(uname -m)' -o /tmp/docker-compose"
echo 'mv /tmp/docker-compose /usr/local/bin/docker-compose' echo 'mv /tmp/docker-compose /usr/local/bin/docker-compose'
# Change permissions # Change permissions
echo 'chmod +x /usr/local/bin/docker-compose' echo 'chmod +x /usr/local/bin/docker-compose'
fi fi

View file

@ -22,10 +22,10 @@
state="$(cat "$__object/parameter/state")" state="$(cat "$__object/parameter/state")"
# Needed packages # Needed packages
if [ ${state} = "present" ]; then if [ "${state}" = "present" ]; then
__docker __docker
__package curl __package curl
elif [ ${state} = "absent" ]; then elif [ "${state}" = "absent" ]; then
__file /usr/local/bin/docker-compose --state absent __file /usr/local/bin/docker-compose --state absent
else else
echo "Unknown state: ${state}" >&2 echo "Unknown state: ${state}" >&2

View file

@ -23,7 +23,7 @@ destination="/$__object_id"
state_should="$(cat "$__object/parameter/state")" state_should="$(cat "$__object/parameter/state")"
type="$(cat "$__object/explorer/type")" type="$(cat "$__object/explorer/type")"
[ "$state_should" = "exists" -a "$type" = "file" ] && exit 0 # nothing to do [ "$state_should" = "exists" ] && [ "$type" = "file" ] && exit 0 # nothing to do
if [ "$state_should" = "pre-exists" ]; then if [ "$state_should" = "pre-exists" ]; then
if [ -f "$__object/parameter/source" ]; then if [ -f "$__object/parameter/source" ]; then
@ -41,7 +41,7 @@ fi
upload_file= upload_file=
create_file= create_file=
if [ "$state_should" = "present" -o "$state_should" = "exists" ]; then if [ "$state_should" = "present" ] || [ "$state_should" = "exists" ]; then
if [ ! -f "$__object/parameter/source" ]; then if [ ! -f "$__object/parameter/source" ]; then
remote_stat="$(cat "$__object/explorer/stat")" remote_stat="$(cat "$__object/explorer/stat")"
if [ -z "$remote_stat" ]; then if [ -z "$remote_stat" ]; then
@ -54,7 +54,7 @@ if [ "$state_should" = "present" -o "$state_should" = "exists" ]; then
source="$__object/stdin" source="$__object/stdin"
fi fi
if [ ! -f "$source" ]; then if [ ! -f "$source" ]; then
echo "Source \"$source\" does not exist." >&2 echo "Source '$source' does not exist." >&2
exit 1 exit 1
else else
if [ "$type" != "file" ]; then if [ "$type" != "file" ]; then
@ -70,7 +70,7 @@ if [ "$state_should" = "present" -o "$state_should" = "exists" ]; then
fi fi
fi fi
fi fi
if [ "$create_file" -o "$upload_file" ]; then if [ "$create_file" ] || [ "$upload_file" ]; then
# tell gencode-remote that we created or uploaded a file and that it must # tell gencode-remote that we created or uploaded a file and that it must
# set all attributes no matter what the explorer retreived # set all attributes no matter what the explorer retreived
mkdir "$__object/files" mkdir "$__object/files"
@ -84,7 +84,7 @@ DONE
if [ "$upload_file" ]; then if [ "$upload_file" ]; then
echo upload >> "$__messages_out" echo upload >> "$__messages_out"
# IPv6 fix # IPv6 fix
if $(echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$') if echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$'
then then
my_target_host="[${__target_host}]" my_target_host="[${__target_host}]"
else else
@ -96,7 +96,7 @@ DONE
fi fi
# move uploaded file into place # move uploaded file into place
cat << DONE cat << DONE
$__remote_exec $__target_host "rm -rf \"$destination\"; mv \"\$destination_upload\" \"$destination\"" $__remote_exec $__target_host "rm -rf '$destination'; mv \"\$destination_upload\" '$destination'"
DONE DONE
fi fi
fi fi

View file

@ -43,21 +43,20 @@ get_current_value() {
} }
set_group() { set_group() {
echo chgrp \"$1\" \"$destination\" echo "chgrp '$1' '$destination'"
echo chgrp $1 >> "$__messages_out" echo "chgrp $1" >> "$__messages_out"
} }
set_owner() { set_owner() {
echo chown \"$1\" \"$destination\" echo "chown '$1' '$destination'"
echo chown $1 >> "$__messages_out" echo "chown $1" >> "$__messages_out"
} }
set_mode() { set_mode() {
echo chmod \"$1\" \"$destination\" echo "chmod '$1' '$destination'"
echo chmod $1 >> "$__messages_out" echo "chmod $1" >> "$__messages_out"
} }
set_attributes=
case "$state_should" in case "$state_should" in
present|exists|pre-exists) present|exists|pre-exists)
# Note: Mode - needs to happen last as a chown/chgrp can alter mode by # Note: Mode - needs to happen last as a chown/chgrp can alter mode by
@ -68,11 +67,11 @@ case "$state_should" in
# change 0xxx format to xxx format => same as stat returns # change 0xxx format to xxx format => same as stat returns
if [ "$attribute" = mode ]; then if [ "$attribute" = mode ]; then
value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')" value_should="$(echo "$value_should" | sed 's/^0\(...\)/\1/')"
fi fi
value_is="$(get_current_value "$attribute" "$value_should")" value_is="$(get_current_value "$attribute" "$value_should")"
if [ -f "$__object/files/set-attributes" -o "$value_should" != "$value_is" ]; then if [ -f "$__object/files/set-attributes" ] || [ "$value_should" != "$value_is" ]; then
"set_$attribute" "$value_should" "set_$attribute" "$value_should"
fi fi
fi fi
@ -82,7 +81,7 @@ case "$state_should" in
absent) absent)
if [ "$type" = "file" ]; then if [ "$type" = "file" ]; then
echo rm -f \"$destination\" echo "rm -f '$destination'"
echo remove >> "$__messages_out" echo remove >> "$__messages_out"
fi fi
;; ;;

View file

@ -25,7 +25,7 @@ chain="$(cat "$__object/parameter/chain")"
priority="$(cat "$__object/parameter/priority")" priority="$(cat "$__object/parameter/priority")"
rule="$(cat "$__object/parameter/rule")" rule="$(cat "$__object/parameter/rule")"
if firewall-cmd --permanent --direct --query-rule "$protocol" "$table" "$chain" "$priority" $rule >/dev/null; then if firewall-cmd --permanent --direct --query-rule "$protocol" "$table" "$chain" "$priority" "$rule" >/dev/null; then
echo present echo present
else else
echo absent echo absent

View file

@ -19,7 +19,7 @@
# #
# #
name="$__object_id" # name="$__object_id"
state_should="$(cat "$__object/parameter/state")" state_should="$(cat "$__object/parameter/state")"
state_is="$(cat "$__object/explorer/rule")" state_is="$(cat "$__object/explorer/rule")"
@ -33,13 +33,13 @@ rule="$(cat "$__object/parameter/rule")"
case "$state_should" in case "$state_should" in
present) present)
echo firewall-cmd --quiet --permanent --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule echo "firewall-cmd --quiet --permanent --direct --add-rule '$protocol' '$table' '$chain' '$priority' $rule"
echo firewall-cmd --quiet --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule echo "firewall-cmd --quiet --direct --add-rule '$protocol' '$table' '$chain' '$priority' $rule"
;; ;;
absent) absent)
echo firewall-cmd --quiet --permanent --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule echo "firewall-cmd --quiet --permanent --direct --remove-rule '$protocol' '$table' '$chain' '$priority' $rule"
echo firewall-cmd --quiet --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule echo "firewall-cmd --quiet --direct --remove-rule '$protocol' '$table' '$chain' '$priority' $rule"
;; ;;
*) *)
echo "Unknown state $state_should" >&2 echo "Unknown state $state_should" >&2

View file

@ -42,16 +42,16 @@ esac
if [ "$init" = 'systemd' ]; then if [ "$init" = 'systemd' ]; then
# this handles ALL linux distros with systemd # this handles ALL linux distros with systemd
# e.g. archlinux, gentoo in some cases, new RHEL and SLES versions # e.g. archlinux, gentoo in some cases, new RHEL and SLES versions
echo "systemctl \"$cmd\" \"$name\"" echo "systemctl '$cmd' '$name'"
else else
case "$os" in case "$os" in
debian) debian)
case "$os_version" in case "$os_version" in
[1-7]*) [1-7]*)
echo "service \"$name\" \"$cmd\"" echo "service '$name' '$cmd'"
;; ;;
8*) 8*)
echo "systemctl \"$cmd\" \"$name\"" echo "systemctl '$cmd' '$name'"
;; ;;
*) *)
echo "Unsupported version $os_version of $os" >&2 echo "Unsupported version $os_version of $os" >&2
@ -61,19 +61,19 @@ else
;; ;;
gentoo) gentoo)
echo service \"$name\" \"$cmd\" echo "service '$name' '$cmd'"
;; ;;
amazon|scientific|centos|fedora|owl|redhat|suse) amazon|scientific|centos|fedora|owl|redhat|suse)
echo service \"$name\" \"$cmd\" echo "service '$name' '$cmd'"
;; ;;
openwrt) openwrt)
echo "/etc/init.d/\"$name\" \"$cmd\"" echo "'/etc/init.d/$name' '$cmd'"
;; ;;
ubuntu) ubuntu)
echo "service \"$name\" \"$cmd\"" echo "service '$name' '$cmd'"
;; ;;
*) *)

View file

@ -2,4 +2,4 @@
destination="/$__object_id/.git" destination="/$__object_id/.git"
stat --print "%G" ${destination} 2>/dev/null || exit 0 stat --print "%G" "${destination}" 2>/dev/null || exit 0

View file

@ -2,4 +2,4 @@
destination="/$__object_id/.git" destination="/$__object_id/.git"
stat --print "%U" ${destination} 2>/dev/null || exit 0 stat --print "%U" "${destination}" 2>/dev/null || exit 0

View file

@ -35,10 +35,10 @@ owner="$(cat "$__object/parameter/owner")"
group="$(cat "$__object/parameter/group")" group="$(cat "$__object/parameter/group")"
mode="$(cat "$__object/parameter/mode")" mode="$(cat "$__object/parameter/mode")"
[ "$state_should" = "$state_is" -a \ [ "$state_should" = "$state_is" ] && \
"$owner" = "$owner_is" -a \ [ "$owner" = "$owner_is" ] && \
"$group" = "$group_is" -a \ [ "$group" = "$group_is" ] && \
-n "$mode" ] && exit 0 [ -n "$mode" ] && exit 0
case $state_should in case $state_should in
present) present)
@ -46,8 +46,8 @@ case $state_should in
if [ "$state_should" != "$state_is" ]; then if [ "$state_should" != "$state_is" ]; then
echo git clone --quiet --branch "$branch" "$source" "$destination" echo git clone --quiet --branch "$branch" "$source" "$destination"
fi fi
if [ \( -n "$owner" -a "$owner_is" != "$owner" \) -o \ if ([ -n "$owner" ] && [ "$owner_is" != "$owner" ]) || \
\( -n "$group" -a "$group_is" != "$group" \) ]; then ([ -n "$group" ] && [ "$group_is" != "$group" ]); then
echo chown -R "${owner}:${group}" "$destination" echo chown -R "${owner}:${group}" "$destination"
fi fi
if [ -n "$mode" ]; then if [ -n "$mode" ]; then

View file

@ -2,7 +2,7 @@
version=$(cat "$__object/parameter/version") version=$(cat "$__object/parameter/version")
kernel_name=$(cat "$__global/explorer/kernel_name" | tr '[:upper:]' '[:lower:]') kernel_name=$(tr '[:upper:]' '[:lower:]' < "$__global/explorer/kernel_name")
machine=$(cat "$__global/explorer/machine") machine=$(cat "$__global/explorer/machine")
case $machine in case $machine in
x86_64|amd64) x86_64|amd64)

View file

@ -1,7 +1,7 @@
#!/bin/sh -e #!/bin/sh -e
os=$(cat $__global/explorer/os) os="$(cat "$__global/explorer/os")"
os_version=$(cat $__global/explorer/os_version) os_version="$(cat "$__global/explorer/os_version")"
case $os in case $os in
debian|devuan) debian|devuan)

View file

@ -22,7 +22,7 @@
# #
name=$__object_id name=$__object_id
os="$($__explorer/os)" os="$("${__explorer}"/os)"
case "$os" in case "$os" in
"freebsd"|"netbsd") "freebsd"|"netbsd")

View file

@ -30,9 +30,9 @@ state="$(cat "$__object/parameter/state")"
# Use short option names for portability # Use short option names for portability
shorten_property() { shorten_property() {
case "$1" in case "$1" in
gid) echo "-g";; gid) printf -- "-g\n";;
password) echo "-p";; password) printf -- "-p\n";;
system) echo "-r";; system) printf -- "-r\n";;
esac esac
} }
@ -40,11 +40,9 @@ shorten_property() {
if [ "$state" = "present" ]; then if [ "$state" = "present" ]; then
case "$os" in case "$os" in
freebsd) freebsd)
supported_add_properties="gid"
supported_change_properties="gid" supported_change_properties="gid"
;; ;;
*) *)
supported_add_properties="gid password system"
supported_change_properties="gid password" supported_change_properties="gid password"
;; ;;
esac esac
@ -63,8 +61,8 @@ if [ "$state" = "present" ]; then
;; ;;
esac esac
if [ "$new_value" != "$current_value" ]; then if [ "$new_value" != "$current_value" ]; then
set -- "$@" "$(shorten_property $property)" \'$new_value\' set -- "$@" "$(shorten_property "$property")" \'"$new_value"\'
echo change $property $new_value $current_value >> "$__messages_out" echo change "$property" "$new_value" "$current_value" >> "$__messages_out"
fi fi
fi fi
done done
@ -83,9 +81,9 @@ if [ "$state" = "present" ]; then
new_value="$(cat "$__object/parameter/$property")" new_value="$(cat "$__object/parameter/$property")"
if [ -z "$new_value" ]; then if [ -z "$new_value" ]; then
# Boolean parameters have no value # Boolean parameters have no value
set -- "$@" "$(shorten_property $property)" set -- "$@" "$(shorten_property "$property")"
else else
set -- "$@" "$(shorten_property $property)" \'$new_value\' set -- "$@" "$(shorten_property "$property")" \'"$new_value"\'
fi fi
fi fi
done done

View file

@ -22,7 +22,7 @@
if [ -f "$__object/parameter/name" ]; then if [ -f "$__object/parameter/name" ]; then
name_should="$(cat "$__object/parameter/name")" name_should="$(cat "$__object/parameter/name")"
else else
name_should="$(echo "${__target_host%%.*}")" name_should="${__target_host%%.*}"
fi fi
os=$(cat "$__global/explorer/os") os=$(cat "$__global/explorer/os")
@ -36,12 +36,12 @@ has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl")
# #
case "$os" in case "$os" in
archlinux|debian|suse|ubuntu|devuan|coreos) archlinux|debian|suse|ubuntu|devuan|coreos)
if [ "$name_config" = "$name_should" -a "$name_running" = "$name_should" ]; then if [ "$name_config" = "$name_should" ] && [ "$name_running" = "$name_should" ]; then
exit 0 exit 0
fi fi
;; ;;
scientific|centos|freebsd|openbsd) scientific|centos|freebsd|openbsd)
if [ "$name_sysconfig" = "$name_should" -a "$name_running" = "$name_should" ]; then if [ "$name_sysconfig" = "$name_should" ] && [ "$name_running" = "$name_should" ]; then
exit 0 exit 0
fi fi
;; ;;

View file

@ -25,10 +25,10 @@ if [ -f "$__object/parameter/name" ]; then
else else
case "$os" in case "$os" in
openbsd) openbsd)
name_should="$(echo "${__target_host}")" name_should="${__target_host}"
;; ;;
*) *)
name_should="$(echo "${__target_host%%.*}")" name_should="${__target_host%%.*}"
;; ;;
esac esac
fi fi

View file

@ -28,7 +28,7 @@ install_script="$__object/files/install_script"
# Link file descriptor #6 with stdout # Link file descriptor #6 with stdout
exec 6>&1 exec 6>&1
# Link stdout with $install_script # Link stdout with $install_script
exec > $install_script exec > "$install_script"
# Generate script to install bootloader on distro # Generate script to install bootloader on distro
printf '#!/bin/sh -l\n' printf '#!/bin/sh -l\n'

View file

@ -23,12 +23,13 @@ cat "$__type/files/fstab.header" > "$destination"
mkdir "$__object/files" mkdir "$__object/files"
# get current UUID's from target_host # get current UUID's from target_host
$__remote_exec $__target_host blkid > "$__object/files/blkid" $__remote_exec "$__target_host" blkid > "$__object/files/blkid"
for object in $(find "$__global/object/__install_mount" -type d -name "$__cdist_object_marker"); do find "$__global/object/__install_mount" -type d -name "$__cdist_object_marker" |
while IFS= read -r object
do
device="$(cat "$object/parameter/device")" device="$(cat "$object/parameter/device")"
dir="$(cat "$object/parameter/dir")" dir="$(cat "$object/parameter/dir")"
prefix="$(cat "$object/parameter/prefix")"
type="$(cat "$object/parameter/type")" type="$(cat "$object/parameter/type")"
if [ -f "$object/parameter/options" ]; then if [ -f "$object/parameter/options" ]; then
options="$(cat "$object/parameter/options")" options="$(cat "$object/parameter/options")"
@ -54,7 +55,7 @@ for object in $(find "$__global/object/__install_mount" -type d -name "$__cdist_
;; ;;
esac esac
if [ -f "$__object/parameter/uuid" ]; then if [ -f "$__object/parameter/uuid" ]; then
uuid="$(grep -w $device "$__object/files/blkid" | awk '{print $2}')" uuid="$(grep -w "$device" "$__object/files/blkid" | awk '{print $2}')"
if [ -n "$uuid" ]; then if [ -n "$uuid" ]; then
echo "# $dir was on $device during installation" >> "$destination" echo "# $dir was on $device during installation" >> "$destination"
device="$uuid" device="$uuid"

View file

@ -19,13 +19,18 @@
# #
# set defaults # set defaults
if [ -f "$__object/parameter/device" ]; then # if [ -f "$__object/parameter/device" ]; then
device="(cat "$__object/parameter/device")" # device="(cat "$__object/parameter/device")"
else # else
# device="/$__object_id"
# echo "$device" > "$__object/parameter/device"
# fi
# type="(cat "$__object/parameter/type")"
# options="(cat "$__object/parameter/options")"
if [ ! -f "$__object/parameter/device" ]; then
device="/$__object_id" device="/$__object_id"
echo "$device" > "$__object/parameter/device" echo "$device" > "$__object/parameter/device"
fi fi
type="(cat "$__object/parameter/type")"
options="(cat "$__object/parameter/options")"

View file

@ -20,7 +20,9 @@
get_type_from_mkfs() { get_type_from_mkfs() {
_device="$1" _device="$1"
for mkfs_object in $(find "$__global/object/__install_mkfs" -type d -name "$__cdist_object_marker"); do find "$__global/object/__install_mkfs" -type d -name "$__cdist_object_marker" |
while IFS= read -r mkfs_object
do
mkfs_device="$(cat "$mkfs_object/parameter/device")" mkfs_device="$(cat "$mkfs_object/parameter/device")"
if [ "$_device" = "$mkfs_device" ]; then if [ "$_device" = "$mkfs_device" ]; then
cat "$mkfs_object/parameter/type" cat "$mkfs_object/parameter/type"

View file

@ -21,7 +21,7 @@
#set -x #set -x
die() { die() {
echo "[__install_partition_msdos_apply] $@" >&2 echo "[__install_partition_msdos_apply]" "$@" >&2
exit 1 exit 1
} }
debug() { debug() {
@ -31,25 +31,25 @@ debug() {
# Convert a size specifier 1G 100M or 50% into the corresponding numeric MB. # Convert a size specifier 1G 100M or 50% into the corresponding numeric MB.
size_to_mb() { size_to_mb() {
local size=$1 size=$1
local available_size="$2" available_size="$2"
local number_suffix="$(echo ${size} | sed -e 's:\.[0-9]\+::' -e 's:\([0-9]\+\)\([KkMmGg%]\)[Bb]\?:\1|\2:')" number_suffix="$(echo "${size}" | sed -e 's:\.[0-9]\+::' -e 's:\([0-9]\+\)\([KkMmGg%]\)[Bb]\?:\1|\2:')"
local number="$(echo ${number_suffix} | cut -d '|' -f1)" number="$(echo "${number_suffix}" | cut -d '|' -f1)"
local suffix="$(echo ${number_suffix} | cut -d '|' -f2)" suffix="$(echo "${number_suffix}" | cut -d '|' -f2)"
case "$suffix" in case "$suffix" in
K|k) K|k)
size="$(( $number / 1024 ))" size="$(( number / 1024 ))"
;; ;;
M|m) M|m)
size="$number" size="$number"
;; ;;
G|g) G|g)
size="$(( $number * 1024 ))" size="$(( number * 1024 ))"
;; ;;
%) %)
size="$(( $available_size * $number / 100 ))" size="$(( available_size * number / 100 ))"
;; ;;
*) *)
size="-1" size="-1"
@ -59,13 +59,15 @@ size_to_mb() {
get_objects() { get_objects() {
objects_file=$(mktemp) objects_file=$(mktemp)
for object in $(find "$__global/object/__install_partition_msdos" -type d -name "$__cdist_object_marker"); do find "$__global/object/__install_partition_msdos" -type d -name "$__cdist_object_marker" |
while IFS= read -r object
do
object_device="$(cat "$object/parameter/device")" object_device="$(cat "$object/parameter/device")"
object_minor="$(cat "$object/parameter/minor")" object_minor="$(cat "$object/parameter/minor")"
echo "$object_device $object_minor $object" >> $objects_file echo "$object_device $object_minor $object" >> "$objects_file"
done done
sort -k 1,2 $objects_file | cut -d' ' -f 3 sort -k 1,2 "$objects_file" | cut -d' ' -f 3
rm $objects_file rm "$objects_file"
unset objects_file unset objects_file
unset object unset object
unset object_device unset object_device
@ -85,9 +87,9 @@ primary_count=0
for object in $objects; do for object in $objects; do
device="$(cat "$object/parameter/device")" device="$(cat "$object/parameter/device")"
if [ "$current_device" != "$device" ]; then if [ "$current_device" != "$device" ]; then
echo "create_disklabel \"$device\" || die 'Failed to create disklabel for $device'" echo "create_disklabel '$device' || die 'Failed to create disklabel for $device'"
current_device="$device" current_device="$device"
device_name=$(echo ${device} | sed -e 's:^/dev/::;s:/:\\/:g') device_name=$(echo "${device}" | sed -e 's:^/dev/::;s:/:\\/:g')
available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024)) available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024))
# make sure we don't go past the end of the drive # make sure we don't go past the end of the drive
available_device_size=$((available_device_size - 2)) available_device_size=$((available_device_size - 2))
@ -108,7 +110,7 @@ for object in $objects; do
if [ "${minor}" -lt "5" ]; then if [ "${minor}" -lt "5" ]; then
# Primary partitions # Primary partitions
primary_count=$(( $primary_count + 1 )) primary_count=$(( primary_count + 1 ))
available_size=$available_device_size available_size=$available_device_size
else else
# Logical partitions # Logical partitions
@ -121,13 +123,13 @@ for object in $objects; do
available_size=0 available_size=0
else else
partition_size=$(size_to_mb "$size" "$available_size") partition_size=$(size_to_mb "$size" "$available_size")
available_size="$(( $available_size - $partition_size ))" available_size="$(( available_size - partition_size ))"
fi fi
if [ "${minor}" -lt "5" ]; then if [ "${minor}" -lt "5" ]; then
# Primary partitions # Primary partitions
available_device_size=$available_size available_device_size=$available_size
if [ "$type" = "extended" -o "$type" = "5" ]; then if [ "$type" = "extended" ] || [ "$type" = "5" ]; then
# Extended partition # Extended partition
available_extended_size=$partition_size available_extended_size=$partition_size
fi fi

View file

@ -18,7 +18,7 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>. # along with cdist. If not, see <http://www.gnu.org/licenses/>.
# #
options="$(cat "$__object/parameter/options")" # options="$(cat "$__object/parameter/options")"
#echo "reboot $options" #echo "reboot $options"
cat << DONE cat << DONE

View file

@ -19,5 +19,6 @@
# #
# set defaults # set defaults
options="$(cat "$__object/parameter/options" 2>/dev/null \ # options="$(cat "$__object/parameter/options" 2>/dev/null \
|| echo "" | tee "$__object/parameter/options")" # || echo "" | tee "$__object/parameter/options")"
[ -f "$__object/parameter/options" ] || touch "$__object/parameter/options"

View file

@ -19,5 +19,6 @@
# #
# set defaults # set defaults
target="$(cat "$__object/parameter/target" 2>/dev/null \ # target="$(cat "$__object/parameter/target" 2>/dev/null \
|| echo "/target" | tee "$__object/parameter/target")" # || echo "/target" | tee "$__object/parameter/target")"
cat "$__object/parameter/target" 2>/dev/null 1>/dev/null || echo "/target" > "$__object/parameter/target"

View file

@ -35,16 +35,16 @@ fi
jaildir="$(cat "$__object/parameter/jaildir")" jaildir="$(cat "$__object/parameter/jaildir")"
__directory ${jaildir} --parents __directory "${jaildir}" --parents
set -- "$@" "$__object_id" "--state" "$state" set -- "$@" "$__object_id" "--state" "$state"
cd "$__object/parameter" cd "$__object/parameter"
for property in $(ls .); do for property in *; do
set -- "$@" "--$property" "$(cat "$property")" set -- "$@" "--$property" "$(cat "$property")"
done done
ver="$(cat "$__global/explorer/os_version")" ver="$(cat "$__global/explorer/os_version")"
if [ -n "$(echo "$ver" | grep '^10\.' )" ]; then # Version is 10.x if echo "$ver" | grep -q '^10\.'; then # Version is 10.x
__jail_freebsd10 "$@" __jail_freebsd10 "$@"
else else
__jail_freebsd9 "$@" __jail_freebsd9 "$@"

View file

@ -44,7 +44,7 @@ basepresent="$(cat "$__object/explorer/basepresent")"
if [ "$state" = "present" ]; then if [ "$state" = "present" ]; then
if [ "$basepresent" = "NONE" ]; then if [ "$basepresent" = "NONE" ]; then
# IPv6 fix # IPv6 fix
if $(echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$') if echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$'
then then
my_target_host="[${__target_host}]" my_target_host="[${__target_host}]"
else else

View file

@ -36,7 +36,7 @@ state="$(cat "$__object/parameter/state")"
started="true" started="true"
# If the user wants the jail gone, it implies it shouldn't be started. # If the user wants the jail gone, it implies it shouldn't be started.
[ -f "$__object/parameter/stopped" -o "$state" = "absent" ] && started="false" ([ -f "$__object/parameter/stopped" ] || [ "$state" = "absent" ]) && started="false"
if [ -f "$__object/parameter/ip" ]; then if [ -f "$__object/parameter/ip" ]; then
ip="$(cat "$__object/parameter/ip")" ip="$(cat "$__object/parameter/ip")"
@ -66,7 +66,7 @@ devfsruleset="$(cat "$__object/parameter/devfs-ruleset")"
# devfs_ruleset being defined without devfs_enable being true # devfs_ruleset being defined without devfs_enable being true
# is pointless. Treat this as an error. # is pointless. Treat this as an error.
if [ -n "$devfsruleset" -a "$devfsenable" = "false" ]; then if [ -n "$devfsruleset" ] && [ "$devfsenable" = "false" ]; then
exec >&2 exec >&2
echo "Can't have --devfs-ruleset defined with --devfs-disable" echo "Can't have --devfs-ruleset defined with --devfs-disable"
exit 1 exit 1
@ -83,13 +83,13 @@ present="$(cat "$__object/explorer/present")"
status="$(cat "$__object/explorer/status")" status="$(cat "$__object/explorer/status")"
# Handle ip="addr, addr" format # Handle ip="addr, addr" format
if [ $(expr "${ip}" : ".*, .*") -gt "0" ]; then if [ "$(expr "${ip}" : ".*, .*")" -gt "0" ]; then
SAVE_IFS="$IFS" SAVE_IFS="$IFS"
IFS=", " IFS=", "
for cur_ip in ${ip}; do # for cur_ip in ${ip}; do
# Just get the last IP address for SSH to listen on # Just get the last IP address for SSH to listen on
mgmt_ip=$(echo "${ip}" | cut '-d ' -f1) # In case using "ip netmask" format rather than CIDR mgmt_ip=$(echo "${ip}" | cut '-d ' -f1) # In case using "ip netmask" format rather than CIDR
done # done
IFS="$SAVE_IFS" IFS="$SAVE_IFS"
else else
mgmt_ip=$(echo "${ip}" | cut '-d ' -f1) # In case using "ip netmask" format rather than CIDR mgmt_ip=$(echo "${ip}" | cut '-d ' -f1) # In case using "ip netmask" format rather than CIDR
@ -130,14 +130,15 @@ deleteJail() {
fi fi
EOF EOF
# Remove the jail's rw mountpoints # Remove the jail's rw mountpoints
echo "rm -rf \"${jaildir}/rw/${name}\"" echo "rm -rf '${jaildir}/rw/${name}'"
# Remove the jail directory # Remove the jail directory
echo "rm -rf \"${jaildir}/${name}\"" echo "rm -rf '${jaildir}/${name}'"
# Remove the jail's fstab # Remove the jail's fstab
echo "rm -f \"/etc/fstab.${name}\"" echo "rm -f '/etc/fstab.${name}'"
# Remove jail entry from jail.conf # Remove jail entry from jail.conf
cat <<EOF cat <<EOF
sed -i .bak -E -e "/^${name} {\$/,/^}\\\$/d" /etc/jail.conf mv /etc/jail.conf /etc/jail.conf.bak
sed -E -e "/^${name} {\$/,/^}\\\$/d" /etc/jail.conf.bak > /etc/jail.conf
if [ -f "/etc/jail.conf.bak" ]; then if [ -f "/etc/jail.conf.bak" ]; then
rm -f "/etc/jail.conf.bak" rm -f "/etc/jail.conf.bak"
fi fi
@ -153,7 +154,8 @@ EOF
done done
jail_list="\${new_list}" jail_list="\${new_list}"
sed -i '.bak' "s/^jail_list=\".*\"/jail_list=\"\${jail_list}\"/" /etc/rc.conf mv /etc/rc.conf /etc/rc.conf.bak
sed "s/^jail_list=\".*\"/jail_list=\"\${jail_list}\"/" /etc/rc.conf.bak > /etc/rc.conf
unset jail_list unset jail_list
if [ -f "/etc/rc.conf.bak" ]; then if [ -f "/etc/rc.conf.bak" ]; then
rm -f /etc/rc.conf.bak rm -f /etc/rc.conf.bak
@ -239,7 +241,8 @@ cat <<EOF
if [ -z "\$jail_enable" ]; then # no jail_enable line in rc.conf at all if [ -z "\$jail_enable" ]; then # no jail_enable line in rc.conf at all
echo "jail_enable=\"YES\"" >>/etc/rc.conf echo "jail_enable=\"YES\"" >>/etc/rc.conf
elif [ ! "\$(echo \$jail_enable | tr '[a-z]' '[A-Z]' | tr -d '"')" = "YES" ]; then # jail_enable="NO" elif [ ! "\$(echo \$jail_enable | tr '[a-z]' '[A-Z]' | tr -d '"')" = "YES" ]; then # jail_enable="NO"
sed -i '.bak' 's/^jail_enable=.*$/jail_enable="YES"/g' /etc/rc.conf # fix this -^ mv /etc/rc.conf /etc/rc.conf.bak
sed 's/^jail_enable=.*$/jail_enable="YES"/g' /etc/rc.conf.bak > /etc/rc.conf # fix this -^
rm -f /etc/rc.conf.bak rm -f /etc/rc.conf.bak
fi fi
@ -313,7 +316,8 @@ if [ "$onboot" = "yes" ]; then
echo "jail_list=\"${name}\"" >>/etc/rc.conf echo "jail_list=\"${name}\"" >>/etc/rc.conf
else else
jail_list="\${jail_list} ${name}" jail_list="\${jail_list} ${name}"
sed -i '.bak' "s/^jail_list=\".*\"/jail_list=\"\${jail_list}\"/" /etc/rc.conf mv /etc/rc.conf /etc/rc.conf.bak
sed "s/^jail_list=\".*\"/jail_list=\"\${jail_list}\"/" /etc/rc.conf.bak > /etc/rc.conf
rm -f /etc/rc.conf.bak rm -f /etc/rc.conf.bak
fi fi
unset jail_list unset jail_list

View file

@ -40,7 +40,7 @@ basepresent="$(cat "$__object/explorer/basepresent")"
if [ "$state" = "present" ]; then if [ "$state" = "present" ]; then
if [ "$basepresent" = "NONE" ]; then if [ "$basepresent" = "NONE" ]; then
# IPv6 fix # IPv6 fix
if $(echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$') if echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$'
then then
my_target_host="[${__target_host}]" my_target_host="[${__target_host}]"
else else

View file

@ -36,7 +36,7 @@ state="$(cat "$__object/parameter/state")"
started="true" started="true"
# If the user wants the jail gone, it implies it shouldn't be started. # If the user wants the jail gone, it implies it shouldn't be started.
[ -f "$__object/parameter/stopped" -o "$state" = "absent" ] && started="false" ([ -f "$__object/parameter/stopped" ] || [ "$state" = "absent" ]) && started="false"
if [ -f "$__object/parameter/ip" ]; then if [ -f "$__object/parameter/ip" ]; then
ip="$(cat "$__object/parameter/ip")" ip="$(cat "$__object/parameter/ip")"
@ -70,7 +70,7 @@ devfsruleset="$(cat "$__object/parameter/devfs-ruleset")"
# devfs_ruleset being defined without devfs_enable being true # devfs_ruleset being defined without devfs_enable being true
# is pointless. Treat this as an error. # is pointless. Treat this as an error.
if [ -n "$devfsruleset" -a "$devfsenable" = "false" ]; then if [ -n "$devfsruleset" ] && [ "$devfsenable" = "false" ]; then
exec >&2 exec >&2
echo "Can't have --devfs-ruleset defined with --devfs-disable" echo "Can't have --devfs-ruleset defined with --devfs-disable"
exit 1 exit 1
@ -86,15 +86,15 @@ present="$(cat "$__object/explorer/present")"
status="$(cat "$__object/explorer/status")" status="$(cat "$__object/explorer/status")"
# Handle ip="iface|addr, iface|addr" format # Handle ip="iface|addr, iface|addr" format
if [ $(expr "${ip}" : ".*|.*") -gt "0" ]; then if [ "$(expr "${ip}" : ".*|.*")" -gt "0" ]; then
# If we have multiple IPs defined, $interface doesn't make sense because ip="iface|addr, iface|addr" implies it # If we have multiple IPs defined, $interface doesn't make sense because ip="iface|addr, iface|addr" implies it
interface="" interface=""
SAVE_IFS="$IFS" SAVE_IFS="$IFS"
IFS=", " IFS=", "
for cur_ip in ${ip}; do # for cur_ip in ${ip}; do
# Just get the last IP address for SSH to listen on # Just get the last IP address for SSH to listen on
mgmt_ip=$(echo "${ip}" | sed -E -e 's/^.*\|(.*)\/[0-9]+$/\1/') mgmt_ip=$(echo "${ip}" | sed -E -e 's/^.*\|(.*)\/[0-9]+$/\1/')
done # done
IFS="$SAVE_IFS" IFS="$SAVE_IFS"
else else
mgmt_ip=$(echo "${ip}" | cut '-d ' -f1) mgmt_ip=$(echo "${ip}" | cut '-d ' -f1)
@ -135,14 +135,15 @@ deleteJail() {
fi fi
EOF EOF
# Remove the jail's rw mountpoints # Remove the jail's rw mountpoints
echo "rm -rf \"${jaildir}/rw/${name}\"" echo "rm -rf '${jaildir}/rw/${name}'"
# Remove the jail directory # Remove the jail directory
echo "rm -rf \"${jaildir}/${name}\"" echo "rm -rf '${jaildir}/${name}'"
# Remove the jail's fstab # Remove the jail's fstab
echo "rm -f \"/etc/fstab.${name}\"" echo "rm -f '/etc/fstab.${name}'"
# Remove jail_$name_* lines from rc.conf # Remove jail_$name_* lines from rc.conf
cat <<EOF cat <<EOF
sed -i '.bak' "/^jail_${name}_/d" /etc/rc.conf mv /etc/rc.conf /etc/rc.conf.bak
sed "/^jail_${name}_/d" /etc/rc.conf.bak > /etc/rc.conf
if [ -f "/etc/rc.conf.bak" ]; then if [ -f "/etc/rc.conf.bak" ]; then
rm -f /etc/rc.conf.bak rm -f /etc/rc.conf.bak
fi fi
@ -158,7 +159,8 @@ EOF
done done
jail_list="\${new_list}" jail_list="\${new_list}"
sed -i '.bak' "s/^jail_list=\".*\"/jail_list=\"\${jail_list}\"/" /etc/rc.conf mv /etc/rc.conf /etc/rc.conf.bak
sed "s/^jail_list=\".*\"/jail_list=\"\${jail_list}\"/" /etc/rc.conf.bak > /etc/rc.conf
unset jail_list unset jail_list
if [ -f "/etc/rc.conf.bak" ]; then if [ -f "/etc/rc.conf.bak" ]; then
rm -f /etc/rc.conf.bak rm -f /etc/rc.conf.bak
@ -241,7 +243,8 @@ cat <<EOF
if [ -z "\$jail_enable" ]; then # no jail_enable line in rc.conf at all if [ -z "\$jail_enable" ]; then # no jail_enable line in rc.conf at all
echo "jail_enable=\"YES\"" >>/etc/rc.conf echo "jail_enable=\"YES\"" >>/etc/rc.conf
elif [ ! "\$(echo \$jail_enable | tr '[a-z]' '[A-Z]')" = "YES" ]; then # jail_enable="NO" elif [ ! "\$(echo \$jail_enable | tr '[a-z]' '[A-Z]')" = "YES" ]; then # jail_enable="NO"
sed -i '.bak' 's/^jail_enable=.*$/jail_enable="YES"/g' /etc/rc.conf # fix this -^ mv /etc/rc.conf /etc/rc.conf.bak
sed 's/^jail_enable=.*$/jail_enable="YES"/g' /etc/rc.conf.bak > /etc/rc.conf # fix this -^
rm -f /etc/rc.conf.bak rm -f /etc/rc.conf.bak
fi fi
cat >>/etc/rc.conf <<END cat >>/etc/rc.conf <<END
@ -309,7 +312,8 @@ if [ "$onboot" = "yes" ]; then
echo "jail_list=\"${name}\"" >>/etc/rc.conf echo "jail_list=\"${name}\"" >>/etc/rc.conf
else else
jail_list="\${jail_list} ${name}" jail_list="\${jail_list} ${name}"
sed -i '.bak' "s/^jail_list=\".*\"/jail_list=\"\${jail_list}\"/" /etc/rc.conf mv /etc/rc.conf /etc/rc.conf.bak
sed "s/^jail_list=\".*\"/jail_list=\"\${jail_list}\"/" /etc/rc.conf.bak > /etc/rc.conf
rm -f /etc/rc.conf.bak rm -f /etc/rc.conf.bak
fi fi
unset jail_list unset jail_list

View file

@ -21,7 +21,7 @@
state_should="$(cat "$__object/parameter/state")" state_should="$(cat "$__object/parameter/state")"
if [ "$state_should" = "present" -a ! -f "$__object/parameter/value" ]; then if [ "$state_should" = "present" ] && [ ! -f "$__object/parameter/value" ]; then
echo "Missing required parameter 'value'" >&2 echo "Missing required parameter 'value'" >&2
exit 1 exit 1
fi fi

View file

@ -34,13 +34,13 @@ case "$os" in
__key_value KEYTABLE \ __key_value KEYTABLE \
--file /etc/sysconfig/keyboard \ --file /etc/sysconfig/keyboard \
--delimiter '=' \ --delimiter '=' \
--value "\"$keyboard_type\"" --value "'$keyboard_type'"
require="__file/etc/sysconfig/keyboard" \ require="__file/etc/sysconfig/keyboard" \
__key_value LAYOUT \ __key_value LAYOUT \
--file /etc/sysconfig/keyboard \ --file /etc/sysconfig/keyboard \
--delimiter '=' \ --delimiter '=' \
--value "\"$keyboard_type\"" --value "'$keyboard_type'"
;; ;;
*) *)
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2

View file

@ -32,7 +32,7 @@ elif [ -f "$destination" ]; then
case "$type" in case "$type" in
hard) hard)
link_count=$(ls -l "$destination" | awk '{ print $2 }') link_count=$(ls -l "$destination" | awk '{ print $2 }')
if [ $link_count -gt 1 ]; then if [ "$link_count" -gt 1 ]; then
echo hardlink echo hardlink
exit 0 exit 0
fi fi

View file

@ -61,7 +61,7 @@ case "$state_should" in
;; ;;
absent) absent)
# only delete if it is a sym/hard link # only delete if it is a sym/hard link
if [ "$file_type" = "symlink" -o "$file_type" = "hardlink" ]; then if [ "$file_type" = "symlink" ] || [ "$file_type" = "hardlink" ]; then
printf 'rm -f "%s"\n' "$destination" printf 'rm -f "%s"\n' "$destination"
fi fi
;; ;;

View file

@ -21,7 +21,7 @@
# Retrieve the status of a package - parsed dpkg output # Retrieve the status of a package - parsed dpkg output
# #
if [ "$($__explorer/os)" = "freebsd" ]; then if [ "$("${__explorer}"/os)" = "freebsd" ]; then
command -v pkg command -v pkg
fi fi

View file

@ -55,8 +55,8 @@ state="$(cat "$__object/parameter/state")"
set -- "$@" "$__object_id" "--state" "$state" set -- "$@" "$__object_id" "--state" "$state"
cd "$__object/parameter" cd "$__object/parameter"
for property in $(ls .); do for property in *; do
if [ "$property" != "type" -a "$property" != "state" ]; then if [ "$property" != "type" ] && [ "$property" != "state" ]; then
set -- "$@" "--$property" "$(cat "$property")" set -- "$@" "--$property" "$(cat "$property")"
fi fi
done done

View file

@ -64,7 +64,7 @@ esac
# Hint if we need to avoid questions at some point: # Hint if we need to avoid questions at some point:
# DEBIAN_PRIORITY=critical can reduce the number of questions # DEBIAN_PRIORITY=critical can reduce the number of questions
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold"
if [ "$state_is" = "$state_should" ]; then if [ "$state_is" = "$state_should" ]; then
if [ -z "$version" ] || [ "$version" = "$version_is" ]; then if [ -z "$version" ] || [ "$version" = "$version_is" ]; then

View file

@ -38,11 +38,11 @@ fi
pkg_version="$(cat "$__object/explorer/pkg_version")" pkg_version="$(cat "$__object/explorer/pkg_version")"
if [ -z "$pkg_version" ]; then if [ -z "$pkg_version" ]; then
state_is="absent" state_is="absent"
elif [ -z "$version" -a $(echo "$pkg_version" | wc -l) -gt 1 ]; then elif [ -z "$version" ] && [ "$(echo "$pkg_version" | wc -l)" -gt 1 ]; then
echo "Package name is not unique! The following packages are installed:" echo "Package name is not unique! The following packages are installed:"
echo "$pkg_version" echo "$pkg_version"
exit 1 exit 1
elif [ -n "$version" -a $(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l) -gt 1 ]; then elif [ -n "$version" ] && [ "$(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l)" -gt 1 ]; then
echo "Package name is not unique! The following packages are installed:" echo "Package name is not unique! The following packages are installed:"
echo "$pkg_version" echo "$pkg_version"
exit 1 exit 1
@ -63,10 +63,10 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo "emerge \"$name\" &>/dev/null || exit 1" echo "emerge '$name' &>/dev/null || exit 1"
;; ;;
absent) absent)
echo "emerge -C \"$name\" &>/dev/null || exit 1" echo "emerge -C '$name' &>/dev/null || exit 1"
;; ;;
*) *)
echo "Unknown state: $state_should" >&2 echo "Unknown state: $state_should" >&2

View file

@ -42,10 +42,10 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo luarocks install \"$name\" echo "luarocks install '$name'"
;; ;;
absent) absent)
echo luarocks remove \"$name\" echo "luarocks remove '$name'"
;; ;;
*) *)
echo "Unknown state: $state_should" >&2 echo "Unknown state: $state_should" >&2

View file

@ -43,12 +43,12 @@ esac
case "$state_should" in case "$state_should" in
present) present)
if [ "$present" = "notpresent" ]; then if [ "$present" = "notpresent" ]; then
echo opkg --verbosity=0 update echo "opkg --verbosity=0 update"
fi fi
echo opkg --verbosity=0 install \"$name\" echo "opkg --verbosity=0 install '$name'"
;; ;;
absent) absent)
echo opkg --verbosity=0 remove \"$name\" echo "opkg --verbosity=0 remove '$name'"
;; ;;
*) *)
echo "Unknown state: $state" >&2 echo "Unknown state: $state" >&2

View file

@ -45,10 +45,10 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo pacman --needed --noconfirm --noprogressbar -S \"$name\" echo "pacman --needed --noconfirm --noprogressbar -S '$name'"
;; ;;
absent) absent)
echo pacman --noconfirm --noprogressbar -R \"$name\" echo "pacman --noconfirm --noprogressbar -R '$name'"
;; ;;
*) *)
echo "Unknown state: $state_should" >&2 echo "Unknown state: $state_should" >&2

View file

@ -53,7 +53,7 @@ case "$state_should" in
present) present)
if [ "$runas" ] if [ "$runas" ]
then then
echo "su -c \"$pip install -q $name\" $runas" echo "su -c '$pip install -q $name' '$runas'"
else else
echo $pip install -q "$name" echo $pip install -q "$name"
fi fi
@ -61,7 +61,7 @@ case "$state_should" in
absent) absent)
if [ "$runas" ] if [ "$runas" ]
then then
echo "su -c \"$pip uninstall -q -y $name\" $runas" echo "su -c '$pip uninstall -q -y $name' '$runas'"
else else
echo $pip uninstall -q -y "$name" echo $pip uninstall -q -y "$name"
fi fi

View file

@ -30,10 +30,10 @@ fi
# Don't produce "no pkgs installed" output -- breaks things # Don't produce "no pkgs installed" output -- breaks things
PKG_OUTPUT=$(pkg_info 2>&1) PKG_OUTPUT=$(pkg_info 2>&1)
if [ ! "$PKG_OUTPUT" = "pkg_info: no packages installed" ]; then if [ ! "$PKG_OUTPUT" = "pkg_info: no packages installed" ]; then
echo -n "$(echo "$PKG_OUTPUT" \ printf "%s" "$PKG_OUTPUT" \
| awk '{print $1}' \ | awk '{print $1}' \
| sed 's/^\(.*\)-\([^-]*\)$/name:\1 ver:\2/g' \ | sed 's/^\(.*\)-\([^-]*\)$/name:\1 ver:\2/g' \
| grep "name:$name ver:" \ | grep "name:$name ver:" \
| sed 's/^.*ver:\(.*\)/\1/g')" | sed 's/^.*ver:\(.*\)/\1/g'
fi fi

View file

@ -23,20 +23,12 @@
assert () # If condition false, assert () # If condition false,
{ #+ exit from script with error message. { #+ exit from script with error message.
E_PARAM_ERR=98
E_ASSERT_FAILED=99 E_ASSERT_FAILED=99
if [ -z "$2" ] # Not enough parameters passed. if [ ! "$1" ]
then then
return $E_PARAM_ERR # No damage done. echo "Assertion failed: '$1'"
fi echo "File '$0'"
lineno=$2
if [ ! $1 ]
then
echo "Assertion failed: \"$1\""
echo "File \"$0\", line $lineno, called by $(caller 0)"
exit $E_ASSERT_FAILED exit $E_ASSERT_FAILED
fi fi
} }
@ -66,18 +58,20 @@ cmd=""
# FIXME: This is ugly. # FIXME: This is ugly.
execcmd(){ execcmd(){
# Set the PACKAGESITE if we're ADDing a new package # Set the PACKAGESITE if we're ADDing a new package
if [ "$1" = "add" -a -n "$pkgsite" ]; then if [ "$1" = "add" ] && [ -n "$pkgsite" ]; then
# Use http.../All/ if we know the exact version we want, use .../Latest/ otherwise # Use http.../All/ if we know the exact version we want, use .../Latest/ otherwise
pkgsite="export PACKAGESITE=${pkgsite}" pkgsite="export PACKAGESITE=${pkgsite}"
[ -n "$version" ] && pkgsite="${pkgsite}/All/" || pkgsite="${pkgsite}/Latest/" [ -n "$version" ] && pkgsite="${pkgsite}/All/" || pkgsite="${pkgsite}/Latest/"
echo "${pkgsite}" echo "${pkgsite}"
fi fi
echo "${2} 2>&- >&-" # Silence the output of the command cat <<EOF
echo "status=\$?" ${2} 2>&- >&- # Silence the output of the command
echo "if [ \"\$status\" -ne \"0\" ]; then" status=\$?
echo " echo \"Error: ${cmd} exited nonzero with \$status\"'!' >&2" if [ "\$status" -ne "0" ]; then
echo " exit 1" echo "Error: ${cmd} exited nonzero with \$status!" >&2
echo "fi" exit 1
fi
EOF
} }
if [ -n "$curr_version" ]; then # PKG *is* installed if [ -n "$curr_version" ]; then # PKG *is* installed
@ -95,7 +89,7 @@ if [ -n "$curr_version" ]; then # PKG *is* installed
exit 0 exit 0
else # Current version is wrong, fix else # Current version is wrong, fix
#updatepkg "$name" "$version" #updatepkg "$name" "$version"
assert "! ${version} = ${curr_version}" $LINENO assert "! ${version} = ${curr_version}"
cmd="${rm_cmd} ${name}-${curr_version}" cmd="${rm_cmd} ${name}-${curr_version}"
execcmd "remove" "${cmd}" execcmd "remove" "${cmd}"
cmd="${add_cmd} -r ${name}-${version}" cmd="${add_cmd} -r ${name}-${version}"

View file

@ -46,7 +46,7 @@ else
name="$__object_id" name="$__object_id"
fi fi
if [ -n "$version" -a -n "$flavor" ]; then if [ -n "$version" ] && [ -n "$flavor" ]; then
pkgid="$name-$version-$flavor" pkgid="$name-$version-$flavor"
elif [ -n "$version" ]; then elif [ -n "$version" ]; then
pkgid="$name-$version" pkgid="$name-$version"

View file

@ -29,9 +29,9 @@ fi
# Don't produce "no pkgs installed" output -- breaks things # Don't produce "no pkgs installed" output -- breaks things
PKG_OUTPUT=$(pkg info 2>&1) PKG_OUTPUT=$(pkg info 2>&1)
echo -n "$(echo "$PKG_OUTPUT" \ printf "%s" "$PKG_OUTPUT" \
| awk '{print $1}' \ | awk '{print $1}' \
| sed 's/^\(.*\)-\([^-]*\)$/name:\1 ver:\2/g' \ | sed 's/^\(.*\)-\([^-]*\)$/name:\1 ver:\2/g' \
| grep "name:$name ver:" \ | grep "name:$name ver:" \
| sed 's/^.*ver:\(.*\)/\1/g')" | sed 's/^.*ver:\(.*\)/\1/g'

View file

@ -52,7 +52,7 @@ cmd=""
# Parms: $1 -- mode, "rm", "add", or "upg" # Parms: $1 -- mode, "rm", "add", or "upg"
# $2 -- the command to be echoed # $2 -- the command to be echoed
execcmd(){ execcmd(){
local _cmd="" _cmd=""
case "$1" in case "$1" in
add) add)

View file

@ -39,10 +39,10 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo gem install \"$name\" --no-ri --no-rdoc echo "gem install '$name' --no-ri --no-rdoc"
;; ;;
absent) absent)
echo gem uninstall \"$name\" echo "gem uninstall '$name'"
;; ;;
*) *)
echo "Unknown state: $state_should" >&2 echo "Unknown state: $state_should" >&2

View file

@ -44,7 +44,7 @@ else
esac esac
fi fi
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold"
case "$type" in case "$type" in
yum) yum)
@ -53,8 +53,8 @@ case "$type" in
;; ;;
apt) apt)
if [ -f "$apt_dist_upgrade" ] if [ -f "$apt_dist_upgrade" ]
then echo $aptget dist-upgrade then echo "$aptget dist-upgrade"
else echo $aptget upgrade else echo "$aptget upgrade"
fi fi
if [ -f "$apt_clean" ] if [ -f "$apt_clean" ]

View file

@ -60,10 +60,10 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo yum $opts install \"$install_name\" echo "yum $opts install '$install_name'"
;; ;;
absent) absent)
echo yum $opts remove \"$name\" echo "yum $opts remove '$name'"
;; ;;
*) *)
echo "Unknown state: $state_should" >&2 echo "Unknown state: $state_should" >&2

View file

@ -61,15 +61,15 @@ case "$state_should" in
present) present)
if [ -z "$version_should" ]; then if [ -z "$version_should" ]; then
[ "$state_is" = "present" ] && exit 0 # if state is present, we dont need to do anything [ "$state_is" = "present" ] && exit 0 # if state is present, we dont need to do anything
echo zypper $globalopts install --type \"$ptype\" --auto-agree-with-licenses \"$name\" ">/dev/null" echo "zypper $globalopts install --type '$ptype' --auto-agree-with-licenses '$name' >/dev/null"
else else
[ "$state_is" = "present" ] && [ "$version_should" = "$version_is" ] && exit 0 # if state is present and version is correct, we dont need to do anything [ "$state_is" = "present" ] && [ "$version_should" = "$version_is" ] && exit 0 # if state is present and version is correct, we dont need to do anything
echo zypper $globalopts install --oldpackage --type \"$ptype\" --auto-agree-with-licenses \"$name\" = \"$version_should\" ">/dev/null" echo "zypper $globalopts install --oldpackage --type '$ptype' --auto-agree-with-licenses '$name' = '$version_should' >/dev/null"
fi fi
;; ;;
absent) absent)
[ "$state_is" = "absent" ] && exit 0 # if state is absent, we dont need to do anything [ "$state_is" = "absent" ] && exit 0 # if state is absent, we dont need to do anything
echo zypper $globalopts remove --type \"$ptype\" \"$name\" ">/dev/null" echo "zypper $globalopts remove --type '$ptype' '$name' >/dev/null"
;; ;;
*) *)
echo "Unknown state: $state_should" >&2 echo "Unknown state: $state_should" >&2

View file

@ -59,13 +59,13 @@ if [ "${file}" ]; then
if [ "${state}" = "present" ]; then if [ "${state}" = "present" ]; then
require="__file/${sec_path}/plain_file_${file}" __key_value ${file}_${key}\ require="__file/${sec_path}/plain_file_${file}" __key_value "${file}_${key}"\
--file ${sec_path}/plain_file_${file} --key ${key} --value ${value} --delimiter ' = ' --file "${sec_path}/plain_file_${file}" --key "${key}" --value "${value}" --delimiter ' = '
exit 0 exit 0
elif [ "${state}" = "absent" ]; then elif [ "${state}" = "absent" ]; then
require="__file/${sec_path}/plain_file_${file}" __key_value ${file}_${key}\ require="__file/${sec_path}/plain_file_${file}" __key_value "${file}_${key}"\
--state absent --state absent
exit 0 exit 0
@ -87,19 +87,19 @@ eof
if [ "${MATCH}" -eq 1 ]; then if [ "${MATCH}" -eq 1 ]; then
if [ "${value}" = "on" ]; then if [ "${value}" = "on" ]; then
require="__file/${sec_path}/${section}" __line ${key}_${value}\ require="__file/${sec_path}/${section}" __line "${key}_${value}"\
--file ${sec_path}/${section} --line ${key} --file "${sec_path}/${section}" --line "${key}"
elif [ "${value}" = "off" ]; then elif [ "${value}" = "off" ]; then
require="__file/${sec_path}/${section}" __line ${key}_${value}\ require="__file/${sec_path}/${section}" __line "${key}_${value}"\
--file ${sec_path}/${section} --line ${key} --state absent --file "${sec_path}/${section}" --line "${key}" --state absent
fi fi
else else
contains_element "${key}" "${allowed_option_keys}" contains_element "${key}" "${allowed_option_keys}"
if [ "${MATCH}" -eq 1 ]; then if [ "${MATCH}" -eq 1 ]; then
require="__file/${sec_path}/${section}" __key_value ${section}_${key}\ require="__file/${sec_path}/${section}" __key_value "${section}_${key}"\
--file ${sec_path}/${section} --key ${key} --value ${value} --delimiter ' = ' --file "${sec_path}/${section}" --key "${key}" --value "${value}" --delimiter ' = '
else else
echo "Key: ${key} is not valid. Have a look at man pacman.conf" >&2 echo "Key: ${key} is not valid. Have a look at man pacman.conf" >&2
fi fi
@ -118,12 +118,12 @@ eof
exit exit
fi fi
require="__file/${sec_path}/repo_${section}" __key_value ${section}_${key}\ require="__file/${sec_path}/repo_${section}" __key_value "${section}_${key}"\
--file ${sec_path}/repo_${section} --key ${key} --value ${value} --delimiter ' = ' --file "${sec_path}/repo_${section}" --key "${key}" --value "${value}" --delimiter ' = '
elif [ "${state}" = "absent" ]; then elif [ "${state}" = "absent" ]; then
require="__file/${sec_path}/repo_${section}" __key_value ${section}_${key}\ require="__file/${sec_path}/repo_${section}" __key_value "${section}_${key}"\
--state absent --state absent
else else

View file

@ -18,16 +18,16 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>. # along with cdist. If not, see <http://www.gnu.org/licenses/>.
# #
state=$(cat $__object/parameter/state 2>/dev/null) state="$(cat "$__object/parameter/state" 2>/dev/null)"
path="/etc/" # path="/etc/"
if [ "${state}" = "present" ]; then if [ "${state}" = "present" ]; then
__file /etc/pacman.conf\ __file /etc/pacman.conf\
--owner root --group root --mode 644 --source $__type/files/pacman.conf.cdist --owner root --group root --mode 644 --source "$__type/files/pacman.conf.cdist"
__file /etc/pacman.d/options\ __file /etc/pacman.d/options\
--owner root --group root --mode 644 --source $__type/files/options --owner root --group root --mode 644 --source "$__type/files/options"
__file /etc/pacman.d/repo_empty_placeholder\ __file /etc/pacman.d/repo_empty_placeholder\
--owner root --group root --mode 644 --owner root --group root --mode 644
@ -38,10 +38,10 @@ if [ "${state}" = "present" ]; then
elif [ "${state}" = "absent" ]; then elif [ "${state}" = "absent" ]; then
__file /etc/pacman.conf\ __file /etc/pacman.conf\
--owner root --group root --mode 644 --source $__type/files/pacman.conf.pacman --owner root --group root --mode 644 --source "$__type/files/pacman.conf.pacman"
__file /etc/pacman.d/mirrorlist\ __file /etc/pacman.d/mirrorlist\
--owner root --group root --mode 644 --source $__type/files/mirrorlist --owner root --group root --mode 644 --source "$__type/files/mirrorlist"
__file /etc/pacman.d/options\ __file /etc/pacman.d/options\
--state absent --state absent

View file

@ -29,7 +29,7 @@
RC="/etc/rc.conf" RC="/etc/rc.conf"
PFCONF="$(grep '^pf_rules=' ${RC} | cut -d= -f2 | sed 's/"//g')" PFCONF="$(grep '^pf_rules=' ${RC} | cut -d= -f2 | sed 's/"//g')"
echo ${PFCONF:-"/etc/pf.conf"} echo "${PFCONF:-"/etc/pf.conf"}"
# Debug # Debug
#set +x #set +x

View file

@ -33,7 +33,7 @@ TMP="$(grep '^pf_rules=' ${RC} | cut -d= -f2 | sed 's/"//g')"
PFCONF="${TMP:-"/etc/pf.conf"}" PFCONF="${TMP:-"/etc/pf.conf"}"
if [ -f "${PFCONF}" ]; then # The pf config file exists, find its cksum. if [ -f "${PFCONF}" ]; then # The pf config file exists, find its cksum.
cksum -o 1 ${PFCONF} | cut -d= -f2 | awk '{print $1}' cksum -o 1 "${PFCONF}" | cut -d= -f2 | awk '{print $1}'
fi fi
# Debug # Debug

View file

@ -29,7 +29,7 @@
RC="/etc/rc.conf" RC="/etc/rc.conf"
PFCONF="$(grep '^pf_rules=' ${RC} | cut -d= -f2 | sed 's/"//g')" PFCONF="$(grep '^pf_rules=' ${RC} | cut -d= -f2 | sed 's/"//g')"
echo ${PFCONF:-"/etc/pf.conf"} echo "${PFCONF:-"/etc/pf.conf"}"
# Debug # Debug
#set +x #set +x

View file

@ -54,7 +54,7 @@ case $uname in
currentSum=\$(cksum -o 1 ${source} | cut -d= -f2 | sed 's/ //g') currentSum=\$(cksum -o 1 ${source} | cut -d= -f2 | sed 's/ //g')
;; ;;
*) *)
echo "Sorry, I do not know how to find a cksum on ${UNAME}." >&2 echo "Sorry, I do not know how to find a cksum on ${uname}." >&2
exit 1 exit 1
;; ;;
esac esac

View file

@ -36,7 +36,7 @@ __postfix
# Default to object_id # Default to object_id
service="$(cat "$__object/parameter/service" 2>/dev/null || echo "$__object_id")" service="$(cat "$__object/parameter/service" 2>/dev/null || echo "$__object_id")"
state="$(cat "$__object/parameter/state")" # state="$(cat "$__object/parameter/state")"
# NOTE: keep variables in sync in manifest,explorer,gencode-* # NOTE: keep variables in sync in manifest,explorer,gencode-*
prefix="#cdist:$__object_name" prefix="#cdist:$__object_name"

View file

@ -20,7 +20,7 @@
name="$__object_id" name="$__object_id"
if su - postgres -c "echo '\q' | psql '$name'" 2>/dev/null; then if su -l postgres -c "echo '\q' | psql '$name'" 2>/dev/null; then
echo "present" echo "present"
else else
echo "absent" echo "absent"

View file

@ -29,10 +29,10 @@ if [ "$state_should" != "$state_is" ]; then
if [ -f "$__object/parameter/owner" ]; then if [ -f "$__object/parameter/owner" ]; then
owner="-O '$(cat "$__object/parameter/owner")'" owner="-O '$(cat "$__object/parameter/owner")'"
fi fi
echo "su - postgres -c \"createdb $owner '$name'\"" echo "su -l postgres -c \"createdb $owner '$name'\""
;; ;;
absent) absent)
echo "su - postgres -c \"dropdb '$name'\"" echo "su -l postgres -c \"dropdb '$name'\""
;; ;;
esac esac
fi fi

View file

@ -30,10 +30,10 @@ state_should=$( cat "$__object/parameter/state" )
case "$state_should" in case "$state_should" in
present) present)
cmd="CREATE EXTENSION IF NOT EXISTS $extension" cmd="CREATE EXTENSION IF NOT EXISTS $extension"
echo "su - postgres -c 'psql -c \"$cmd\" \"$dbname\"'" echo "su -l postgres -c 'psql -c \"$cmd\" \"$dbname\"'"
;; ;;
absent) absent)
cmd="DROP EXTENSION IF EXISTS $extenstion" cmd="DROP EXTENSION IF EXISTS $extenstion"
echo "su - postgres -c 'psql -c \"$cmd\" \"$dbname\"'" echo "su -l postgres -c 'psql -c \"$cmd\" \"$dbname\"'"
;; ;;
esac esac

View file

@ -20,7 +20,7 @@
name="$__object_id" name="$__object_id"
if su - postgres -c "psql -c '\du' | grep -q '^ *$name *|'"; then if su -l postgres -c "psql -c '\du' | grep -q '^ *$name *|'"; then
echo "present" echo "present"
else else
echo "absent" echo "absent"

View file

@ -34,16 +34,16 @@ case "$state_should" in
if [ ! -f "$__object/parameter/$boolean" ]; then if [ ! -f "$__object/parameter/$boolean" ]; then
boolean="no${boolean}" boolean="no${boolean}"
fi fi
upper=$(echo $boolean | tr '[a-z]' '[A-Z]') upper=$(echo $boolean | tr '[:lower:]' '[:upper:]')
booleans="$booleans $upper" booleans="$booleans $upper"
done done
[ -n "$password" ] && password="PASSWORD '$password'" [ -n "$password" ] && password="PASSWORD '$password'"
cmd="CREATE ROLE $name WITH $password $booleans" cmd="CREATE ROLE $name WITH $password $booleans"
echo "su - postgres -c \"psql -c \\\"$cmd\\\"\"" echo "su -l postgres -c \"psql -c \\\"$cmd\\\"\""
;; ;;
absent) absent)
echo "su - postgres -c \"dropuser \\\"$name\\\"\"" echo "su -l postgres -c \"dropuser \\\"$name\\\"\""
;; ;;
esac esac

View file

@ -2,7 +2,7 @@
export GOBIN=/opt/gocode/bin # where to find go binaries export GOBIN=/opt/gocode/bin # where to find go binaries
exporter="$(cat $__object/parameter/exporter)" exporter="$(cat "$__object/parameter/exporter")"
[ -z "$exporter" ] && exporter="$__object_id" [ -z "$exporter" ] && exporter="$__object_id"
__user prometheus --system __user prometheus --system
@ -18,7 +18,7 @@ case $exporter in
;; ;;
blackbox) blackbox)
require="$require __daemontools_service/${exporter}-exporter __user/prometheus" __config_file "/service/${exporter}-exporter/blackbox.yml" \ require="$require __daemontools_service/${exporter}-exporter __user/prometheus" __config_file "/service/${exporter}-exporter/blackbox.yml" \
--source $__type/files/blackbox.yml \ --source "$__type/files/blackbox.yml" \
--group prometheus --mode 640 \ --group prometheus --mode 640 \
--onchange "svc -h /service/${exporter}-exporter" --onchange "svc -h /service/${exporter}-exporter"
require="$require __golang_from_vendor" __go_get github.com/prometheus/blackbox_exporter require="$require __golang_from_vendor" __go_get github.com/prometheus/blackbox_exporter
@ -39,9 +39,9 @@ case $exporter in
;; ;;
esac esac
require="$require __daemontools" __daemontools_service ${exporter}-exporter --run "$run" require="$require __daemontools" __daemontools_service "${exporter}-exporter" --run "$run"
if [ -f "$__object/parameter/add-consul-service" ]; then if [ -f "$__object/parameter/add-consul-service" ]; then
__consul_service ${exporter}-exporter --port $port --check-http "http://localhost:$port/metrics" --check-interval 10s __consul_service "${exporter}-exporter" --port "$port" --check-http "http://localhost:$port/metrics" --check-interval 10s
fi fi
#__daemontools --install-init-script #__daemontools --install-init-script

View file

@ -13,7 +13,7 @@ storage_path="$(cat "$__object/parameter/storage-path")"
rule_files="$(cat "$__object/parameter/rule-files")" rule_files="$(cat "$__object/parameter/rule-files")"
# explorer in kB => convert; by default we go with 1/2 RAM # explorer in kB => convert; by default we go with 1/2 RAM
[ "$target_heap_size" = "auto" ] && target_heap_size=$(($(cat $__global/explorer/memory)*1024/2)) [ "$target_heap_size" = "auto" ] && target_heap_size=$(( "$(cat "$__global/explorer/memory")" * 1024 / 2 ))
##### INSTALL THE PACKAGE ################################################### ##### INSTALL THE PACKAGE ###################################################
@ -55,7 +55,7 @@ __key_value prometheus_args --file /etc/default/prometheus \
require="$require __directory/$storage_path $require_pkg" \ require="$require __directory/$storage_path $require_pkg" \
__config_file $CONF \ __config_file $CONF \
--source $config \ --source "$config" \
--group prometheus --mode 640 \ --group prometheus --mode 640 \
--onchange "promtool check config $CONF && service prometheus reload" --onchange "promtool check config $CONF && service prometheus reload"

View file

@ -2,4 +2,4 @@
destination="/$__object_id" destination="/$__object_id"
stat --print "%G" ${destination} 2>/dev/null || exit 0 stat --print "%G" "${destination}" 2>/dev/null || exit 0

View file

@ -2,4 +2,4 @@
destination="/$__object_id" destination="/$__object_id"
stat --print "%U" ${destination} 2>/dev/null || exit 0 stat --print "%U" "${destination}" 2>/dev/null || exit 0

View file

@ -29,10 +29,10 @@ owner="$(cat "$__object/parameter/owner")"
group="$(cat "$__object/parameter/group")" group="$(cat "$__object/parameter/group")"
mode="$(cat "$__object/parameter/mode")" mode="$(cat "$__object/parameter/mode")"
[ "$state_should" = "$state_is" -a \ [ "$state_should" = "$state_is" ] && \
"$owner" = "$owner_is" -a \ [ "$owner" = "$owner_is" ] && \
"$group" = "$group_is" -a \ [ "$group" = "$group_is" ] && \
-n "$mode" ] && exit 0 [ -n "$mode" ] && exit 0
destination="/$__object_id" destination="/$__object_id"
venvparams="$(cat "$__object/parameter/venvparams")" venvparams="$(cat "$__object/parameter/venvparams")"
@ -47,10 +47,10 @@ fi
case $state_should in case $state_should in
present) present)
if [ "$state_should" != "$state_is" ]; then if [ "$state_should" != "$state_is" ]; then
echo $pyvenv $venvparams "$destination" echo "$pyvenv" "$venvparams" "$destination"
fi fi
if [ \( -n "$owner" -a "$owner_is" != "$owner" \) -o \ if ([ -n "$owner" ] && [ "$owner_is" != "$owner" ]) || \
\( -n "$group" -a "$group_is" != "$group" \) ]; then ([ -n "$group" ] && [ "$group_is" != "$group" ]); then
echo chown -R "${owner}:${group}" "$destination" echo chown -R "${owner}:${group}" "$destination"
fi fi
if [ -n "$mode" ]; then if [ -n "$mode" ]; then

View file

@ -18,4 +18,4 @@ format="$(cat "$__object/parameter/format")"
size="$(cat "$__object/parameter/size")" size="$(cat "$__object/parameter/size")"
diskimage="/$__object_id" diskimage="/$__object_id"
echo qemu-img create -f \"$format\" \"$diskimage\" \"$size\" echo "qemu-img create -f '$format' '$diskimage' '$size'"

View file

@ -4,7 +4,7 @@
# Default settings # Default settings
# #
format="$(cat "$__object/parameter/format")" # format="$(cat "$__object/parameter/format")"
state_should="$(cat "$__object/parameter/state")" state_should="$(cat "$__object/parameter/state")"
diskimage="/$__object_id" diskimage="/$__object_id"

View file

@ -29,9 +29,9 @@ fi
set -- set --
if [ -f "$__object/parameter/rsync-opts" ]; then if [ -f "$__object/parameter/rsync-opts" ]; then
while read opts; do while read -r opts; do
set -- "$@" "--$opts" set -- "$@" "--$opts"
done < $__object/parameter/rsync-opts done < "$__object/parameter/rsync-opts"
fi fi
echo rsync -a \ echo rsync -a \

View file

@ -28,7 +28,7 @@ if [ "$user" = "root" ]; then
echo absent echo absent
fi fi
else else
if su - $user -c "[ -d \"\$HOME/.rvm\" ]" ; then if su -l "$user" -c "[ -d \"\$HOME/.rvm\" ]" ; then
echo "present" echo "present"
else else
echo "absent" echo "absent"

View file

@ -28,12 +28,12 @@ state_should="$(cat "$__object/parameter/state")"
case "$state_should" in case "$state_should" in
present) present)
cat << DONE cat << DONE
su - $user -c "unset rvm_path; unset rvm_bin_path; unset rvm_prefix; unset rvm_version; curl -L get.rvm.io | bash -s stable" su -l $user -c "unset rvm_path; unset rvm_bin_path; unset rvm_prefix; unset rvm_version; curl -L get.rvm.io | bash -s stable"
DONE DONE
;; ;;
absent) absent)
cat << DONE cat << DONE
su - $user -c "rm -Rf \"\\\$HOME/.rvm\"; su -l $user -c "rm -Rf \"\\\$HOME/.rvm\";
sed '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\" > \"\\\$HOME/.bashrc.cdist-tmp\" sed '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\" > \"\\\$HOME/.bashrc.cdist-tmp\"
mv \"\\\$HOME/.bashrc.cdist-tmp\" \"\\\$HOME/.bashrc\"" mv \"\\\$HOME/.bashrc.cdist-tmp\" \"\\\$HOME/.bashrc\""
DONE DONE

View file

@ -24,13 +24,13 @@ gemset="$(cat "$__object/parameter/gemset")"
ruby="$(echo "$gemset" | cut -d '@' -f 1)" ruby="$(echo "$gemset" | cut -d '@' -f 1)"
gemsetname="$(echo "$gemset" | cut -d '@' -f2)" gemsetname="$(echo "$gemset" | cut -d '@' -f2)"
user="$(cat "$__object/parameter/user")" user="$(cat "$__object/parameter/user")"
if su - "$user" -c "[ ! -d \"\$HOME/.rvm\" ]" ; then if su -l "$user" -c "[ ! -d \"\$HOME/.rvm\" ]" ; then
echo "absent" echo "absent"
exit 0 exit 0
fi fi
if su - "$user" -c "source \"\$HOME/.rvm/scripts/rvm\" if su -l "$user" -c "source \"\$HOME/.rvm/scripts/rvm\"
rvm list | grep -q $ruby"; then rvm list | grep -q $ruby"; then
if su - "$user" -c "source \"\$HOME/.rvm/scripts/rvm\" if su -l "$user" -c "source \"\$HOME/.rvm/scripts/rvm\"
rvm use $ruby > /dev/null 2>&1; rvm gemset list | grep -q $gemsetname && rvm use $ruby > /dev/null 2>&1; rvm gemset list | grep -q $gemsetname &&
rvm use $gemset > /dev/null 2>&1 && gem list | grep -q $gem"; then rvm use $gemset > /dev/null 2>&1 && gem list | grep -q $gem"; then
echo "present" echo "present"

Some files were not shown because too many files have changed in this diff Show more