Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
Warden
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pavel Valach
Warden
Commits
220f9318
Commit
220f9318
authored
13 years ago
by
Tomáš Plesník
Browse files
Options
Downloads
Patches
Plain Diff
zmena verze skriptu; pridana kontrola nainstalovaneho klienta; zmena odsazeni
parent
ae775364
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/warden-client/sh/install.sh
+163
-147
163 additions, 147 deletions
src/warden-client/sh/install.sh
with
163 additions
and
147 deletions
src/warden-client/sh/install.sh
+
163
−
147
View file @
220f9318
...
...
@@ -31,205 +31,216 @@
# otherwise) arising in any way out of the use of this software, even
# if advised of the possibility of such damage.
VERSION
=
"1.1
.0
"
VERSION
=
"1.1"
#-------------------------------------------------------------------------------
# FUNCTIONS
#-------------------------------------------------------------------------------
usage
()
{
echo
"Usage:
`
basename
$0
`
[-d <directory>] [-u <user>] [-k <ssl_key_file>] [-c <ssl_cert_file>] [-a <ssl_ca_file>] [-hV]"
echo
"-d <directory> installation directory (default: /opt)"
echo
"-u <user> owner of warden client package (user for running detection scripts)"
echo
"-k <ssl_key_file> path to SSL certificate key file"
echo
"-c <ssl_cert_file> path to SSL certificate file"
echo
"-a <ssl_ca_file> path to CA certificate file"
echo
"-h print this help"
echo
"-V print script version number and exit"
echo
echo
"Example: ./
`
basename
$0
`
-d /opt -u detector -k /etc/ssl/private/client.key -c /etc/ssl/certs/client.pem -a /etc/ssl/certs/tcs-ca-bundle.pem"
echo
echo
"Note: You must be root for running this script."
echo
" For more information about installation process, see README file (section Installation)."
echo
exit
0
echo
"Usage:
`
basename
$0
`
[-d <directory>] [-u <user>] [-k <ssl_key_file>] [-c <ssl_cert_file>] [-a <ssl_ca_file>] [-hV]"
echo
"-d <directory> installation directory (default: /opt)"
echo
"-u <user> owner of warden client package (user for running detection scripts)"
echo
"-k <ssl_key_file> path to SSL certificate key file"
echo
"-c <ssl_cert_file> path to SSL certificate file"
echo
"-a <ssl_ca_file> path to CA certificate file"
echo
"-h print this help"
echo
"-V print script version number and exit"
echo
echo
"Example: ./
`
basename
$0
`
-d /opt -u detector -k /etc/ssl/private/client.key -c /etc/ssl/certs/client.pem -a /etc/ssl/certs/tcs-ca-bundle.pem"
echo
echo
"Note: You must be root for running this script."
echo
" For more information about installation process, see README file (section Installation)."
echo
exit
0
}
version
()
{
echo
"
`
basename
${
0
}
`
- current version is
$VERSION
"
exit
0
echo
"
`
basename
${
0
}
`
- current version is
$VERSION
"
exit
0
}
err
()
{
echo
"FAILED!"
cat
$err
rm
-rf
$err
echo
echo
"Installation of
$package_
name
package FAILED!!!"
exit
1
echo
"FAILED!"
cat
$err
rm
-rf
$err
echo
echo
"Installation of
$package_
version
package FAILED!!!"
exit
1
}
err_clean
()
{
echo
"FAILED!"
echo
" -> Uninstalling client package ... OK"
rm
-rf
$client_path
>
/dev/null 2>&1
cat
$err
rm
-rf
$err
echo
echo
"Installation of
$package_
name
package FAILED!!!"
exit
1
echo
"FAILED!"
echo
" -> Uninstalling client package ... OK"
rm
-rf
$client_path
>
/dev/null 2>&1
cat
$err
rm
-rf
$err
echo
echo
"Installation of
$package_
version
package FAILED!!!"
exit
1
}
os_chck
()
{
OS
=
`
uname
`
if
[
"
$OS
"
!=
"Linux"
]
;
then
echo
"Sorry, unsupported operating system detected -
\"
$OS
\"
!"
exit
1
fi
OS
=
`
uname
`
if
[
"
$OS
"
!=
"Linux"
]
;
then
echo
"Sorry, unsupported operating system detected -
\"
$OS
\"
!"
exit
1
fi
}
shell_chck
()
{
SHELL
=
`
echo
$SHELL
`
if
[
"
$SHELL
"
!=
"/bin/bash"
]
;
then
echo
"Sorry, this script is usable in Bourne Again Shell (bash) only!"
exit
1
fi
SHELL
=
`
echo
$SHELL
`
if
[
"
$SHELL
"
!=
"/bin/bash"
]
;
then
echo
"Sorry, this script is usable in Bourne Again Shell (bash) only!"
exit
1
fi
}
root_chck
()
{
if
[
$UID
-ne
0
]
;
then
echo
"You must be root for running this script!"
exit
1
fi
if
[
$UID
-ne
0
]
;
then
echo
"You must be root for running this script!"
exit
1
fi
}
params_chck
()
{
if
[
-z
$prefix
]
;
then
prefix
=
/opt
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!"
exit
1
fi
if
[
-z
$key
]
;
then
echo
"Parameter -k <ssl_key_file> is not set!"
exit
1
fi
if
[
-z
$cert
]
;
then
echo
"Parameter -c <ssl_cert_file> is not set!"
exit
1
fi
if
[
-z
$ca_file
]
;
then
echo
"Parameter -a <ssl_ca_file> is not set!"
exit
1
fi
if
[
-z
$prefix
]
;
then
prefix
=
/opt
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!"
exit
1
fi
if
[
-z
$key
]
;
then
echo
"Parameter -k <ssl_key_file> is not set!"
exit
1
fi
if
[
-z
$cert
]
;
then
echo
"Parameter -c <ssl_cert_file> is not set!"
exit
1
fi
if
[
-z
$ca_file
]
;
then
echo
"Parameter -a <ssl_ca_file> is not set!"
exit
1
fi
}
old_client_chck
()
{
old_package_version
=
"
$etc
/package_version.txt"
if
[
-f
$old_package_version
]
;
then
echo
"Sorry, but
$old_package_version
package is installed!"
echo
"For update of warden client package please use update.sh script."
exit
1
fi
}
perl_chck
()
{
echo
-n
"Checking Perl interpreter ... "
which perl 1>/dev/null
;
ret_val
=
`
echo
$?
`
if
[
$ret_val
-eq
0
]
;
then
echo
"OK"
else
echo
"FAILED!"
echo
"Error: Perl interpreter is not installed!"
exit
1
fi
echo
-n
"Checking Perl interpreter ... "
which perl 1>/dev/null
;
ret_val
=
`
echo
$?
`
if
[
$ret_val
-eq
0
]
;
then
echo
"OK"
else
echo
"FAILED!"
echo
"Error: Perl interpreter is not installed!"
exit
1
fi
}
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
echo
"OK"
else
err
fi
done
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
echo
"OK"
else
err
fi
done
}
installation_dir_chck
()
{
echo
-n
"Checking installation directory ... "
if
[
!
-d
$prefix
]
;
then
echo
"FAILED!"
ls
$prefix
exit
1
else
echo
"OK"
fi
echo
-n
"Checking installation directory ... "
if
[
!
-d
$prefix
]
;
then
echo
"FAILED!"
ls
$prefix
exit
1
else
echo
"OK"
fi
}
make_warden_dir
()
{
echo
-n
"Creating warden client directory ... "
cp
-R
`
dirname
$0
`
/warden-client
$prefix
2>
$err
;
ret_val
=
`
echo
$?
`
if
[
$ret_val
-eq
0
]
;
then
echo
"OK"
else
err_clean
fi
files
=(
CHANGELOG INSTALL LICENSE README README.cesnet
)
for
file
in
${
files
[@]
}
;
do
cp
-u
"
`
dirname
$0
`
/
$file
"
"
$client_path
/doc"
done
cp
-u
"
`
dirname
$0
`
/uninstall.sh
"
"
$client_path
"
echo
-n
"Creating warden client directory ... "
cp
-R
$
dirname
/warden-client
$prefix
2>
$err
;
ret_val
=
`
echo
$?
`
if
[
$ret_val
-eq
0
]
;
then
echo
"OK"
else
err_clean
fi
files
=(
CHANGELOG INSTALL LICENSE README README.cesnet
)
for
file
in
${
files
[@]
}
;
do
cp
-u
$
dirname
/
$file
"
$client_path
/doc"
done
cp
-u
$
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
echo
"OK"
else
err_clean
fi
echo
-n
"Copying certificate key file ... "
cp
$key
$etc
2>
$err
;
ret_val
=
`
echo
$?
`
if
[
$ret_val
-eq
0
]
;
then
echo
"OK"
else
err_clean
fi
}
copy_cert
()
{
echo
-n
"Copying certificate file ... "
cp
$cert
$etc
2>
$err
;
ret_val
=
`
echo
$?
`
if
[
$ret_val
-eq
0
]
;
then
echo
"OK"
else
err_clean
fi
echo
-n
"Copying certificate file ... "
cp
$cert
$etc
2>
$err
;
ret_val
=
`
echo
$?
`
if
[
$ret_val
-eq
0
]
;
then
echo
"OK"
else
err_clean
fi
}
make_conf_file
()
{
echo
-n
"Creating configuration file ... "
echo
"#
echo
-n
"Creating configuration file ... "
echo
"#
# warden-client.conf - configuration file for the warden sender/receiver client
#
...
...
@@ -253,23 +264,24 @@ echo "#
#-------------------------------------------------------------------------------
\$
SSL_CA_FILE =
\"
$ca_file
\"
;
"
>
$conf_file
2>
$err
;
ret_val
=
`
echo
$?
`
if
[
$ret_val
-eq
0
]
;
then
echo
"OK"
else
err_clean
fi
if
[
$ret_val
-eq
0
]
;
then
echo
"OK"
else
err_clean
fi
}
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
echo
"OK"
else
err_clean
fi
echo
-n
"Changing permissions to installed package ... "
chown
-R
$user
:
$client_path
2>
$err
;
ret_val
=
`
echo
$?
`
if
[
$ret_val
-eq
0
]
;
then
echo
"OK"
else
err_clean
fi
}
...
...
@@ -289,16 +301,16 @@ shell_chck
# read input
while
getopts
"d:u:k:c:a:Vh"
options
;
do
case
$options
in
d
)
prefix
=
$OPTARG
;;
u
)
user
=
$OPTARG
;;
k
)
key
=
$OPTARG
;;
c
)
cert
=
$OPTARG
;;
a
)
ca_file
=
$OPTARG
;;
h
)
usage
;;
V
)
version
;;
*
)
usage
;;
esac
case
$options
in
d
)
prefix
=
$OPTARG
;;
u
)
user
=
$OPTARG
;;
k
)
key
=
$OPTARG
;;
c
)
cert
=
$OPTARG
;;
a
)
ca_file
=
$OPTARG
;;
h
)
usage
;;
V
)
version
;;
*
)
usage
;;
esac
done
# root test
...
...
@@ -308,7 +320,8 @@ root_chck
params_chck
# create variables
package_name
=
"warden-client-
$VERSION
"
dirname
=
`
dirname
$0
`
package_version
=
`
cat
$dirname
/warden-client/etc/package_version.txt
`
key_file
=
`
basename
$key
`
cert_file
=
`
basename
$cert
`
client_path
=
"
$prefix
/warden-client"
...
...
@@ -316,6 +329,9 @@ etc="$client_path/etc"
conf_file
=
"
$etc
/warden-client.conf"
err
=
"/tmp/warden-err"
# check if warden-client is installed
old_client_chck
echo
echo
"------------------------- Dependencies check-in -------------------------"
...
...
@@ -350,7 +366,7 @@ change_permissions
echo
echo
"Please check configuration file in
$conf_file
!"
echo
echo
"Installation of
$package_
name
package was SUCCESSFUL!!!"
echo
"Installation of
$package_
version
package was SUCCESSFUL!!!"
# cleanup section
rm
-rf
$err
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment