We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 7eef01d + 6128fef commit fc2b523Copy full SHA for fc2b523
1 file changed
templates/occ.epp
@@ -1,6 +1,18 @@
1
#!/bin/sh
2
3
-cd <%= $nextcloud::current_version_dir %> && \
4
- sudo -u <%= $nextcloud::user %> \
5
- --preserve-env=OC_PASS \
6
- OC_CONFIG_WRITABLE=1 OC_CONFIG_APPSTORE_ENABLE=1 /usr/bin/php <%= $nextcloud::current_version_dir %>/occ "$@"
+NC_DIR="<%= $nextcloud::current_version_dir %>"
+NC_USER="<%= $nextcloud::user %>"
+
+cd "$NC_DIR" || exit 1
7
8
+if [ "$(id -un)" = "$NC_USER" ]; then
9
+ # Already the nextcloud user: run directly, no sudo, no extra envvars.
10
+ exec /usr/bin/php "$NC_DIR/occ" "$@"
11
+else
12
+ # Running as someone else: drop to nextcloud via sudo, with the hardcoded envvars.
13
+ exec sudo -u "$NC_USER" \
14
+ --preserve-env=OC_PASS \
15
+ OC_CONFIG_WRITABLE=1 \
16
+ OC_CONFIG_APPSTORE_ENABLE=1 \
17
+ /usr/bin/php "$NC_DIR/occ" "$@"
18
+fi
0 commit comments