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
3f29a9cc
Commit
3f29a9cc
authored
11 years ago
by
Tomáš Plesník
Browse files
Options
Downloads
Patches
Plain Diff
zapracovany poznamky z #628
parent
6f90c0c7
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-server/sh/install.sh
+55
-94
55 additions, 94 deletions
src/warden-server/sh/install.sh
with
55 additions
and
94 deletions
src/warden-server/sh/install.sh
+
55
−
94
View file @
3f29a9cc
...
@@ -10,22 +10,21 @@
...
@@ -10,22 +10,21 @@
VERSION
=
"2.2"
VERSION
=
"2.2"
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
#
FUNCTIONS
#
Script functions
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
usage
()
usage
()
{
{
echo
"Usage:
`
basename
$0
`
[
-d <directory>
] [
-k <ssl_key_file>
] [
-c <ssl_cert_file>
] [
-a <ssl_ca_file>
]
[-hV]"
echo
"Usage:
${
0
##*/
}
-d <directory>
-k <ssl_key_file>
-c <ssl_cert_file>
-a <ssl_ca_file> [-hV]"
echo
"-d <directory> installation directory
(default: /opt)
"
echo
"-d <directory> installation directory"
echo
"-k <ssl_key_file> path to SSL certificate key file"
echo
"-k <ssl_key_file> path to SSL certificate key file"
echo
"-c <ssl_cert_file> path to SSL certificate file"
echo
"-c <ssl_cert_file> path to SSL certificate file"
echo
"-a <ssl_ca_file> path to CA certificate file"
echo
"-a <ssl_ca_file> path to CA certificate file"
echo
"-h print this help"
echo
"-h print this help"
echo
"-V print script version number and exit"
echo
"-V print script version number and exit"
echo
echo
echo
"Example: # ./
`
basename
$0
`
-d /opt -k /etc/ssl/private/server.key -c /etc/ssl/certs/server.pem -a /etc/ssl/certs/tcs-ca-bundle.pem"
echo
"Example: # ./
${
0
##*/
}
-d /opt -k /etc/ssl/private/server.key -c /etc/ssl/certs/server.pem -a /etc/ssl/certs/tcs-ca-bundle.pem"
echo
echo
echo
"Note: You must be root for running this script."
echo
"For more information about installation process, see README file (section Installation)."
echo
" For more information about installation process, see README file (section Installation)."
echo
echo
exit
0
exit
0
}
}
...
@@ -33,7 +32,7 @@ usage()
...
@@ -33,7 +32,7 @@ usage()
version
()
version
()
{
{
echo
"
`
basename
${
0
}
`
- current version is
$VERSION
"
echo
"
${
0
##*/
}
- current version is
$VERSION
"
exit
0
exit
0
}
}
...
@@ -41,8 +40,8 @@ version()
...
@@ -41,8 +40,8 @@ version()
err
()
err
()
{
{
echo
"FAILED!"
echo
"FAILED!"
cat
$err
cat
"
$err
"
rm
-
r
f
$err
rm
-f
"
$err
"
echo
echo
echo
"Installation of
$package_version
package FAILED!!!"
echo
"Installation of
$package_version
package FAILED!!!"
exit
1
exit
1
...
@@ -53,50 +52,45 @@ errClean()
...
@@ -53,50 +52,45 @@ errClean()
{
{
echo
"FAILED!"
echo
"FAILED!"
echo
" -> Uninstalling server package ... OK"
echo
" -> Uninstalling server package ... OK"
rm
-rf
$server_
path
>
/dev/null 2>&1
rm
-rf
"
$server_
dir
/"
*
>
/dev/null 2>&1
cat
$err
cat
"
$err
"
rm
-
r
f
$err
rm
-f
"
$err
"
echo
echo
echo
"Installation of
$package_version
package FAILED!!!"
echo
"Installation of
$package_version
package FAILED!!!"
exit
1
exit
1
}
}
rootChck
()
{
if
[
$UID
-ne
0
]
;
then
echo
"You must be root for running this script!"
exit
1
fi
}
paramsChck
()
paramsChck
()
{
{
if
[
-z
$prefix
]
;
then
if
[
-z
"
$server_dir
"
]
;
then
echo
"Parameter -d <directory> is not set!"
echo
"Parameter -d <directory> is not set!"
exit
1
exit
1
fi
fi
if
[
-z
$key
]
;
then
if
[
-z
"
$key
_file
"
]
;
then
echo
"Parameter -k <ssl_key_file> is not set!"
echo
"Parameter -k <ssl_key_file> is not set!"
exit
1
exit
1
fi
fi
if
[
-z
$cert
]
;
then
if
[
-z
"
$cert
_file
"
]
;
then
echo
"Parameter -c <ssl_cert_file> is not set!"
echo
"Parameter -c <ssl_cert_file> is not set!"
exit
1
exit
1
fi
fi
if
[
-z
$ca_file
]
;
then
if
[
-z
"
$ca_file
"
]
;
then
echo
"Parameter -a <ssl_ca_file> is not set!"
echo
"Parameter -a <ssl_ca_file> is not set!"
exit
1
exit
1
fi
fi
}
}
#-------------------------------------------------------------------------------
# Installation functions
#-------------------------------------------------------------------------------
oldPackageChck
()
oldPackageChck
()
{
{
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
=
$(
<
"
$old_package_version_file
"
)
||
err
echo
"Sorry, but
$old_package_version
package is installed!"
echo
"Sorry, but
$old_package_version
package is installed!"
echo
"For update of warden server package please use update.sh"
echo
"For update of warden server package please use update.sh"
exit
1
exit
1
...
@@ -118,31 +112,23 @@ perlChck()
...
@@ -118,31 +112,23 @@ perlChck()
modulesChck
()
modulesChck
()
{
{
for
module
in
${
modules
[@]
}
;
sed
'/^use [A-Z]/!d; /Warden/d'
`
find
"
${
dirname
}
/warden-server"
-type
f
`
2>/dev/null |
cut
-f
2
-d
" "
|
sed
's/;//'
|
sort
-u
>
"
$modules_file
"
for
module
in
$(
<
"
$modules_file
"
)
;
do
do
echo
-n
"Checking
$module
module ... "
echo
-n
"Checking
$module
module ... "
if
perl
-e
"use
$module
"
2>
$err
;
then
perl
-e
"use
$module
"
2>
"
$err
"
&&
echo
"OK"
||
err
echo
"OK"
else
err
fi
done
done
}
}
mak
eWardenDir
()
creat
eWardenDir
()
{
{
echo
-n
"Creating Warden server directory ... "
echo
-n
"Creating Warden server directory ... "
test
-d
$prefix
||
mkdir
-p
$prefix
test
-d
"
$server_dir
"
&&
test
-w
"
$server_dir
"
||
mkdir
-p
"
$server_dir
"
2>
"
$err
"
||
err
if
cp
-R
${
dirname
}
/warden-server
$prefix
2>
$err
;
then
cp
-R
"
${
dirname
}
/warden-server/"
*
"
$server_dir
"
2>
"
$err
"
&&
echo
"OK"
||
errClean
echo
"OK"
cp
"
${
dirname
}
/uninstall.sh"
"
$server_dir
"
else
errClean
fi
cp
${
dirname
}
/uninstall.sh
$server_path
}
}
makeServerConf
()
makeServerConf
()
{
{
echo
-n
"Creating server configuration file ... "
echo
-n
"Creating server configuration file ... "
...
@@ -153,7 +139,7 @@ makeServerConf()
...
@@ -153,7 +139,7 @@ makeServerConf()
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# BASEDIR - base directory of Warden server
# BASEDIR - base directory of Warden server
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
\$
BASEDIR =
\"
${
server_
path
}
\"
;
\$
BASEDIR =
\"
${
server_
dir
}
\"
;
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# SYSLOG - enable/disable syslog logging
# SYSLOG - enable/disable syslog logging
...
@@ -202,13 +188,7 @@ makeServerConf()
...
@@ -202,13 +188,7 @@ makeServerConf()
%VALID_STRINGS = (
%VALID_STRINGS = (
\"
type
\"
=> [
\"
portscan
\"
,
\"
bruteforce
\"
,
\"
probe
\"
,
\"
spam
\"
,
\"
phishing
\"
,
\"
botnet_c_c
\"
,
\"
dos
\"
,
\"
malware
\"
,
\"
copyright
\"
,
\"
webattack
\"
,
\"
test
\"
,
\"
other
\"
,
\"
_any_
\"
],
\"
type
\"
=> [
\"
portscan
\"
,
\"
bruteforce
\"
,
\"
probe
\"
,
\"
spam
\"
,
\"
phishing
\"
,
\"
botnet_c_c
\"
,
\"
dos
\"
,
\"
malware
\"
,
\"
copyright
\"
,
\"
webattack
\"
,
\"
test
\"
,
\"
other
\"
,
\"
_any_
\"
],
\"
source_type
\"
=> [
\"
IP
\"
,
\"
URL
\"
,
\"
Reply-To:
\"
]
\"
source_type
\"
=> [
\"
IP
\"
,
\"
URL
\"
,
\"
Reply-To:
\"
]
);"
>
$server_conf
2>
$err
;
ret_val
=
`
echo
$?
`
);"
>
"
$server_conf
"
2>
"
$err
"
&&
echo
"OK"
||
errClean
if
[
$ret_val
-eq
0
]
;
then
echo
"OK"
else
errClean
fi
}
}
makeApacheConf
()
makeApacheConf
()
...
@@ -227,8 +207,8 @@ SSLOptions +StdEnvVars +ExportCertData
...
@@ -227,8 +207,8 @@ SSLOptions +StdEnvVars +ExportCertData
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile
$cert
SSLCertificateFile
$cert
_file
SSLCertificateKeyFile
$key
SSLCertificateKeyFile
$key
_file
SSLCACertificateFile
$ca_file
SSLCACertificateFile
$ca_file
PerlOptions +Parent
PerlOptions +Parent
...
@@ -238,23 +218,17 @@ PerlSwitches -I $lib
...
@@ -238,23 +218,17 @@ PerlSwitches -I $lib
SetHandler perl-script
SetHandler perl-script
PerlHandler Warden::ApacheDispatch
PerlHandler Warden::ApacheDispatch
SSLOptions +StdEnvVars
SSLOptions +StdEnvVars
</Location>"
>
$apache_conf
2>
$err
;
ret_val
=
`
echo
$?
`
</Location>"
>
"
$apache_conf
"
2>
"
$err
"
&&
echo
"OK"
||
errClean
if
[
$ret_val
-eq
0
]
;
then
echo
"OK"
else
errClean
fi
}
}
createSymlinks
()
createSymlinks
()
{
{
echo
"Creating symbolic links ..."
echo
"Creating symbolic links
to local bin path
..."
for
file
in
`
ls
-1
$bin
`
for
file
in
"
${
bin
}
/"
*
do
do
echo
"- making symlink:
${
local_bin
}
/
$file
->
${
bin
}
/
$file
"
echo
"- making symlink:
${
local_bin
}
/
$
{
file
##*/
}
->
$file
"
ln
-s
${
bin
}
/
$file
${
local_bin
}
/
$file
ln
-s
"
$file
"
"
${
local_bin
}
/
$
{
file
##*/
}
"
done
done
}
}
...
@@ -262,47 +236,34 @@ createSymlinks()
...
@@ -262,47 +236,34 @@ createSymlinks()
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# MAIN
# MAIN
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# list of used Perl modules
modules
=(
SOAP::Lite SOAP::Transport::HTTP DBI DBD::mysql Format::Human::Bytes Sys::Syslog File::Basename Net::CIDR::Lite DateTime Getopt::Std Switch IO::Socket::SSL MIME::Base64 Crypt::X509 Carp FindBin
)
# read input
# read input
while
getopts
"d:k:c:a:Vh"
options
;
do
while
getopts
"d:k:c:a:Vh"
options
;
do
case
$options
in
case
"
$options
"
in
d
)
prefix
=
$OPTARG
;;
d
)
server_dir
=
"
$OPTARG
"
;;
k
)
key
=
$OPTARG
;;
k
)
key
_file
=
"
$OPTARG
"
;;
c
)
cert
=
$OPTARG
;;
c
)
cert
_file
=
"
$OPTARG
"
;;
a
)
ca_file
=
$OPTARG
;;
a
)
ca_file
=
"
$OPTARG
"
;;
h
)
usage
;;
h
)
usage
;;
V
)
version
;;
V
)
version
;;
*
)
usage
;;
*
)
usage
;;
esac
esac
done
done
# root test
rootChck
# params test
# params test
paramsChck
paramsChck
# create variables
# set variables
dirname
=
`
dirname
$0
`
dirname
=
${
0
%/*
}
hostname
=
`
hostname
-f
`
package_version
=
$(
<
"
${
dirname
}
/warden-server/etc/package_version"
)
||
err
key_file
=
`
basename
$key
`
bin
=
"
${
server_dir
}
/bin"
cert_file
=
`
basename
$cert
`
package_version
=
`
cat
${
dirname
}
/warden-server/etc/package_version
`
[[
$prefix
==
*
/
]]
&&
prefix
=
"
${
prefix
%?
}
"
# remove last char (slash) from prefix
server_path
=
"
${
prefix
}
/warden-server"
bin
=
"
${
server_path
}
/bin"
local_bin
=
"/usr/local/bin"
local_bin
=
"/usr/local/bin"
etc
=
"
${
server_
path
}
/etc"
etc
=
"
${
server_
dir
}
/etc"
server_conf
=
"
${
etc
}
/warden-server.conf"
server_conf
=
"
${
etc
}
/warden-server.conf"
apache_conf
=
"
${
etc
}
/warden-apache.conf"
apache_conf
=
"
${
etc
}
/warden-apache.conf"
var
=
"
${
server_path
}
/var"
lib
=
"
${
server_dir
}
/lib"
lib
=
"
${
server_path
}
/lib"
doc
=
"
${
server_dir
}
/doc"
doc
=
"
${
server_path
}
/doc"
err
=
"/tmp/warden-err"
err
=
"/tmp/warden-err"
modules_file
=
"/tmp/warden-modules.txt"
# check if warden-server is installed
# check if warden-server is installed
oldPackageChck
oldPackageChck
...
@@ -320,7 +281,7 @@ echo
...
@@ -320,7 +281,7 @@ echo
echo
"------------------------- Installation process --------------------------"
echo
"------------------------- Installation process --------------------------"
# make warden server directory
# make warden server directory
mak
eWardenDir
creat
eWardenDir
# create server configuration file
# create server configuration file
makeServerConf
makeServerConf
...
@@ -333,16 +294,16 @@ createSymlinks
...
@@ -333,16 +294,16 @@ createSymlinks
echo
echo
echo
"Please check configuration files:"
echo
"Please check configuration files:"
echo
" -
$
{
server_conf
}
"
echo
" -
$server_conf
"
echo
" -
$
{
apache_conf
}
"
echo
" -
$apache_conf
"
echo
echo
echo
"Warden server directory:
$server_
path
"
echo
"Warden server directory:
$server_
dir
"
echo
echo
echo
"Please follow post-installation steps in
${
doc
}
/INSTALL!"
echo
"Please follow post-installation steps in
${
doc
}
/INSTALL!"
echo
echo
echo
"Installation of
$package_version
package was SUCCESSFUL!!!"
echo
"Installation of
$package_version
package was SUCCESSFUL!!!"
echo
echo
# cleanup section
# cleanup section
rm
-
r
f
$err
rm
-f
"
$err
"
"
$modules_file
"
exit
0
exit
0
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