nelle-observer/build.sh

98 lines
2.9 KiB
Bash
Raw Normal View History

2024-09-15 19:51:50 -06:00
#!/bin/bash
2024-09-15 21:23:21 -06:00
# Reset
RESET='\033[0m' # Text Reset
# Regular Colors
BLACK='\033[0;30m' # Black
RED='\033[0;31m' # Red
GREEN='\033[0;32m' # Green
YELLOW='\033[0;33m' # Yellow
BLUE='\033[0;34m' # Blue
PURPLE='\033[0;35m' # Purple
CYAN='\033[0;36m' # Cyan
WHITE='\033[0;37m' # White
2024-09-15 21:43:14 -06:00
BACKEND_Q="${CYAN}build the backend? ${GREEN}Yes(y) ${RESET}/ ${RED}No(n) ${RESET}/ ${YELLOW}Cancel(c)${RESET}:- "
FRONTEND_Q="${CYAN}build the frontend? ${GREEN}Yes(y) ${RESET}/ ${RED}No(n) ${RESET}/ ${YELLOW}Cancel(c)${RESET}:- "
EXITING="${RED}exiting...${RESET}"
NO_CHOICE="${RED}no choice given, exiting...${RESET}"
BUILD_CANCELLED="${YELLOW}canelling build...${RESET}"
BUILDING_BACK="${PURPLE}building backend!${RESET}"
2024-09-16 01:36:07 -06:00
IMPREGNATING="${PURPLE}preparing backend...${RESET}"
2024-09-15 21:43:14 -06:00
BUILDING_FRONT="${PURPLE}building static site!${RESET}"
2024-09-16 01:33:19 -06:00
FIRST_TIME_Q="${CYAN}first time building backend? ${GREEN}Yes(y) ${RESET}/ ${RED}No(n) ${RESET}/ ${YELLOW}Cancel(c)${RESET}:- "
2024-09-15 21:43:14 -06:00
read -p "$(echo -e ${FRONTEND_Q})" choice
2024-09-15 20:09:45 -06:00
if [ "$choice" = "y" ]; then
2024-09-15 21:43:14 -06:00
echo -e "${BUILDING_FRONT}"
2024-09-16 01:33:19 -06:00
cd frontend
2024-09-15 20:09:45 -06:00
pnpm i
pnpm run build
2024-09-16 01:33:19 -06:00
cd ../
2024-09-15 21:43:14 -06:00
read -p "$(echo -e ${BACKEND_Q})" choice
2024-09-15 20:09:45 -06:00
if [ "$choice" = "y" ]; then
2024-09-16 01:33:19 -06:00
read -p "$(echo -e ${FIRST_TIME_Q})" choice
if [ "$choice" = "y" ]; then
2024-09-17 20:43:56 -06:00
echo -e "${IMPREGNATING}"
2024-09-16 01:33:19 -06:00
cd backend
mkdir build
mkdir build/libs
cp application.yaml build/libs
2024-09-16 01:36:07 -06:00
cd ../
2024-09-16 01:33:19 -06:00
elif [ "$choice" = "n" ]; then
echo -e "${EXITING}"
elif [ "$choice" = "c" ]; then
echo -e "${BUILD_CANCELLED}"
else
echo -e "${NO_CHOICE}"
fi
2024-09-15 21:43:14 -06:00
echo -e "${BUILDING_BACK}"
2024-09-15 20:09:45 -06:00
cd backend
./gradlew shadowJar
2024-09-16 01:33:19 -06:00
cd ../
2024-09-15 20:12:10 -06:00
systemctl restart nelle-observer-api
2024-09-15 20:09:45 -06:00
elif [ "$choice" = "n" ]; then
2024-09-15 21:43:14 -06:00
echo -e "${EXITING}"
2024-09-15 20:09:45 -06:00
elif [ "$choice" = "c" ]; then
2024-09-15 21:43:14 -06:00
echo -e "${BUILD_CANCELLED}"
2024-09-15 20:09:45 -06:00
else
2024-09-15 21:43:14 -06:00
echo -e "${NO_CHOICE}"
2024-09-15 20:09:45 -06:00
fi
elif [ "$choice" = "n" ]; then
2024-09-15 21:43:14 -06:00
read -p "$(echo -e ${BACKEND_Q})" choice
2024-09-15 20:09:45 -06:00
if [ "$choice" = "y" ]; then
2024-09-16 01:33:19 -06:00
read -p "$(echo -e ${FIRST_TIME_Q})" choice
if [ "$choice" = "y" ]; then
2024-09-17 20:43:56 -06:00
echo -e "${IMPREGNATING}"
2024-09-16 01:33:19 -06:00
cd backend
mkdir build
mkdir build/libs
cp application.yaml build/libs
2024-09-16 01:36:07 -06:00
cd ../
2024-09-16 01:33:19 -06:00
elif [ "$choice" = "n" ]; then
echo -e "${EXITING}"
elif [ "$choice" = "c" ]; then
echo -e "${BUILD_CANCELLED}"
else
echo -e "${NO_CHOICE}"
fi
2024-09-17 20:43:56 -06:00
echo -e "${BUILDING_BACK}"
2024-09-15 20:09:45 -06:00
cd backend
./gradlew shadowJar
2024-09-16 01:33:19 -06:00
cd ../
2024-09-15 20:12:10 -06:00
systemctl restart nelle-observer-api
2024-09-15 20:09:45 -06:00
elif [ "$choice" = "n" ]; then
2024-09-15 21:43:14 -06:00
echo -e "${EXITING}"
2024-09-15 20:09:45 -06:00
elif [ "$choice" = "c" ]; then
2024-09-15 21:43:14 -06:00
echo -e "${BUILD_CANCELLED}"
2024-09-15 20:09:45 -06:00
else
2024-09-15 21:43:14 -06:00
echo -e "${NO_CHOICE}"
2024-09-15 20:09:45 -06:00
fi
elif [ "$choice" = "c" ]; then
2024-09-15 21:43:14 -06:00
echo -e "${BUILD_CANCELLED}"
2024-09-15 20:09:45 -06:00
else
2024-09-15 21:43:14 -06:00
echo -e "${NO_CHOICE}"
2024-09-15 20:09:45 -06:00
fi