Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
855b64d
chore(readme): remove unnecessary trailing newline in code block
printminion-co Jul 11, 2025
8c3a082
refactor: replace ooc function calls with execute_occ_command
printminion-co Jul 11, 2025
02a9225
refactor: rename functions in configure.sh for clarity and consistency
printminion-co Jul 11, 2025
efb1b26
feat(config): enhance configure.sh with detailed documentation and us…
printminion-co Jul 11, 2025
b151c01
feat(config): improve output messages in configure.sh for better clarity
printminion-co Jul 11, 2025
01b5dde
refactor(config): update script directory variable for improved clarity
printminion-co Jul 11, 2025
31ebc2a
refactor(config): make script variables readonly for improved safety
printminion-co Jul 11, 2025
c1b7fc8
refactor(config): improve script readability by standardizing quoting…
printminion-co Jul 11, 2025
9c021a1
feat(config): enhance logging in configure.sh with dedicated log func…
printminion-co Jul 11, 2025
af24076
refactor(config): rename internal variable for homepage URL in for im…
printminion-co Jul 11, 2025
c28529e
refactor(config): add comments for initial checks and configuration s…
printminion-co Jul 11, 2025
3731d0e
fix(config): add validation for app name in disable_single_app functi…
printminion-co Jul 11, 2025
469c1d1
fix(config): rename internal variable for app name in disable_single_…
printminion-co Jul 11, 2025
8a5872a
fix(config): update command execution in disable_configured_apps func…
printminion-co Jul 11, 2025
0619dd9
fix(config): rename internal variable in loop for consistency in app …
printminion-co Jul 11, 2025
fe82abf
fix(logging): enhance log messages with color coding for better visib…
printminion-co Jul 11, 2025
b6c1593
fix(logging): replace echo statements with log_info for better loggin…
printminion-co Jul 11, 2025
be4b489
fix(installation): extract nextcloud installation as own function
printminion-co Jul 11, 2025
db257ca
fix(apps-enable): improve error handling in enable_app function and r…
printminion-co Jul 11, 2025
6359d8b
fix(apps-enable): redirect error messages to stderr in fail function
printminion-co Jul 11, 2025
df1bdda
fix(apps-enable): rename ooc function to execute_occ_command for clarity
printminion-co Jul 14, 2025
d89f5ab
fix(apps-enable): replace direct occ command calls with execute_occ_c…
printminion-co Jul 14, 2025
d5bb851
fix(configure): correct boolean comparison for main status check
printminion-co Jul 14, 2025
b4a88f2
fix(apps-enable): quote variable in failed apps count check for safety
printminion-co Jul 14, 2025
2c6df09
fix(apps): replace fail function with log_fatal for consistent error …
printminion-co Jul 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apps-disable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@ SHIPPED_JSON="${BDIR}/../core/shipped.json"

. ${BDIR}/disabled-apps.inc.sh

