add: allow informing user and group id or name
Some checks failed
Caprover: Build & Deploy (backup-databases) / build (push) Failing after 7s

This commit is contained in:
2024-11-24 21:21:53 -03:00
parent 60b0b467f8
commit 5a8c4c1b1a
2 changed files with 17 additions and 13 deletions

View File

@@ -3,7 +3,7 @@
#
# Connect to a Cloudflare's R2 storage using mochoa/s3fs
#
# Run this script on the Docker HOST to bind buckets using "linode-bucket"
# Run this script on the Docker HOST to bind buckets using "cloudflare-r2"
# -- Or any alias you give with "--alias" option -- driver name.
# Please refer to https://hub.docker.com/r/mochoa/s3fs-volume-plugin.
# You may bind to different buckets using different aliases.
@@ -30,16 +30,18 @@ while test $# -ne 0; do
elif test "${key}" = "-a" || test "${key}" = "--alias"; then
PLUGIN_ALIAS="${value}";
elif test "${key}" = "-u" || test "${key}" = "--user"; then
if id "${value}" > /dev/null 2>&1; then
USER_ID="$(id -u "${value}")";
else
passwdEntry=$(getent passwd ${value} || echo ":NOT_FOUND:");
if test "${passwdEntry}" = ":NOT_FOUND:"; then
USER_ID="$(id -u)";
else
USER_ID=$(echo $passwdEntry | cut -d ':' -f 3);
fi
elif test "${key}" = "-g" || test "${key}" = "--group"; then
if id "${value}" > /dev/null 2>&1; then
GROUP_ID="$(id -g "${value}")";
else
groupEntry=$(getent group ${value} || echo ":NOT_FOUND:");
if test "${groupEntry}" = ":NOT_FOUND:"; then
GROUP_ID="$(id -g)";
else
GROUP_ID=$(echo $groupEntry | cut -d ':' -f 3);
fi
else
echo "Invalid \"${key}\" option";

View File

@@ -28,16 +28,18 @@ while test $# -ne 0; do
elif test "${key}" = "-a" || test "${key}" = "--alias"; then
PLUGIN_ALIAS="${value}";
elif test "${key}" = "-u" || test "${key}" = "--user"; then
if id "${value}" > /dev/null 2>&1; then
USER_ID="$(id -u "${value}")";
else
passwdEntry=$(getent passwd ${value} || echo ":NOT_FOUND:");
if test "${passwdEntry}" = ":NOT_FOUND:"; then
USER_ID="$(id -u)";
else
USER_ID=$(echo $passwdEntry | cut -d ':' -f 3);
fi
elif test "${key}" = "-g" || test "${key}" = "--group"; then
if id "${value}" > /dev/null 2>&1; then
GROUP_ID="$(id -g "${value}")";
else
groupEntry=$(getent group ${value} || echo ":NOT_FOUND:");
if test "${groupEntry}" = ":NOT_FOUND:"; then
GROUP_ID="$(id -g)";
else
GROUP_ID=$(echo $groupEntry | cut -d ':' -f 3);
fi
else
echo "Invalid \"${key}\" option";