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

Merge branch 'master' of homeproj.cesnet.cz:warden

parents 59fa5883 f86bec60
No related branches found
No related tags found
No related merge requests found
Showing
with 297 additions and 190 deletions
#
#
# warden-apache.conf - configuration file for the Apache server
#
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
SSLEngine on
......@@ -9,7 +11,7 @@ SSLVerifyDepth 3
SSLVerifyClient require
SSLOptions +StdEnvVars +ExportCertData
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+EXP:+eNULL
SSLCertificateFile /etc/ssl/certs/warden-dev.cesnet.cz.pem
SSLCertificateKeyFile /etc/ssl/private/warden-dev.cesnet.cz.key
......
#
#
# warden-apache.conf - configuration file for the Apache server
#
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
SSLEngine on
......@@ -9,11 +11,11 @@ SSLVerifyDepth 3
SSLVerifyClient require
SSLOptions +StdEnvVars +ExportCertData
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+EXP:+eNULL
SSLCertificateFile _CERT_FILE_
SSLCertificateKeyFile _KEY_FILE_
SSLCACertificateFile _CA_FILE_
SSLCertificateFile _CERTFILE_
SSLCertificateKeyFile _KEYFILE_
SSLCACertificateFile _CAFILE_
PerlOptions +Parent
PerlSwitches -I _LIB_
......
#
#
# warden-apache.conf - configuration file for the Apache server
#
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
SSLEngine on
......@@ -9,11 +11,11 @@ SSLVerifyDepth 3
SSLVerifyClient require
SSLOptions +StdEnvVars +ExportCertData
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+EXP:+eNULL
SSLCertificateFile _CERT_FILE_
SSLCertificateKeyFile _KEY_FILE_
SSLCACertificateFile _CA_FILE_
SSLCertificateFile _CERTFILE_
SSLCertificateKeyFile _KEYFILE_
SSLCACertificateFile _CAFILE_
PerlOptions +Parent
PerlSwitches -I _LIB_
......
#
# warden-server.conf - configuration file for Warden server
#
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
#-------------------------------------------------------------------------------
# BASEDIR - base directory of Warden server
......
#
# warden-server.conf - configuration file for Warden server
#
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
#-------------------------------------------------------------------------------
# BASEDIR - base directory of Warden server
......
#
# warden-server.conf - configuration file for Warden server
#
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
#-------------------------------------------------------------------------------
# BASEDIR - base directory of Warden server
......@@ -15,42 +18,42 @@ $SYSLOG = "_SYSLOG_";
#-------------------------------------------------------------------------------
# SYSLOG_VERBOSE - enable/disable logging in verbose mode (stack info added)
#-------------------------------------------------------------------------------
$SYSLOG_VERBOSE = "_SYSLOG_VERBOSE_";
$SYSLOG_VERBOSE = "_SYSLOGVERBOSE_";
#-------------------------------------------------------------------------------
# SYSLOG_FACILITY - syslog facility
#-------------------------------------------------------------------------------
$SYSLOG_FACILITY = "_SYSLOG_FACILITY_";
$SYSLOG_FACILITY = "_SYSLOGFACILITY_";
#-------------------------------------------------------------------------------
# DB_NAME - MySQL database name of Warden server
#-------------------------------------------------------------------------------
$DB_NAME = "_DB_NAME_";
$DB_NAME = "_DBNAME_";
#-------------------------------------------------------------------------------
# DB_USER - MySQL database user of Warden server
#-------------------------------------------------------------------------------
$DB_USER = "_DB_USER_";
$DB_USER = "_DBUSER_";
#-------------------------------------------------------------------------------
# DB_PASS - MySQL database password of Warden server
#-------------------------------------------------------------------------------
$DB_PASS = "_DB_PASS_";
$DB_PASS = "_DBPASS_";
#-------------------------------------------------------------------------------
# DB_HOST - MySQL database host
#-------------------------------------------------------------------------------
$DB_HOST = "_DB_HOST_";
$DB_HOST = "_DBHOST_";
#-------------------------------------------------------------------------------
# MAX_EVENTS_LIMIT - server limit of maximum number of events that can be
# delivered to one client in one batch
#-------------------------------------------------------------------------------
$MAX_EVENTS_LIMIT = "_MAX_EVENTS_LIMIT_";
$MAX_EVENTS_LIMIT = "_MAXEVENTSLIMIT_";
#-------------------------------------------------------------------------------
# VALID_STRINGS - validation hash containing allowed event attributes
#-------------------------------------------------------------------------------
%VALID_STRINGS = (
_VALID_STRINGS_
_VALIDSTRINGS_
);
#
# warden-watchdog.conf - configuration file for Wachdog script
#
# Copyright (C) 2011-2014 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
......
#
# warden-watchdog.conf - configuration file for Wachdog script
#
# Copyright (C) 2011-2014 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
#-------------------------------------------------------------------------------
# DOMAIN_NAME - server full domain name
#-------------------------------------------------------------------------------
$DOMAIN_NAME = "_DOMAIN_NAME_";
$DOMAIN_NAME = "_DOMAINNAME_";
#-------------------------------------------------------------------------------
# EMAIL_SUBJECT - subject of an report for Warden watchdog script
......
#
# warden-watchdog.conf - configuration file for Wachdog script
#
# Copyright (C) 2011-2014 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
#-------------------------------------------------------------------------------
# DOMAIN_NAME - server full domain name
#-------------------------------------------------------------------------------
$DOMAIN_NAME = "_DOMAIN_NAME_";
$DOMAIN_NAME = "_DOMAINNAME_";
#-------------------------------------------------------------------------------
# EMAIL_SUBJECT - subject of an report for Warden watchdog script
#-------------------------------------------------------------------------------
$EMAIL_SUBJECT = "_EMAIL_SUBJECT_";
$EMAIL_SUBJECT = "_EMAILSUBJECT_";
#-------------------------------------------------------------------------------
# EMAIL_SERVER_CONF - path and params of an email server for reports sending
#-------------------------------------------------------------------------------
$EMAIL_SERVER_CONF = '_EMAIL_SERVER_CONF_';
$EMAIL_SERVER_CONF = '_EMAILSERVERCONF_';
#-------------------------------------------------------------------------------
# SQL_PRECONDITION - array of procedures which are executed "before" main action
#-------------------------------------------------------------------------------
@SQL_PRECONDITION = (_SQL_PRECONDITION_);
@SQL_PRECONDITION = (_SQLPRECONDITION_);
#-------------------------------------------------------------------------------
# SQL_QUERIES - array of hashes of actions for the WardenWatchdog script.
......@@ -35,9 +35,9 @@ $EMAIL_SERVER_CONF = '_EMAIL_SERVER_CONF_';
# in a database table.
#-------------------------------------------------------------------------------
@SQL_QUERIES = (
_SQL_QUERIES_);
_SQLQUERIES_);
#-------------------------------------------------------------------------------
# SQL_POSTCONDITION - array of procedures which are executed "after" main action
#-------------------------------------------------------------------------------
@SQL_POSTCONDITION = (_SQL_POSTCONDITION_);
@SQL_POSTCONDITION = (_SQLPOSTCONDITION_);
# Warden.pm
#
# Copyright (C) 2011-2014 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
......
# ApacheDispatch.pm
#
# Copyright (C) 2011-2014 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
......
# WardenCommon.pm
#
# Copyright (C) 2011-2014 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
......
# WardenWatchdog.pm
#
# Copyright (C) 2011-2014 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
......
......@@ -2,7 +2,7 @@
#
# WardenWatchdog.t
#
# Copyright (C) 2011-2014 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
......
......@@ -2,7 +2,7 @@
#
# install.sh
#
# Copyright (C) 2011-2014 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
......@@ -14,13 +14,13 @@ VERSION="2.2"
#-------------------------------------------------------------------------------
usage()
{
echo "Usage: ${0##*/} -d <directory> -k <ssl_key_file> -c <ssl_cert_file> -a <ssl_ca_file> -e <email_address> [-s <directory>] [-hV]"
echo "-d <directory> installation directory of Warden server"
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 "Usage: ${0##*/} -d <directory> -k <ssl_key> -c <ssl_cert> -a <ssl_ca_cert> -e <email_address> [-s <directory>] [-hV]"
echo "-d <directory> Warden server installation directory"
echo "-k <ssl_key> path to SSL key"
echo "-c <ssl_cert> path to SSL certificate"
echo "-a <ssl_ca_cert> path to SSL CA certificate"
echo "-e <e-mail address> e-mail address to Warden server administrator"
echo "-s <directory> directory for symlinks to Warden server control scripts (optional)"
echo "-s <directory> directory of symlinks to system control scripts (optional)"
echo "-h print this help"
echo "-V print script version number and exit"
echo
......@@ -42,8 +42,7 @@ version()
err()
{
echo "FAILED!"
echo
cat "$err"
echo -n "Error: " && cat "$err"
rm -f "$err"
echo
echo "Installation of $package_version package FAILED!!!"
......@@ -54,17 +53,15 @@ err()
errClean()
{
echo "FAILED!"
echo " -> Uninstalling server package ... OK"
echo -n "Error: " && cat "$err"
echo " -> Uninstalling server package ..."
for file in $(<"$manifest")
do
rm -f "${basedir}/$file" 2> /dev/null
directory="${file%/*}"
rm -f "${basedir}/$file"
rmdir --ignore-fail-on-non-empty "${basedir}/$directory"
rm -f "${basedir}/uninstall.sh"
rmdir --ignore-fail-on-non-empty "${basedir}/$directory" 2> /dev/null
done
echo
cat "$err"
rm -f "${basedir}/uninstall.sh" 2> /dev/null
rm -f "$err"
echo
echo "Installation of $package_version package FAILED!!!"
......@@ -109,8 +106,8 @@ oldPackageChck()
old_package_version=$(<"$old_package_version_file")
echo "FAILED!"
echo
echo "Package $old_package_version is installed!"
echo "For update of warden server package please use update.sh"
echo "Package $old_package_version has been already installed!"
echo "For update of Warden server package please use update.sh."
exit 1
fi
echo "OK"
......@@ -146,13 +143,12 @@ createWardenDir()
{
echo -n "Creating Warden server directory ... "
test -d "$basedir" && test -w "$basedir" || mkdir -p "$basedir" 2> "$err" || err
for dir in "${dirname}/"*
for file in $(<"$manifest")
do
if [ -d "$dir" ]; then
cp -R "$dir" "$basedir" 2> "$err" || errClean
fi
dir="$basedir/${file%/*}"
[[ ! -d "$dir" ]] && mkdir -p "$dir"
cp "$file" "${basedir}/$file" 2> "$err" || errClean
done
rm -f "${etc}/"*.tmpl*
ln -s "${sh}/uninstall.sh" "$basedir"
echo "OK"
}
......@@ -179,12 +175,18 @@ createManifest()
createSymlinks()
{
echo "Creating symbolic links to $symbin ..."
echo -n "Checking symlinks directory $symbin ... "
if [[ -d $symbin && -w $symbin ]]; then
echo "OK"
for file in "${bin}/"*
do
echo "- making symlink: ${symbin}/${file##*/} -> $file"
ln -s "$file" "${symbin}/${file##*/}"
echo "- creating symlink: ${symbin}/${file##*/} -> $file"
ln -s "$file" "${symbin}/${file##*/}" 2>/dev/null
done
else
echo "FAILED!"
fi
}
......@@ -228,10 +230,11 @@ watchdog_conf="${etc}/warden-watchdog.conf"
server_conf_tmpl="${dirname}/etc/warden-server.conf.tmpl"
apache_conf_tmpl="${dirname}/etc/warden-apache.conf.tmpl"
watchdog_conf_tmpl="${dirname}/etc/warden-watchdog.conf.tmpl"
package_version=$(<"${dirname}/etc/package_version")
package_version=$(<"${dirname}/etc/package_version") 2> "$err" || err
manifest="${dirname}/doc/MANIFEST"
echo "Installation of Warden server package ($package_version) ..."
echo
echo "----------------------- Checking for Dependencies -----------------------"
......@@ -242,13 +245,13 @@ echo "----------------------- Checking for Dependencies -----------------------"
perlChck
# Perl modules test
modulesChck
modulesChck || exit 1
echo
echo "------------------------- Installation process --------------------------"
# make warden server directory
createWardenDir
createWardenDir || exit 1
# create server configuration file
echo -n "Creating Warden server configuration file ... "
......@@ -260,9 +263,9 @@ doTemplate \
# create Apache configuration file
echo -n "Creating Apache configuration file ... "
doTemplate \
_CERT_FILE_ "$cert_file" \
_KEY_FILE_ "$key_file" \
_CA_FILE_ "$ca_file" \
_CERTFILE_ "$cert_file" \
_KEYFILE_ "$key_file" \
_CAFILE_ "$ca_file" \
_LIB_ "$lib" \
< $apache_conf_tmpl \
> $apache_conf && echo "OK" || errClean
......@@ -270,7 +273,7 @@ doTemplate \
# create wardenWatchdog configuration file
echo -n "Creating Warden Watchdog configuration file ... "
doTemplate \
_DOMAIN_NAME_ "$domain_name" \
_DOMAINNAME_ "$domain_name" \
_CONTACT_ "$contact" \
< $watchdog_conf_tmpl \
> $watchdog_conf && echo "OK" || errClean
......@@ -279,9 +282,11 @@ doTemplate \
createManifest
# crate symlinks from warden server bin to user path (if -s option is set)
[[ ! -z "$symbin" ]] && [[ -d "$symbin" ]] && [[ -w "$symbin" ]] && createSymlinks
[[ ! -z "$symbin" ]] && createSymlinks
echo
echo "------------------------- Summary ---------------------------------------"
echo "Please check configuration files:"
echo " - $server_conf"
echo " - $server_conf"
......@@ -289,7 +294,7 @@ echo " - $watchdog_conf"
echo
echo "Warden server directory: $basedir"
echo
echo "Please follow post-installation steps in ${doc}/INSTALL!"
echo "Please follow post-installation steps in ${doc}/INSTALL."
echo
echo "Installation of $package_version package was SUCCESSFUL!!!"
echo
......
......@@ -2,7 +2,7 @@
#
# uninstall.sh
#
# Copyright (C) 2011-2014 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
......@@ -15,12 +15,12 @@ VERSION="2.2"
usage()
{
echo "Usage: ${0##*/} -d <directory> [-s <directory>] [-hV]"
echo "-d <directory> uninstallation directory of Warden server"
echo "-s <directory> directory for symlinks to Warden server control scripts (optional)"
echo "-d <directory> Warden server to uninstall"
echo "-s <directory> directory of symlinks to system control scripts (optional)"
echo "-h print this help"
echo "-V print script version number and exit"
echo
echo "Example: $ ${0##*/} -d /opt/warden-server -s /usr/local/bin"
echo "Example: $ ./${0##*/} -d /opt/warden-server -s /usr/local/bin"
echo
echo "For more information about uninstallation process, see README file (section Uninstallation)."
echo
......@@ -38,8 +38,7 @@ version()
err()
{
echo "FAILED!"
echo
cat "$err"
echo -n "Error: " && cat "$err"
rm -f "$err"
rm -rf "$backup"
echo
......@@ -51,6 +50,7 @@ err()
errClean()
{
echo "FAILED!"
echo -n "Error: " && cat "$err"
echo " -> Reverting changes of warden server package ... "
rm -rf "${basedir}/"* > /dev/null 2>&1
cp -R "${backup}/"* "$basedir"
......@@ -60,8 +60,6 @@ errClean()
ln -s "${bin}/${file##*/}" "${symbin}/${file##*/}"
done
fi
echo
cat "$err"
rm -f "$err"
rm -rf "$backup"
echo
......@@ -86,9 +84,13 @@ paramsChck()
wardenDirChck()
{
echo -n "Checking Warden server directory ... "
if [[ ! -d "$basedir" ]] && [[ ! -w "$basedir" ]]; then
if [[ ! -d "$basedir" ]]; then
echo "FAILED!"
echo "Warden server package is not installed!"
exit 1
elif [[ ! -w "$basedir" ]]; then
echo "FAILED!"
echo "No version of Warden server is not installed!"
echo "You don't have permission to Warden server directory!"
exit 1
else
echo "OK"
......@@ -102,10 +104,12 @@ getPackageVersion()
old_package_version_file=$(find "$basedir" -name package_version)
if [ -f "$old_package_version_file" ]; then
package_version=$(<"$old_package_version_file")
echo "OK"
else
package_version="unknown"
echo "FAILED!"
echo "Warden server is not installed in this directory!"
exit 1
fi
echo "OK"
}
......@@ -121,30 +125,37 @@ createBackup()
}
uninstallWardenServer()
removeSymlinks()
{
echo -n "Uninstalling $package_version package ... "
cp "${doc}/UNINSTALL" "$uninstall"
manifest=$(find "$basedir" -name MANIFEST) || err
for file in $(<"$manifest")
echo -n "Checking symlinks directory $symbin ... "
if [[ -d $symbin && -w $symbin ]]; then
echo "OK"
for file in "$bin/"*
do
directory="${file%/*}"
rm -f "${basedir}/$file"
rmdir --ignore-fail-on-non-empty "${basedir}/$directory"
if [[ -f "${symbin}/${file##*/}" ]]; then
echo "- removing symlink: ${symbin}/${file##*/} -> $file"
rm -f "${symbin}/${file##*/}" 2> /dev/null
fi
done
rm -f "${basedir}/uninstall.sh"
rmdir --ignore-fail-on-non-empty "$basedir"
echo "OK"
else
echo "FAILED!"
fi
}
deleteSymlinks()
uninstallWardenServer()
{
echo -n "Deleting symlinks from $symbin ..."
for file in "$symbin/"*
echo -n "Uninstalling $package_version package ... "
cp "${doc}/UNINSTALL" "$uninstall" 2> /dev/null
manifest=$(find "$basedir" -name MANIFEST) || err
for file in $(<"$manifest")
do
rm -f "${symbin}/${file##*/}" 2> /dev/null
rm -f "${basedir}/$file" 2> "$err" || errClean
directory="${file%/*}"
rmdir --ignore-fail-on-non-empty "${basedir}/$directory" 2> "$err" || errClean
done
rm -f "${basedir}/uninstall.sh"
rmdir --ignore-fail-on-non-empty "$basedir" 2> /dev/null
echo "OK"
}
......@@ -165,6 +176,7 @@ done
# remove last char (slash) from name of directories
[[ "$basedir" == */ ]] && basedir="${basedir%?}"
[[ "$symbin" == */ ]] && symbin="${symbin%?}"
# params test
paramsChck
......@@ -177,9 +189,9 @@ err="/tmp/warden-err"
uninstall="/tmp/UNINSTALL.warden"
backup="/tmp/warden-backup"
echo "Uninstallation of Warden server package ..."
echo
echo "------------------------- Uninstallation process --------------------------------"
echo "------------------------- Uninstallation process ------------------------"
# check Warden server directory if exists
wardenDirChck
......@@ -190,14 +202,17 @@ getPackageVersion
# make backup of currently installed warden-server package
createBackup
# remove symlinks from $symbin (if -s option is set)
[[ ! -z "$symbin" ]] && removeSymlinks
# uninstall Warden server
uninstallWardenServer
uninstallWardenServer || exit 1
# delete symlinks from $symbin (if -s option is set)
[[ ! -z "$symbin" ]] && [[ -d "$symbin" ]] && [[ -w "$symbin" ]] && deleteSymlinks
echo
echo "Please follow post-uninstallation steps in $uninstall!"
echo "------------------------- Summary ---------------------------------------"
echo "Please follow post-uninstallation steps in ${uninstall}."
echo
echo "Uninstallation of $package_version package was SUCCESSFUL!!!"
echo
......
......@@ -2,7 +2,7 @@
#
# update.sh
#
# Copyright (C) 2011-2014 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
......@@ -14,13 +14,13 @@ VERSION="2.2"
#-------------------------------------------------------------------------------
usage()
{
echo "Usage: ${0##*/} -d <directory> [-hV]"
echo "-d <directory> destination directory of Warden server"
echo "-s <directory> directory for symlinks to Warden server control scripts (optional)"
echo "Usage: ${0##*/} -d <directory> [-s <directory>] [-hV]"
echo "-d <directory> Warden server to update"
echo "-s <directory> directory of symlinks to system control scripts (optional)"
echo "-h print this help"
echo "-V print script version number and exit"
echo
echo "Example: $ ./${0##*/} -d /opt/warden-server"
echo "Example: $ ./${0##*/} -d /opt/warden-server -s /usr/local/bin"
echo
echo "For more information about update process, see README file (section Update)."
echo
......@@ -38,8 +38,7 @@ version()
err()
{
echo "FAILED!"
echo
cat "$err"
echo -n "Error: " && cat "$err"
rm -f "$backup" 2>/dev/null
rm -f "$err"
echo
......@@ -51,11 +50,11 @@ err()
errClean()
{
echo "FAILED!"
echo -n "Error: " && cat "$err"
echo " -> Reverting changes of Warden server package ... OK"
rm -r "${basedir}/"* > /dev/null 2>&1
cp -R "${backup}/"* "$basedir"
echo
cat "$err"
rm -r "$err" "$backup"
echo
echo "Update from $old_package_version to $package_version package FAILED!!!"
......@@ -103,7 +102,7 @@ oldPackageChck()
if [ "$old_package_version" == "$package_version" ]; then
echo "FAILED!"
echo
echo "Package $package_version is already installed!"
echo "Package $package_version has been already installed!"
exit 1
elif [ "$old_package_version" == "warden-server-2.0" ]; then
echo "FAILED!"
......@@ -115,7 +114,7 @@ oldPackageChck()
echo "FAILED!"
echo
echo "Warden server package is not yet installed!"
echo "For installation of Warden server package please use install.sh"
echo "For installation of Warden server package please use install.sh."
exit 1
fi
echo "OK"
......@@ -150,7 +149,7 @@ modulesChck()
backup()
{
echo -n "Making Warden server backup ... "
mkdir "$backup"
mkdir "$backup" 2> "$err" || err
if cp -R "${basedir}/"* "$backup" 2> "$err"; then
echo "OK"
else
......@@ -168,6 +167,8 @@ updateWardenDir()
[[ ! -d "$dir" ]] && mkdir -p "$dir"
cp "$file" "${basedir}/$file" 2> "$err" || errClean
done
rm -f "${basedir}/uninstall.sh" 2> /dev/null
ln -s "${sh}/uninstall.sh" "$basedir"
echo "OK"
}
......@@ -188,9 +189,20 @@ doTemplate()
}
removeOldFiles()
{
echo -n "Removing old package files ... "
rm -f "${etc}/warden-client.conf" 2> /dev/null
rm -f "${doc}/warden20to21.patch" 2> /dev/null
rm -f "${lib}/WardenConf.pm" 2> /dev/null
rm -f "${lib}/WardenStatus.pm" 2> /dev/null
rm -f "${lib}/WardenReg.pm" 2> /dev/null
echo "OK"
}
createManifest()
{
echo -n "Creating MANIFEST file ... "
echo -n "Creating new MANIFEST file ... "
cd "$basedir" && find . -mindepth 2 -type f | sed 's/.\///' | sort > "${doc}/MANIFEST" && cd $OLDPWD 2> "$err" || errClean
echo "OK"
}
......@@ -198,12 +210,17 @@ createManifest()
createSymlinks()
{
echo "Creating symbolic links to $symbin ..."
echo -n "Checking symlinks directory $symbin ... "
if [[ -d $symbin && -w $symbin ]]; then
echo "OK"
for file in "${bin}/"*
do
echo "- making symlink: ${symbin}/${file##*/} -> $file"
echo "- updating symlink: ${symbin}/${file##*/} -> $file"
ln -s "$file" "${symbin}/${file##*/}"
done
else
echo "FAILED!"
fi
}
......@@ -236,15 +253,20 @@ hostname=$(hostname -f || echo "unspecified.server")
dirname=${0%/*}
doc="${basedir}/doc"
etc="${basedir}/etc"
sh="${basedir}/sh"
server_conf="${etc}/warden-server.conf"
apache_conf="${etc}/warden-apache.conf"
watchdog_conf="${etc}/warden-watchdog.conf"
server_conf_tmpl="${dirname}/etc/warden-server.conf.tmpl.update"
apache_conf_tmpl="${dirname}/etc/warden-apache.conf.tmpl.update"
watchdog_conf_tmpl="${dirname}/etc/warden-watchdog.conf.tmpl.update"
server_conf_tmpl="${dirname}/etc/warden-server.conf.tmpl"
server_conf_tmpl_update="${dirname}/etc/warden-server.conf.tmpl.update"
apache_conf_tmpl="${dirname}/etc/warden-apache.conf.tmpl"
apache_conf_tmpl_update="${dirname}/etc/warden-apache.conf.tmpl.update"
watchdog_conf_tmpl="${dirname}/etc/warden-watchdog.conf.tmpl"
watchdog_conf_tmpl_update="${dirname}/etc/warden-watchdog.conf.tmpl.update"
package_version=$(<"${dirname}/etc/package_version")
manifest="${dirname}/doc/MANIFEST"
echo "Update of Warden server package to $package_version ..."
echo
echo "------------------------- Dependencies check-in -------------------------"
......@@ -258,7 +280,7 @@ oldPackageChck
perlChck
# Perl modules test
modulesChck
modulesChck || exit 1
echo
echo "------------------------- Update process --------------------------------"
......@@ -267,10 +289,13 @@ echo "------------------------- Update process --------------------------------"
backup
# make warden server directory
updateWardenDir
updateWardenDir || exit 1
# update server configuration file
echo -n "Updating Warden server configuration file ... "
echo -n "Checking Warden server configuration file ... "
if [[ -r "$server_conf" ]]; then
echo "OK"
echo -n " -> Updating Warden server configuration file ... "
syslog=$(getConfValue "$server_conf" SYSLOG)
syslog_verbose=$(getConfValue "$server_conf" SYSLOG_VERBOSE)
syslog_facility=$(getConfValue "$server_conf" SYSLOG_FACILITY)
......@@ -283,19 +308,31 @@ valid_strings=$(perl -e "use updateCommon; updateCommon::getConfHash(\"$server_c
doTemplate \
_BASEDIR_ "$basedir" \
_SYSLOG_ "$syslog" \
_SYSLOG_VERBOSE_ "$syslog_verbose" \
_SYSLOG_FACILITY_ "$syslog_facility" \
_DB_NAME_ "$db_name" \
_DB_USER_ "$db_user" \
_DB_PASS_ "$db_pass" \
_DB_HOST_ "$db_host" \
_MAX_EVENTS_LIMIT_ "$max_events_limit" \
_VALID_STRINGS_ "$valid_strings" \
_SYSLOGVERBOSE_ "$syslog_verbose" \
_SYSLOGFACILITY_ "$syslog_facility" \
_DBNAME_ "$db_name" \
_DBUSER_ "$db_user" \
_DBPASS_ "$db_pass" \
_DBHOST_ "$db_host" \
_MAXEVENTSLIMIT_ "$max_events_limit" \
_VALIDSTRINGS_ "$valid_strings" \
< $server_conf_tmpl_update \
> $server_conf && echo "OK" || errClean
else
echo "FAILED!"
echo -n " -> Creating Warden server configuration file ... "
doTemplate \
_BASEDIR_ "$basedir" \
< $server_conf_tmpl \
> $server_conf && echo "OK" || errClean
fi
# update Apache configuration file
echo -n "Updating Apache configuration file ... "
echo -n "Checking Apache configuration file ... "
if [[ -r "$apache_conf" ]]; then
echo "OK"
echo -n " -> Updating Apache configuration file ... "
cert_file_tmp=`fgrep SSLCertificateFile $apache_conf`
key_file_tmp=`fgrep SSLCertificateKeyFile $apache_conf`
ca_file_tmp=`fgrep SSLCACertificateFile $apache_conf`
......@@ -305,15 +342,33 @@ key_file=${key_file_tmp##*" "}
ca_file=${ca_file_tmp##*" "}
lib=${lib_tmp##*" "}
doTemplate \
_CERT_FILE_ "$cert_file" \
_KEY_FILE_ "$key_file" \
_CA_FILE_ "$ca_file" \
_CERTFILE_ "$cert_file" \
_KEYFILE_ "$key_file" \
_CAFILE_ "$ca_file" \
_LIB_ "$lib" \
< $apache_conf_tmpl_update \
> $apache_conf && echo "OK" || errClean
else
echo "FAILED!"
echo -n " -> Creating Apache configuration file ... "
cert_file="unspecified.cert"
key_file="unspecified.key"
ca_file="unspecified.ca_cert"
lib="unspecified.lib_path"
doTemplate \
_CERTFILE_ "$cert_file" \
_KEYFILE_ "$key_file" \
_CAFILE_ "$ca_file" \
_LIB_ "$lib" \
< $apache_conf_tmpl \
> $apache_conf && echo "OK" || errClean
fi
# update wardenWatchdog configuration file
echo -n "Updating Warden Watchdog configuration file ... "
echo -n "Checking Warden Watchdog configuration file ... "
if [[ -r "$watchdog_conf" ]]; then
echo "OK"
echo -n " -> Updating Warden Watchdog configuration file ... "
domain_name=$(getConfValue "$watchdog_conf" DOMAIN_NAME)
email_subject=$(getConfValue "$warden_conf" EMAIL_SUBJECT)
email_server_conf=$(getConfValue "$warden_conf" EMAIL_SERVER_CONF)
......@@ -321,23 +376,39 @@ sql_precondition=$(perl -e "use updateCommon; updateCommon::getConfArrayPre(\"$w
sql_queries=$(perl -e "use updateCommon; updateCommon::getConfArrayQueries(\"$watchdog_conf\");")
sql_postcondition=$(perl -e "use updateCommon; updateCommon::getConfArrayPost(\"$watchdog_conf\");")
doTemplate \
_DOMAIN_NAME_ "$domain_name" \
_EMAIL_SUBJECT_ "$email_subject" \
_EMAIL_SERVER_CONF_ "$email_server_conf" \
_SQL_PRECONDITION_ "$sql_precondition" \
_SQL_QUERIES_ "$sql_queries" \
_SQL_POSTCONDITION_ "$sql_postcondition" \
_DOMAINNAME_ "$domain_name" \
_EMAILSUBJECT_ "$email_subject" \
_EMAILSERVER_CONF_ "$email_server_conf" \
_SQLPRECONDITION_ "$sql_precondition" \
_SQLQUERIES_ "$sql_queries" \
_SQLPOSTCONDITION_ "$sql_postcondition" \
< $watchdog_conf_tmpl_update \
> $watchdog_conf && echo "OK" || errClean
else
echo "FAILED!"
echo -n " -> Creating Warden Watchdog configuration file ... "
domain_name=$(hostname -f || echo "unspecified.server")
contact="unspecified.contact"
doTemplate \
_DOMAINNAME_ "$domain_name" \
_CONTACT_ "$contact" \
< $watchdog_conf_tmpl \
> $watchdog_conf && echo "OK" || errClean
fi
# remove files of old packages - file list depend on package version
removeOldFiles
# create MANIFEST file
createManifest
# crate symlinks from warden server bin to user path (if -s option is set)
[[ ! -z "$symbin" ]] && [[ -d "$symbin" ]] && [[ -w "$symbin" ]] && createSymlinks
[[ ! -z "$symbin" ]] && createSymlinks
echo
echo "Please check updated configuration files:"
echo "------------------------- Summary ---------------------------------------"
echo "Please check updated/created configuration files:"
echo " - $server_conf"
echo " - $server_conf"
echo " - $watchdog_conf"
......@@ -350,6 +421,7 @@ echo "Please follow post-update steps in ${doc}/UPDATE!"
echo
# cleanup section
rm -f "$err" "$backup"
rm -f "$err"
rm -rf "$backup"
exit 0
# updateCommon.pm
#
# Copyright (C) 2011-2014 Cesnet z.s.p.o
# Copyright (C) 2011-2015 Cesnet z.s.p.o
#
# Use of this source is governed by a BSD-style license, see LICENSE file.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment