forked from ungleich-public/cdist
		
	Merge pull request #711 from darko-poljak/shellcheck-rest
Shellcheck rest
This commit is contained in:
		
				commit
				
					
						791473cc2e
					
				
			
		
					 29 changed files with 46 additions and 38 deletions
				
			
		| 
						 | 
					@ -22,6 +22,7 @@
 | 
				
			||||||
set +e
 | 
					set +e
 | 
				
			||||||
case "$("$__explorer/os")" in
 | 
					case "$("$__explorer/os")" in
 | 
				
			||||||
   openwrt)
 | 
					   openwrt)
 | 
				
			||||||
 | 
					      # shellcheck disable=SC1091
 | 
				
			||||||
      (. /etc/openwrt_release && echo "$DISTRIB_CODENAME")
 | 
					      (. /etc/openwrt_release && echo "$DISTRIB_CODENAME")
 | 
				
			||||||
   ;;
 | 
					   ;;
 | 
				
			||||||
   *)
 | 
					   *)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@
 | 
				
			||||||
set +e
 | 
					set +e
 | 
				
			||||||
case "$("$__explorer/os")" in
 | 
					case "$("$__explorer/os")" in
 | 
				
			||||||
   openwrt)
 | 
					   openwrt)
 | 
				
			||||||
 | 
					      # shellcheck disable=SC1091
 | 
				
			||||||
      (. /etc/openwrt_release && echo "$DISTRIB_DESCRIPTION")
 | 
					      (. /etc/openwrt_release && echo "$DISTRIB_DESCRIPTION")
 | 
				
			||||||
   ;;
 | 
					   ;;
 | 
				
			||||||
   *)
 | 
					   *)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@
 | 
				
			||||||
set +e
 | 
					set +e
 | 
				
			||||||
case "$("$__explorer/os")" in
 | 
					case "$("$__explorer/os")" in
 | 
				
			||||||
   openwrt)
 | 
					   openwrt)
 | 
				
			||||||
 | 
					      # shellcheck disable=SC1091
 | 
				
			||||||
      (. /etc/openwrt_release && echo "$DISTRIB_ID")
 | 
					      (. /etc/openwrt_release && echo "$DISTRIB_ID")
 | 
				
			||||||
   ;;
 | 
					   ;;
 | 
				
			||||||
   *)
 | 
					   *)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@
 | 
				
			||||||
set +e
 | 
					set +e
 | 
				
			||||||
case "$("$__explorer/os")" in
 | 
					case "$("$__explorer/os")" in
 | 
				
			||||||
   openwrt)
 | 
					   openwrt)
 | 
				
			||||||
 | 
					      # shellcheck disable=SC1091
 | 
				
			||||||
      (. /etc/openwrt_release && echo "$DISTRIB_RELEASE")
 | 
					      (. /etc/openwrt_release && echo "$DISTRIB_RELEASE")
 | 
				
			||||||
   ;;
 | 
					   ;;
 | 
				
			||||||
   *)
 | 
					   *)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -58,7 +58,7 @@ state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo "present")"
 | 
				
			||||||
# These are the old markers
 | 
					# These are the old markers
 | 
				
			||||||
prefix="#cdist:__cron/$__object_id"
 | 
					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" '
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@ __directory "$servicedir" --mode 700
 | 
				
			||||||
os=$(cat "$__global/explorer/os")
 | 
					os=$(cat "$__global/explorer/os")
 | 
				
			||||||
init=$(cat "$__global/explorer/init")
 | 
					init=$(cat "$__global/explorer/init")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					require=""
 | 
				
			||||||
case $os in
 | 
					case $os in
 | 
				
			||||||
	freebsd)
 | 
						freebsd)
 | 
				
			||||||
		# TODO change to __start_on_boot once it supports freebsd
 | 
							# TODO change to __start_on_boot once it supports freebsd
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,6 +3,7 @@
 | 
				
			||||||
os=$(cat "$__global/explorer/os")
 | 
					os=$(cat "$__global/explorer/os")
 | 
				
			||||||
os_version=$(cat "$__global/explorer/os_version")
 | 
					os_version=$(cat "$__global/explorer/os_version")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					require=""
 | 
				
			||||||
case $os in
 | 
					case $os in
 | 
				
			||||||
    debian|devuan)
 | 
					    debian|devuan)
 | 
				
			||||||
        case $os_version in
 | 
					        case $os_version in
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -12,7 +12,7 @@ eof
 | 
				
			||||||
 | 
					
 | 
				
			||||||
