|
@@ -17,26 +17,20 @@ handleServices()
|
|
servicesArray=()
|
|
servicesArray=()
|
|
invalidServices=false
|
|
invalidServices=false
|
|
for x in "$@"; do
|
|
for x in "$@"; do
|
|
- for validService in "${validServices[@]}"
|
|
|
|
- do
|
|
|
|
- if [[ ${validService} =~ (^|[[:space:]])"$x"($|[[:space:]]) ]]; then
|
|
|
|
- for service in "${servicesArray[@]}"
|
|
|
|
- do
|
|
|
|
- if ! [[ "$service" =~ (^|[[:space:]])"$x"($|[[:space:]]) ]]; then
|
|
|
|
- servicesArray+=("$x")
|
|
|
|
- fi
|
|
|
|
- done
|
|
|
|
|
|
+ if [[ ${validServices[*]} =~ (^|[[:space:]])"$x"($|[[:space:]]) ]]; then
|
|
|
|
+ if ! [[ ${servicesArray[*]} =~ (^|[[:space:]])"$x"($|[[:space:]]) ]]; then
|
|
|
|
+ servicesArray+=("${x}")
|
|
|
|
+ fi
|
|
|
|
+ else
|
|
|
|
+ if [[ $invalidServices == false ]]; then
|
|
|
|
+ invalidServices="${x}"
|
|
else
|
|
else
|
|
- if [[ $invalidServices == false ]]; then
|
|
|
|
- invalidServices="${x}"
|
|
|
|
- else
|
|
|
|
- invalidServices="${invalidServices} ${x}"
|
|
|
|
- fi
|
|
|
|
|
|
+ invalidServices="${invalidServices} ${x}"
|
|
fi
|
|
fi
|
|
- done
|
|
|
|
|
|
+ fi
|
|
done
|
|
done
|
|
if [[ $invalidServices == false && ${#servicesArray[@]} -gt 0 ]]; then
|
|
if [[ $invalidServices == false && ${#servicesArray[@]} -gt 0 ]]; then
|
|
- echo "1|" "${servicesArray[@]}"
|
|
|
|
|
|
+ echo "1|${servicesArray[*]}"
|
|
elif [[ $invalidServices == false ]]; then
|
|
elif [[ $invalidServices == false ]]; then
|
|
echo "1|all"
|
|
echo "1|all"
|
|
else
|
|
else
|
|
@@ -52,7 +46,7 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
|
|
if [[ ${servicesString:0:1} == 1 && ${servicesString:2:4} == "all" ]]; then
|
|
if [[ ${servicesString:0:1} == 1 && ${servicesString:2:4} == "all" ]]; then
|
|
docker-compose up -d
|
|
docker-compose up -d
|
|
elif [[ ${servicesString:0:1} == 1 ]]; then
|
|
elif [[ ${servicesString:0:1} == 1 ]]; then
|
|
- docker-compose up -d "${servicesString:2}"
|
|
|
|
|
|
+ docker-compose up -d ${servicesString:2}
|
|
else
|
|
else
|
|
echo -e "${RED}${servicesString:2}\n${YELLOW}Usage: $(basename "$0") start [backend, frontend, mongo, redis]${NC}"
|
|
echo -e "${RED}${servicesString:2}\n${YELLOW}Usage: $(basename "$0") start [backend, frontend, mongo, redis]${NC}"
|
|
fi
|
|
fi
|
|
@@ -64,7 +58,7 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
|
|
if [[ ${servicesString:0:1} == 1 && ${servicesString:2:4} == "all" ]]; then
|
|
if [[ ${servicesString:0:1} == 1 && ${servicesString:2:4} == "all" ]]; then
|
|
docker-compose stop
|
|
docker-compose stop
|
|
elif [[ ${servicesString:0:1} == 1 ]]; then
|
|
elif [[ ${servicesString:0:1} == 1 ]]; then
|
|
- docker-compose stop "${servicesString:2}"
|
|
|
|
|
|
+ docker-compose stop ${servicesString:2}
|
|
else
|
|
else
|
|
echo -e "${RED}${servicesString:2}\n${YELLOW}Usage: $(basename "$0") stop [backend, frontend, mongo, redis]${NC}"
|
|
echo -e "${RED}${servicesString:2}\n${YELLOW}Usage: $(basename "$0") stop [backend, frontend, mongo, redis]${NC}"
|
|
fi
|
|
fi
|
|
@@ -77,8 +71,8 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
|
|
docker-compose stop
|
|
docker-compose stop
|
|
docker-compose up -d
|
|
docker-compose up -d
|
|
elif [[ ${servicesString:0:1} == 1 ]]; then
|
|
elif [[ ${servicesString:0:1} == 1 ]]; then
|
|
- docker-compose stop "${servicesString:2}"
|
|
|
|
- docker-compose up -d "${servicesString:2}"
|
|
|
|
|
|
+ docker-compose stop ${servicesString:2}
|
|
|
|
+ docker-compose up -d ${servicesString:2}
|
|
else
|
|
else
|
|
echo -e "${RED}${servicesString:2}\n${YELLOW}Usage: $(basename "$0") restart [backend, frontend, mongo, redis]${NC}"
|
|
echo -e "${RED}${servicesString:2}\n${YELLOW}Usage: $(basename "$0") restart [backend, frontend, mongo, redis]${NC}"
|
|
fi
|
|
fi
|
|
@@ -90,7 +84,7 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
|
|
if [[ ${servicesString:0:1} == 1 && ${servicesString:2:4} == "all" ]]; then
|
|
if [[ ${servicesString:0:1} == 1 && ${servicesString:2:4} == "all" ]]; then
|
|
docker-compose build
|
|
docker-compose build
|
|
elif [[ ${servicesString:0:1} == 1 ]]; then
|
|
elif [[ ${servicesString:0:1} == 1 ]]; then
|
|
- docker-compose build "${servicesString:2}"
|
|
|
|
|
|
+ docker-compose build ${servicesString:2}
|
|
else
|
|
else
|
|
echo -e "${RED}${servicesString:2}\n${YELLOW}Usage: $(basename "$0") build [backend, frontend, mongo, redis]${NC}"
|
|
echo -e "${RED}${servicesString:2}\n${YELLOW}Usage: $(basename "$0") build [backend, frontend, mongo, redis]${NC}"
|
|
fi
|
|
fi
|
|
@@ -115,11 +109,11 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
|
|
echo -e "${RED}Cancelled reset${NC}"
|
|
echo -e "${RED}Cancelled reset${NC}"
|
|
fi
|
|
fi
|
|
elif [[ ${servicesString:0:1} == 1 ]]; then
|
|
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
|
|
read -r confirm
|
|
if [[ "${confirm}" == y* ]]; then
|
|
if [[ "${confirm}" == y* ]]; then
|
|
- docker-compose stop "${servicesString:2}"
|
|
|
|
- docker-compose rm -v --force "${servicesString:2}"
|
|
|
|
|
|
+ docker-compose stop ${servicesString:2}
|
|
|
|
+ docker-compose rm -v --force ${servicesString:2}
|
|
if [[ "${servicesString:2}" == *redis* && -d ".redis" ]]; then
|
|
if [[ "${servicesString:2}" == *redis* && -d ".redis" ]]; then
|
|
rm -rf .redis
|
|
rm -rf .redis
|
|
fi
|
|
fi
|
|
@@ -141,6 +135,7 @@ if [[ -x "$(command -v docker)" && -x "$(command -v docker-compose)" ]]; then
|
|
if [[ -z $containerId ]]; then
|
|
if [[ -z $containerId ]]; then
|
|
echo -e "${RED}Error: Backend offline, please start to attach.${NC}"
|
|
echo -e "${RED}Error: Backend offline, please start to attach.${NC}"
|
|
else
|
|
else
|
|
|
|
+ echo -e "${YELLOW}Detach with CTRL+P+Q${NC}"
|
|
docker attach "$containerId"
|
|
docker attach "$containerId"
|
|
fi
|
|
fi
|
|
else
|
|
else
|