@@ -50,6 +50,11 @@ while [[ $# -gt 0 ]]; do
5050 shift # past argument
5151 shift # past value
5252 ;;
53+ -y|--yes)
54+ AUTO_YES=" true"
55+ echo -e " ${YELLOW} Non-interactive mode enabled (Auto-Yes).${NC} "
56+ shift # past argument
57+ ;;
5358 * )
5459 echo -e " ${RED} Unknown option: $1 ${NC} "
5560 echo -e " Usage: ./setup-services.sh [-p|--project <name>]"
@@ -94,7 +99,12 @@ echo -e "${BLUE}Installing to $TARGET_DIR...${NC}"
9499
95100if [ -d " $TARGET_DIR " ]; then
96101 echo -e " ${YELLOW} Directory $TARGET_DIR already exists.${NC} "
97- read -p " Backup and overwrite? (y/N) " confirm
102+ if [ " $AUTO_YES " == " true" ]; then
103+ confirm=" y"
104+ echo -e " ${BLUE} Auto-confirming backup and overwrite.${NC} "
105+ else
106+ read -p " Backup and overwrite? (y/N) " confirm
107+ fi
98108 if [[ " $confirm " != " y" && " $confirm " != " Y" ]]; then
99109 echo " Aborting."
100110 exit 0
@@ -184,7 +194,11 @@ else
184194 # Always suggest the detected IP (or empty if detection failed)
185195 IP_DEFAULT=" $DETECTED_IP "
186196
187- read -p " Enter Server Public IP [${IP_DEFAULT} ]: " INPUT_IP
197+ if [ " $AUTO_YES " == " true" ]; then
198+ INPUT_IP=$IP_DEFAULT
199+ else
200+ read -p " Enter Server Public IP [${IP_DEFAULT} ]: " INPUT_IP
201+ fi
188202 INPUT_IP=${INPUT_IP:- $IP_DEFAULT }
189203
190204 COMMENT_IP=" User-defined"
@@ -198,7 +212,11 @@ else
198212 # Logic: Default to the IP address entered above
199213 HOST_DEFAULT=${CURRENT_HOST:- $INPUT_IP }
200214
201- read -p " Enter Server Hostname (e.g., google.com) [${HOST_DEFAULT} ]: " INPUT_HOST
215+ if [ " $AUTO_YES " == " true" ]; then
216+ INPUT_HOST=$HOST_DEFAULT
217+ else
218+ read -p " Enter Server Hostname (e.g., google.com) [${HOST_DEFAULT} ]: " INPUT_HOST
219+ fi
202220 INPUT_HOST=${INPUT_HOST:- $HOST_DEFAULT }
203221
204222 COMMENT_HOST=" User-defined"
@@ -229,7 +247,12 @@ else
229247 echo -e " 1) Keep existing passwords (Recommended if preserving data)"
230248 echo -e " 2) Rename old data dir & Generate new passwords (WARNING: Hides old data)"
231249 echo -e " 3) Abort deployment"
232- read -p " Select option [1]: " DATA_OPT
250+ if [ " $AUTO_YES " == " true" ]; then
251+ DATA_OPT=1
252+ echo -e " ${BLUE} Auto-selecting Option 1 (Keep existing passwords).${NC} "
253+ else
254+ read -p " Select option [1]: " DATA_OPT
255+ fi
233256 DATA_OPT=${DATA_OPT:- 1}
234257
235258 case $DATA_OPT in
@@ -257,7 +280,12 @@ else
257280 esac
258281 else
259282 # Data dir empty or doesn't exist, safe to prompt for generation
260- read -p " Generate new random passwords for key services? (Y/n) " GEN_PASS
283+ if [ " $AUTO_YES " == " true" ]; then
284+ GEN_PASS=" y"
285+ echo -e " ${BLUE} Auto-confirming password generation.${NC} "
286+ else
287+ read -p " Generate new random passwords for key services? (Y/n) " GEN_PASS
288+ fi
261289 if [[ " $GEN_PASS " != " n" && " $GEN_PASS " != " N" ]]; then
262290 SHOULD_GENERATE_PASS=" y"
263291 fi
@@ -281,7 +309,12 @@ else
281309 # Heuristic: if ssl folder exists, and current config is placeholder or empty, prompt to update
282310 if [[ " $SSL_VAL " == * " placeholder" * ]] || [ -z " $SSL_VAL " ]; then
283311 echo -e " ${YELLOW} Local SSL certificates detected in ./ssl directory.${NC} "
284- read -p " Update SSL_CERTIFICATE path to local file? (Y/n) " UPD_SSL
312+ if [ " $AUTO_YES " == " true" ]; then
313+ UPD_SSL=" y"
314+ echo -e " ${BLUE} Auto-confirming SSL path update.${NC} "
315+ else
316+ read -p " Update SSL_CERTIFICATE path to local file? (Y/n) " UPD_SSL
317+ fi
285318 if [[ " $UPD_SSL " != " n" && " $UPD_SSL " != " N" ]]; then
286319 # Find the crt file
287320 CRT_FILE=$( find " $TARGET_DIR /ssl" -name " *.crt" | head -n 1)
0 commit comments