[dl-x86solaris-devel 116] CVS update: dlkit2

アーカイブの一覧に戻る

teelime teeli****@users*****
2006年 8月 23日 (水) 00:47:09 JST


Index: dlkit2/dlkit
diff -u dlkit2/dlkit:1.1.2.3 dlkit2/dlkit:1.1.2.4
--- dlkit2/dlkit:1.1.2.3	Sat Apr  1 15:02:35 2006
+++ dlkit2/dlkit	Wed Aug 23 00:47:09 2006
@@ -11,13 +11,18 @@
 	dlkit add <clientname>		add client information
 	dlkit install <clientname>	install client environment at server side
 	dlkit finish <clientname>	finish client installation
+	dlkit gensh <clientname>	generate maintenance script
 
-	dlkit remove <clientname>		remove client information
+	dlkit cleaninfo <clientname>		cleanup client information
 	dlkit clear miniroot <clientname>	clear client miniroot
 	dlkit clear finroot <clientname>	clear client root
 EOF
 }
 
+echon() {
+    printf "%s" "$@"
+}
+
 perror() {
     echo "ERROR: " "$@"
     exit 1
@@ -26,6 +31,7 @@
 # load_conf_file: Load common configuration file and client-specific
 # configuration file.  Needs $CL_CONFIG and must be set.
 load_conf_file() {
+	CL_NAME=$CL_CONFIG
     [ ! -r config/server00.conf ] && perror "cannot load config/server00.conf"
     . config/server00.conf
     client_conf=config/client.$CL_CONFIG.conf
@@ -33,6 +39,58 @@
     . $client_conf
     [ ! -r config/server99.conf ] && perror "cannot load config/server99.conf"
     . config/server99.conf
+
+	tempfile1=/tmp/temp.$CL_CONFIG.1.$$
+	tempfile2=/tmp/temp.$CL_CONFIG.2.$$
+	set > $tempfile1
+	grep "^\#\%" < $client_conf > $tempfile2
+	RET=0
+	while read i npval ;do
+		valname=`echo $i|cut -b3-`
+		if ( grep "^$valname" < $tempfile1 > /dev/null ); then
+			val=`grep $valname < $tempfile1 | cut -d"=" -f2`
+			if [ "x$val" = "x$npval" ]; then
+				echo "error, \"$npval\" is not permitted for $valname"
+				RET=1
+			fi
+		else
+			echo "error, $valname is mandatory"
+			RET=1
+		fi
+	done < $tempfile2
+	rm -f $tempfile1
+	rm -f $tempfile2
+	if [ $RET -eq 1 ]; then
+		echo "exit"
+		exit
+	fi
+}
+
+yesno()
+{
+	msg="$1"
+	def="$2"
+	while true ; do
+	echon "$msg"
+	read answer
+	if [ "$answer" ] ; then
+		case "$answer" in
+		y|Y|yes|YES)
+			return 0
+			;;
+		n|N|no|NO)
+			return 1
+			;;
+		*)
+			echo " "
+			echo "ERROR: Invalid response, expected \"yes\" or \"no\"."
+			continue
+			;;
+		esac
+	else
+		return $def
+	fi
+	done
 }
 
 #----------------------------------------------------------------------
@@ -55,10 +113,16 @@
 	. sv/finish-client.sub
 	;;
 
-    remove)
+    gensh)
+	CL_CONFIG=${2:?"ERROR: client name not supplied"}
+	load_conf_file
+	. sv/gensh-client.sub
+	;;
+
+    cleaninfo)
 	CL_CONFIG=${2:?"ERROR: client name not supplied"}
 	load_conf_file
-	. sv/remove-client.sub # TODO
+	. sv/cleaninfo-client.sub # TODO
 	;;
 
     clear)
@@ -67,12 +131,22 @@
 	case "$2" in
 	    miniroot)
 		basedir=`dirname $SV_INSTROOT`; dirname=`basename $SV_INSTROOT`
-		echo "Clearing $basedir/$dirname..."
+		echo "$basedir/$dirname will be deleted"
+		if yesno "Do you agree? yes or no [n] " 1 ; then
+			echo "Clearing $basedir/$dirname..."
+		else
+			echo "Aborted" && exit
+		fi
 		cd $basedir && rm -rf $dirname
 		;;
 	    finroot)
 		basedir=`dirname $SV_FIN_ROOT`; dirname=`basename $SV_FIN_ROOT`
-		echo "Clearing $basedir/$dirname..."
+		echo "$basedir/$dirname will be deleted"
+		if yesno "Do you agree? yes or no [n] " 1 ; then
+			echo "Clearing $basedir/$dirname..."
+		else
+			echo "Aborted" && exit
+		fi
 		cd $basedir && rm -rf $dirname
 		;;
 	esac


dl-x86solaris-devel メーリングリストの案内
アーカイブの一覧に戻る