coreos-install -d "${device}" \
 | 
					coreos-install -d "${device}" \
 | 
				
			||||||
	\$(if [ -s "\${ignition_file}" ]; then
 | 
						\$(if [ -s "\${ignition_file}" ]; then
 | 
				
			||||||
		printf -- "-i \${ignition_file}\n"
 | 
							printf -- "-i \${ignition_file}\\n"
 | 
				
			||||||
	fi)
 | 
						fi)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
rm "\${ignition_file}"
 | 
					rm "\${ignition_file}"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -67,5 +67,5 @@ fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# erase partition table
 | 
					# erase partition table
 | 
				
			||||||
dd if=/dev/zero of=$disk bs=512 count=1
 | 
					dd if=/dev/zero of=$disk bs=512 count=1
 | 
				
			||||||
printf 'w\n' | fdisk -u -c $disk || true
 | 
					printf 'w\\n' | fdisk -u -c $disk || true
 | 
				
			||||||
DONE
 | 
					DONE
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -37,7 +37,7 @@ jaildir="$(cat "$__object/parameter/jaildir")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__directory "${jaildir}" --parents
 | 
					__directory "${jaildir}" --parents
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set -- "$@" "$__object_id" "--state" "$state"
 | 
					set -- "$@" "$__object_id"
 | 
				
			||||||
cd "$__object/parameter"
 | 
					cd "$__object/parameter"
 | 
				
			||||||
for property in *; do
 | 
					for property in *; do
 | 
				
			||||||
	set -- "$@" "--$property" "$(cat "$property")"
 | 
						set -- "$@" "--$property" "$(cat "$property")"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,7 +45,7 @@ else
 | 
				
			||||||
