From a11910e4889aa1d6e238202dbc0db843f2c9e47d Mon Sep 17 00:00:00 2001
From: Tomas Plesnik <plesnik@ics.muni.cz>
Date: Tue, 11 Dec 2012 18:20:50 +0100
Subject: [PATCH] odstranena nutnost pouziti parametru -d z uninstall.sh

---
 src/warden-server/doc/README      |  5 ++---
 src/warden-server/doc/UNINSTALL   |  2 +-
 src/warden-server/sh/uninstall.sh | 30 +++++++-----------------------
 3 files changed, 10 insertions(+), 27 deletions(-)

diff --git a/src/warden-server/doc/README b/src/warden-server/doc/README
index 097bd2f..ea9826d 100644
--- a/src/warden-server/doc/README
+++ b/src/warden-server/doc/README
@@ -252,12 +252,11 @@ E. Uninstallation
     
  For more information about uninstall.sh options run uninstall.sh -h
 
-   Usage: $ ./uninstall.sh [-d <directory>] [-hV]
-        -d <directory>            uninstallation directory (default: /opt)
+   Usage: $ ./uninstall.sh [-hV]
         -h                        print this help
         -V                        print script version number and exit
 
-   Example: # ./uninstall.sh -d /opt
+   Example: # ./uninstall.sh
 
  You must be root for running this script.
 
diff --git a/src/warden-server/doc/UNINSTALL b/src/warden-server/doc/UNINSTALL
index ea227b8..97c3e8d 100644
--- a/src/warden-server/doc/UNINSTALL
+++ b/src/warden-server/doc/UNINSTALL
@@ -26,7 +26,7 @@ B. Uninstallation step
 
 1) Uninstall Warden server package (default installation path)
 
-	# /opt/warden-server/uninstall.sh -d /opt
+	# /opt/warden-server/uninstall.sh
 
 
 C. Post-uninstallation steps
diff --git a/src/warden-server/sh/uninstall.sh b/src/warden-server/sh/uninstall.sh
index 112d420..df1a533 100755
--- a/src/warden-server/sh/uninstall.sh
+++ b/src/warden-server/sh/uninstall.sh
@@ -12,12 +12,11 @@ VERSION="2.1"
 #-------------------------------------------------------------------------------
 usage()
 {
-	echo "Usage: `basename $0` [-d <directory>] [-hV]"
-	echo "-d <directory>            uninstallation directory (default: /opt)"
+	echo "Usage: `basename $0` [-hV]"
 	echo "-h                        print this help"
 	echo "-V                        print script version number and exit"
 	echo
-	echo "Example: # ./`basename $0` -d /opt"
+	echo "Example: # ./`basename $0`"
 	echo
 	echo "Note: You must be root for running this script."
 	echo "      For more information about uninstallation process, see README file (section Uninstallation)."
@@ -72,15 +71,6 @@ root_chck()
 }
 
 
-params_chck()
-{
-	if [ -z $prefix ]; then
-		prefix=/opt
-		echo "Warning: parameter -d <directory> is not set - default uninstallation directory is ${prefix}!"
-	fi
-}
-
-
 obtain_package_version()
 {
 	if [ -f $old_package_version_file ]; then 
@@ -94,9 +84,9 @@ obtain_package_version()
 warden_dir_chck()
 {
 	echo -n "Checking Warden server directory ... "
-	if [ ! -d $server_path ]; then
+	if [ ! -f ${server_path}/etc/package_version ]; then
 		echo "FAILED!"
-		ls $server_path
+		ls ${server_path}/etc/package_version
 		exit 1
 	else
 		echo "OK"
@@ -138,7 +128,7 @@ uninstall_warden_server()
 {
 	echo -n "Uninstalling $package_version package ... "
 	cp ${doc}/UNINSTALL $uninstall_file
-	if rm -rf $server_path 2> $err; then
+	if rm -rf $(server_path)/* 2> $err; then
 		echo "OK"
 	else
 		err_clean
@@ -152,9 +142,8 @@ uninstall_warden_server()
 #-------------------------------------------------------------------------------
 
 # read input
-while getopts "d:Vh" options; do
+while getopts "Vh" options; do
 	case $options in
-		d ) prefix=$OPTARG;;
 		h ) usage;;
 		V ) version;;
 		* ) usage;;
@@ -164,13 +153,8 @@ done
 # root test
 root_chck
 
-# params test
-params_chck
-
 # create variables
-[[ $prefix == */ ]] && prefix="${prefix%?}" # remove last char (slash) from prefix
-dirname=`dirname $0`
-server_path="${prefix}/warden-server"
+server_path=`dirname $0`
 bin="${server_path}/bin"
 local_bin="/usr/local/bin"
 etc="${server_path}/etc"
-- 
GitLab