Skip to content

Commit e46ae69

Browse files
committed
impr(entrypoint): Fix / disable shellcheck warnings
Signed-off-by: Sebastian Neuser <[email protected]>
1 parent 6df9599 commit e46ae69

File tree

10 files changed

+200
-90
lines changed

10 files changed

+200
-90
lines changed

29/apache/entrypoint.sh

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ run_as() {
2121

2222
# Execute all executable files in a given directory in alphanumeric order
2323
run_path() {
24-
local hook_folder_path="/docker-entrypoint-hooks.d/$1"
25-
local return_code=0
26-
local found=0
24+
hook_folder_path="/docker-entrypoint-hooks.d/$1"
25+
return_code=0
26+
found=0
2727

2828
echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\""
2929

@@ -57,18 +57,22 @@ run_path() {
5757
echo "=> Completed executing scripts in the \"$1\" folder"
5858
fi
5959
)
60+
61+
unset hook_folder_path
62+
unset return_code
63+
unset found
6064
}
6165

6266
# usage: file_env VAR [DEFAULT]
6367
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
6468
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
6569
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
6670
file_env() {
67-
local var="$1"
68-
local fileVar="${var}_FILE"
69-
local def="${2:-}"
70-
local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//")
71-
local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//")
71+
var="$1"
72+
fileVar="${var}_FILE"
73+
def="${2:-}"
74+
varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//")
75+
fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//")
7276
if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then
7377
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
7478
exit 1
@@ -80,7 +84,11 @@ file_env() {
8084
elif [ -n "${def}" ]; then
8185
export "$var"="$def"
8286
fi
83-
unset "$fileVar"
87+
unset var
88+
unset fileVar
89+
unset def
90+
unset varValue
91+
unset fileVarValue
8492
}
8593

8694
if expr "$1" : "apache" 1>/dev/null; then
@@ -186,12 +194,15 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
186194
rsync_options="-rlD"
187195
fi
188196

197+
# shellcheck disable=SC2086
189198
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/
190199
for dir in config data custom_apps themes; do
191200
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
201+
# shellcheck disable=SC2086
192202
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/
193203
fi
194204
done
205+
# shellcheck disable=SC2086
195206
rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/
196207

197208
# Install

29/fpm-alpine/entrypoint.sh

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ run_as() {
2121

2222
# Execute all executable files in a given directory in alphanumeric order
2323
run_path() {
24-
local hook_folder_path="/docker-entrypoint-hooks.d/$1"
25-
local return_code=0
26-
local found=0
24+
hook_folder_path="/docker-entrypoint-hooks.d/$1"
25+
return_code=0
26+
found=0
2727

2828
echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\""
2929

@@ -57,18 +57,22 @@ run_path() {
5757
echo "=> Completed executing scripts in the \"$1\" folder"
5858
fi
5959
)
60+
61+
unset hook_folder_path
62+
unset return_code
63+
unset found
6064
}
6165

6266
# usage: file_env VAR [DEFAULT]
6367
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
6468
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
6569
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
6670
file_env() {
67-
local var="$1"
68-
local fileVar="${var}_FILE"
69-
local def="${2:-}"
70-
local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//")
71-
local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//")
71+
var="$1"
72+
fileVar="${var}_FILE"
73+
def="${2:-}"
74+
varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//")
75+
fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//")
7276
if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then
7377
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
7478
exit 1
@@ -80,7 +84,11 @@ file_env() {
8084
elif [ -n "${def}" ]; then
8185
export "$var"="$def"
8286
fi
83-
unset "$fileVar"
87+
unset var
88+
unset fileVar
89+
unset def
90+
unset varValue
91+
unset fileVarValue
8492
}
8593

8694
if expr "$1" : "apache" 1>/dev/null; then
@@ -186,12 +194,15 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
186194
rsync_options="-rlD"
187195
fi
188196

197+
# shellcheck disable=SC2086
189198
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/
190199
for dir in config data custom_apps themes; do
191200
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
201+
# shellcheck disable=SC2086
192202
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/
193203
fi
194204
done
205+
# shellcheck disable=SC2086
195206
rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/
196207

197208
# Install

29/fpm/entrypoint.sh

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ run_as() {
2121

2222
# Execute all executable files in a given directory in alphanumeric order
2323
run_path() {
24-
local hook_folder_path="/docker-entrypoint-hooks.d/$1"
25-
local return_code=0
26-
local found=0
24+
hook_folder_path="/docker-entrypoint-hooks.d/$1"
25+
return_code=0
26+
found=0
2727

2828
echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\""
2929

@@ -57,18 +57,22 @@ run_path() {
5757
echo "=> Completed executing scripts in the \"$1\" folder"
5858
fi
5959
)
60+
61+
unset hook_folder_path
62+
unset return_code
63+
unset found
6064
}
6165

6266
# usage: file_env VAR [DEFAULT]
6367
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
6468
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
6569
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
6670
file_env() {
67-
local var="$1"
68-
local fileVar="${var}_FILE"
69-
local def="${2:-}"
70-
local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//")
71-
local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//")
71+
var="$1"
72+
fileVar="${var}_FILE"
73+
def="${2:-}"
74+
varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//")
75+
fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//")
7276
if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then
7377
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
7478
exit 1
@@ -80,7 +84,11 @@ file_env() {
8084
elif [ -n "${def}" ]; then
8185
export "$var"="$def"
8286
fi
83-
unset "$fileVar"
87+
unset var
88+
unset fileVar
89+
unset def
90+
unset varValue
91+
unset fileVarValue
8492
}
8593

8694
if expr "$1" : "apache" 1>/dev/null; then
@@ -186,12 +194,15 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
186194
rsync_options="-rlD"
187195
fi
188196

197+
# shellcheck disable=SC2086
189198
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/
190199
for dir in config data custom_apps themes; do
191200
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
201+
# shellcheck disable=SC2086
192202
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/
193203
fi
194204
done
205+
# shellcheck disable=SC2086
195206
rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/
196207

197208
# Install

30/apache/entrypoint.sh

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ run_as() {
2121

2222
# Execute all executable files in a given directory in alphanumeric order
2323
run_path() {
24-
local hook_folder_path="/docker-entrypoint-hooks.d/$1"
25-
local return_code=0
26-
local found=0
24+
hook_folder_path="/docker-entrypoint-hooks.d/$1"
25+
return_code=0
26+
found=0
2727

2828
echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\""
2929

@@ -57,18 +57,22 @@ run_path() {
5757
echo "=> Completed executing scripts in the \"$1\" folder"
5858
fi
5959
)
60+
61+
unset hook_folder_path
62+
unset return_code
63+
unset found
6064
}
6165

6266
# usage: file_env VAR [DEFAULT]
6367
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
6468
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
6569
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
6670
file_env() {
67-
local var="$1"
68-
local fileVar="${var}_FILE"
69-
local def="${2:-}"
70-
local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//")
71-
local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//")
71+
var="$1"
72+
fileVar="${var}_FILE"
73+
def="${2:-}"
74+
varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//")
75+
fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//")
7276
if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then
7377
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
7478
exit 1
@@ -80,7 +84,11 @@ file_env() {
8084
elif [ -n "${def}" ]; then
8185
export "$var"="$def"
8286
fi
83-
unset "$fileVar"
87+
unset var
88+
unset fileVar
89+
unset def
90+
unset varValue
91+
unset fileVarValue
8492
}
8593

8694
if expr "$1" : "apache" 1>/dev/null; then
@@ -186,12 +194,15 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
186194
rsync_options="-rlD"
187195
fi
188196

197+
# shellcheck disable=SC2086
189198
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/
190199
for dir in config data custom_apps themes; do
191200
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
201+
# shellcheck disable=SC2086
192202
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/
193203
fi
194204
done
205+
# shellcheck disable=SC2086
195206
rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/
196207

197208
# Install

30/fpm-alpine/entrypoint.sh

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ run_as() {
2121

2222
# Execute all executable files in a given directory in alphanumeric order
2323
run_path() {
24-
local hook_folder_path="/docker-entrypoint-hooks.d/$1"
25-
local return_code=0
26-
local found=0
24+
hook_folder_path="/docker-entrypoint-hooks.d/$1"
25+
return_code=0
26+
found=0
2727

2828
echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\""
2929

@@ -57,18 +57,22 @@ run_path() {
5757
echo "=> Completed executing scripts in the \"$1\" folder"
5858
fi
5959
)
60+
61+
unset hook_folder_path
62+
unset return_code
63+
unset found
6064
}
6165

6266
# usage: file_env VAR [DEFAULT]
6367
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
6468
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
6569
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
6670
file_env() {
67-
local var="$1"
68-
local fileVar="${var}_FILE"
69-
local def="${2:-}"
70-
local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//")
71-
local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//")
71+
var="$1"
72+
fileVar="${var}_FILE"
73+
def="${2:-}"
74+
varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//")
75+
fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//")
7276
if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then
7377
echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
7478
exit 1
@@ -80,7 +84,11 @@ file_env() {
8084
elif [ -n "${def}" ]; then
8185
export "$var"="$def"
8286
fi
83-
unset "$fileVar"
87+
unset var
88+
unset fileVar
89+
unset def
90+
unset varValue
91+
unset fileVarValue
8492
}
8593

8694
if expr "$1" : "apache" 1>/dev/null; then
@@ -186,12 +194,15 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP
186194
rsync_options="-rlD"
187195
fi
188196

197+
# shellcheck disable=SC2086
189198
rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/
190199
for dir in config data custom_apps themes; do
191200
if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then
201+
# shellcheck disable=SC2086
192202
rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/
193203
fi
194204
done
205+
# shellcheck disable=SC2086
195206
rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/
196207

197208
# Install

0 commit comments

Comments
 (0)