#    when $state=present, it's required. Enforce this.
 | 
					#    when $state=present, it's required. Enforce this.
 | 
				
			||||||
   if [ "$state" = "present" ]; then
 | 
					   if [ "$state" = "present" ]; then
 | 
				
			||||||
      exec >&2
 | 
					      exec >&2
 | 
				
			||||||
      echo "If --state is 'present,' --ip must be given\!"
 | 
					      printf 'If --state is "present", --ip must be given\!\n'
 | 
				
			||||||
      exit 1
 | 
					      exit 1
 | 
				
			||||||
   fi
 | 
					   fi
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
| 
						 | 
					@ -114,19 +114,19 @@ startJail() {
 | 
				
			||||||
deleteJail() {
 | 
					deleteJail() {
 | 
				
			||||||
# Unmount the jail's mountpoints if necessary
 | 
					# Unmount the jail's mountpoints if necessary
 | 
				
			||||||
   cat <<EOF
 | 
					   cat <<EOF
 | 
				
			||||||
      output="\$(mount | grep "\/${name}\/dev")" || true
 | 
					      output="\$(mount | grep "\\/${name}\\/dev")" || true
 | 
				
			||||||
      if [ -n "\${output}" ]; then # /dev is still mounted...jail still running?
 | 
					      if [ -n "\${output}" ]; then # /dev is still mounted...jail still running?
 | 
				
			||||||
         /etc/rc.d/jail stop "${name}"
 | 
					         /etc/rc.d/jail stop "${name}"
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
      output="\$(mount | grep "\/rw\/${name}\/")" || true
 | 
					      output="\$(mount | grep "\\/rw\\/${name}\\/")" || true
 | 
				
			||||||
      if [ -n "\${output}" ]; then # >=1 rw mount is mounted still
 | 
					      if [ -n "\${output}" ]; then # >=1 rw mount is mounted still
 | 
				
			||||||
         for DIR in "${output}"; do
 | 
					         for DIR in "\${output}"; do
 | 
				
			||||||
            umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print \$3}')"
 | 
					            umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print \$3}')"
 | 
				
			||||||
         done
 | 
					         done
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
      output="\$(mount | grep "\/${name} (")" || true
 | 
					      output="\$(mount | grep "\\/${name} (")" || true
 | 
				
			||||||
      if [ -n "\${output}" ]; then # ro mount is mounted still
 | 
					      if [ -n "\${output}" ]; then # ro mount is mounted still
 | 
				
			||||||
         umount -F "/etc/fstab.${name}" "\$(echo "${output}" | awk '{print \$3}')"
 | 
					         umount -F "/etc/fstab.${name}" "\$(echo "\${output}" | awk '{print \$3}')"
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
# Remove the jail's rw mountpoints
 | 
					# Remove the jail's rw mountpoints
 | 
				
			||||||
| 
						 | 
					@ -275,9 +275,9 @@ cat <<EOF
 | 
				
			||||||
      if [ ! -f /etc/devfs.rules ]; then
 | 
					      if [ ! -f /etc/devfs.rules ]; then
 | 
				
			||||||
         touch /etc/devfs.rules
 | 
					         touch /etc/devfs.rules
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
      if [ -z "\$(grep '\[jailrules=' /etc/devfs.rules)" ]; then   # The default ruleset doesn't exist
 | 
					      if [ -z "\$(grep '\\[jailrules=' /etc/devfs.rules)" ]; then   # The default ruleset doesn't exist
 | 
				
			||||||
         # Get the highest-numbered ruleset
 | 
					         # Get the highest-numbered ruleset
 | 
				
			||||||
         highest="\$(sed -n 's/\[.*=\([0-9]*\)\]/\1/pg' /etc/devfs.rules | sort -u | tail -n 1)" || true
 | 
					         highest="\$(sed -n 's/\\[.*=\\([0-9]*\\)\\]/\\1/pg' /etc/devfs.rules | sort -u | tail -n 1)" || true
 | 
				
			||||||
         # increment by 1
 | 
					         # increment by 1
 | 
				
			||||||
         [ -z "\$highest" ] && highest=10
 | 
					         [ -z "\$highest" ] && highest=10
 | 
				
			||||||
         let num="\${highest}+1" 2>&1 >/dev/null   # Close the FD==fail...
 | 
					         let num="\${highest}+1" 2>&1 >/dev/null   # Close the FD==fail...
 | 
				
			||||||
| 
						 | 
					@ -290,7 +290,7 @@ add include \\\$devfsrules_unhide_basic
 | 
				
			||||||
add include \\\$devfsrules_unhide_login
 | 
					add include \\\$devfsrules_unhide_login
 | 
				
			||||||
END
 | 
					END
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
      devfsruleset_num=\$(grep "\[${devfsruleset}=" /etc/devfs.rules | sed -n 's/\[.*=\([0-9]*\)\]/\1/pg')
 | 
					      devfsruleset_num=\$(grep "\\[${devfsruleset}=" /etc/devfs.rules | sed -n 's/\\[.*=\\([0-9]*\\)\\]/\\1/pg')
 | 
				
			||||||
      if [ -n "\$devfsruleset_num" ]; then
 | 
					      if [ -n "\$devfsruleset_num" ]; then
 | 
				
			||||||
         jaildata="\$jaildata
 | 
					         jaildata="\$jaildata
 | 
				
			||||||
         devfs_ruleset=\"\${devfsruleset_num}\";"
 | 
					         devfs_ruleset=\"\${devfsruleset_num}\";"
 | 
				
			||||||
| 
						 | 
					@ -299,7 +299,7 @@ END
 | 
				
			||||||
 | 
					
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
   # shellcheck disable=SC2028
 | 
					   # shellcheck disable=SC2028
 | 
				
			||||||
   echo "printf \"%s\\n%s\n%s\n\" \"\$jailheader\" \"\$jaildata\" \"\$jailtrailer\" >>\"\$jailfile\""
 | 
					   echo "printf \"%s\\n%s\\n%s\\n\" \"\$jailheader\" \"\$jaildata\" \"\$jailtrailer\" >>\"\$jailfile\""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Add $name to jail_list if $onboot=yes
 | 
					# Add $name to jail_list if $onboot=yes
 | 
				
			||||||
if [ "$onboot" = "yes" ]; then
 | 
					if [ "$onboot" = "yes" ]; then
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,7 +45,7 @@ else
 | 
				
			||||||
#    when $state=present, it's required. Enforce this.
 | 
					#    when $state=present, it's required. Enforce this.
 | 
				
			||||||
   if [ "$state" = "present" ]; then
 | 
					   if [ "$state" = "present" ]; then
 | 
				
			||||||
      exec >&2
 | 
					      exec >&2
 | 
				
			||||||
      echo "If --state is 'present,' --ip must be given\!"
 | 
					      printf 'If --state is "present", --ip must be given\!\n'
 | 
				
			||||||
      exit 1
 | 
					      exit 1
 | 
				
			||||||
   fi
 | 
					   fi
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
| 
						 | 
					@ -119,19 +119,19 @@ startJail() {
 | 
				
			||||||
deleteJail() {
 | 
					deleteJail() {
 | 
				
			||||||
# Unmount the jail's mountpoints if necessary
 | 
					# Unmount the jail's mountpoints if necessary
 | 
				
			||||||
   cat <<EOF
 | 
					   cat <<EOF
 | 
				
			||||||
      output="\$(mount | grep "\/${name}\/dev")" || true
 | 
					      output="\$(mount | grep "\\/${name}\\/dev")" || true
 | 
				
			||||||
      if [ -n "\${output}" ]; then # /dev is still mounted...jail still running?
 | 
					      if [ -n "\${output}" ]; then # /dev is still mounted...jail still running?
 | 
				
			||||||
         /etc/rc.d/jail stop "${name}"
 | 
					         /etc/rc.d/jail stop "${name}"
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
      output="\$(mount | grep "\/rw\/${name}\/")" || true
 | 
					      output="\$(mount | grep "\\/rw\\/${name}\\/")" || true
 | 
				
			||||||
      if [ -n "\${output}" ]; then # >=1 rw mount is mounted still
 | 
					      if [ -n "\${output}" ]; then # >=1 rw mount is mounted still
 | 
				
			||||||
         for DIR in "${output}"; do
 | 
					         for DIR in "\${output}"; do
 | 
				
			||||||
            umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print \$3}')"
 | 
					            umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print \$3}')"
 | 
				
			||||||
         done
 | 
					         done
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
      output="\$(mount | grep "\/${name} (")" || true
 | 
					      output="\$(mount | grep "\\/${name} (")" || true
 | 
				
			||||||
      if [ -n "\${output}" ]; then # ro mount is mounted still
 | 
					      if [ -n "\${output}" ]; then # ro mount is mounted still
 | 
				
			||||||
         umount -F "/etc/fstab.${name}" "\$(echo "${output}" | awk '{print \$3}')"
 | 
					         umount -F "/etc/fstab.${name}" "\$(echo "\${output}" | awk '{print \$3}')"
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
# Remove the jail's rw mountpoints
 | 
					# Remove the jail's rw mountpoints
 | 
				
			||||||
| 
						 | 
					@ -279,9 +279,9 @@ END
 | 
				
			||||||
      if [ ! -f /etc/devfs.rules ]; then
 | 
					      if [ ! -f /etc/devfs.rules ]; then
 | 
				
			||||||
         touch /etc/devfs.rules
 | 
					         touch /etc/devfs.rules
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
      if [ -z "\$(grep '\[jailrules=' /etc/devfs.rules)" ]; then   # The default ruleset doesn't exist
 | 
					      if [ -z "\$(grep '\\[jailrules=' /etc/devfs.rules)" ]; then   # The default ruleset doesn't exist
 | 
				
			||||||
         # Get the highest-numbered ruleset
 | 
					         # Get the highest-numbered ruleset
 | 
				
			||||||
	 highest="\$(sed -n 's/\[.*=\([0-9]*\)\]/\1/pg' /etc/devfs.rules | sort -u | tail -n 1)" || true
 | 
						 highest="\$(sed -n 's/\\[.*=\\([0-9]*\\)\\]/\\1/pg' /etc/devfs.rules | sort -u | tail -n 1)" || true
 | 
				
			||||||
         # increment by 1
 | 
					         # increment by 1
 | 
				
			||||||
         let num="\${highest}+1" 2>&- >&-
 | 
					         let num="\${highest}+1" 2>&- >&-
 | 
				
			||||||
         # add default ruleset
 | 
					         # add default ruleset
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,7 +91,7 @@ if [ -f "${__object}/parameter/automatic-renewal" ]; then
 | 
				
			||||||
	renew_hook_param="${__object}/parameter/renew-hook"
 | 
						renew_hook_param="${__object}/parameter/renew-hook"
 | 
				
			||||||
	renew_hook=""
 | 
						renew_hook=""
 | 
				
			||||||
	if [ -f "${renew_hook_param}" ]; then
 | 
						if [ -f "${renew_hook_param}" ]; then
 | 
				
			||||||
		while read hook; do
 | 
							while read -r hook; do
 | 
				
			||||||
			renew_hook="${renew_hook} --renew-hook \"${hook}\""
 | 
								renew_hook="${renew_hook} --renew-hook \"${hook}\""
 | 
				
			||||||
		done < "${renew_hook_param}"
 | 
							done < "${renew_hook_param}"
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -39,7 +39,7 @@ case "$state_should" in
 | 
				
			||||||
            printf ' -o %s' "$(cat "$__object/parameter/options")"
 | 
					            printf ' -o %s' "$(cat "$__object/parameter/options")"
 | 
				
			||||||
         fi
 | 
					         fi
 | 
				
			||||||
         printf ' %s' "$(cat "$__object/parameter/device")"
 | 
					         printf ' %s' "$(cat "$__object/parameter/device")"
 | 
				
			||||||
         printf " %s\n" "$path"
 | 
					         printf ' %s\n' "$path"
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
         # mount using existing fstab entry
 | 
					         # mount using existing fstab entry
 | 
				
			||||||
         printf 'mount "%s"\n' "$path"
 | 
					         printf 'mount "%s"\n' "$path"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -31,7 +31,7 @@ printf " %s" "$type"
 | 
				
			||||||
options="$(cat "$__object/parameter/options")"
 | 
					options="$(cat "$__object/parameter/options")"
 | 
				
			||||||
printf " %s" "$options"
 | 
					printf " %s" "$options"
 | 
				
			||||||
printf " %s" "$(cat "$__object/parameter/dump")"
 | 
					printf " %s" "$(cat "$__object/parameter/dump")"
 | 
				
			||||||
printf " %s\n" "$(cat "$__object/parameter/pass")"
 | 
					printf ' %s\n' "$(cat "$__object/parameter/pass")"
 | 
				
			||||||
) | \
 | 
					) | \
 | 
				
			||||||
__block "$__object_name" \
 | 
					__block "$__object_name" \
 | 
				
			||||||
   --file "/etc/fstab" \
 | 
					   --file "/etc/fstab" \
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -51,7 +51,7 @@ case "$state_should" in
 | 
				
			||||||
        echo "opkg --verbosity=0 remove '$name'"
 | 
					        echo "opkg --verbosity=0 remove '$name'"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
    *)
 | 
					    *)
 | 
				
			||||||
        echo "Unknown state: $state" >&2
 | 
					        echo "Unknown state: ${state_should}" >&2
 | 
				
			||||||
        exit 1
 | 
					        exit 1
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
esac
 | 
					esac
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,7 +95,7 @@ if [ -n "$curr_version" ]; then  # PKG *is* installed
 | 
				
			||||||
      if [ "$upgrade" = "true" ]; then
 | 
					      if [ "$upgrade" = "true" ]; then
 | 
				
			||||||
         execcmd "upg" "${cmd}"
 | 
					         execcmd "upg" "${cmd}"
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
         printf "Version %s is already installed and pkg-ng can't upgrade directly to version %s.\nTo upgrade to the latest version, use the --upgrade flag.\n" "$curr_version" "$version" >&2
 | 
					         printf 'Version %s is already installed and pkg-ng cannot upgrade directly to version %s.\nTo upgrade to the latest version, use the --upgrade flag.\n' "$curr_version" "$version" >&2
 | 
				
			||||||
         exit 1
 | 
					         exit 1
 | 
				
			||||||
      fi
 | 
					      fi
 | 
				
			||||||
   # PKG is supposed to be installed to the latest version
 | 
					   # PKG is supposed to be installed to the latest version
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,10 +69,10 @@ fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [ -n "${cksum}" ]; then
 | 
					if [ -n "${cksum}" ]; then
 | 
				
			||||||
   if [ ! "\${currentSum}" = "${cksum}" ]; then
 | 
					   if [ ! "\${currentSum}" = "${cksum}" ]; then
 | 
				
			||||||
      $__remote_copy "${source}" "${my_target_host}:${rcvar}.new"
 | 
					      $__remote_copy "${source}" "\${my_target_host}:${rcvar}.new"
 | 
				
			||||||
   fi
 | 
					   fi
 | 
				
			||||||
else # File just doesn't exist yet
 | 
					else # File just doesn't exist yet
 | 
				
			||||||
   $__remote_copy "${source}" "${my_target_host}:${rcvar}.new"
 | 
					   $__remote_copy "${source}" "\${my_target_host}:${rcvar}.new"
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
EOF
 | 
					EOF
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -50,7 +50,6 @@ entry="$__object/files/entry"
 | 
				
			||||||
      echo "# $(cat "$__object/parameter/comment")"
 | 
					      echo "# $(cat "$__object/parameter/comment")"
 | 
				
			||||||
   fi
 | 
					   fi
 | 
				
			||||||
   printf "%s " "$service"
 | 
					   printf "%s " "$service"
 | 
				
			||||||
   printf "%s " "$type"
 | 
					 | 
				
			||||||
   for parameter in type private unpriv chroot wakeup maxproc; do
 | 
					   for parameter in type private unpriv chroot wakeup maxproc; do
 | 
				
			||||||
      printf "%s " "$(cat "$__object/parameter/$parameter")"
 | 
					      printf "%s " "$(cat "$__object/parameter/$parameter")"
 | 
				
			||||||
   done
 | 
					   done
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,7 +33,7 @@ case "$state_should" in
 | 
				
			||||||
         echo "su - postgres -c 'psql -c \"$cmd\" \"$dbname\"'"
 | 
					         echo "su - postgres -c 'psql -c \"$cmd\" \"$dbname\"'"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
    absent)
 | 
					    absent)
 | 
				
			||||||
         cmd="DROP   EXTENSION IF     EXISTS $extenstion"
 | 
					         cmd="DROP   EXTENSION IF     EXISTS $extension"
 | 
				
			||||||
         echo "su - postgres -c 'psql -c \"$cmd\" \"$dbname\"'"
 | 
					         echo "su - postgres -c 'psql -c \"$cmd\" \"$dbname\"'"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
