diff options
| author | UMTS at Teleco <crt@teleco.ch> | 2026-01-11 20:53:14 +0100 |
|---|---|---|
| committer | UMTS at Teleco <crt@teleco.ch> | 2026-01-11 20:53:14 +0100 |
| commit | db3dd1aa6341d1cba07b198b859f6cf51d941e5a (patch) | |
| tree | 9977efb4ad9c44885079bfefdd1db37f6077f075 | |
| parent | 79a4be4a0b7f7a3127a815e14cc3534699d8bfce (diff) | |
ugh
| -rwxr-xr-x | beepzone-helper.sh | 76 |
1 files changed, 65 insertions, 11 deletions
diff --git a/beepzone-helper.sh b/beepzone-helper.sh index 0383e82..562ebe0 100755 --- a/beepzone-helper.sh +++ b/beepzone-helper.sh @@ -228,8 +228,16 @@ show_capabilities_screen() { echo " [X] Clean sources" echo " [X] Quit" echo "Options that depend on missing tools are hidden in the main menu." + echo "" + if $IS_DEBIAN_NATIVE; then + echo "Quick Setup for Debian Native:" + echo " sudo apt install mariadb-server mariadb-client apache2-utils git build-essential libssl-dev pkg-config libclang-dev" + echo "" + echo "For Rust/Cargo:" + echo " curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh" + fi } > "$cf" - "$DIALOG" --title "BeepZone Helper" "${DIALOG_OK_FLAG[@]}" --textbox "$cf" 22 78 || true + "$DIALOG" --title "BeepZone Helper" "${DIALOG_OK_FLAG[@]}" --textbox "$cf" 24 80 || true rm -f "$cf" } @@ -680,19 +688,32 @@ create_user() { return fi - # Hash password with bcrypt (cost 12) - local password_hash + # Hash password with bcrypt (cost 12) and avoid set -e aborts + local password_hash status + status=1 # Try htpasswd first (native Unix tool) if command -v htpasswd >/dev/null 2>&1; then - password_hash=$(htpasswd -nbB -C 12 "$username" "$password" 2>>"$LOG_FILE" | cut -d: -f2) + set +e + password_hash=$(htpasswd -nbB -C 12 "$username" "$password" 2>>"$LOG_FILE") + status=$? + set -e + password_hash=$(echo "$password_hash" | cut -d: -f2) # Fall back to Python bcrypt elif command -v python3 >/dev/null 2>&1; then - password_hash=$(python3 -c "import bcrypt; print(bcrypt.hashpw('$password'.encode('utf-8'), bcrypt.gensalt(12)).decode('utf-8'))" 2>>"$LOG_FILE") + set +e + password_hash=$(python3 - "$password" "$username" 2>>"$LOG_FILE" <<'PY' +import sys, bcrypt +pw = sys.argv[1] +print(bcrypt.hashpw(pw.encode('utf-8'), bcrypt.gensalt(12)).decode('utf-8')) +PY +) + status=$? + set -e fi - if [[ -z "$password_hash" ]]; then - $DIALOG --msgbox "Error: Failed to hash password. No bcrypt tool found.\n\nInstall options:\n- htpasswd: brew install httpd (macOS) or apt install apache2-utils (Linux)\n- Python bcrypt: pip3 install bcrypt" 12 70 + if [[ $status -ne 0 || -z "$password_hash" ]]; then + $DIALOG --msgbox "Error: Failed to hash password.\n\nInstall one of these:\n- htpasswd: brew install httpd (macOS) or apt install apache2-utils (Linux)\n- Python bcrypt: pip3 install bcrypt" 12 70 return fi @@ -1003,7 +1024,40 @@ setup_seckelapi_native() { return 1 fi - # 5. Install Systemd Service + # 5. Ask for installation directory + local install_dir default_install_dir + default_install_dir="$HOME/seckelapi" + + $DIALOG --inputbox "Where should SeckelAPI be installed?\n\n(Binary and config will be copied here)" 12 70 "$default_install_dir" 2>"$TMP_FILE" || return + install_dir=$(<"$TMP_FILE") + + if [[ -z "$install_dir" ]]; then + install_dir="$default_install_dir" + fi + + # Create installation directory + mkdir -p "$install_dir/config" || { + $DIALOG --msgbox "Failed to create installation directory:\n$install_dir" 10 70 + return 1 + } + + # Copy binary and config files + local target_dir="$sources_dir/target/release" + cp "$target_dir/seckelapi" "$install_dir/" 2>>"$LOG_FILE" || { + $DIALOG --msgbox "Failed to copy binary to $install_dir" 10 70 + return 1 + } + cp "$sources_dir/config"/*.toml "$install_dir/config/" 2>>"$LOG_FILE" || { + $DIALOG --msgbox "Failed to copy config files to $install_dir/config" 10 70 + return 1 + } + + # Make binary executable + chmod +x "$install_dir/seckelapi" + + $DIALOG --msgbox "SeckelAPI installed to:\n$install_dir\n\nBinary: $install_dir/seckelapi\nConfig: $install_dir/config/" 12 70 + + # 6. Install Systemd Service if $DIALOG --yesno "Do you want to install SeckelAPI as a systemd service?" 8 60; then local service_name="beepzone-seckelapi" local service_file="/tmp/${service_name}.service" @@ -1011,8 +1065,8 @@ setup_seckelapi_native() { current_user=$(whoami) # Working directory for the binary - local working_dir="$sources_dir/target/release" - local exec_path="$working_dir/seckelapi" + local working_dir="$install_dir" + local exec_path="$install_dir/seckelapi" cat > "$service_file" <<EOF [Unit] @@ -1039,7 +1093,7 @@ EOF sudo systemctl enable "${service_name}" if sudo systemctl start "${service_name}"; then - $DIALOG --msgbox "Service '${service_name}' installed and started successfully!" 8 60 + $DIALOG --msgbox "Service '${service_name}' installed and started successfully!\n\nInstallation: $install_dir\nService: $service_name" 10 70 else $DIALOG --msgbox "Failed to start service '${service_name}'. Check 'sudo systemctl status ${service_name}'" 10 70 fi |
