Skip to content
Snippets Groups Projects
Commit e011fff1 authored by Tomáš Plesník's avatar Tomáš Plesník
Browse files

presun skriptu z opravene verzi 1.2.0

parent 338355c8
No related branches found
No related tags found
No related merge requests found
...@@ -10,12 +10,12 @@ $URI = "https://warden-dev.cesnet.cz:443/Warden"; ...@@ -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 - 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 - 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 # SSL_CA_FILE - path to CA certificate file
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
# #
# 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" VERSION="2.0"
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
...@@ -75,7 +76,7 @@ params_chck() ...@@ -75,7 +76,7 @@ params_chck()
{ {
if [ -z $prefix ]; then if [ -z $prefix ]; then
prefix=/opt 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 fi
if [ -z $user ]; then if [ -z $user ]; then
echo "Parameter -u <user> is not set!" echo "Parameter -u <user> is not set!"
...@@ -98,7 +99,7 @@ params_chck() ...@@ -98,7 +99,7 @@ params_chck()
old_client_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 if [ -f $old_package_version_file ]; then
old_package_version=`cat $old_package_version_file` old_package_version=`cat $old_package_version_file`
echo "Sorry, but $old_package_version package is installed!" echo "Sorry, but $old_package_version package is installed!"
...@@ -111,8 +112,7 @@ old_client_chck() ...@@ -111,8 +112,7 @@ old_client_chck()
perl_chck() perl_chck()
{ {
echo -n "Checking Perl interpreter ... " echo -n "Checking Perl interpreter ... "
which perl 1>/dev/null; ret_val=`echo $?` if which perl 1> /dev/null; then
if [ $ret_val -eq 0 ]; then
echo "OK" echo "OK"
else else
echo "FAILED!" echo "FAILED!"
...@@ -127,8 +127,7 @@ modules_chck() ...@@ -127,8 +127,7 @@ modules_chck()
for module in ${modules[@]}; for module in ${modules[@]};
do do
echo -n "Checking $module module ... " echo -n "Checking $module module ... "
perl -e "use $module" 2> $err; ret_val=`echo $?` if perl -e "use $module" 2> $err; then
if [ $ret_val -eq 0 ]; then
echo "OK" echo "OK"
else else
err err
...@@ -140,8 +139,8 @@ modules_chck() ...@@ -140,8 +139,8 @@ modules_chck()
make_warden_dir() make_warden_dir()
{ {
echo -n "Creating warden client directory ... " echo -n "Creating warden client directory ... "
cp -R $dirname/warden-client $prefix 2> $err; ret_val=`echo $?` test -d $prefix || mkdir -p $prefix
if [ $ret_val -eq 0 ]; then if cp -R ${dirname}/warden-client $prefix 2> $err; then
echo "OK" echo "OK"
else else
err_clean err_clean
...@@ -150,17 +149,16 @@ make_warden_dir() ...@@ -150,17 +149,16 @@ make_warden_dir()
files=(CHANGELOG INSTALL LICENSE README README.cesnet) files=(CHANGELOG INSTALL LICENSE README README.cesnet)
for file in ${files[@]}; for file in ${files[@]};
do do
cp $dirname/$file "$client_path/doc" cp ${dirname}/$file ${client_path}/doc
done done
cp $dirname/uninstall.sh "$client_path" cp ${dirname}/uninstall.sh $client_path
} }
copy_key() copy_key()
{ {
echo -n "Copying certificate key file ... " echo -n "Copying certificate key file ... "
cp $key $etc 2> $err; ret_val=`echo $?` if cp $key $etc 2> $err; then
if [ $ret_val -eq 0 ]; then
echo "OK" echo "OK"
else else
err_clean err_clean
...@@ -171,8 +169,7 @@ copy_key() ...@@ -171,8 +169,7 @@ copy_key()
copy_cert() copy_cert()
{ {
echo -n "Copying certificate file ... " echo -n "Copying certificate file ... "
cp $cert $etc 2> $err; ret_val=`echo $?` if cp $cert $etc 2> $err; then
if [ $ret_val -eq 0 ]; then
echo "OK" echo "OK"
else else
err_clean err_clean
...@@ -195,17 +192,17 @@ make_conf_file() ...@@ -195,17 +192,17 @@ make_conf_file()
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# SSL_KEY_FILE - path to client SSL certificate key 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 - 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 - path to CA certificate file
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
\$SSL_CA_FILE = \"$ca_file\"; \$SSL_CA_FILE = \"${ca_file}\";
" > $conf_file 2> $err; ret_val=`echo $?` " > $conf_file 2> $err; ret_val=`echo $?`
if [ $ret_val -eq 0 ]; then if [ $ret_val -eq 0 ]; then
...@@ -219,8 +216,10 @@ make_conf_file() ...@@ -219,8 +216,10 @@ make_conf_file()
change_permissions() change_permissions()
{ {
echo -n "Changing permissions to installed package ... " echo -n "Changing permissions to installed package ... "
chown -R $user: $client_path 2>$err; ret_val=`echo $?` chown -R $user: $client_path 2> $err || err_clean
if [ $ret_val -eq 0 ]; then 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" echo "OK"
else else
err_clean err_clean
...@@ -258,13 +257,13 @@ params_chck ...@@ -258,13 +257,13 @@ params_chck
# create variables # create variables
dirname=`dirname $0` 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` key_file=`basename $key`
cert_file=`basename $cert` cert_file=`basename $cert`
[[ $prefix == */ ]] && prefix="${prefix%?}" # remove last char (slash) from prefix [[ $prefix == */ ]] && prefix="${prefix%?}" # remove last char (slash) from prefix
client_path="$prefix/warden-client" client_path="${prefix}/warden-client"
etc="$client_path/etc" etc="${client_path}/etc"
conf_file="$etc/warden-client.conf" conf_file="${etc}/warden-client.conf"
err="/tmp/warden-err" err="/tmp/warden-err"
# check if warden-client is installed # check if warden-client is installed
...@@ -299,7 +298,9 @@ make_conf_file ...@@ -299,7 +298,9 @@ make_conf_file
change_permissions change_permissions
echo 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
echo "Installation of $package_version package was SUCCESSFUL!!!" echo "Installation of $package_version package was SUCCESSFUL!!!"
......
...@@ -72,7 +72,7 @@ params_chck() ...@@ -72,7 +72,7 @@ params_chck()
{ {
if [ -z $prefix ]; then if [ -z $prefix ]; then
prefix=/opt 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 fi
} }
...@@ -104,7 +104,7 @@ backup() ...@@ -104,7 +104,7 @@ backup()
{ {
echo -n "Backing-up warden client directory ... " echo -n "Backing-up warden client directory ... "
mkdir $backup_dir 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" echo "OK"
else else
err err
...@@ -126,6 +126,12 @@ uninstall_warden_client() ...@@ -126,6 +126,12 @@ uninstall_warden_client()
# MAIN # MAIN
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# OS test
os_chck
# Shell test
shell_chck
# read input # read input
while getopts "d:Vh" options; do while getopts "d:Vh" options; do
case $options in case $options in
...@@ -136,12 +142,6 @@ while getopts "d:Vh" options; do ...@@ -136,12 +142,6 @@ while getopts "d:Vh" options; do
esac esac
done done
# root test
root_chck
# params test
params_chck
# create variables # create variables
[[ $prefix == */ ]] && prefix="${prefix%?}" # remove last char (slash) from prefix [[ $prefix == */ ]] && prefix="${prefix%?}" # remove last char (slash) from prefix
client_path="${prefix}/warden-client" client_path="${prefix}/warden-client"
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
# #
# Copyright (C) 2011-2012 Cesnet z.s.p.o # 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" VERSION="2.0"
...@@ -73,7 +74,7 @@ params_chck() ...@@ -73,7 +74,7 @@ params_chck()
{ {
if [ -z $prefix ]; then if [ -z $prefix ]; then
prefix=/opt 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 fi
} }
...@@ -138,7 +139,7 @@ backup() ...@@ -138,7 +139,7 @@ backup()
{ {
echo -n "Backing-up warden client directory ... " echo -n "Backing-up warden client directory ... "
mkdir $backup_dir 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" echo "OK"
else else
err err
...@@ -220,9 +221,9 @@ change_permissions() ...@@ -220,9 +221,9 @@ change_permissions()
{ {
echo -n "Changing permissions to updated package ... " echo -n "Changing permissions to updated package ... "
chown -R $user: $client_path 2>$err || err_clean chown -R $user: $client_path 2>$err || err_clean
key_file=`echo $ssl_key_file` | cut -d "\"" -f 2 | cut -d "\"" -f 1 key_file=`echo $ssl_key_file | cut -d "\"" -f 2`
cert_file=`echo $ssl_cert_file` | cut -d "\"" -f 2 | cut -d "\"" -f 1 cert_file=`echo $ssl_cert_file | cut -d "\"" -f 2`
chmod 400 ${etc}/$key_file ${etc}/$cert_file || err_clean chmod 400 $key_file $cert_file || err_clean
chmod 644 $old_package_version_file || err_clean chmod 644 $old_package_version_file || err_clean
if chmod 600 $conf_file; then if chmod 600 $conf_file; then
echo "OK" echo "OK"
...@@ -301,7 +302,7 @@ make_conf_file ...@@ -301,7 +302,7 @@ make_conf_file
change_permissions change_permissions
echo echo
echo "Please check configuration file in $conf_file!" echo "Please check configuration file in ${conf_file}!"
echo echo
echo "Warden client directory: $client_path" echo "Warden client directory: $client_path"
echo echo
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment