Browse Source

Updated method init

Paolo Galli 4 years ago
parent
commit
b980dce4a6
1 changed files with 25 additions and 24 deletions
  1. 25 24
      lcmlog-server-utils

+ 25 - 24
lcmlog-server-utils

@@ -37,6 +37,7 @@ method_init()
 {
 	if ! [ -d $DIR ]; then
 		echo "Folder $DIR not present: you should create it first!"
+		exit 0
 	else
 		# auth folder
 		if [ -d $DIR/auth ]; then
@@ -68,37 +69,37 @@ method_init()
 			mkdir $DIR/logs
 			echo "Completed."
 		fi
-	fi
-
-	# chmod to let everyone write their logs
-	echo "To correct run the program, you should set the following permissions:"
-	echo "  755 for $(cd $DIR/.. && pwd) , $DIR and $DIR/auth"
-	echo "  777 for $DIR/data and $DIR/logs"
 
-	echo "Do you want to set these permissions (chmod)? [y|n]"
+		# chmod to let everyone write their logs
+		echo "To correct run the program, you should set the following permissions:"
+		echo "  755 for $(cd $DIR/.. && pwd) , $DIR and $DIR/auth"
+		echo "  777 for $DIR/data and $DIR/logs"
 
-	read ANSWER
-	while [ -z $ANSWER ]; do
-		echo "Yes (y) or no (n)? "
-		read ANSWER
-	done
+		echo "Do you want to set these permissions (chmod)? [y|n]"
 
-	while [ $ANSWER != "y" ] && [ $ANSWER != "n" ]; do
-		echo "Yes (y) or no (n)? "
 		read ANSWER
-
 		while [ -z $ANSWER ]; do
-			echo  "Yes (y) or no (n)? "
+			echo "Yes (y) or no (n)? "
+			read ANSWER
+		done
+
+		while [ $ANSWER != "y" ] && [ $ANSWER != "n" ]; do
+			echo "Yes (y) or no (n)? "
 			read ANSWER
+
+			while [ -z $ANSWER ]; do
+				echo  "Yes (y) or no (n)? "
+				read ANSWER
+			done
 		done
-	done
-
-	if [ $ANSWER == "y" ]; then
-		chmod 755 $DIR/..
-		chmod 755 $DIR
-		chmod 755 $DIR/auth
-		chmod 777 $DIR/data
-		chmod 777 $DIR/logs
+
+		if [ $ANSWER == "y" ]; then
+			chmod 755 $DIR/..
+			chmod 755 $DIR
+			chmod 755 $DIR/auth
+			chmod 777 $DIR/data
+			chmod 777 $DIR/logs
+		fi
 	fi
 }