From e011fff10aa32815825a1328518bff657f253637 Mon Sep 17 00:00:00 2001 From: Tomas Plesnik <plesnik@ics.muni.cz> Date: Fri, 11 May 2012 13:32:14 +0200 Subject: [PATCH] presun skriptu z opravene verzi 1.2.0 --- src/warden-client/etc/warden-client.conf | 4 +- src/warden-client/sh/install.sh | 49 ++++++++++++------------ src/warden-client/sh/uninstall.sh | 16 ++++---- src/warden-client/sh/update.sh | 15 ++++---- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/src/warden-client/etc/warden-client.conf b/src/warden-client/etc/warden-client.conf index af9e8de..276b8ed 100644 --- a/src/warden-client/etc/warden-client.conf +++ b/src/warden-client/etc/warden-client.conf @@ -10,12 +10,12 @@ $URI = "https://warden-dev.cesnet.cz:443/Warden"; #------------------------------------------------------------------------------- # SSL_KEY_FILE - path to client SSL certificate key file #------------------------------------------------------------------------------- -$SSL_KEY_FILE = "/opt/warden-client/etc/barny.ics.muni.cz.key"; +$SSL_KEY_FILE = "/opt/warden-client/etc/warden-dev.cesnet.cz.key"; #------------------------------------------------------------------------------- # SSL_CERT_FILE - path to client SSL certificate file #------------------------------------------------------------------------------- -$SSL_CERT_FILE = "/opt/warden-client/etc/barny.ics.muni.cz.pem"; +$SSL_CERT_FILE = "/opt/warden-client/etc/warden-dev.cesnet.cz.pem"; #------------------------------------------------------------------------------- # SSL_CA_FILE - path to CA certificate file diff --git a/src/warden-client/sh/install.sh b/src/warden-client/sh/install.sh index 5919c95..f121a99 100755 --- a/src/warden-client/sh/install.sh +++ b/src/warden-client/sh/install.sh @@ -6,6 +6,7 @@ # # Use of this source is governed by a BSD-style license, see LICENSE file. + VERSION="2.0" #------------------------------------------------------------------------------- @@ -75,7 +76,7 @@ params_chck() { if [ -z $prefix ]; then prefix=/opt - echo "Warning: parameter -d <directory> is not set - default installation directory is $prefix!" + echo "Warning: parameter -d <directory> is not set - default installation directory is ${prefix}!" fi if [ -z $user ]; then echo "Parameter -u <user> is not set!" @@ -98,7 +99,7 @@ params_chck() old_client_chck() { - old_package_version_file="$etc/package_version" + old_package_version_file={$etc}/package_version if [ -f $old_package_version_file ]; then old_package_version=`cat $old_package_version_file` echo "Sorry, but $old_package_version package is installed!" @@ -111,8 +112,7 @@ old_client_chck() perl_chck() { echo -n "Checking Perl interpreter ... " - which perl 1>/dev/null; ret_val=`echo $?` - if [ $ret_val -eq 0 ]; then + if which perl 1> /dev/null; then echo "OK" else echo "FAILED!" @@ -127,8 +127,7 @@ modules_chck() for module in ${modules[@]}; do echo -n "Checking $module module ... " - perl -e "use $module" 2> $err; ret_val=`echo $?` - if [ $ret_val -eq 0 ]; then + if perl -e "use $module" 2> $err; then echo "OK" else err @@ -140,8 +139,8 @@ modules_chck() make_warden_dir() { echo -n "Creating warden client directory ... " - cp -R $dirname/warden-client $prefix 2> $err; ret_val=`echo $?` - if [ $ret_val -eq 0 ]; then + test -d $prefix || mkdir -p $prefix + if cp -R ${dirname}/warden-client $prefix 2> $err; then echo "OK" else err_clean @@ -150,17 +149,16 @@ make_warden_dir() files=(CHANGELOG INSTALL LICENSE README README.cesnet) for file in ${files[@]}; do - cp $dirname/$file "$client_path/doc" + cp ${dirname}/$file ${client_path}/doc done - cp $dirname/uninstall.sh "$client_path" + cp ${dirname}/uninstall.sh $client_path } copy_key() { echo -n "Copying certificate key file ... " - cp $key $etc 2> $err; ret_val=`echo $?` - if [ $ret_val -eq 0 ]; then + if cp $key $etc 2> $err; then echo "OK" else err_clean @@ -171,8 +169,7 @@ copy_key() copy_cert() { echo -n "Copying certificate file ... " - cp $cert $etc 2> $err; ret_val=`echo $?` - if [ $ret_val -eq 0 ]; then + if cp $cert $etc 2> $err; then echo "OK" else err_clean @@ -195,17 +192,17 @@ make_conf_file() #------------------------------------------------------------------------------- # SSL_KEY_FILE - path to client SSL certificate key file #------------------------------------------------------------------------------- -\$SSL_KEY_FILE = \"$etc/$key_file\"; +\$SSL_KEY_FILE = \"${etc}/${key_file}\"; #------------------------------------------------------------------------------- # SSL_CERT_FILE - path to client SSL certificate file #------------------------------------------------------------------------------- -\$SSL_CERT_FILE = \"$etc/$cert_file\"; +\$SSL_CERT_FILE = \"${etc}/${cert_file}\"; #------------------------------------------------------------------------------- # SSL_CA_FILE - path to CA certificate file #------------------------------------------------------------------------------- -\$SSL_CA_FILE = \"$ca_file\"; +\$SSL_CA_FILE = \"${ca_file}\"; " > $conf_file 2> $err; ret_val=`echo $?` if [ $ret_val -eq 0 ]; then @@ -219,8 +216,10 @@ make_conf_file() change_permissions() { echo -n "Changing permissions to installed package ... " - chown -R $user: $client_path 2>$err; ret_val=`echo $?` - if [ $ret_val -eq 0 ]; then + chown -R $user: $client_path 2> $err || err_clean + chmod 400 ${etc}/$key_file ${etc}/$cert_file || err_clean + chmod 644 ${etc}/package_version || err_clean + if chmod 600 $conf_file; then echo "OK" else err_clean @@ -258,13 +257,13 @@ params_chck # create variables dirname=`dirname $0` -package_version=`cat $dirname/warden-client/etc/package_version` +package_version=`cat ${dirname}/warden-client/etc/package_version` key_file=`basename $key` cert_file=`basename $cert` [[ $prefix == */ ]] && prefix="${prefix%?}" # remove last char (slash) from prefix -client_path="$prefix/warden-client" -etc="$client_path/etc" -conf_file="$etc/warden-client.conf" +client_path="${prefix}/warden-client" +etc="${client_path}/etc" +conf_file="${etc}/warden-client.conf" err="/tmp/warden-err" # check if warden-client is installed @@ -299,7 +298,9 @@ make_conf_file change_permissions echo -echo "Please check configuration file in $conf_file!" +echo "Please check configuration file in ${conf_file}!" +echo +echo "Warden client directory: $client_path" echo echo "Installation of $package_version package was SUCCESSFUL!!!" diff --git a/src/warden-client/sh/uninstall.sh b/src/warden-client/sh/uninstall.sh index b927de0..c2b52d0 100755 --- a/src/warden-client/sh/uninstall.sh +++ b/src/warden-client/sh/uninstall.sh @@ -72,7 +72,7 @@ params_chck() { if [ -z $prefix ]; then prefix=/opt - echo "Warning: parameter -d <directory> is not set - default uninstallation directory is $prefix!" + echo "Warning: parameter -d <directory> is not set - default uninstallation directory is ${prefix}!" fi } @@ -104,7 +104,7 @@ backup() { echo -n "Backing-up warden client directory ... " mkdir $backup_dir - if cp -R $client_path $backup_dir 2> $err; then + if cp -R ${client_path}/* $backup_dir 2> $err; then echo "OK" else err @@ -126,6 +126,12 @@ uninstall_warden_client() # MAIN #------------------------------------------------------------------------------- +# OS test +os_chck + +# Shell test +shell_chck + # read input while getopts "d:Vh" options; do case $options in @@ -136,12 +142,6 @@ while getopts "d:Vh" options; do esac done -# root test -root_chck - -# params test -params_chck - # create variables [[ $prefix == */ ]] && prefix="${prefix%?}" # remove last char (slash) from prefix client_path="${prefix}/warden-client" diff --git a/src/warden-client/sh/update.sh b/src/warden-client/sh/update.sh index bbf644c..5590252 100755 --- a/src/warden-client/sh/update.sh +++ b/src/warden-client/sh/update.sh @@ -4,7 +4,8 @@ # # Copyright (C) 2011-2012 Cesnet z.s.p.o # -# Use of this source is governed by a BSD-style license, see LICENSE file. +# Use of this source is governed by a BSD-style license, see LICENSE file. + VERSION="2.0" @@ -73,7 +74,7 @@ params_chck() { if [ -z $prefix ]; then prefix=/opt - echo "Warning: parameter -d <directory> is not set - default installation directory is $prefix!" + echo "Warning: parameter -d <directory> is not set - default installation directory is ${prefix}!" fi } @@ -138,7 +139,7 @@ backup() { echo -n "Backing-up warden client directory ... " mkdir $backup_dir - if cp -R $client_path $backup_dir 2> $err; then + if cp -R ${client_path}/* $backup_dir 2> $err; then echo "OK" else err @@ -220,9 +221,9 @@ change_permissions() { echo -n "Changing permissions to updated package ... " chown -R $user: $client_path 2>$err || err_clean - key_file=`echo $ssl_key_file` | cut -d "\"" -f 2 | cut -d "\"" -f 1 - cert_file=`echo $ssl_cert_file` | cut -d "\"" -f 2 | cut -d "\"" -f 1 - chmod 400 ${etc}/$key_file ${etc}/$cert_file || err_clean + key_file=`echo $ssl_key_file | cut -d "\"" -f 2` + cert_file=`echo $ssl_cert_file | cut -d "\"" -f 2` + chmod 400 $key_file $cert_file || err_clean chmod 644 $old_package_version_file || err_clean if chmod 600 $conf_file; then echo "OK" @@ -301,7 +302,7 @@ make_conf_file change_permissions echo -echo "Please check configuration file in $conf_file!" +echo "Please check configuration file in ${conf_file}!" echo echo "Warden client directory: $client_path" echo -- GitLab