aboutsummaryrefslogtreecommitdiff
path: root/beepzone-helper.sh
diff options
context:
space:
mode:
authorUMTS at Teleco <crt@teleco.ch>2026-01-11 20:21:14 +0100
committerUMTS at Teleco <crt@teleco.ch>2026-01-11 20:21:14 +0100
commitb85b6d83d6c90dc6f8b2ef761fa39f9a4b280493 (patch)
treecfb56775d68b820c766927b3d82340f341325d50 /beepzone-helper.sh
parentb9506be0a6cb9b58a6ce634a13cbf3b3c7155545 (diff)
better dependency check
Diffstat (limited to 'beepzone-helper.sh')
-rwxr-xr-xbeepzone-helper.sh114
1 files changed, 95 insertions, 19 deletions
diff --git a/beepzone-helper.sh b/beepzone-helper.sh
index 96098cf..da4b8a6 100755
--- a/beepzone-helper.sh
+++ b/beepzone-helper.sh
@@ -17,13 +17,18 @@ if ! command -v "$DIALOG" >/dev/null 2>&1; then
exit 1
fi
+# Determine whether the dialog implementation supports custom OK label
+# 'dialog' uses --ok-label, 'whiptail' uses --ok-button
+declare -a DIALOG_OK_FLAG=()
+if "$DIALOG" --help 2>&1 | grep -q -- "--ok-label"; then
+ DIALOG_OK_FLAG=(--ok-label "Continue")
+elif "$DIALOG" --help 2>&1 | grep -q -- "--ok-button"; then
+ DIALOG_OK_FLAG=(--ok-button "Continue")
+fi
+
HAS_PODMAN=true
if ! command -v podman >/dev/null 2>&1; then
HAS_PODMAN=false
- "$DIALOG" --title "BeepZone Setup" --yes-label "Exit" --no-label "Ignore" --yesno "podman is recommended but not found in PATH.\nPlease install and configure podman (for dev work podman-desktop is recommended)." 10 60
- if [ $? -eq 0 ]; then
- exit 1
- fi
fi
IS_DEBIAN_NATIVE=false
@@ -60,11 +65,17 @@ elif [[ -x /usr/local/bin/mariadb ]]; then
elif [[ -x /usr/local/bin/mysql ]]; then
MYSQL_CLIENT="/usr/local/bin/mysql"
export PATH="/usr/local/bin:$PATH"
-else
- "$DIALOG" --title "BeepZone Setup" --yes-label "Exit" --no-label "Ignore" --yesno "MariaDB/MySQL client is required but not found.\n\nSearched locations:\n- System PATH\n- /opt/homebrew/opt/mysql-client/bin/\n- /opt/homebrew/opt/mariadb/bin/\n- /opt/homebrew/bin/\n- /usr/local/opt/mysql-client/bin/\n- /usr/local/bin/\n\nOn macOS: brew install mysql-client\nOn Debian: sudo apt-get install mariadb-client" 18 70
- if [ $? -eq 0 ]; then
- exit 1
- fi
+fi
+
+# Cargo / Git detection (hide menu options if missing)
+HAS_CARGO=false
+if command -v cargo >/dev/null 2>&1; then
+ HAS_CARGO=true
+fi
+
+HAS_GIT=false
+if command -v git >/dev/null 2>&1; then
+ HAS_GIT=true
fi
TMP_FILE="$(mktemp)"
@@ -97,7 +108,7 @@ fi
save_env() {
cat > "$ENV_FILE" << EOF
# BeepZone Setup Configuration
-# Auto-generated by beepzone-helper.sh
+# Mostly autogenerated by beepzone-helper
BEEPZONE_DB_CONTAINER_NAME="$BEEPZONE_DB_CONTAINER_NAME"
BEEPZONE_DB_IMAGE="$BEEPZONE_DB_IMAGE"
@@ -113,6 +124,58 @@ DEPLOYMENT_TYPE="$DEPLOYMENT_TYPE"
EOF
}
+show_capabilities_screen() {
+ local cf
+ cf="$(mktemp)"
+ {
+ echo "Dependency Overview"
+ echo ""
+ echo "What you can do :"
+ if $HAS_PODMAN; then
+ echo " [X] Configure and run MariaDB using podman"
+ else
+ echo " [ ] Configure and run MariaDB using podman - requires podman in PATH"
+ fi
+ if $IS_DEBIAN_NATIVE; then
+ echo " [X] Configure and run MariaDB natively on your system"
+ else
+ echo " [ ] Configure and run MariaDB natively on your system - requires Debian 12/13"
+ fi
+ if [[ -n "$MYSQL_CLIENT" ]]; then
+ echo " [X] Import DB schema or seeded demo DB"
+ echo " [X] Manage users and roles"
+ else
+ echo " [ ] Import DB schema or seeded demo DB - requires MariaDB/MySQL client"
+ echo " [ ] Manage users and roles - requires MariaDB/MySQL client"
+ fi
+ if $HAS_PODMAN; then
+ echo " [X] Configure and setup SeckelAPI using podman"
+ else
+ echo " [ ] Configure and setup SeckelAPI using podman - requires podman in PATH"
+ fi
+ if $IS_DEBIAN_NATIVE && $HAS_CARGO; then
+ echo " [X] Setup SeckelAPI natively on your system"
+ else
+ echo " [ ] Setup SeckelAPI natively on your system - requires Debian 12/13 and cargo"
+ fi
+ if $HAS_CARGO; then
+ echo " [X] Build desktop client"
+ else
+ echo " [ ] Build desktop client - requires cargo (Rust toolchain)"
+ fi
+ if $HAS_GIT; then
+ echo " [X] Update from git masters"
+ else
+ echo " [ ] Update from git masters - requires git"
+ fi
+ echo " [X] Clean sources"
+ echo " [X] Quit"
+ echo "Options that depend on missing tools are hidden in the main menu."
+ } > "$cf"
+ "$DIALOG" --title "BeepZone Helper" "${DIALOG_OK_FLAG[@]}" --textbox "$cf" 22 78 || true
+ rm -f "$cf"
+}
+
ask_main_menu() {
while true; do
local options=()
@@ -122,7 +185,11 @@ ask_main_menu() {
fi
if $IS_DEBIAN_NATIVE; then
- options+=(9 "Configure and run MariaDB (native Debian)") options+=(10 "Setup SeckelAPI (Native Debian)") fi
+ options+=(9 "Configure and run MariaDB (native Debian)")
+ if $HAS_CARGO; then
+ options+=(10 "Setup SeckelAPI (Native Debian)")
+ fi
+ fi
if [[ -n "$MYSQL_CLIENT" ]]; then
options+=(
@@ -135,12 +202,13 @@ ask_main_menu() {
options+=(4 "Configure and setup SeckelAPI (podman)")
fi
- options+=(
- 5 "Build desktop client"
- 6 "Update from git masters"
- 7 "Clean sources"
- 8 "Quit"
- )
+ if $HAS_CARGO; then
+ options+=(5 "Build desktop client")
+ fi
+
+ options+=(6 "Update from git masters")
+ options+=(7 "Clean sources")
+ options+=(8 "Quit")
$DIALOG --clear \
--title "BeepZone Setup" \
@@ -680,7 +748,7 @@ setup_seckelapi() {
--title "Build & Deploy SeckelAPI" \
--menu "Choose an action:" 12 70 2 \
1 "Build and deploy to podman container" \
- 2 "Build natively on host" 2>"$CHOICE_FILE"
+ $( $HAS_CARGO && echo "2 \"Build natively on host\"" ) 2>"$CHOICE_FILE"
[[ ! -s "$CHOICE_FILE" ]] && return 0
build_choice=$(<"$CHOICE_FILE")
@@ -787,6 +855,10 @@ setup_seckelapi() {
}
setup_seckelapi_native() {
+ if ! $HAS_CARGO; then
+ "$DIALOG" --msgbox "Cargo not found in PATH.\n\nInstall Rust toolchain (rustup) to use native SeckelAPI setup." 10 70
+ return
+ fi
# 1. Check Pre-requisites
$DIALOG --msgbox "Pre-requisites for Native SeckelAPI Setup:\n\n1. Rust toolchain (rustup, cargo)\n2. build-essential (gcc, etc.)\n3. pkg-config\n4. libssl-dev\n5. Sudo privileges (for systemd service)\n\nEnsure these are met before proceeding." 14 60
@@ -978,6 +1050,10 @@ clean_sources() {
build_desktop_client() {
local sources_dir="$WORK_DIR/frontend/desktop-client/sources"
+ if ! $HAS_CARGO; then
+ "$DIALOG" --msgbox "Cargo not found in PATH.\n\nInstall Rust toolchain (rustup) to build the desktop client." 10 70
+ return
+ fi
# Check if sources are already cloned
if [[ ! -d "$sources_dir/.git" ]]; then
@@ -986,7 +1062,6 @@ build_desktop_client() {
fi
if $DIALOG --yesno "Build BeepZone desktop client in release mode now?" 8 70; then
- clear
echo "Building BeepZone Desktop Client..."
echo "===================================="
echo ""
@@ -1005,4 +1080,5 @@ build_desktop_client() {
fi
}
+show_capabilities_screen
ask_main_menu