|
@@ -228,8 +228,16 @@ show_capabilities_screen() {
|
|
|
echo " [X] Clean sources"
|
|
echo " [X] Clean sources"
|
|
|
echo " [X] Quit"
|
|
echo " [X] Quit"
|
|
|
echo "Options that depend on missing tools are hidden in the main menu."
|
|
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"
|
|
} > "$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"
|
|
rm -f "$cf"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -680,19 +688,32 @@ create_user() {
|
|
|
return
|
|
return
|
|
|
fi
|
|
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)
|
|
# Try htpasswd first (native Unix tool)
|
|
|
if command -v htpasswd >/dev/null 2>&1; then
|
|
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
|
|
# Fall back to Python bcrypt
|
|
|
elif command -v python3 >/dev/null 2>&1; then
|
|
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
|
|
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
|
|
return
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
@@ -1003,7 +1024,40 @@ setup_seckelapi_native() {
|
|
|
return 1
|
|
return 1
|
|
|
fi
|
|
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
|
|
if $DIALOG --yesno "Do you want to install SeckelAPI as a systemd service?" 8 60; then
|
|
|
local service_name="beepzone-seckelapi"
|
|
local service_name="beepzone-seckelapi"
|
|
|
local service_file="/tmp/${service_name}.service"
|
|
local service_file="/tmp/${service_name}.service"
|
|
@@ -1011,8 +1065,8 @@ setup_seckelapi_native() {
|
|
|
current_user=$(whoami)
|
|
current_user=$(whoami)
|
|
|
|
|
|
|
|
# Working directory for the binary
|
|
# 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
|
|
cat > "$service_file" <<EOF
|
|
|
[Unit]
|
|
[Unit]
|
|
@@ -1039,7 +1093,7 @@ EOF
|
|
|
sudo systemctl enable "${service_name}"
|
|
sudo systemctl enable "${service_name}"
|
|
|
|
|
|
|
|
if sudo systemctl start "${service_name}"; then
|
|
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
|
|
else
|
|
|
$DIALOG --msgbox "Failed to start service '${service_name}'. Check 'sudo systemctl status ${service_name}'" 10 70
|
|
$DIALOG --msgbox "Failed to start service '${service_name}'. Check 'sudo systemctl status ${service_name}'" 10 70
|
|
|
fi
|
|
fi
|