esac
 | 
					esac
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,7 +52,7 @@ case "$state_should" in
 | 
				
			||||||
        if [ -f "$__object/parameter/stop" ]; then
 | 
					        if [ -f "$__object/parameter/stop" ]; then
 | 
				
			||||||
            cat "$__object/parameter/stop"
 | 
					            cat "$__object/parameter/stop"
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
            echo kill "${runs}"
 | 
					            echo kill "$(cat "$__object/parameter/runs")"
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
        echo "stopped" >> "$__messages_out"
 | 
					        echo "stopped" >> "$__messages_out"
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,6 +15,7 @@ storage_path="$(cat "$__object/parameter/storage-path")"
 | 
				
			||||||
##### INSTALL THE PACKAGE ###################################################
 | 
					##### INSTALL THE PACKAGE ###################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require_pkg=""  # what to require if I want to require "the package"
 | 
					require_pkg=""  # what to require if I want to require "the package"
 | 
				
			||||||
 | 
					require=""
 | 
				
			||||||
if [ -f "$__object/parameter/install-from-backports" ]; then
 | 
					if [ -f "$__object/parameter/install-from-backports" ]; then
 | 
				
			||||||
	os=$(cat "$__global/explorer/os")
 | 
						os=$(cat "$__global/explorer/os")
 | 
				
			||||||
	os_version=$(cat "$__global/explorer/os_version")
 | 
						os_version=$(cat "$__global/explorer/os_version")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ exporter="$(cat "$__object/parameter/exporter")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
