From 4d692b51b50ccf91c53fd1b91e71d027514bcf88 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 25 May 2025 08:16:47 +0000 Subject: [PATCH] Updates --- filebrowser/.env | 0 filebrowser/install.sh | 63 +++++++++++++++++++++++++- smb_utilities_install.sh => install.sh | 4 +- list_smb_users.sh | 15 +----- 4 files changed, 66 insertions(+), 16 deletions(-) create mode 100644 filebrowser/.env mode change 100644 => 100755 filebrowser/install.sh rename smb_utilities_install.sh => install.sh (97%) diff --git a/filebrowser/.env b/filebrowser/.env new file mode 100644 index 0000000..e69de29 diff --git a/filebrowser/install.sh b/filebrowser/install.sh old mode 100644 new mode 100755 index d4d791a..ef18501 --- a/filebrowser/install.sh +++ b/filebrowser/install.sh @@ -1,3 +1,64 @@ #!/bin/bash -docker compose up -d \ No newline at end of file +# Helper function to check a command +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +DOCKER_OK=true +COMPOSE_OK=true + +# Check for Docker +if ! command_exists docker; then + DOCKER_OK=false +fi + +# Check for Docker Compose (plugin or legacy) +if ! docker compose version >/dev/null 2>&1 && ! command_exists docker-compose; then + COMPOSE_OK=false +fi + +# If either is missing, run install script +if [[ "$DOCKER_OK" = false || "$COMPOSE_OK" = false ]]; then + echo "Missing required tools. Running installer..." + git clone https://git.giovanesaggio.com/Selfhosting/docker_setup.git + ./docker_setup/docker_setup.sh + rm -r docker_setup +fi + +# Parse and prompt for .env variables +ENV_FILE=".env" + +if [[ ! -f "$ENV_FILE" ]]; then + echo "$ENV_FILE not found. Creating a new one." + touch "$ENV_FILE" +fi + +declare -A ENV_VARS + +# Load existing env vars +while IFS='=' read -r key value; do + [[ "$key" =~ ^[A-Z_][A-Z0-9_]*$ ]] || continue + ENV_VARS["$key"]="$value" +done < "$ENV_FILE" + +echo "Configure environment variables (press ENTER to keep current value):" + +# Prompt for each variable +for key in "${!ENV_VARS[@]}"; do + current="${ENV_VARS[$key]}" + read -p "$key [$current]: " new_value + if [[ -n "$new_value" ]]; then + ENV_VARS["$key"]="$new_value" + fi +done + +# Overwrite .env with updated values +> "$ENV_FILE" +for key in "${!ENV_VARS[@]}"; do + echo "$key=${ENV_VARS[$key]}" >> "$ENV_FILE" +done + +# Launch Docker +docker compose up -d + diff --git a/smb_utilities_install.sh b/install.sh similarity index 97% rename from smb_utilities_install.sh rename to install.sh index 4f97fef..6eb0985 100755 --- a/smb_utilities_install.sh +++ b/install.sh @@ -35,5 +35,5 @@ export SMB_TOOLS_PATH="$SCRIPT_DIR" echo "SMB_TOOLS_PATH set to: $SMB_TOOLS_PATH" cd filebrowser -bash ./install -cd .. \ No newline at end of file +bash ./install.sh +cd .. diff --git a/list_smb_users.sh b/list_smb_users.sh index 550ea61..97e1485 100755 --- a/list_smb_users.sh +++ b/list_smb_users.sh @@ -1,23 +1,12 @@ #!/bin/bash -# Define colors -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -NC='\033[0m' # No Color - # Check if pdbedit is installed if ! command -v pdbedit &> /dev/null; then echo -e "${YELLOW}Error:${NC} pdbedit is not installed. Install Samba first." exit 1 fi -# Display heading -echo -e "${GREEN}------------------------${NC}" -echo -e "${GREEN}Registered Samba users:${NC}" -echo -e "${GREEN}------------------------${NC}" - # List users with color pdbedit -L | cut -d: -f1 | while read -r user; do - echo -e " ${YELLOW}${user}${NC}" -done -echo " " \ No newline at end of file + echo -e "${user}" +done \ No newline at end of file