From 0a0e4d26b4a6a765c556035725371ee0206a38ab Mon Sep 17 00:00:00 2001 From: Matthias Stecher Date: Sat, 24 Oct 2020 09:31:59 +0200 Subject: [PATCH] __nextcloud: fix shellcheck Mostly simply because of php inline code .. also because of the argument generation for the installation setup. --- type/__nextcloud/explorer/config | 5 +++-- type/__nextcloud/explorer/version | 3 ++- type/__nextcloud/gencode-remote | 7 +++++-- type/__nextcloud/map-conf-changes.sh | 4 ++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/type/__nextcloud/explorer/config b/type/__nextcloud/explorer/config index 998264e..f97f39d 100755 --- a/type/__nextcloud/explorer/config +++ b/type/__nextcloud/explorer/config @@ -5,7 +5,6 @@ # Get the installdir -user="$( cat "$__object/parameter/user" )" installdir="$( "$__type_explorer/installdir" )" # Check if the tools are available @@ -14,9 +13,11 @@ if [ -d "$installdir" ]; then # if those files exist, everything should be good if [ -f "occ" ] && [ -f "config/config.php" ]; then - # dump out config instead of fuzz every possible option through + # Dump out config instead of fuzz every possible option through # `occ config:system:get`. Or parse through the whole json or # yaml-like output of `occ config:list system --private`. + # + # shellcheck disable=SC2016 # cause of the php inline code php -r 'require("lib/private/Config.php"); $config = new OC\Config("config/"); function printv($key, $value) {printf("%s = %s\n", $key, $value);} foreach($config->getKeys() as $key){ diff --git a/type/__nextcloud/explorer/version b/type/__nextcloud/explorer/version index fc79206..5a75258 100755 --- a/type/__nextcloud/explorer/version +++ b/type/__nextcloud/explorer/version @@ -13,7 +13,8 @@ if [ -d "$installdir" ]; then # if those files exist, everything should be good if [ -f "occ" ] && [ -f "version.php" ]; then - # detect php version with the version file + # Detect php version with the version file. + # shellcheck disable=SC2016 # cause of the php inline code php -r 'require("version.php"); print($OC_VersionString);' fi fi diff --git a/type/__nextcloud/gencode-remote b/type/__nextcloud/gencode-remote index 60d9b42..e0317c1 100755 --- a/type/__nextcloud/gencode-remote +++ b/type/__nextcloud/gencode-remote @@ -91,6 +91,8 @@ fi # Check if the nextcloud application needs to be installed. # This checks the state of the configuration, not of the directory. +# +# shellcheck disable=SC2089 # disabled to write args string if ! grep -q -F "installed = 1" "$__object/explorer/config"; then # argument construction occ_install_args="" @@ -159,8 +161,9 @@ if ! grep -q -F "installed = 1" "$__object/explorer/config"; then fi - # Execute the install command - occ maintenance:install $occ_install_args + # Execute the install command. + # generated parameters will be splited in the remote shell + occ maintenance:install "$occ_install_args" # send install message echo installed >> "$__messages_out" diff --git a/type/__nextcloud/map-conf-changes.sh b/type/__nextcloud/map-conf-changes.sh index 8a00ac6..f107f5f 100755 --- a/type/__nextcloud/map-conf-changes.sh +++ b/type/__nextcloud/map-conf-changes.sh @@ -57,6 +57,7 @@ conf_base() { value="$(cat "$__object/parameter/$1")" if ! testparam "$2" "$value"; then # set it because it does not exist + # shellcheck disable=SC2059 # $3 contains patterns printf "php occ config:system:$3\n" "$2" "$value" fi else @@ -122,6 +123,7 @@ conf_array() { # else, default behaviour of the array else # save counter of the next free index + # shellcheck disable=SC1004 # the \ is required for awk counter=$( awk -v FS=" = " -v name="$2" ' BEGIN { counter = 0 } split($1, header, "|") == 2 && header[1] ~ /^[[:digit:]]+$/ && header[2] == name \ @@ -156,6 +158,8 @@ conf_array() { if [ -z "$install" ]; then # interate through the leftover values # remove them, as they should not exist (at least can be) + # + # shellcheck disable=SC2034 # $equal left for readability while read -r start equal value; do # remove those specific elements from the array printf "php occ config:system:delete '%s' '%s' --error-if-not-exists\n" \