Skip to content

Commit 25a5fce

Browse files
committed
Enhance docker-php-serversideup-set-file-permissions script to support additional --dir parameter for specifying extra directories. Update usage documentation accordingly for improved clarity.
1 parent f58e227 commit 25a5fce

1 file changed

Lines changed: 27 additions & 6 deletions

File tree

src/common/usr/local/bin/docker-php-serversideup-set-file-permissions

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -eu
33

44
###################################################
5-
# Usage: docker-php-serversideup-set-file-permissions --owner USER:GROUP --service SERVICE
5+
# Usage: docker-php-serversideup-set-file-permissions --owner USER:GROUP --service SERVICE [--dir PATH]...
66
###################################################
77
# This script is intended to be called on build for sysadmins who want to
88
# change the UID and GID of a specific user. This is useful for when you
@@ -13,7 +13,7 @@ script_name="docker-php-serversideup-set-file-permissions"
1313

1414
# Usage function
1515
usage() {
16-
echo "Usage: $0 --owner USER:GROUP --service SERVICE"
16+
echo "Usage: $0 --owner USER:GROUP --service SERVICE [--dir PATH]..."
1717
exit 1
1818
}
1919

@@ -23,10 +23,10 @@ if [ "$(id -u)" -ne 0 ]; then
2323
exit 1
2424
fi
2525

26-
# Check for minimum number of arguments
27-
if [ "$#" -ne 4 ]; then
28-
usage
29-
fi
26+
# Initialize variables to avoid unbound variable errors with 'set -u'
27+
OWNER=""
28+
SERVICE=""
29+
EXTRA_DIRS=""
3030

3131
# Parse arguments
3232
while [ "$#" -gt 0 ]; do
@@ -35,10 +35,26 @@ while [ "$#" -gt 0 ]; do
3535
OWNER="$2"
3636
shift 2
3737
;;
38+
--owner=*)
39+
OWNER="${1#--owner=}"
40+
shift 1
41+
;;
3842
--service)
3943
SERVICE="$2"
4044
shift 2
4145
;;
46+
--service=*)
47+
SERVICE="${1#--service=}"
48+
shift 1
49+
;;
50+
--dir)
51+
EXTRA_DIRS="$EXTRA_DIRS $2"
52+
shift 2
53+
;;
54+
--dir=*)
55+
EXTRA_DIRS="$EXTRA_DIRS ${1#--dir=}"
56+
shift 1
57+
;;
4258
*)
4359
usage
4460
;;
@@ -196,5 +212,10 @@ case "$OS" in
196212
;;
197213
esac
198214

215+
# Append any extra directories provided via --dir flags
216+
if [ -n "$EXTRA_DIRS" ]; then
217+
DIRS="$DIRS $EXTRA_DIRS"
218+
fi
219+
199220
# Change ownership of the directories
200221
change_ownership $DIRS

0 commit comments

Comments
 (0)