fail() {
echo "${*}"
# Log fatal error message and exit with failure code
# Usage: log_fatal <message>
log_fatal() {
echo "\033[1;31m[x] Fatal Error: ${*}\033[0m" >&2
exit 1
}

main() {
if ! which jq 2>&1 >/dev/null; then
fail "Error: jq is required"
log_fatal "jq is required"
fi

# alwaysEnabled should be the only attribute in this json file which really matters,
Expand Down
45 changes: 31 additions & 14 deletions apps-enable.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,31 @@ NEXTCLOUD_DIR="${BDIR}/.."
. ${BDIR}/enabled-core-apps.inc.sh
. ${BDIR}/disabled-apps.inc.sh

ooc() {
execute_occ_command() {
php "${NEXTCLOUD_DIR}/occ" \
"${@}"
}

fail() {
echo "${*}"
# Log fatal error message and exit with failure code
# Usage: log_fatal <message>
log_fatal() {
echo "\033[1;31m[x] Fatal Error: ${*}\033[0m" >&2
exit 1
}

enable_app() {
# Enable app and check if it was enabled
# Fail if enabling the app failed
# Return 1 if enabling the app failed, 0 if successful
#
app_name="${1}"
echo "Enable app '${app_name}' ..."

if ! ooc app:enable "${app_name}"
if ! execute_occ_command app:enable "${app_name}"
then
fail "Enabling app \"${app_name}\" failed."
echo "ERROR: Enabling app \"${app_name}\" failed."
Copy link

Copilot AI Jul 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This error branch uses a plain echo while other failures use log_fatal; consider unifying to a consistent logging function for maintainability.

Suggested change
echo "ERROR: Enabling app \"${app_name}\" failed."
log_error "Enabling app \"${app_name}\" failed."

Copilot uses AI. Check for mistakes.
return 1
fi
return 0
}

disable_app() {
Expand All @@ -40,9 +44,9 @@ disable_app() {
app_name="${1}"
echo "Disable app '${app_name}' ..."

if ! ooc app:disable "${app_name}"
if ! execute_occ_command app:disable "${app_name}"
then
fail "Disable app \"${app_name}\" failed."
log_fatal "Disable app \"${app_name}\" failed."
fi
}

Expand All @@ -52,12 +56,14 @@ enable_apps() {
apps_dir="${1}"
_enabled_apps_count=0
_disabled_apps_count=0
_failed_apps_count=0
_failed_apps_list=""

if [ ! -d "${apps_dir}" ]; then
fail "Apps directory does not exist: $( readlink -f "${apps_dir}" )"
log_fatal "Apps directory does not exist: $( readlink -f "${apps_dir}" )"
fi

_enabled_apps=$(./occ app:list --enabled --output json | jq -j '.enabled | keys | join("\n")')
_enabled_apps=$(execute_occ_command app:list --enabled --output json | jq -j '.enabled | keys | join("\n")')

for app in $( find "${apps_dir}" -mindepth 1 -maxdepth 1 -type d | sort); do
app_name="$( basename "${app}" )"
Expand All @@ -81,14 +87,25 @@ enable_apps() {
fi

echo " - currently disabled - enabling"
enable_app "${app_name}"
_enabled_apps_count=$(( _enabled_apps_count + 1 ))
if enable_app "${app_name}"; then
_enabled_apps_count=$(( _enabled_apps_count + 1 ))
else
_failed_apps_count=$(( _failed_apps_count + 1 ))
if [ -z "${_failed_apps_list}" ]; then
_failed_apps_list="${app_name}"
else
_failed_apps_list="${_failed_apps_list}, ${app_name}"
fi
fi
fi
done

echo
echo "Enabled ${_enabled_apps_count} apps in ${apps_dir}"
echo "Disabled ${_disabled_apps_count} apps in ${apps_dir}"
if [ "${_failed_apps_count}" -gt 0 ]; then
log_fatal "PANIC: Failed to enable ${_failed_apps_count} apps in ${apps_dir}: ${_failed_apps_list}"
fi
echo
}

Expand All @@ -99,7 +116,7 @@ enable_core_apps() {

echo "Check required core apps are enabled..."

disabled_apps=$(./occ app:list --disabled --output json | jq -j '.disabled | keys | join("\n")')
disabled_apps=$(execute_occ_command app:list --disabled --output json | jq -j '.disabled | keys | join("\n")')

if [ -z "${disabled_apps}" ]; then
echo "No disabled apps found."
Expand Down Expand Up @@ -130,7 +147,7 @@ enable_core_apps() {

main() {
if ! jq --version 2>&1 >/dev/null; then
fail "Error: jq is required"
log_fatal "Error: jq is required"
fi

echo "Enable all apps in 'apps-external' folder"
Expand Down
26 changes: 14 additions & 12 deletions configure-object-store.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

NEXTCLOUD_ROOT_DIR="/var/www/html"

fail() {
echo "${*}" >/dev/stderr
# Log fatal error message and exit with failure code
# Usage: log_fatal <message>
log_fatal() {
echo "\033[1;31m[x] Fatal Error: ${*}\033[0m" >/dev/stderr
exit 1
}

Expand Down Expand Up @@ -52,39 +54,39 @@ main() {
use_path_style_value="false"

if [ ! -x "occ" ]; then
fail "occ command not found, are you in Nextcloud's root dir?"
log_fatal "occ command not found, are you in Nextcloud's root dir?"
fi

if [ -z "${ENC_OBJECT_STORAGE_BUCKET_NAME}" ]; then
fail "ENC_OBJECT_STORAGE_BUCKET_NAME not set"
log_fatal "ENC_OBJECT_STORAGE_BUCKET_NAME not set"
fi

if [ -z "${ENC_OBJECT_STORAGE_ACCESS_KEY}" ]; then
fail "ENC_OBJECT_STORAGE_ACCESS_KEY not set"
log_fatal "ENC_OBJECT_STORAGE_ACCESS_KEY not set"
fi

if [ -z "${ENC_OBJECT_STORAGE_SECRET}" ]; then
fail "ENC_OBJECT_STORAGE_SECRET not set"
log_fatal "ENC_OBJECT_STORAGE_SECRET not set"
fi

if [ -z "${ENC_OBJECT_STORAGE_REGION}" ]; then
fail "ENC_OBJECT_STORAGE_REGION not set"
log_fatal "ENC_OBJECT_STORAGE_REGION not set"
fi

if [ -z "${ENC_OBJECT_STORAGE_HOSTNAME}" ]; then
fail "ENC_OBJECT_STORAGE_HOSTNAME not set"
log_fatal "ENC_OBJECT_STORAGE_HOSTNAME not set"
fi

if [ -z "${ENC_OBJECT_STORAGE_PORT}" ]; then
fail "ENC_OBJECT_STORAGE_PORT not set"
log_fatal "ENC_OBJECT_STORAGE_PORT not set"
fi

if [ -n "${ENC_OBJECT_STORAGE_USE_SSL}" ] && [ "${ENC_OBJECT_STORAGE_USE_SSL}" != "true" ] && [ "${ENC_OBJECT_STORAGE_USE_SSL}" != "false" ]; then
fail "ENC_OBJECT_STORAGE_USE_SSL, if set should either be true or false"
log_fatal "ENC_OBJECT_STORAGE_USE_SSL, if set should either be true or false"
fi

if [ -n "${ENC_OBJECT_STORAGE_USE_PATH_STYLE}" ] && [ "${ENC_OBJECT_STORAGE_USE_PATH_STYLE}" != "true" ] && [ "${ENC_OBJECT_STORAGE_USE_PATH_STYLE}" != "false" ]; then
fail "ENC_OBJECT_STORAGE_USE_PATH_STYLE, if set should either be true or false"
log_fatal "ENC_OBJECT_STORAGE_USE_PATH_STYLE, if set should either be true or false"
fi

if [ "${ENC_OBJECT_STORAGE_USE_SSL}" = "false" ]; then
Expand All @@ -98,7 +100,7 @@ main() {
echo "Writing ${config} ..."

if ! write_config_file; then
fail "Error writing the object store config: ${config}"
log_fatal "Error writing the object store config: ${config}"
fi

echo "Object store config written: ${config}"
Expand Down
28 changes: 15 additions & 13 deletions configure-user-oidc.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env sh

fail() {
echo "${*}" >/dev/stderr
# Log fatal error message and exit with failure code
# Usage: log_fatal <message>
log_fatal() {
echo "\033[1;31m[x] Fatal Error: ${*}\033[0m" >/dev/stderr
exit 1
}

Expand Down Expand Up @@ -37,49 +39,49 @@ main() {
# - ENC_OIDC_SCOPES (space separated list of scopes, usually at least "openid email profile")

if [ ! -x "occ" ]; then
fail "occ command not found, are you in Nextcloud's root dir?"
log_fatal "occ command not found, are you in Nextcloud's root dir?"
fi

if ! jq --version 2>/dev/null 2>&1; then
fail "jq not found"
log_fatal "jq not found"
fi

if [ -z "${ENC_OIDC_PROVIDER_IDENTIFIER}" ]; then
fail "ENC_OIDC_PROVIDER_IDENTIFIER not set"
log_fatal "ENC_OIDC_PROVIDER_IDENTIFIER not set"
fi

if [ -z "${ENC_OIDC_CLIENT_ID}" ]; then
fail "ENC_OIDC_CLIENT_ID not set"
log_fatal "ENC_OIDC_CLIENT_ID not set"
fi

if [ -z "${ENC_OIDC_SECRET}" ]; then
fail "ENC_OIDC_SECRET not set"
log_fatal "ENC_OIDC_SECRET not set"
fi

if [ -z "${ENC_OIDC_DISCOVERY_URI}" ]; then
fail "ENC_OIDC_DISCOVERY_URI not set"
log_fatal "ENC_OIDC_DISCOVERY_URI not set"
fi

if [ -z "${ENC_OIDC_EXTRA_CLAIMS}" ]; then
fail "ENC_OIDC_EXTRA_CLAIMS not set"
log_fatal "ENC_OIDC_EXTRA_CLAIMS not set"
fi

if [ -z "${ENC_OIDC_MAPPING_UID}" ]; then
fail "ENC_OIDC_MAPPING_UID not set"
log_fatal "ENC_OIDC_MAPPING_UID not set"
fi

if [ -z "${ENC_OIDC_SCOPES}" ]; then
fail "ENC_OIDC_SCOPES not set"
log_fatal "ENC_OIDC_SCOPES not set"
fi

if ! configure_user_oidc; then
fail "Error creating provider \"${ENC_OIDC_PROVIDER_IDENTIFIER}\" with client ID \"${ENC_OIDC_CLIENT_ID}\" (occ failed)"
log_fatal "Error creating provider \"${ENC_OIDC_PROVIDER_IDENTIFIER}\" with client ID \"${ENC_OIDC_CLIENT_ID}\" (occ failed)"
fi

provider_id=$( ./occ user_oidc:provider "${ENC_OIDC_PROVIDER_IDENTIFIER}" --output=json | jq --arg "clientId" "${ENC_OIDC_CLIENT_ID}" 'select(.clientId == $clientId).id' 2>/dev/null )

if [ -z "${provider_id}" ]; then
fail "Error creating provider \"${ENC_OIDC_PROVIDER_IDENTIFIER}\" with client ID \"${ENC_OIDC_CLIENT_ID}\": not found"
log_fatal "Error creating provider \"${ENC_OIDC_PROVIDER_IDENTIFIER}\" with client ID \"${ENC_OIDC_CLIENT_ID}\": not found"
fi

echo "Provider \"${ENC_OIDC_PROVIDER_IDENTIFIER}\" with client ID \"${ENC_OIDC_CLIENT_ID}\" created. Provider ID: ${provider_id}"
Expand Down
Loading