From 400af104e18e82099a2ea4407824db87d079e1d5 Mon Sep 17 00:00:00 2001 From: Tomas Plesnik <plesnik@ics.muni.cz> Date: Wed, 12 Dec 2012 10:46:24 +0100 Subject: [PATCH] Revert "odstranena nutnost pouziti parametru -d z uninstall.sh" This reverts commit a11910e4889aa1d6e238202dbc0db843f2c9e47d. Skript uninstall.sh bude i nadale pouzivat parametr -d. Uzivatel tedy stale bude muset zadavat cestu k adresari, ktery se ma odinstalovat. --- src/warden-server/doc/README | 5 +++-- src/warden-server/doc/UNINSTALL | 2 +- src/warden-server/sh/uninstall.sh | 30 +++++++++++++++++++++++------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/warden-server/doc/README b/src/warden-server/doc/README index ea9826d..097bd2f 100644 --- a/src/warden-server/doc/README +++ b/src/warden-server/doc/README @@ -252,11 +252,12 @@ E. Uninstallation For more information about uninstall.sh options run uninstall.sh -h - Usage: $ ./uninstall.sh [-hV] + Usage: $ ./uninstall.sh [-d <directory>] [-hV] + -d <directory> uninstallation directory (default: /opt) -h print this help -V print script version number and exit - Example: # ./uninstall.sh + Example: # ./uninstall.sh -d /opt You must be root for running this script. diff --git a/src/warden-server/doc/UNINSTALL b/src/warden-server/doc/UNINSTALL index 97c3e8d..ea227b8 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 + # /opt/warden-server/uninstall.sh -d /opt C. Post-uninstallation steps diff --git a/src/warden-server/sh/uninstall.sh b/src/warden-server/sh/uninstall.sh index df1a533..112d420 100755 --- a/src/warden-server/sh/uninstall.sh +++ b/src/warden-server/sh/uninstall.sh @@ -12,11 +12,12 @@ VERSION="2.1" #------------------------------------------------------------------------------- usage() { - echo "Usage: `basename $0` [-hV]" + echo "Usage: `basename $0` [-d <directory>] [-hV]" + echo "-d <directory> uninstallation directory (default: /opt)" echo "-h print this help" echo "-V print script version number and exit" echo - echo "Example: # ./`basename $0`" + echo "Example: # ./`basename $0` -d /opt" echo echo "Note: You must be root for running this script." echo " For more information about uninstallation process, see README file (section Uninstallation)." @@ -71,6 +72,15 @@ 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 @@ -84,9 +94,9 @@ obtain_package_version() warden_dir_chck() { echo -n "Checking Warden server directory ... " - if [ ! -f ${server_path}/etc/package_version ]; then + if [ ! -d $server_path ]; then echo "FAILED!" - ls ${server_path}/etc/package_version + ls $server_path exit 1 else echo "OK" @@ -128,7 +138,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 @@ -142,8 +152,9 @@ uninstall_warden_server() #------------------------------------------------------------------------------- # read input -while getopts "Vh" options; do +while getopts "d:Vh" options; do case $options in + d ) prefix=$OPTARG;; h ) usage;; V ) version;; * ) usage;; @@ -153,8 +164,13 @@ done # root test root_chck +# params test +params_chck + # create variables -server_path=`dirname $0` +[[ $prefix == */ ]] && prefix="${prefix%?}" # remove last char (slash) from prefix +dirname=`dirname $0` +server_path="${prefix}/warden-server" bin="${server_path}/bin" local_bin="/usr/local/bin" etc="${server_path}/etc" -- GitLab