diff --git a/bin/disable_mail.sh b/bin/disable_mail.sh index 7ad7bfd..735b003 100644 --- a/bin/disable_mail.sh +++ b/bin/disable_mail.sh @@ -1,6 +1,6 @@ #!/bin/bash -BASE=/root/atlassian-tools +BASE=${HOME}/atlassian-tools . ${BASE}/conf/config.sh . ${BASE}/lib/utils.sh diff --git a/bin/disable_notifications.sh b/bin/disable_notifications.sh index d8881c2..6eac343 100644 --- a/bin/disable_notifications.sh +++ b/bin/disable_notifications.sh @@ -1,22 +1,8 @@ #!/bin/bash -BASE=/root/atlassian-tools +BASE=${HOME}/atlassian-tools . ${BASE}/conf/config.sh . ${BASE}/lib/utils.sh -[[ $VERBOSE -eq $YES ]] && set -x - -SETENV="${APP_INSTALL_DIR}"/bin/setenv.sh -[[ -f "$SETENV" ]] || die "File not found, SETENV: '$SETENV'" - - -sed_opts=( '-i' ) -[[ $DEBUG -eq $YES ]] && unset sed_opts - -# # JIRA -# grep -q DISABLE_NOTIFICATIONS "$SETENV" \ -# && sed "${sed_opts[@]}" -e 's/^[ #]*\(DISABLE_NOTIFICATIONS=\)/\1/' "$SETENV" - -# CONFLUENCE & JIRA -sed "${sed_opts[@]}" -e '/atlassian.mail.senddisabled=true/ s/^[ #]*//' "$SETENV" +"${BASE}"/bin/set_notifications.sh disable diff --git a/bin/enable_notifications.sh b/bin/enable_notifications.sh new file mode 100644 index 0000000..405aa44 --- /dev/null +++ b/bin/enable_notifications.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +BASE=${HOME}/atlassian-tools + +. ${BASE}/conf/config.sh +. ${BASE}/lib/utils.sh + +"${BASE}"/bin/set_notifications.sh enable diff --git a/bin/fix_app_config.sh b/bin/fix_app_config.sh index e0fa027..504a481 100644 --- a/bin/fix_app_config.sh +++ b/bin/fix_app_config.sh @@ -1,6 +1,6 @@ #!/bin/bash -BASE=/root/atlassian-tools +BASE=${HOME}/atlassian-tools . ${BASE}/conf/config.sh . ${BASE}/lib/utils.sh diff --git a/bin/fix_cron.sh b/bin/fix_cron.sh index 2e11fdb..f84d1dd 100644 --- a/bin/fix_cron.sh +++ b/bin/fix_cron.sh @@ -1,6 +1,6 @@ #!/bin/bash -BASE=/root/atlassian-tools +BASE=${BASE}/atlassian-tools . ${BASE}/conf/config.sh . ${BASE}/lib/utils.sh diff --git a/bin/fix_hostname.sh b/bin/fix_hostname.sh index 60a376c..1d940fa 100644 --- a/bin/fix_hostname.sh +++ b/bin/fix_hostname.sh @@ -1,6 +1,6 @@ #!/bin/bash -BASE=/root/atlassian-tools +BASE=${HOME}/atlassian-tools . ${BASE}/conf/config.sh . ${BASE}/lib/utils.sh diff --git a/bin/fix_keytab.sh b/bin/fix_keytab.sh index 0416fba..ec0cdb4 100644 --- a/bin/fix_keytab.sh +++ b/bin/fix_keytab.sh @@ -1,6 +1,6 @@ #!/bin/bash -BASE=/root/atlassian-tools +BASE=${HOME}/atlassian-tools . ${BASE}/conf/config.sh . ${BASE}/lib/utils.sh diff --git a/bin/fix_network.sh b/bin/fix_network.sh index cc5c1e5..d0b9f92 100644 --- a/bin/fix_network.sh +++ b/bin/fix_network.sh @@ -1,6 +1,6 @@ #!/bin/bash -BASE=/root/atlassian-tools +BASE=${HOME}/atlassian-tools . ${BASE}/conf/config.sh . ${BASE}/lib/utils.sh diff --git a/bin/fix_web_configs.sh b/bin/fix_web_configs.sh index 5d5e81e..04b9e85 100644 --- a/bin/fix_web_configs.sh +++ b/bin/fix_web_configs.sh @@ -1,6 +1,6 @@ #!/bin/bash -BASE=/root/atlassian-tools +BASE=${HOME}/atlassian-tools . ${BASE}/conf/config.sh . ${BASE}/lib/utils.sh diff --git a/bin/go_fix_web.sh b/bin/go_fix_web.sh index fbfcd13..271965c 100644 --- a/bin/go_fix_web.sh +++ b/bin/go_fix_web.sh @@ -1,6 +1,6 @@ #!/bin/bash -BASE=/root/atlassian-tools +BASE=${HOME}/atlassian-tools BIN="$BASE"/bin . "$BASE"/conf/config.sh diff --git a/bin/go_install_app.sh b/bin/go_install_app.sh new file mode 100755 index 0000000..3ea4d0a --- /dev/null +++ b/bin/go_install_app.sh @@ -0,0 +1,105 @@ +#!/usr/bin/bash + +BASE=${HOME}/atlassian-tools + +. ${BASE}/conf/config.sh +. ${BASE}/lib/utils.sh + +BIN="${BASE}"/bin +FULLPATH=$(/usr/bin/readlink -e "$0") +SOURCES="${BASE}"/install-upgrade/"${APP_NAME}" + +[[ $VERBOSE -eq $YES ]] && set -x + +set -x + + +install_core() { + [[ -d "${APP_INSTALL_DIR}" ]] && { + /usr/bin/echo "APP_INSTALL_DIR '${APP_INSTALL_DIR}' exists ... skipping app install" 1>&2 + return -1 + } + + local _installer=$( /usr/bin/find "${SOURCES}" + -type f \ + -name "${FILE_NAME_PATTERN}" \ + -print \ + | /usr/bin/sort -V \ + | /usr/bin/tail -1) + /usr/bin/chmod +x "${_installer}" + "${_installer}" -q -varfile "${SOURCES}"/response.varfile +} + + +install_config() { + set -x + local _hn=$(/usr/bin/hostname -f) + local _template="${SOURCES}"/server.xml.tmpl + /usr/bin/sed -e "s/___PROXYNAME___/${_hn}/" "${_template}" \ + > "${APP_INSTALL_DIR}"/conf/server.xml +} + + +install_admin_pwd() { + set -x + local _pwd_file=$(/usr/bin/find "${SOURCES}" -type f -name '*.pwd' -print) + [[ -f "${_pwd_file}" ]] && { + /usr/bin/mv "${_pwd_file}" /root/. + } +} + + +print_usage() { + local _prg=$(/usr/bin/basename "${FULLPATH}") + cat <&2 - return -1 - } - local _installer=$(/usr/bin/find "${BASE}" -type f -name "${FILE_NAME_PATTERN}" -print \ - | /usr/bin/sort -V \ - | /usr/bin/tail -1) - /usr/bin/chmod +x "${_installer}" - "${_installer}" -q -varfile "${ANSWER_FILE}" -} - - -install_config() { - set -x - local _hn=$(/usr/bin/hostname -f) - local _template="${BASE}"/server.xml.tmpl - /usr/bin/sed -e "s/___PROXYNAME___/${_hn}/" "${_template}" \ - > "${APPDIR}"/conf/server.xml -} - - -disable_notifications() { - if [[ ${APPNAME} == "jira" ]] ; then - sed -i -e 's/^#\(DISABLE_NOTIFICATIONS\)/\1/' "${APPDIR}"/bin/setenv.sh - elif [[ ${APPNAME} == "confluence" ]] ; then - sed -i -e 's/^#\(CATALINA_OPTS=.*atlassian.mail.senddisabled\)/\1/' "${APPDIR}"/bin/setenv.sh - fi -} - - -set_java_heap_size() { - if [[ ${APPNAME} == "jira" ]] ; then - sed -i \ - -e '/^JVM_MINIMUM_MEMORY=/ c JVM_MINIMUM_MEMORY="2048m"' \ - -e '/^JVM_MAXIMUM_MEMORY=/ c JVM_MAXIMUM_MEMORY="4096m"' \ - "${APPDIR}"/bin/setenv.sh - elif [[ ${APPNAME} == "confluence" ]] ; then - sed -i -e 's/\(-Xm[sx]\)[0-9]\+m/\18192m/g' "${APPDIR}"/bin/setenv.sh - fi -} - - -install_admin_pwd() { - set -x - local _pwd_file=$(/usr/bin/find "${BASE}" -type f -name '*.pwd' -print) - [[ -f "${_pwd_file}" ]] && { - /usr/bin/mv "${_pwd_file}" /root/. - } -} - - -print_usage() { - cat <] [-a ] -t + -h: obligatory, absolute path of Confluence home directory + -a: obligatory, absolute path of Confluence application directory + -t: optional, to run and collect thread dumps" 1>&2; exit 1; } +while getopts ":a:h:t" o; do + case $o in + h|H) + h=${OPTARG} + ;; + a|A) + a=${OPTARG} + ;; + s|S) + s=${OPTARG} + ;; + t|T) + TD=1 + ;; + *) + usage + ;; + esac +done + +if [ -z $h ] || [ -z $a ]; then + usage +fi + +###############THE PATHS +CONFAPP=$a +CONFHOME=$h +SHAREDHOME=$s +BEXPORT=$CONFHOME/export +LOG=$BEXPORT/Confluence_support_$DATE.log +EXPORT=$BEXPORT/Confluence_support_$DATE + + + + +echo ' + __ ------------------------------------------ + _(\ |@@| | Beep - Generating Atlassian Support Zip | +(__/\__ \--/ __ /_------------------------------------------ + \___|----| | __ + \ }{ /\ )_ / _\ + /\__/\ \__O (__ + (--/\--) \__/ + _)( )(_ + `---''---` +' +echo " +############################## +# Atlassian support zip tool # +############################## +User = $USER +Confluence Home = $CONFHOME +Confluence App Directory = $CONFAPP + +Hit CTRL+C (10s wait) if any path or user is incorrect. +" +sleep 10 + +echo "`date +%Y-%m-%d-%H-%M-%S` - Start creating the Support Zip file" >> $LOG +#Create the basic structure +mkdir -p $EXPORT/{application-config,application-logs,application-properties,auth-cfg,cache-cfg,confluence-customisations,healthchecks,thread-dump,synchrony-config,tomcat-config,tomcat-logs} +mkdir -p $EXPORT/confluence-customisations/layouts + +#application-logs +echo ' - Packing application logs' +echo "`date +%Y-%m-%d-%H-%M-%S` - application-logs" >> $LOG +cp -f $CONFHOME/logs/* $EXPORT/application-logs/ + +# application-config +#Confluence configuration files +echo ' - Packing application config files' +echo "`date +%Y-%m-%d-%H-%M-%S` - application-config" >> $LOG + + +cat $CONFHOME/confluence.cfg.xml | sed 's/password\"\>.*/password\"\>Sanitized by Support Utility\<\/property\>/g' | sed 's/username\"\>.*/username\"\>Sanitized by Support Utility\<\/property\>/g' > $EXPORT/application-config/confluence.cfg.xml +#OLD cat -> cat $CONFHOME/confluence.cfg.xml | sed 's/password\"\>.*/password\"\>Sanitized by Support Utility/g' | sed 's/username\>.*/username\"\>Sanitized by Support Utility/g' > $EXPORT/application-config/confluence.cfg.xml +##Sanitized by Support Utility +##Sanitized by Support Utility + +cp -f $CONFAPP/confluence/WEB-INF/classes/{confluence-init.properties,log4j-diagnostic.properties,log4j.properties} $EXPORT/application-config/ +cp -f $CONFAPP/confluence/WEB-INF/classes/logging.properties $EXPORT/application-config/logging.properties +cp -f $CONFAPP/confluence/WEB-INF/web.xml $EXPORT/application-config/web.xml +cp -f $CONFAPP/bin/{setclasspath.sh,setclasspath.bat,setenv.sh,setenv.bat,shutdown.sh,shutdown.bat,start-confluence.sh,start-confluence.bat,startup.sh,startup.bat,stop-confluence.sh,stop-confluence.bat} $EXPORT/application-config/ + +for i in setclasspath.sh setclasspath.bat setenv.sh setenv.bat shutdown.sh shutdown.bat start-confluence.sh start-confluence.bat startup.sh startup.bat stop-confluence.sh stop-confluence.bat ; do tmp=`echo $i | sed 's/\./-/g'`; mv $EXPORT/application-config/$i $EXPORT/application-config/$tmp.txt; done + +#auth-cfg +#If exists /logs/support (possibly will gather old data) will grab the file however changing name to avoid confusion + +echo ' - Packing configuration summary, if any available' +echo "`date +%Y-%m-%d-%H-%M-%S` - auth-cfg" >> $LOG +if [ -f $CONFHOME/logs/support/directoryConfigurationSummary.txt ]; then + echo ' - Packing the last directoryConfigurationSummary available.' + cat $CONFHOME/logs/support/directoryConfigurationSummary.txt | sed 's/password:.*/password: Sanitized by Support Utility/g' > $EXPORT/auth-cfg/`ls -l $CONFHOME/logs/support/directoryConfigurationSummary.txt | awk -F' ' '{print $6"-"$7}'`.directoryConfigurationSummary.txt; +fi + +echo ' - Packing seraph and crowd configuration files' +echo "`date +%Y-%m-%d-%H-%M-%S` - auth-cfg" >> $LOG +cp -f $CONFAPP/confluence/WEB-INF/classes/{crowd.properties,seraph-config.xml,seraph-paths.xml} $EXPORT/auth-cfg/ + + +#confluence-customisations +echo ' - Packing confluence customisations files' +echo "`date +%Y-%m-%d-%H-%M-%S` - confluence-customisations" >> $LOG +cp -f $CONFHOME/logs/support/{customHtml.txt,customStylesheet.txt}} $EXPORT/confluence-customisations +echo ' - Packing custom layouts files' +echo "`date +%Y-%m-%d-%H-%M-%S` - confluence-customisations/layouts" >> $LOG +cp -f $CONFHOME/logs/support/customLayouts.txt $EXPORT/confluence-customisations/layouts +cp -f $CONFHOME/logs/support/*.vmd $EXPORT/confluence-customisations/layouts + +#synchrony-config +echo ' - Packing synchrony configuration file' +echo "`date +%Y-%m-%d-%H-%M-%S` - synchrony-config" >> $LOG +cp -f $CONFHOME/synchrony-args.properties $EXPORT/synchrony-config + + +################################################ +######## Double check this one for shared home folder on DC +################################################ +#cache-cfg +echo ' - Packing cache configuration files' +echo "`date +%Y-%m-%d-%H-%M-%S` - cache-cfg" >> $LOG +cp -f $SHAREDHOME/cache-settings-overrides.properties $EXPORT/cache-cfg + + +#tomcat-config +echo ' - Packing tomcat configuration files' +echo "`date +%Y-%m-%d-%H-%M-%S` - tomcat-config" >> $LOG +cp -f $CONFAPP/conf/{catalina.policy,catalina.properties,context.xml,jaspic-providers.xml,logging.properties,server.xml,tomcat-users.xml,web.xml} $EXPORT/tomcat-config + +#sanitization +cd $EXPORT/tomcat-config; cat server.xml | sed 's/keystorePass=\".*\"/keystorePass=\"Sanitized by Support Utility\"/g' | sed "s/keystorePass=\'.*\'/keystorePass=\'Sanitized by Support Utility\'/g" > server.xml.tmp; mv -f server.xml.tmp server.xml +cd $EXPORT/tomcat-config; cat tomcat-users.xml | sed 's/password=\".*\"/password=\"Sanitized by Support Utility\"/g' > tomcat-users.xml.tmp; mv -f tomcat-users.xml.tmp tomcat-users.xml + +#healthchecks +#If exists /logs/support (possibly will gather old data) will grab the file however changing name to avoid confusion +echo ' - Packing healthcheckResults, if any available' +echo "`date +%Y-%m-%d-%H-%M-%S` - healthchecks" >> $LOG +if [ -f $CONFHOME/logs/support/healthcheckResults.txt ]; then + ## cp -f $CONFHOME/logs/support/healthcheckResults.txt $EXPORT/healthchecks/`ls -l $CONFHOME/logs/support/healthcheckResults.txt | awk -F' ' '{print $6"-"$7}'`.healthcheckResults.txt; + cp -f $CONFHOME/logs/support/healthcheckResults.txt $EXPORT/healthchecks +fi + +#tomcat-logs +echo ' - Packing Tomcat logs' +echo "`date +%Y-%m-%d-%H-%M-%S` - tomcat-logs" >> $LOG +#find $CONFAPP/logs -type f \( ! -iname "access_log*" \) -mtime -10 -exec cp -a "{}" $EXPORT/tomcat-logs \; +cp -f $CONFAPP/logs/* $EXPORT/tomcat-logs + +#application-properties +#If exists /logs/support (possibly will gather old data) will grab the file however changing name to avoid confusion +echo ' - Packing the application.xml, if any available' +echo "`date +%Y-%m-%d-%H-%M-%S` - application-properties" >> $LOG +if [ -f $CONFHOME/logs/support/application.xml ]; then + ## cp -f $CONFHOME/logs/support/application.xml $EXPORT/application-properties/`ls -l $CONFHOME/logs/support/application.xml | awk -F' ' '{print $6"-"$7}'`.application.xml; + cp -f $CONFHOME/logs/support/application.xml $EXPORT/application-properties + +fi + + +#thread-dump +if [ $TD == 1 ] +then + echo ' - Generating thread dumps - this will take ~1 minute' + echo "`date +%Y-%m-%d-%H-%M-%S` - thread dump" >> $LOG + APP_PID=`ps aux | grep -i confluence | grep -i java | grep -v synchrony.core | awk -F '[ ]*' '{print $2}'`; + for i in $(seq 6); do top -b -H -p $APP_PID -n 1 > $EXPORT/thread-dump/threaddump_`date +%s`_cpu_usage.txt; jstack $APP_PID > $EXPORT/thread-dump/threaddump_`date +%s`.tdump; sleep 10; done + +else + echo ' - Thread dump will not be collected' + echo "`date +%Y-%m-%d-%H-%M-%S` - no thread dump" >> $LOG +fi + +#Pack and go +if [ -x "$(command -v zip)" ] ; then + echo; echo 'Creating zip file...' + echo "`date +%Y-%m-%d-%H-%M-%S` - Packing as zip" >> $LOG + cd $EXPORT + zip -r ../Confluence_support_$DATE.zip ./* 2>&1 >> $LOG; + echo; echo "The support zip file can be found in $BEXPORT/Confluence_support_$DATE.zip, please upload this file to Atlassian." + echo "." + echo "Have a g'day =)" + echo +else + echo; echo 'Zip not found, packing as tar.gz...' + echo "`date +%Y-%m-%d-%H-%M-%S` - Zip not found, packing as tar.gz" >> $LOG + cd $BEXPORT; tar -cvf Confluence_support_$DATE.tar $EXPORT/*; gzip Confluence_support_$DATE.tar 2>&1 >> $LOG; + echo; echo "The support zip file can be found in $BEXPORT/Confluence_support_$DATE.tar.gz, please upload this file to Atlassian." + echo "." + echo "Have a g'day =)" + echo +fi + + +#EOF \ No newline at end of file diff --git a/install-upgrade/01_push_installer_files.sh b/install-upgrade/sync_install_files.sh similarity index 57% rename from install-upgrade/01_push_installer_files.sh rename to install-upgrade/sync_install_files.sh index 0847c5b..a7e3457 100755 --- a/install-upgrade/01_push_installer_files.sh +++ b/install-upgrade/sync_install_files.sh @@ -12,6 +12,4 @@ APP="$2" [[ -z "$APP" ]] && die "missing app name" [[ -d "$APP" ]] || die "no directory matching name '$APP'" -/usr/bin/ssh "${REMOTE_HOST}" "mkdir -p ${HOME}/${APP}" -/usr/bin/rsync -rtvPL "${APP}"/ "${REMOTE_HOST}":"${APP}" -/usr/bin/rsync -tvP ./02_installer.sh "${REMOTE_HOST}":"${APP}" +/usr/bin/rsync -rtvPL "${APP}"/ "${REMOTE_HOST}":sudo /root/atlassian-tools/install-upgrade/"${APP}" diff --git a/lib/utils.sh b/lib/utils.sh index ba38a87..c4b5658 100644 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -16,6 +16,7 @@ success() { die() { err "$*" + echo "from (${BASH_SOURCE[1]} [${BASH_LINENO[0]}] ${FUNCNAME[1]})" exit 99 }