A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
fix: missing double brackets for conditionals in startDocker.sh
aminnausincb1ec01f8603
diff --git a/startDocker.sh b/startDocker.shindex e3fd143f..d7948311 100644--- a/startDocker.sh+++ b/startDocker.sh@@ -40,7 +40,7 @@ echo -e "${YELLOW}[STEP 1/6]${RESET} Verifying required files and folders..."echo# Check for docker-compose.yaml-if [ ! -f "docker-compose.yaml" ]; then+if [[ ! -f "docker-compose.yaml" ]]; thenecho -e "${RED}[ERROR]${RESET} Missing 'docker-compose.yaml' file."echo "Please ensure this file is present in the root directory."exit 1@@ -50,7 +50,7 @@ fiecho# Check for nginx configuration-if [ ! -f "$NGINX_CONF_FILE" ]; then+if [[ ! -f "$NGINX_CONF_FILE" ]]; thenecho -e "${RED}[ERROR]${RESET} Missing 'docker/etc/nginx/conf.d/default.conf' file."echo "Please ensure this file is present in the correct directory."exit 1@@ -60,7 +60,7 @@ fiecho# Check for Caddyfile-if [ ! -f "docker/etc/caddy/Caddyfile" ]; then+if [[ ! -f "docker/etc/caddy/Caddyfile" ]]; thenecho -e "${RED}[ERROR]${RESET} Missing 'docker/etc/caddy/Caddyfile' file."echo "Please ensure this file is present in the correct directory."exit 1@@ -72,17 +72,17 @@ fiecho# Check for .env.docker-if [ ! -f "docker/.env.docker" ]; then+if [[ ! -f "docker/.env.docker" ]]; thenecho -e "${RED}[ERROR]${RESET} Missing 'docker/.env.docker' file."echo "Please ensure this file is present in the correct directory."exit 1fi# Create .env if it doesn't exist-if [ ! -f "$ENV_FILE" ]; then+if [[ ! -f "$ENV_FILE" ]]; thenecho -e "${BLUE}[INFO]${RESET} '.env' file not found. Creating from '.env.docker'..."cp "docker/.env.docker" "$ENV_FILE"- if [ $? -ne 0 ]; then+ if [[ $? -ne 0 ]]; thenecho -e "${RED}[ERROR]${RESET} Failed to create '.env' file."exit 1fi@@ -93,7 +93,7 @@ fiecho# Ensure data/app subdirectories exists-if [ ! -d "data/media" ] || [ ! -d "data/avatars" ] || [ ! -d "data/thumbnails" ] || [ ! -d "app" ]; then+if [[ ! -d "data/media" ]] || [[ ! -d "data/avatars" ]] || [[ ! -d "data/thumbnails" ]] || [[ ! -d "app" ]]; thenecho -e "${BLUE}[INFO]${RESET} One or more 'data/app' subdirectories are missing. Creating them..."echomkdir -p data/media data/avatars data/thumbnails app@@ -106,13 +106,13 @@ echo# Ensure permissions are set for data directoriessudo chown -R 9999:9999 data appsudo chmod -R 775 data app-if [ $? -ne 0 ]; then+if [[ $? -ne 0 ]]; thenecho -e "${RED}[ERROR]${RESET} Failed to create 'data/app' subdirectories or set permissions."exit 1fi# Ensure logs directory exists-if [ ! -d "logs" ]; then+if [[ ! -d "logs" ]]; thenecho -e "${BLUE}[INFO]${RESET} Missing 'logs' directory. Creating it..."echomkdir -p "logs/mediaServer"@@ -121,7 +121,7 @@ if [ ! -d "logs" ]; thensudo chown -R 9999:9999 ./logs/nginxsudo chown -R 9999:9999 ./logs/mediaServersudo chmod -R 755 logs- if [ $? -ne 0 ]; then+ if [[ $? -ne 0 ]]; thenecho -e "${RED}[ERROR]${RESET} Failed to create 'logs' directory."exit 1fi@@ -132,13 +132,13 @@ fiecho# Ensure caddy directory exists-if [ ! -d "caddy/data" ]; then+if [[ ! -d "caddy/data" ]]; thenecho -e "${BLUE}[INFO]${RESET} Missing 'caddy' directory. Creating it..."echomkdir -p "caddy/data"mkdir -p "caddy/config"sudo chown -R 1000:1000 ./caddy- if [ $? -ne 0 ]; then+ if [[ $? -ne 0 ]]; thenecho -e "${RED}[ERROR]${RESET} Failed to create 'caddy' directory."exit 1fi@@ -154,7 +154,7 @@ echo# Get existing APP_HOST and APP_PORT or use defaultsCURRENT_APP_HOST=""CURRENT_APP_PORT=""-if [ -f "$ENV_FILE" ]; then+if [[ -f "$ENV_FILE" ]]; thenCURRENT_APP_HOST=$(grep "^APP_HOST=" "$ENV_FILE" | sed -E 's/^APP_HOST="?([^"]*)"?/\1/')CURRENT_APP_PORT=$(grep "^APP_PORT=" "$ENV_FILE" | sed -E 's/^APP_PORT="?([^"]*)"?/\1/')fi@@ -185,7 +185,7 @@ echo# Update APP_HOST in .env file using sedsed -i "s|^APP_HOST=.*|APP_HOST=\"${APP_HOST}\"|" "$ENV_FILE"-if [ $? -ne 0 ]; then+if [[ $? -ne 0 ]]; thenecho -e "${RED}[ERROR]${RESET} Failed to update APP_HOST in ${ENV_FILE}."echo "Please check the .env file format or script permissions."exit 1@@ -198,7 +198,7 @@ ESCAPED_APP_HOST=$(echo "$APP_HOST" | sed 's/\./\\./g') # Escape dotssed -i "s#valid_referers 127.0.0.1, .*;#valid_referers 127.0.0.1, ${ESCAPED_APP_HOST};#" "$NGINX_CONF_FILE"-if [ $? -ne 0 ]; then+if [[ $? -ne 0 ]]; thenecho -e "${RED}[ERROR]${RESET} Failed to update valid_referers in ${NGINX_CONF_FILE}."echo "Please check the Nginx config file format or script permissions."exit 1@@ -211,7 +211,7 @@ echo -e "${YELLOW}[STEP 3/6]${RESET} Stopping and cleaning up Existing mediaServechodocker compose down-if [ $? -ne 0 ]; then+if [[ $? -ne 0 ]]; thenecho -e "${RED}[ERROR]${RESET} Failed to bring down Docker containers."echo "Please check your Docker setup and try again."exit 1@@ -222,7 +222,7 @@ echoecho -e "${YELLOW}[STEP 4/6]${RESET} Pruning Docker volumes..."echodocker volume prune -f-if [ $? -ne 0 ]; then+if [[ $? -ne 0 ]]; thenecho -e "${RED}[ERROR]${RESET} Failed to prune Docker volumes."echo "Please check your Docker setup and try again."exit 1@@ -233,7 +233,7 @@ echoecho -e "${YELLOW}[STEP 5/6]${RESET} Pulling latest Docker images..."echodocker compose pull-if [ $? -ne 0 ]; then+if [[ $? -ne 0 ]]; thenecho -e "${RED}[ERROR]${RESET} Failed to pull Docker images."echo "Please check your internet connection and Docker setup."exit 1@@ -249,7 +249,7 @@ echoif ! docker volume inspect "$SHARED_VOLUME_NAME" &>/dev/null; thenecho -e "${BLUE}[INFO]${RESET} Shared volume '$SHARED_VOLUME_NAME' does not exist. Creating it..."docker volume create "$SHARED_VOLUME_NAME"- if [ $? -ne 0 ]; then+ if [[ $? -ne 0 ]]; thenecho -e "${RED}[ERROR]${RESET} Failed to create shared volume '$SHARED_VOLUME_NAME'."echo "Please check Docker daemon status and permissions."exit 1@@ -269,7 +269,7 @@ docker run --rm \-v "${SHARED_VOLUME_NAME}:/shared" \alpine sh -c "mkdir -p /shared && chown -R ${VOLUME_UID}:${VOLUME_GID} /shared && chmod 775 /shared && echo 'Volume permissions set.'"-if [ $? -ne 0 ]; then+if [[ $? -ne 0 ]]; thenecho -e "${RED}[ERROR]${RESET} Failed to set shared volume permissions."echo "Please check your Docker volume and user/group ID configurations."exit 1@@ -279,7 +279,7 @@ echodocker compose up -d-if [ $? -ne 0 ]; then+if [[ $? -ne 0 ]]; thenecho -e "${RED}[ERROR]${RESET} Failed to build docker compose."echo "Please check your configuration."exit 1