aboutsummaryrefslogtreecommitdiff
path: root/beepzone-helper.sh
diff options
context:
space:
mode:
Diffstat (limited to 'beepzone-helper.sh')
-rwxr-xr-xbeepzone-helper.sh56
1 files changed, 53 insertions, 3 deletions
diff --git a/beepzone-helper.sh b/beepzone-helper.sh
index 38735c4..f8d1e59 100755
--- a/beepzone-helper.sh
+++ b/beepzone-helper.sh
@@ -104,13 +104,14 @@ ask_main_menu() {
while true; do
$DIALOG --clear \
--title "BeepZone Setup" \
- --menu "Choose an action" 16 76 6 \
+ --menu "Choose an action" 17 76 7 \
1 "Configure & run MariaDB (podman)" \
2 "Import DB schema & data" \
3 "Manage users & roles" \
4 "Configure & setup SeckelAPI" \
5 "Build desktop client" \
- 6 "Quit" 2>"$CHOICE_FILE"
+ 6 "Clean sources" \
+ 7 "Quit" 2>"$CHOICE_FILE"
choice=$(<"$CHOICE_FILE")
case $choice in
@@ -119,7 +120,8 @@ ask_main_menu() {
3) manage_users_and_roles ;;
4) setup_seckelapi ;;
5) build_desktop_client ;;
- 6) exit 0 ;;
+ 6) clean_sources ;;
+ 7) exit 0 ;;
esac
done
}
@@ -688,6 +690,54 @@ setup_seckelapi() {
fi
}
+clean_sources() {
+ $DIALOG --yesno "This will delete all sources directories including hidden files:\n\n- backend/seckelapi/sources\n- frontend/desktop-client/sources\n\nAre you sure?" 12 70 || return
+
+ local seckelapi_sources="$WORK_DIR/backend/seckelapi/sources"
+ local client_sources="$WORK_DIR/frontend/desktop-client/sources"
+
+ # Clean SeckelAPI sources
+ if [[ -d "$seckelapi_sources" ]]; then
+ find "$seckelapi_sources" -mindepth 1 -delete 2>>"$LOG_FILE"
+ if [[ $? -eq 0 ]]; then
+ echo "SeckelAPI sources contents removed" >>"$LOG_FILE"
+ fi
+ fi
+
+ # Clean desktop client sources
+ if [[ -d "$client_sources" ]]; then
+ find "$client_sources" -mindepth 1 -delete 2>>"$LOG_FILE"
+ if [[ $? -eq 0 ]]; then
+ echo "Desktop client sources contents removed" >>"$LOG_FILE"
+ fi
+ fi
+
+ $DIALOG --msgbox "All sources cleaned!" 7 50
+
+ # Ask to re-clone
+ if $DIALOG --yesno "Do you want to pull fresh sources now?" 7 50; then
+ # Clone SeckelAPI
+ mkdir -p "$(dirname "$seckelapi_sources")"
+ if clone_if_missing "$SECKELAPI_REPO" "$seckelapi_sources"; then
+ $DIALOG --msgbox "SeckelAPI sources cloned successfully!" 7 50
+ else
+ $DIALOG --msgbox "Failed to clone SeckelAPI sources. Check log." 7 50
+ return 1
+ fi
+
+ # Clone desktop client
+ mkdir -p "$(dirname "$client_sources")"
+ if clone_if_missing "$CLIENT_REPO" "$client_sources"; then
+ $DIALOG --msgbox "Desktop client sources cloned successfully!" 7 50
+ else
+ $DIALOG --msgbox "Failed to clone desktop client sources. Check log." 7 50
+ return 1
+ fi
+
+ $DIALOG --msgbox "All sources pulled fresh!" 7 50
+ fi
+}
+
build_desktop_client() {
local sources_dir="$WORK_DIR/frontend/desktop-client/sources"