-
-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathentrypoint.sh
More file actions
96 lines (80 loc) · 2.94 KB
/
entrypoint.sh
File metadata and controls
96 lines (80 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/sh
#
# --- User & Group Setup ---
#
USER_ID=${PUID:-0}
GROUP_ID=${PGID:-0}
if [ "$(id -u)" = "0" ] && [ "$USER_ID" -ne 0 ]; then
echo "Running as user: $USER_ID:$GROUP_ID"
GROUPNAME="appgroup"
if getent group "$GROUP_ID" >/dev/null; then
GROUPNAME=$(getent group "$GROUP_ID" | cut -d: -f1)
echo "Group with GID $GROUP_ID already exists, adopting name '$GROUPNAME'"
else
addgroup --gid "$GROUP_ID" "$GROUPNAME"
fi
USERNAME="appuser"
if getent passwd "$USER_ID" >/dev/null; then
USERNAME=$(getent passwd "$USER_ID" | cut -d: -f1)
echo "User with UID $USER_ID already exists, adopting name '$USERNAME'"
else
adduser --system --uid "$USER_ID" --gid "$GROUP_ID" --shell /sbin/nologin "$USERNAME"
fi
echo "Setting ownership for $USERNAME:$GROUPNAME..."
chown -R "$USERNAME":"$GROUPNAME" /app /app_defaults
exec gosu "$USERNAME" "$0" "$@"
fi
#
# --- Branding ---
#
cat << "EOF"
_______ ___ _ __ __ _ _
|_ _\ \ / / || | | \/ | /\ | | (_)
| | \ \ /\ / /| || |_| \ / | / \ __| |_ __ ___ _ _ __
| | \ \/ \/ / |__ _| |\/| | / /\ \ / _` | '_ ` _ \| | '_ \
_| |_ \ /\ / | | | | | |/ ____ \ (_| | | | | | | | | | |
|_____| \/ \/ |_| |_| |_/_/ \_\__,_|_| |_| |_|_|_| |_|
EOF
echo
echo "Brought to you by RaidMax"
echo "-------------------------"
echo "UID: ${PUID:-0} / GID: ${PGID:-0}"
echo "-------------------------"
echo
#
# --- File & Directory Checks ---
#
CONFIG_DIR="/app/Configuration"
PLUGINS_DIR="/app/Plugins"
LOCALIZATION_DIR="/app/Localization"
if [ ! -f "$CONFIG_DIR/IW4MAdminSettings.json" ]; then
echo "FATAL ERROR: IW4MAdminSettings.json not found in your mounted Configuration directory." >&2
echo "Please create this file or copy it into your local configuration folder before starting." >&2
sleep 5
exit 1
fi
if [ ! -f "$CONFIG_DIR/LoggingConfiguration.json" ]; then
echo "Default configuration files not found, populating..."
cp -n /app_defaults/Configuration/* "$CONFIG_DIR/"
fi
# Sync core plugins — only update if the image version is newer than the mounted version
if [ -d "/app_defaults/Plugins" ]; then
for ref_file in /app_defaults/Plugins/*; do
[ -f "$ref_file" ] || continue
filename=$(basename "$ref_file")
live_file="$PLUGINS_DIR/$filename"
if [ ! -f "$live_file" ] || [ "$ref_file" -nt "$live_file" ]; then
echo "Updating plugin: $filename"
cp -f "$ref_file" "$live_file"
fi
done
fi
if [ ! -f "$LOCALIZATION_DIR/IW4MAdmin.en-US.json" ]; then
echo "Default localization files not found, populating..."
cp -n -r /app_defaults/Localization/* "$LOCALIZATION_DIR/"
fi
#
# --- Start Application ---
#
echo "Configuration verified. Starting IW4MAdmin..."
exec dotnet Lib/IW4MAdmin.dll