64 lines
1.4 KiB
Bash
Executable File
64 lines
1.4 KiB
Bash
Executable File
#!/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 |