__user prometheus --system
 | 
					__user prometheus --system
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					require=""
 | 
				
			||||||
case $exporter in
 | 
					case $exporter in
 | 
				
			||||||
	node)
 | 
						node)
 | 
				
			||||||
		TEXTFILES=/service/node-exporter/textfiles  # path for the textfiles collector
 | 
							TEXTFILES=/service/node-exporter/textfiles  # path for the textfiles collector
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,6 +18,7 @@ rule_files="$(cat "$__object/parameter/rule-files")"
 | 
				
			||||||
##### INSTALL THE PACKAGE ###################################################
 | 
					##### INSTALL THE PACKAGE ###################################################
 | 
				
			||||||
 | 
					
 | 
				
			||||||
require_pkg=""  # what to require if I want to require "the package"
 | 
					require_pkg=""  # what to require if I want to require "the package"
 | 
				
			||||||
 | 
					require=""
 | 
				
			||||||
if [ -f "$__object/parameter/install-from-backports" ]; then
 | 
					if [ -f "$__object/parameter/install-from-backports" ]; then
 | 
				
			||||||
	os=$(cat "$__global/explorer/os")
 | 
						os=$(cat "$__global/explorer/os")
 | 
				
			||||||
	os_version=$(cat "$__global/explorer/os_version")
 | 
						os_version=$(cat "$__global/explorer/os_version")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,7 +34,7 @@ DONE
 | 
				
			||||||
    absent)
 | 
					    absent)
 | 
				
			||||||
        cat << DONE
 | 
					        cat << DONE
 | 
				
			||||||
