From 1fdf8edd6a8773b3f7cb78c0d138f3327548dc74 Mon Sep 17 00:00:00 2001
From: nishi <nishi@f982e544-4a7d-3444-ad1a-fde59a2a69f1>
Date: Sat, 11 May 2024 13:02:57 +0000
Subject: [PATCH] make the installer ask to overwrite  the config or not

git-svn-id: file:///raid/svn-main/nishi-mandshurica/trunk@92 f982e544-4a7d-3444-ad1a-fde59a2a69f1
---
 GNUmakefile | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/GNUmakefile b/GNUmakefile
index b7e5f24..ac8caac 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -54,7 +54,21 @@ replace:
 install: all
 	mkdir -p $(PREFIX) $(MODULE_PREFIX) $(DATABASE_PREFIX) $(WEBROOT_PREFIX) $(PROJECT_PREFIX) $(TOOL_PREFIX) $(PREFIX)/etc $(PREFIX)/bin $(PREFIX)/lib/mandshurica/db
 	touch $(PREFIX)/lib/mandshurica/db/auth.db $(PREFIX)/lib/mandshurica/db/login.db $(PREFIX)/lib/mandshurica/db/project.db
-	./Mandshurica/mandshurica --create $(PREFIX)/etc/mandshurica.conf
+	if [ -e $(PREFIX)/etc/mandshurica.conf ]; then \
+		while true; do\
+			read -p "Overwrite the config with default one? " "yn";\
+			if [ "$$yn" = "y" -o "$$yn" = "Y" ]; then\
+				./Mandshurica/mandshurica --create $(PREFIX)/etc/mandshurica.conf;\
+				break;\
+			elif [ "$$yn" = "n" -o "$$yn" = "N" ]; then\
+				break;\
+			else\
+				echo "Please enter Y or N";\
+			fi;\
+		done;\
+	else\
+		./Mandshurica/mandshurica --create $(PREFIX)/etc/mandshurica.conf;\
+	fi
 	$(MAKE) -C ./Mandshurica install $(PREFIXES)
 	$(MAKE) -C ./Module install $(PREFIXES)
 	$(MAKE) -C ./Tool install $(PREFIXES)
-- 
2.43.0