From ea744ac6f1164f63387f32fee3e9b7ffeeca5aac Mon Sep 17 00:00:00 2001 From: root Date: Fri, 23 May 2025 18:01:30 +0000 Subject: [PATCH] Implemented v1 --- .gitignore | 1 + menu_items.txt | 2 ++ selfhosting.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 .gitignore create mode 100644 menu_items.txt create mode 100755 selfhosting.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea5a616 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +apps diff --git a/menu_items.txt b/menu_items.txt new file mode 100644 index 0000000..a2833a1 --- /dev/null +++ b/menu_items.txt @@ -0,0 +1,2 @@ +Vaultwarden|https://git.giovanesaggio.com/Selfhosting/vaultwarden.git +SMB Tools|https://git.giovanesaggio.com/Selfhosting/smb_utilities.git diff --git a/selfhosting.sh b/selfhosting.sh new file mode 100755 index 0000000..75ab5ff --- /dev/null +++ b/selfhosting.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +MENU_FILE="menu_items.txt" + +# Check for git +if ! command -v git &> /dev/null; then + echo "Error: git is not installed." + exit 1 +fi + +# Check if file exists +if [[ ! -f "$MENU_FILE" ]]; then + echo "Menu file '$MENU_FILE' not found." + exit 1 +fi + +# Temp file for dialog output +tempfile=$(mktemp) + +# Build dialog menu options +options=() +while IFS='|' read -r label url; do + options+=("$label" "") +done < "$MENU_FILE" + +# Show the dialog +dialog --clear --title "Select Repository to Clone" \ +--menu "Choose a repository:" 15 70 6 \ +"${options[@]}" 2>"$tempfile" + +choice=$(<"$tempfile") +rm -f "$tempfile" +clear + +# Find the corresponding URL and clone +if [[ -n "$choice" ]]; then + url=$(awk -F'|' -v label="$choice" '$1 == label {print $2}' "$MENU_FILE") + if [[ -n "$url" ]]; then + echo "Cloning repository: $url" + + # Make sure apps folder exists + mkdir -p apps + cd apps || exit 1 + + # Extract repo name (without .git suffix) + repo_name=$(basename "$url" .git) + + # Clone the repo + git clone "$url" + + # Enter the repo folder + if [[ -d "$repo_name" ]]; then + cd "$repo_name" || echo "Failed to enter folder $repo_name" + echo "You are now in $(pwd)" + $SHELL # start a new shell session here if running interactively + else + echo "Cloning failed or directory not found: $repo_name" + fi + else + echo "No URL found for: $choice" + fi +else + echo "No selection made." +fi \ No newline at end of file