su - $user -c "rm -Rf \"\\\$HOME/.rvm\";
 | 
					su - $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
 | 
				
			||||||
    ;;
 | 
					    ;;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@ add_line() {
 | 
				
			||||||
   line="$2"
 | 
					   line="$2"
 | 
				
			||||||
   # escape single quotes
 | 
					   # escape single quotes
 | 
				
			||||||
   line_sanitised=$(echo "$line" | sed -e "s/'/'\"'\"'/g")
 | 
					   line_sanitised=$(echo "$line" | sed -e "s/'/'\"'\"'/g")
 | 
				
			||||||
   printf '%s' "printf '%s\n' '$line_sanitised' >> $file"
 | 
					   printf '%s' "printf '%s\\n' '$line_sanitised' >> $file"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,7 +61,7 @@ _cksum() {
 | 
				
			||||||
   echo "$1" | cksum | cut -d' ' -f 1
 | 
					   echo "$1" | cksum | cut -d' ' -f 1
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
while read key; do
 | 
					while read -r key; do
 | 
				
			||||||
   type_and_key="$(echo "$key" | tr ' ' '\n' | awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')"
 | 
					   type_and_key="$(echo "$key" | tr ' ' '\n' | awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')"
 | 
				
			||||||
   object_id="$(_cksum "$file")-$(_cksum "$type_and_key")"
 | 
					   object_id="$(_cksum "$file")-$(_cksum "$type_and_key")"
 | 
				
			||||||
   set -- "$object_id"
 | 
					   set -- "$object_id"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -67,10 +67,10 @@ fetch_and_prepare_file() {
 | 
				
			||||||
   # shellcheck disable=SC2016
 | 
					   # shellcheck disable=SC2016
 | 
				
			||||||
   printf 'cd "$tmpdir"\n'
 | 
					   printf 'cd "$tmpdir"\n'
 | 
				
			||||||
   # shellcheck disable=SC2059
 | 
					   # shellcheck disable=SC2059
 | 
				
			||||||
   printf "$fetch_command > \"%s\"\n" "$source" "$source_file_name"
 | 
					   printf "$fetch_command > \"%s\"\\n" "$source" "$source_file_name"
 | 
				
			||||||
   prepare_command="$(cat "$__object/parameter/prepare-command")"
 | 
					   prepare_command="$(cat "$__object/parameter/prepare-command")"
 | 
				
			||||||
   # shellcheck disable=SC2059
 | 
					   # shellcheck disable=SC2059
 | 
				
			||||||
   printf "$prepare_command > \"%s\"\n" "$source_file_name" "$stage_file"
 | 
					   printf "$prepare_command > \"%s\"\\n" "$source_file_name" "$stage_file"
 | 
				
			||||||
   printf 'cd - >/dev/null\n'
 | 
					   printf 'cd - >/dev/null\n'
 | 
				
			||||||
   # shellcheck disable=SC2016
 | 
					   # shellcheck disable=SC2016
 | 
				
			||||||
   printf 'rm -rf "$tmpdir"\n'
 | 
					   printf 'rm -rf "$tmpdir"\n'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -76,7 +76,7 @@ case "$state_should" in
 | 
				
			||||||
         echo "zypper $zypper_def_opts ref"
 | 
					         echo "zypper $zypper_def_opts ref"
 | 
				
			||||||
   ;;
 | 
					   ;;
 | 
				
			||||||
   absent)
 | 
					   absent)
 | 
				
			||||||
         echo "zypper $zypper_def_opts removeservice $service_id"
 | 
					         echo "zypper $zypper_def_opts removeservice $exp_id"
 | 
				
			||||||
         echo "zypper $zypper_def_opts refs"
 | 
					         echo "zypper $zypper_def_opts refs"
 | 
				
			||||||
         echo "zypper $zypper_def_opts ref"
 | 
					         echo "zypper $zypper_def_opts ref"
 | 
				
			||||||
   ;;
 | 
					   ;;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue