Browse Source

musare.sh shellcheck and Configuration doc .env improvements

Owen Diffey 2 years ago
parent
commit
40b304089b
2 changed files with 38 additions and 22 deletions
  1. 13 9
      .wiki/Configuration.md
  2. 25 13
      musare.sh

+ 13 - 9
.wiki/Configuration.md

@@ -48,21 +48,25 @@ Location: `frontend/dist/config/default.json`
 ## Docker Environment
 Location: `.env`
 
+In the table below the container host refers to the IP address that the docker container listens on, setting this to `127.0.0.1` for example will only expose the configured port to localhost, whereas setting to `0.0.0.0` will expose the port on all interfaces.
+
+The container port refers to the external docker container port, used to access services within the container. Changing this does not require any changes to configuration within container. For example setting the `MONGO_PORT` to `21018` will allow you to access the mongo service through that port, even though the application within the container is listening on `21017`.
+
 | Property | Description |
 | --- | --- |
 | `COMPOSE_PROJECT_NAME` | Should be a unique name for this installation, especially if you have multiple instances of Musare on the same machine. |
-| `BACKEND_HOST` | Host that the backend container should listen on. |
-| `BACKEND_PORT` | Port that the backend container should listen on. |
-| `FRONTEND_HOST` | Host that the frontend container should listen on. |
-| `FRONTEND_PORT` | Port that the frontend container should listen on. |
+| `BACKEND_HOST` | Backend container host. |
+| `BACKEND_PORT` | Backend container port. |
+| `FRONTEND_HOST` | Frontend container host. |
+| `FRONTEND_PORT` | Frontend container port. |
 | `FRONTEND_MODE` | Should be either `dev` or `prod`. |
-| `MONGO_HOST` | Host that the mongo container should listen on. |
-| `MONGO_PORT` | Port that the mongo container should listen on. |
+| `MONGO_HOST` | Mongo container host. |
+| `MONGO_PORT` | Mongo container port. |
 | `MONGO_ROOT_PASSWORD` | Password of the root/admin user for MongoDB. |
 | `MONGO_USER_USERNAME` | Application username for MongoDB. |
 | `MONGO_USER_PASSWORD` | Application password for MongoDB. |
-| `REDIS_HOST` | Host that the redis container should listen on. |
-| `REDIS_PORT` | Port that the redis container should listen on. |
+| `REDIS_HOST` | Redis container host. |
+| `REDIS_PORT` | Redis container port. |
 | `REDIS_PASSWORD` | Redis password. |
 | `BACKUP_LOCATION` | Directory to store musare.sh backups. Defaults to `/backups` in script location. |
-| `BACKUP_NAME` | Name of backup files. Defaults to `musare-$(date +"%Y-%m-%d-%s").dump`. |
+| `BACKUP_NAME` | Name of musare.sh backup files. Defaults to `musare-$(date +"%Y-%m-%d-%s").dump`. |

+ 25 - 13
musare.sh

@@ -49,14 +49,17 @@ dockerCommand()
             else
                 servicesString=${servicesString:2}
             fi
-            if [[ $2 == "stop" || $2 == "restart" ]]; then
-                docker-compose stop $servicesString
+            if [[ ${2} == "stop" || ${2} == "restart" ]]; then
+                # shellcheck disable=SC2086
+                docker-compose stop ${servicesString}
             fi
-            if [[ $2 == "start" || $2 == "restart" ]]; then
-                docker-compose up -d $servicesString
+            if [[ ${2} == "start" || ${2} == "restart" ]]; then
+                # shellcheck disable=SC2086
+                docker-compose up -d ${servicesString}
             fi
-            if [[ $2 == "build" || $2 == "ps" ]]; then
-                docker-compose $2 $servicesString
+            if [[ ${2} == "build" || ${2} == "ps" ]]; then
+                # shellcheck disable=SC2086
+                docker-compose "${2}" ${servicesString}
             fi
         else
             echo -e "${RED}${servicesString:2}\n${YELLOW}Usage: ${1} restart [backend, frontend, mongo, redis]${NC}"
@@ -70,27 +73,32 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
     case $1 in
     start)
         echo -e "${CYAN}Musare | Start Services${NC}"
-        dockerCommand $(basename "$0") start ${@:2}
+        # shellcheck disable=SC2068
+        dockerCommand "$(basename "$0")" start ${@:2}
         ;;
 
     stop)
         echo -e "${CYAN}Musare | Stop Services${NC}"
-        dockerCommand $(basename "$0") stop ${@:2}
+        # shellcheck disable=SC2068
+        dockerCommand "$(basename "$0")" stop ${@:2}
         ;;
 
     restart)
         echo -e "${CYAN}Musare | Restart Services${NC}"
-        dockerCommand $(basename "$0") restart ${@:2}
+        # shellcheck disable=SC2068
+        dockerCommand "$(basename "$0")" restart ${@:2}
         ;;
 
     build)
         echo -e "${CYAN}Musare | Build Services${NC}"
-        dockerCommand $(basename "$0") build ${@:2}
+        # shellcheck disable=SC2068
+        dockerCommand "$(basename "$0")" build ${@:2}
         ;;
 
     status)
         echo -e "${CYAN}Musare | Service Status${NC}"
-        dockerCommand $(basename "$0") ps ${@:2}
+        # shellcheck disable=SC2068
+        dockerCommand "$(basename "$0")" ps ${@:2}
         ;;
 
     reset)
@@ -112,10 +120,12 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
                 echo -e "${RED}Cancelled reset${NC}"
             fi
         elif [[ ${servicesString:0:1} == 1 ]]; then
-            echo -e "${GREEN}Are you sure you want to reset all data for $(echo ${servicesString:2} | tr ' ' ',')? ${YELLOW}[y,n]: ${NC}"
+            echo -e "${GREEN}Are you sure you want to reset all data for $(echo "${servicesString:2}" | tr ' ' ',')? ${YELLOW}[y,n]: ${NC}"
             read -r confirm
             if [[ "${confirm}" == y* ]]; then
+                # shellcheck disable=SC2086
                 docker-compose stop ${servicesString:2}
+                # shellcheck disable=SC2086
                 docker-compose rm -v --force ${servicesString:2}
                 if [[ "${servicesString:2}" == *redis* && -d ".redis" ]]; then
                     rm -rf .redis
@@ -149,7 +159,7 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
                     echo -e "${RED}Error: Mongo offline, please start to attach.${NC}"
                 else
                     echo -e "${YELLOW}Detach with CTRL+C${NC}"
-                    docker-compose exec mongo mongo musare -u ${MONGO_USER_USERNAME} -p ${MONGO_USER_PASSWORD}
+                    docker-compose exec mongo mongo musare -u "${MONGO_USER_USERNAME}" -p "${MONGO_USER_PASSWORD}"
                 fi
             else
                 echo -e "${RED}Error: .env does not exist${NC}"
@@ -312,6 +322,7 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
         echo -e "${YELLOW}start - Start services${NC}"
         echo -e "${YELLOW}stop - Stop services${NC}"
         echo -e "${YELLOW}restart - Restart services${NC}"
+        echo -e "${YELLOW}status - Service status${NC}"
         echo -e "${YELLOW}logs - View logs for services${NC}"
         echo -e "${YELLOW}update - Update Musare${NC}"
         echo -e "${YELLOW}attach [backend,mongo] - Attach to backend service or mongo shell${NC}"
@@ -330,6 +341,7 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
         echo -e "${YELLOW}start - Start services${NC}"
         echo -e "${YELLOW}stop - Stop services${NC}"
         echo -e "${YELLOW}restart - Restart services${NC}"
+        echo -e "${YELLOW}status - Service status${NC}"
         echo -e "${YELLOW}logs - View logs for services${NC}"
         echo -e "${YELLOW}update - Update Musare${NC}"
         echo -e "${YELLOW}attach [backend,mongo] - Attach to backend service or mongo shell${NC}"