__nextcloud: fix shellcheck

Mostly simply because of php inline code .. also because of the argument
generation for the installation setup.
This commit is contained in:
matze 2020-10-24 09:31:59 +02:00
parent 979398e398
commit 0a0e4d26b4
4 changed files with 14 additions and 5 deletions

View file

@ -5,7 +5,6 @@
# Get the installdir # Get the installdir
user="$( cat "$__object/parameter/user" )"
installdir="$( "$__type_explorer/installdir" )" installdir="$( "$__type_explorer/installdir" )"
# Check if the tools are available # Check if the tools are available
@ -14,9 +13,11 @@ if [ -d "$installdir" ]; then
# if those files exist, everything should be good # if those files exist, everything should be good
if [ -f "occ" ] && [ -f "config/config.php" ]; then 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 # `occ config:system:get`. Or parse through the whole json or
# yaml-like output of `occ config:list system --private`. # 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/"); php -r 'require("lib/private/Config.php"); $config = new OC\Config("config/");
function printv($key, $value) {printf("%s = %s\n", $key, $value);} function printv($key, $value) {printf("%s = %s\n", $key, $value);}
foreach($config->getKeys() as $key){ foreach($config->getKeys() as $key){

View file

@ -13,7 +13,8 @@ if [ -d "$installdir" ]; then
# if those files exist, everything should be good # if those files exist, everything should be good
if [ -f "occ" ] && [ -f "version.php" ]; then 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);' php -r 'require("version.php"); print($OC_VersionString);'
fi fi
fi fi

View file

@ -91,6 +91,8 @@ fi
# Check if the nextcloud application needs to be installed. # Check if the nextcloud application needs to be installed.
# This checks the state of the configuration, not of the directory. # 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 if ! grep -q -F "installed = 1" "$__object/explorer/config"; then
# argument construction # argument construction
occ_install_args="" occ_install_args=""
@ -159,8 +161,9 @@ if ! grep -q -F "installed = 1" "$__object/explorer/config"; then
fi fi
# Execute the install command # Execute the install command.
occ maintenance:install $occ_install_args # generated parameters will be splited in the remote shell
occ maintenance:install "$occ_install_args"
# send install message # send install message
echo installed >> "$__messages_out" echo installed >> "$__messages_out"

View file

@ -57,6 +57,7 @@ conf_base() {
value="$(cat "$__object/parameter/$1")" value="$(cat "$__object/parameter/$1")"
if ! testparam "$2" "$value"; then if ! testparam "$2" "$value"; then
# set it because it does not exist # set it because it does not exist
# shellcheck disable=SC2059 # $3 contains patterns
printf "php occ config:system:$3\n" "$2" "$value" printf "php occ config:system:$3\n" "$2" "$value"
fi fi
else else
@ -122,6 +123,7 @@ conf_array() {
# else, default behaviour of the array # else, default behaviour of the array
else else
# save counter of the next free index # save counter of the next free index
# shellcheck disable=SC1004 # the \ is required for awk
counter=$( awk -v FS=" = " -v name="$2" ' counter=$( awk -v FS=" = " -v name="$2" '
BEGIN { counter = 0 } BEGIN { counter = 0 }
split($1, header, "|") == 2 && header[1] ~ /^[[:digit:]]+$/ && header[2] == name \ split($1, header, "|") == 2 && header[1] ~ /^[[:digit:]]+$/ && header[2] == name \
@ -156,6 +158,8 @@ conf_array() {
if [ -z "$install" ]; then if [ -z "$install" ]; then
# interate through the leftover values # interate through the leftover values
# remove them, as they should not exist (at least can be) # 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 while read -r start equal value; do
# remove those specific elements from the array # remove those specific elements from the array
printf "php occ config:system:delete '%s' '%s' --error-if-not-exists\n" \ printf "php occ config:system:delete '%s' '%s' --error-if-not-exists\n" \