Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 120 additions & 31 deletions index.bash
Original file line number Diff line number Diff line change
@@ -1,34 +1,123 @@
#!/bin/bash

# Ruta al directorio principal
MAIN_DIR="./"

# Listar las carpetas disponibles en el directorio principal
echo "Carpetas disponibles:"
folders=("$MAIN_DIR"/*/)
for ((i = 0; i < ${#folders[@]}; i++)); do
echo "$(($i + 1))) $(basename "${folders[$i]}")"
done

# Solicitar al usuario que elija la carpeta
echo "Ingrese el número de la carpeta que desea instalar (separados por espacios):"
read -r -a selections

# Iterar sobre las selecciones y ejecutar los scripts de instalación en cada carpeta seleccionada
for selection in "${selections[@]}"; do
index=$((selection - 1))
if [[ $index -ge 0 && $index -lt ${#folders[@]} ]]; then
folder="${folders[$index]}"
install_script="$folder/install.sh"
# Verificar si existe un script de instalación en la carpeta seleccionada
if [[ -f "$install_script" ]]; then
echo "Instalando desde la carpeta: $(basename "$folder")"
# Ejecutar el script de instalación en la carpeta seleccionada
bash "$install_script"
else
echo "No se encontró un script de instalación en la carpeta: $(basename "$folder")"
#!/usr/bin/env bash

set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SYSTEM_DIR="$ROOT_DIR/system"
NETWORK_DIR="$ROOT_DIR/network"
UTILS_DIR="$ROOT_DIR/utils"
LAMP_DIR="$ROOT_DIR/lamp"
DEPENDENCY_SCRIPT="$SYSTEM_DIR/install_dependencies.sh"

handle_interrupt() {
echo
echo "Interrupción detectada. Saliendo..."
exit 130
}

trap handle_interrupt SIGINT SIGTERM

print_header() {
echo
echo "=============================================="
echo " Scripts Manager (Linux / enfoque ArchLinux)"
echo "=============================================="
echo
}

list_scripts() {
local dir="$1"
local exclude_file="${2:-}"

find "$dir" -type f \( -name "*.sh" -o -name "*.bash" \) 2>/dev/null \
| sort \
| while IFS= read -r script; do
if [[ -n "$exclude_file" && "$script" == "$exclude_file" ]]; then
continue
fi
if [[ -x "$script" || "$script" == *.sh || "$script" == *.bash ]]; then
echo "$script"
fi
done
}

run_script() {
local script_path="$1"

if [[ ! -f "$script_path" ]]; then
echo "No se encontró: $script_path"
return
fi

echo
echo "Ejecutando: $script_path"
echo "----------------------------------------------"
bash "$script_path"
echo "----------------------------------------------"
echo
read -r -p "Presiona Enter para continuar..." _
}

show_category_menu() {
local category_name="$1"
local category_dir="$2"
local exclude_file="${3:-}"

while true; do
mapfile -t scripts < <(list_scripts "$category_dir" "$exclude_file")

echo
echo "=== $category_name ==="

if [[ ${#scripts[@]} -eq 0 ]]; then
echo "No hay scripts disponibles en esta categoría."
read -r -p "Presiona Enter para volver..." _
return
fi

for i in "${!scripts[@]}"; do
relative_path="${scripts[$i]#"$ROOT_DIR"/}"
printf "%2d) %s\n" "$((i + 1))" "$relative_path"
done
echo " 0) Volver"

read -r -p "Selecciona una opción: " choice

if [[ "$choice" == "0" ]]; then
return
fi

if [[ "$choice" =~ ^[0-9]+$ ]] && (( choice >= 1 && choice <= ${#scripts[@]} )); then
run_script "${scripts[$((choice - 1))]}"
else
echo "El número de carpeta '$selection' no es válido."
echo "Opción inválida."
fi
done
done
}

main_menu() {
while true; do
print_header
echo "1) Instalar dependencias base (recomendado)"
echo "2) Menú de Sistema"
echo "3) Menú de Red"
echo "4) Menú de Utilidades"
echo "5) Menú LAMP"
echo "0) Salir"
echo

read -r -p "Elige una opción: " option

case "$option" in
1) run_script "$DEPENDENCY_SCRIPT" ;;
2) show_category_menu "Sistema" "$SYSTEM_DIR" "$DEPENDENCY_SCRIPT" ;;
3) show_category_menu "Red" "$NETWORK_DIR" ;;
4) show_category_menu "Utilidades" "$UTILS_DIR" ;;
5) show_category_menu "LAMP" "$LAMP_DIR" ;;
0) echo "Saliendo."; exit 0 ;;
*) echo "Opción inválida." ;;
esac
done
}

main_menu
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
114 changes: 114 additions & 0 deletions system/install_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/usr/bin/env bash

set -euo pipefail

SUDO=""
if [[ ${EUID:-$(id -u)} -ne 0 ]]; then
SUDO="sudo"
fi

detect_manager() {
if command -v pacman >/dev/null 2>&1; then
echo "pacman"
elif command -v apt-get >/dev/null 2>&1; then
echo "apt"
elif command -v dnf >/dev/null 2>&1; then
echo "dnf"
elif command -v zypper >/dev/null 2>&1; then
echo "zypper"
else
echo ""
fi
}

is_arch_like() {
if [[ -f /etc/os-release ]]; then
. /etc/os-release
[[ "${ID:-}" =~ ^(arch|manjaro)$ ]] || [[ "${ID_LIKE:-}" == *"arch"* ]]
else
return 1
fi
}

install_with_pacman() {
local packages=(
bash coreutils grep sed gawk findutils
curl wget git openssh
nmap dialog zenity fzf
net-tools iproute2
python python-pip
)

if is_arch_like; then
packages+=(base-devel)
fi

echo "Instalando dependencias con pacman..."
$SUDO pacman -Sy --needed --noconfirm "${packages[@]}"
}

install_with_apt() {
local packages=(
bash coreutils grep sed gawk findutils
curl wget git openssh-client
nmap dialog zenity fzf
net-tools iproute2
python3 python3-pip
)

echo "Instalando dependencias con apt..."
$SUDO apt-get update
$SUDO apt-get install -y "${packages[@]}"
}

install_with_dnf() {
local packages=(
bash coreutils grep sed gawk findutils
curl wget git openssh-clients
nmap dialog zenity fzf
net-tools iproute
python3 python3-pip
)

echo "Instalando dependencias con dnf..."
$SUDO dnf install -y "${packages[@]}"
}

install_with_zypper() {
local packages=(
bash coreutils grep sed gawk findutils
curl wget git openssh
nmap dialog zenity fzf
net-tools iproute2
python3 python3-pip
)

echo "Instalando dependencias con zypper..."
$SUDO zypper --non-interactive install "${packages[@]}"
}

main() {
local manager
manager="$(detect_manager)"

if [[ -z "$manager" ]]; then
echo "No se encontró un gestor de paquetes soportado (pacman/apt/dnf/zypper)."
exit 1
fi

case "$manager" in
pacman) install_with_pacman ;;
apt) install_with_apt ;;
dnf) install_with_dnf ;;
zypper) install_with_zypper ;;
*)
echo "Gestor de paquetes no soportado: $manager"
exit 1
;;
esac

echo
echo "Dependencias base instaladas correctamente."
}

main "$@"
File renamed without changes.
File renamed without changes.
87 changes: 87 additions & 0 deletions system/servicios/zenity-service/app/gestor_servicios.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

if ! sudo -v; then
zenity --error --title="Error" --text="No se pudo validar sudo. La aplicación se cerrará."
exit 1
fi

# Lista de servicios
servicios=("ModemManager" "packagekit" "avahi-daemon" "colord" "nmb" "smb" "power-profiles-daemon" "rtkit-daemon" "NetworkManager-wait-online" "cups-browsed" "bluetooth" "wpa_supplicant" "org.cups.cupsd" "httpd" "webmin" "sshd")

# Función para obtener el estado de un servicio
get_status() {
local servicio=$1
if systemctl is-active --quiet "$servicio.service"; then
echo "Encendido"
else
echo "Apagado"
fi
}

# Crear la interfaz gráfica
while true; do
# Crear una lista de opciones para zenity
opciones=("Encender todos" "Acción global" "Apagar todos" "Acción global" "Habilitar todos" "Acción global" "Deshabilitar todos" "Acción global")
for servicio in "${servicios[@]}"; do
estado=$(get_status "$servicio")
opciones+=("$servicio" "$estado")
done

# Mostrar la interfaz gráfica con una ventana más grande
seleccion=$(zenity --list --title="Gestión de Servicios" --column="Servicio" --column="Estado" "${opciones[@]}" --extra-button="Salir" --width=800 --height=600)

# Si el usuario selecciona "Salir", salir del bucle
if [ "$seleccion" == "Salir" ]; then
break
fi

# Si el usuario selecciona "Encender todos"
if [ "$seleccion" == "Encender todos" ]; then
for servicio in "${servicios[@]}"; do
sudo systemctl start "$servicio.service"
done
zenity --info --title="Encender todos" --text="Todos los servicios han sido encendidos."
continue
fi

# Si el usuario selecciona "Apagar todos"
if [ "$seleccion" == "Apagar todos" ]; then
for servicio in "${servicios[@]}"; do
sudo systemctl stop "$servicio.service"
done
zenity --info --title="Apagar todos" --text="Todos los servicios han sido apagados."
continue
fi

# Si el usuario selecciona "Habilitar todos"
if [ "$seleccion" == "Habilitar todos" ]; then
for servicio in "${servicios[@]}"; do
sudo systemctl enable "$servicio.service"
done
zenity --info --title="Habilitar todos" --text="Todos los servicios han sido habilitados."
continue
fi

# Si el usuario selecciona "Deshabilitar todos"
if [ "$seleccion" == "Deshabilitar todos" ]; then
for servicio in "${servicios[@]}"; do
sudo systemctl disable "$servicio.service"
done
zenity --info --title="Deshabilitar todos" --text="Todos los servicios han sido deshabilitados."
continue
fi

# Si el usuario selecciona un servicio, mostrar opciones para iniciar/detener/habilitar/deshabilitar
if [ -n "$seleccion" ]; then
accion=$(zenity --list --title="Acción para $seleccion" --column="Acción" "Iniciar" "Detener" "Habilitar" "Deshabilitar" --width=600 --height=400)
if [ "$accion" == "Iniciar" ]; then
sudo systemctl start "$seleccion.service"
elif [ "$accion" == "Detener" ]; then
sudo systemctl stop "$seleccion.service"
elif [ "$accion" == "Habilitar" ]; then
sudo systemctl enable "$seleccion.service"
elif [ "$accion" == "Deshabilitar" ]; then
sudo systemctl disable "$seleccion.service"
fi
fi
done
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start ModemManager.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start NetworkManager-wait-online.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start avahi-daemon.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start bluetooth.service
2 changes: 2 additions & 0 deletions system/servicios/zenity-service/app/scripts/start_colord.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start colord.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start cups-browsed.service
2 changes: 2 additions & 0 deletions system/servicios/zenity-service/app/scripts/start_httpd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start httpd.service
2 changes: 2 additions & 0 deletions system/servicios/zenity-service/app/scripts/start_nmb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start nmb.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start org.cups.cupsd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start packagekit.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start power-profiles-daemon.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start rtkit-daemon.service
2 changes: 2 additions & 0 deletions system/servicios/zenity-service/app/scripts/start_smb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start smb.service
2 changes: 2 additions & 0 deletions system/servicios/zenity-service/app/scripts/start_sshd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
sudo systemctl start sshd.service
Loading