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

instalacni skript serveru

parent 1da619e3
No related branches found
No related tags found
No related merge requests found
......@@ -121,10 +121,6 @@ params_chck()
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
......@@ -140,13 +136,13 @@ params_chck()
}
old_client_chck()
old_package_chck()
{
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!"
echo "For update of warden client package please use update.sh script."
echo "For update of warden server package please use update.sh"
exit 1
fi
}
......@@ -155,8 +151,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!"
......@@ -165,14 +160,24 @@ perl_chck()
fi
}
sqlite_chck()
{
echo -n "Checking SQLite database engine ... "
if which sqlite3 1> /dev/null; then
echo "OK"
else
echo "FAILED!"
echo "Error: SQLite3 database engine 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
if perl -e "use $module" 2> $err; then
echo "OK"
else
err
......@@ -183,39 +188,50 @@ 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
echo -n "Creating warden server directory ... "
if cp -R $dirname/warden-server $prefix 2> $err; then
echo "OK"
else
err_clean
fi
files=(CHANGELOG INSTALL LICENSE README README.cesnet)
files=(CHANGELOG INSTALL LICENSE README)
for file in ${files[@]};
do
cp $dirname/$file "$client_path/doc"
cp $dirname/$file $server_path/doc
done
cp $dirname/uninstall.sh "$client_path"
cp $dirname/uninstall.sh $server_path
}
copy_key()
make_client_conf()
{
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 "Creating client configuration file ... "
echo "#
# warden-client.conf - configuration file for the warden sender/receiver client
#
#-------------------------------------------------------------------------------
# URI - URI address of Warden server
#-------------------------------------------------------------------------------
\$URI = \"https://${hostname}:443/Warden\";
#-------------------------------------------------------------------------------
# SSL_KEY_FILE - path to client SSL certificate key file
#-------------------------------------------------------------------------------
\$SSL_KEY_FILE = \"${etc}/${key_file}\";
#-------------------------------------------------------------------------------
# SSL_CERT_FILE - path to client SSL certificate file
#-------------------------------------------------------------------------------
\$SSL_CERT_FILE = \"${etc}/${cert_file}\";
#-------------------------------------------------------------------------------
# SSL_CA_FILE - path to CA certificate file
#-------------------------------------------------------------------------------
\$SSL_CA_FILE = \"${ca_file}\";
" > $client_conf 2> $err; ret_val=`echo $?`
copy_cert()
{
echo -n "Copying certificate file ... "
cp $cert $etc 2> $err; ret_val=`echo $?`
if [ $ret_val -eq 0 ]; then
echo "OK"
else
......@@ -224,33 +240,63 @@ copy_cert()
}
make_conf_file()
make_server_conf()
{
echo -n "Creating configuration file ... "
echo "#
# warden-client.conf - configuration file for the warden sender/receiver client
echo -n "Creating server configuration file ... "
echo "#
# warden-server.conf - configuration file for Warden server
#
#-------------------------------------------------------------------------------
# URI - URI address of Warden server
# ADDRESS - IP address of warden server
#-------------------------------------------------------------------------------
\$URI = \"https://warden.cesnet.cz:443/Warden\";
\$ADDRESS = \"${hostname}\";
#-------------------------------------------------------------------------------
# SSL_KEY_FILE - path to client SSL certificate key file
# PORT - used TCP port for Warden server
#-------------------------------------------------------------------------------
\$SSL_KEY_FILE = \"$etc/$key_file\";
\$PORT = \"443\";
#-------------------------------------------------------------------------------
# SSL_CERT_FILE - path to client SSL certificate file
# BASEDIR - base directory of Warden server
#-------------------------------------------------------------------------------
\$SSL_CERT_FILE = \"$etc/$cert_file\";
\$BASEDIR = \"${server_path}\";
#-------------------------------------------------------------------------------
# SSL_CA_FILE - path to CA certificate file
# VARDIR - var directory
#-------------------------------------------------------------------------------
\$VARDIR = \"\$BASEDIR/var/\";
#-------------------------------------------------------------------------------
# LOGDIR - logging directory
#-------------------------------------------------------------------------------
\$LOGDIR = \"/var/log/\";
#-------------------------------------------------------------------------------
# PIDDIR - process ID directory
#-------------------------------------------------------------------------------
\$PIDDIR = \"/var/run/\";
#-------------------------------------------------------------------------------
# SSL_KEY_FILE - path to server SSL certificate key file
#-------------------------------------------------------------------------------
\$SSL_KEY_FILE = \"${key}\";
#-------------------------------------------------------------------------------
# SSL_CERT_FILE - path to server SSL certificate file
#-------------------------------------------------------------------------------
\$SSL_CERT_FILE = \"${cert}\";
#-------------------------------------------------------------------------------
# SSL_CA_FILE - path to CA ceritificate file
#-------------------------------------------------------------------------------
\$SSL_CA_FILE = \"$ca_file\";
" > $conf_file 2> $err; ret_val=`echo $?`
\$SSL_CA_FILE = \"${ca_file}\";
#-------------------------------------------------------------------------------
# FACILITY - syslog facility
#-------------------------------------------------------------------------------
\$FACILITY = \"local7\";
" > $server_conf 2> $err; ret_val=`echo $?`
if [ $ret_val -eq 0 ]; then
echo "OK"
......@@ -260,11 +306,11 @@ make_conf_file()
}
change_permissions()
create_db()
{
echo -n "Changing permissions to installed package ... "
chown -R $user: $client_path 2>$err; ret_val=`echo $?`
if [ $ret_val -eq 0 ]; then
echo -n "Creating warden server database ... "
$create_tables $db_file 2> $err || err_clean
if chmod 600 $db_file 2> $err; then
echo "OK"
else
err_clean
......@@ -272,13 +318,24 @@ change_permissions()
}
create_symlinks()
{
echo "Creating symbolic links ..."
for file in `ls -1 $bin | grep -v warden-alive | grep -v create_tables.sh | grep -v wardend`
do
echo "- making symlink: ${local_bin}/$file -> ${bin}/$file"
ln -s ${bin}/$file ${local_bin}/$file
done
echo "- making symlink: ${bin}/wardend -> $init"
ln -s ${bin}/wardend $init
}
#-------------------------------------------------------------------------------
# MAIN
#-------------------------------------------------------------------------------
# list of used Perl modules
modules=(SOAP::Lite IO::Socket::SSL SOAP::Transport::TCP FindBin DateTime)
modules=(SOAP::Lite SOAP::Transport::TCP File::Pid POSIX DBI DBD::SQLite Format::Human::Bytes Sys::Syslog File::Basename FindBin Net::CIDR::Lite DateTime Getopt::Std Switch IO::Socket::SSL)
# OS test
os_chck
......@@ -287,10 +344,9 @@ os_chck
shell_chck
# read input
while getopts "d:u:k:c:a:Vh" options; do
while getopts "d: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;;
......@@ -308,17 +364,26 @@ params_chck
# create variables
dirname=`dirname $0`
package_version=`cat $dirname/warden-client/etc/package_version`
hostname=`hostname`
key_file=`basename $key`
cert_file=`basename $cert`
package_version=`cat ${dirname}/warden-server/etc/package_version`
create_tables="${dirname}/warden-server/bin/create_tables.sh"
[[ $prefix == */ ]] && prefix="${prefix%?}" # remove last char (slash) from prefix
client_path="$prefix/warden-client"
etc="$client_path/etc"
conf_file="$etc/warden-client.conf"
server_path="${prefix}/warden-server"
bin="${server_path}/bin"
local_bin="/usr/local/bin"
etc="${server_path}/etc"
client_conf="${etc}/warden-client.conf"
server_conf="${etc}/warden-server.conf"
var="${server_path}/var"
db_file="${var}/warden.db"
err="/tmp/warden-err"
init="/etc/init.d/wardend"
# check if warden-client is installed
old_client_chck
# check if warden-server is installed
old_package_chck
echo
echo "------------------------- Dependencies check-in -------------------------"
......@@ -326,30 +391,35 @@ echo "------------------------- Dependencies check-in -------------------------"
# Perl interpreter test
perl_chck
# SQLite database engine test
sqlite_chck
# Perl modules test
modules_chck
echo
echo "------------------------- Installation process --------------------------"
# make warden client directory
make_warden_dir
# copy cert key file
copy_key
# create client configuration file
make_client_conf
# copy cert file
copy_cert
# create server configuration file
make_server_conf
# create conf file
make_conf_file
# create warden server database
create_db
# change permissions
change_permissions
# crate symlinks from warden server bin directory to /usr/local/bin
create_symlinks
echo
echo "Please check configuration file in $conf_file!"
echo "Please check client configuration file in $client_conf!"
echo "Please check server configuration file in $server_conf!"
echo
echo "Start Warden server by /etc/init.d/wardend start"
echo
echo "Installation of $package_version package was SUCCESSFUL!!!"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment