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

bugfixes: odchytavani chyby pri vytvareni adresare Warden serveru; vytvareni...

bugfixes: odchytavani chyby pri vytvareni adresare Warden serveru; vytvareni uninstall.sh jako symlinku do adresare sh; prejmenovani promennych sablon konfiguracnich souboru; pridana kontrola dostupnosti konfiguracnich souboru a jejich pripadne vytvoreni nebo update
parent b6c1fbbe
No related branches found
No related tags found
No related merge requests found
......@@ -149,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
......@@ -167,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"
}
......@@ -189,7 +191,7 @@ doTemplate()
cleanOldFiles()
{
echo -n "Cleaning old files ... "
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
......@@ -246,12 +248,16 @@ 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"
......@@ -281,65 +287,109 @@ backup
updateWardenDir || exit 1
# update server configuration file
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)
db_name=$(getConfValue "$server_conf" DB_NAME)
db_user=$(getConfValue "$server_conf" DB_USER)
db_pass=$(getConfValue "$server_conf" DB_PASS)
db_host=$(getConfValue "$server_conf" DB_HOST)
max_events_limit=$(getConfValue "$server_conf" MAX_EVENTS_LIMIT)
valid_strings=$(perl -e "use updateCommon; updateCommon::getConfHash(\"$server_conf\");")
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" \
< $server_conf_tmpl \
> $server_conf && echo "OK" || errClean
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)
db_name=$(getConfValue "$server_conf" DB_NAME)
db_user=$(getConfValue "$server_conf" DB_USER)
db_pass=$(getConfValue "$server_conf" DB_PASS)
db_host=$(getConfValue "$server_conf" DB_HOST)
max_events_limit=$(getConfValue "$server_conf" MAX_EVENTS_LIMIT)
valid_strings=$(perl -e "use updateCommon; updateCommon::getConfHash(\"$server_conf\");")
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" \
< $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 ... "
cert_file_tmp=`fgrep SSLCertificateFile $apache_conf`
key_file_tmp=`fgrep SSLCertificateKeyFile $apache_conf`
ca_file_tmp=`fgrep SSLCACertificateFile $apache_conf`
lib_tmp=`fgrep PerlSwitches $apache_conf`
cert_file=${cert_file_tmp##*" "}
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" \
_LIB_ "$lib" \
< $apache_conf_tmpl \
> $apache_conf && echo "OK" || errClean
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`
lib_tmp=`fgrep PerlSwitches $apache_conf`
cert_file=${cert_file_tmp##*" "}
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" \
_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 \
_CERT_FILE_ "$cert_file" \
_KEY_FILE_ "$key_file" \
_CA_FILE_ "$ca_file" \
_LIB_ "$lib" \
< $apache_conf_tmpl \
> $apache_conf && echo "OK" || errClean
fi
# update wardenWatchdog configuration file
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)
sql_precondition=$(perl -e "use updateCommon; updateCommon::getConfArrayPre(\"$watchdog_conf\");")
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" \
< $watchdog_conf_tmpl \
> $watchdog_conf && echo "OK" || errClean
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)
sql_precondition=$(perl -e "use updateCommon; updateCommon::getConfArrayPre(\"$watchdog_conf\");")
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" \
< $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 \
_DOMAIN_NAME_ "$domain_name" \
_CONTACT_ "$contact" \
< $watchdog_conf_tmpl \
> $watchdog_conf && echo "OK" || errClean
fi
# cleaning of files from old package - depend on package version
cleanOldFiles
......@@ -351,7 +401,7 @@ createManifest
[[ ! -z "$symbin" ]] && [[ -d "$symbin" ]] && [[ -w "$symbin" ]] && createSymlinks
echo
echo "Please check updated configuration files:"
echo "Please check updated/created configuration files:"
echo " - $server_conf"
echo " - $server_conf"
echo " - $watchdog_conf"
......@@ -364,6 +414,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
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