Fix admin password reset guidance in setup.sh (#34)
Test and Lint / backend-test (push) Successful in 1m27s
Test and Lint / frontend-test (push) Successful in 1m56s

This commit is contained in:
Paul Nothaft
2025-10-13 19:58:07 +02:00
parent 013be18d98
commit 7040865154
+19 -8
View File
@@ -64,17 +64,19 @@ FORCE_ADMIN_PASSWORD_RESET=false
# Run a command as the application user, even if sudo is not available # Run a command as the application user, even if sudo is not available
run_as_user() { run_as_user() {
local cmd="$*" local cmd="$*"
local current_dir_escaped
current_dir_escaped=$(printf '%q' "$(pwd)")
if [[ "$(id -u)" -ne 0 ]]; then if [[ "$(id -u)" -ne 0 ]]; then
# Already non-root; just run # Already non-root; preserve working directory
bash -lc "$cmd" bash -lc "cd $current_dir_escaped && $cmd"
return $? return $?
fi fi
if command_exists sudo; then if command_exists sudo; then
sudo -H -u "$NATIVE_APP_USER" bash -lc "$cmd" sudo -H -u "$NATIVE_APP_USER" bash -lc "cd $current_dir_escaped && $cmd"
elif command_exists runuser; then elif command_exists runuser; then
runuser -u "$NATIVE_APP_USER" -- bash -lc "$cmd" runuser -u "$NATIVE_APP_USER" -- bash -lc "cd $current_dir_escaped && $cmd"
else else
su -s /bin/bash - "$NATIVE_APP_USER" -c "$cmd" su -s /bin/bash - "$NATIVE_APP_USER" -c "cd $current_dir_escaped && $cmd"
fi fi
} }
@@ -629,7 +631,14 @@ setup_native_installation() {
apt) apt)
apt-get install -y build-essential python3 apt-get install -y build-essential python3
;; ;;
dnf|yum) dnf)
if ! $PACKAGE_MANAGER install -y @development-tools; then
log_warn "dnf @development-tools group install failed, retrying with legacy groupinstall syntax..."
$PACKAGE_MANAGER groupinstall -y "Development Tools"
fi
$PACKAGE_MANAGER install -y python3
;;
yum)
$PACKAGE_MANAGER groupinstall -y "Development Tools" $PACKAGE_MANAGER groupinstall -y "Development Tools"
$PACKAGE_MANAGER install -y python3 $PACKAGE_MANAGER install -y python3
;; ;;
@@ -953,15 +962,17 @@ configure_email() {
} }
print_success_message() { print_success_message() {
local app_dir port local app_dir port manual_reset_hint
if [[ "$INSTALL_METHOD" == "docker" ]]; then if [[ "$INSTALL_METHOD" == "docker" ]]; then
app_dir="$DOCKER_APP_DIR" app_dir="$DOCKER_APP_DIR"
[[ -n "${SUDO_USER:-}" ]] && app_dir="/home/$SUDO_USER/picpeak" [[ -n "${SUDO_USER:-}" ]] && app_dir="/home/$SUDO_USER/picpeak"
port="${CUSTOM_PORT:-$DEFAULT_PORT}" port="${CUSTOM_PORT:-$DEFAULT_PORT}"
manual_reset_hint="cd $(printf %q "$app_dir") && docker compose exec -T backend node scripts/reset-admin-password.js --force --credentials-file data/ADMIN_CREDENTIALS.txt"
else else
app_dir="$NATIVE_APP_DIR" app_dir="$NATIVE_APP_DIR"
port="${CUSTOM_PORT:-$DEFAULT_PORT}" port="${CUSTOM_PORT:-$DEFAULT_PORT}"
manual_reset_hint="cd $(printf %q "${NATIVE_APP_DIR}/app/backend") && sudo -H -u $(printf %q "$NATIVE_APP_USER") node scripts/reset-admin-password.js --force --credentials-file data/ADMIN_CREDENTIALS.txt"
fi fi
print_header "🎉 Installation Complete!" print_header "🎉 Installation Complete!"
@@ -1006,7 +1017,7 @@ print_success_message() {
fi fi
else else
echo -e "Email: ${CYAN}$ADMIN_EMAIL${NC}" echo -e "Email: ${CYAN}$ADMIN_EMAIL${NC}"
echo -e "Password: ${YELLOW}(credentials file not found - rerun setup with --force-admin-password-reset or run node scripts/reset-admin-password.js manually)${NC}" echo -e "Password: ${YELLOW}(credentials file not found - rerun setup with --force-admin-password-reset or run '${manual_reset_hint}')${NC}"
fi fi
echo echo
echo -e "${YELLOW}⚠️ IMPORTANT: Change the admin password on first login!${NC}" echo -e "${YELLOW}⚠️ IMPORTANT: Change the admin password on first login!${NC}"