#!/bin/bash # 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 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}" IMPREGNATING="${PURPLE}preparing backend...${RESET}" BUILDING_FRONT="${PURPLE}building static site!${RESET}" FIRST_TIME_Q="${CYAN}first time building backend? ${GREEN}Yes(y) ${RESET}/ ${RED}No(n) ${RESET}/ ${YELLOW}Cancel(c)${RESET}:- " read -p "$(echo -e ${FRONTEND_Q})" choice if [ "$choice" = "y" ]; then echo -e "${BUILDING_FRONT}" cd frontend pnpm i pnpm run build cd ../ read -p "$(echo -e ${BACKEND_Q})" choice if [ "$choice" = "y" ]; then read -p "$(echo -e ${FIRST_TIME_Q})" choice if [ "$choice" = "y" ]; then echo -e "${IMPREGNATING}" cd backend mkdir build mkdir build/libs cp application.yaml build/libs cd ../ elif [ "$choice" = "n" ]; then echo -e "${EXITING}" elif [ "$choice" = "c" ]; then echo -e "${BUILD_CANCELLED}" else echo -e "${NO_CHOICE}" fi echo -e "${BUILDING_BACK}" cd backend ./gradlew shadowJar cd ../ systemctl restart nelle-observer-api elif [ "$choice" = "n" ]; then echo -e "${EXITING}" elif [ "$choice" = "c" ]; then echo -e "${BUILD_CANCELLED}" else echo -e "${NO_CHOICE}" fi elif [ "$choice" = "n" ]; then read -p "$(echo -e ${BACKEND_Q})" choice if [ "$choice" = "y" ]; then read -p "$(echo -e ${FIRST_TIME_Q})" choice if [ "$choice" = "y" ]; then echo -e "${IMPREGNATING}" cd backend mkdir build mkdir build/libs cp application.yaml build/libs cd ../ elif [ "$choice" = "n" ]; then echo -e "${EXITING}" elif [ "$choice" = "c" ]; then echo -e "${BUILD_CANCELLED}" else echo -e "${NO_CHOICE}" fi echo -e "${BUILDING_BACK}" cd backend ./gradlew shadowJar cd ../ systemctl restart nelle-observer-api elif [ "$choice" = "n" ]; then echo -e "${EXITING}" elif [ "$choice" = "c" ]; then echo -e "${BUILD_CANCELLED}" else echo -e "${NO_CHOICE}" fi elif [ "$choice" = "c" ]; then echo -e "${BUILD_CANCELLED}" else echo -e "${NO_CHOICE}" fi