2020-10-16 16:37:01 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
2020-10-19 09:12:39 +02:00
|
|
|
|
file="$(find ${HOME}/.local/$(basename $0)/ -name $1)"
|
2020-10-16 16:37:01 +02:00
|
|
|
|
case $1 in
|
2020-10-19 09:12:39 +02:00
|
|
|
|
*cnf*|*conf*)
|
|
|
|
|
[ -z "${file-x}" ] && file="${HOME}/.local/$(basename $0)/confluence"
|
2020-10-19 21:59:01 +02:00
|
|
|
|
libdir=/opt/atlassian/confluence/confluence/WEB-INF/lib
|
2020-10-19 09:12:39 +02:00
|
|
|
|
app=confluence
|
2020-10-19 21:59:01 +02:00
|
|
|
|
appuser=confluence
|
2020-10-16 16:37:01 +02:00
|
|
|
|
;;
|
2020-10-19 09:12:39 +02:00
|
|
|
|
*jra*|*jira*)
|
|
|
|
|
[ -z "${file-x}" ] && file="${HOME}/.local/$(basename $0)/jira"
|
2020-10-19 21:59:01 +02:00
|
|
|
|
libdir=/opt/atlassian/jira/atlassian-jira/WEB-INF/lib
|
2020-10-19 09:12:39 +02:00
|
|
|
|
app=jira
|
2020-10-19 21:59:01 +02:00
|
|
|
|
appuser=jira
|
2020-10-19 09:12:39 +02:00
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "host ${1} not found -> exit"
|
|
|
|
|
exit
|
2020-10-16 16:37:01 +02:00
|
|
|
|
;;
|
|
|
|
|
esac
|
2020-10-19 09:12:39 +02:00
|
|
|
|
|
|
|
|
|
echo "Using configfile $file"
|
2020-10-19 21:59:01 +02:00
|
|
|
|
runtime=$(date "+%x-%X")
|
|
|
|
|
UNINSTALLDIR="${HOME}/UNINSTALL/${runtime}/"
|
2020-10-19 09:12:39 +02:00
|
|
|
|
|
|
|
|
|
if stat "${file}" >/dev/null 2>/dev/null ; then
|
2020-10-19 21:59:01 +02:00
|
|
|
|
echo "Stop $app on ${1}"
|
|
|
|
|
ssh ${1} systemctl stop ${app}.service
|
2020-10-19 09:12:39 +02:00
|
|
|
|
cat ${file}|sort -r |while read cmd pkg version ; do
|
|
|
|
|
case $cmd in
|
|
|
|
|
install)
|
2020-10-19 21:59:01 +02:00
|
|
|
|
echo install $cmd $pkg $version
|
|
|
|
|
if [ -z "${version}" ]; then
|
|
|
|
|
package=$(find ~/.m2 -name "*${pkg}*.jar"|sort -t"." -k 1,1 -k 2,2 -k 3,3|tail -n1)
|
|
|
|
|
else
|
|
|
|
|
package=$(find ~/.m2 -name "*${pkg}-${version}.jar")
|
|
|
|
|
fi
|
2020-10-19 09:12:39 +02:00
|
|
|
|
if [ -n "${package-x}" ]; then
|
2020-10-19 21:59:01 +02:00
|
|
|
|
scp ${package} ${1}:${libdir}
|
|
|
|
|
ssh ${1} chown $appuser:${appusergrp-root} "${libdir}/$(basename ${package})" </dev/null
|
|
|
|
|
ssh ${1} chmod ${fileperm-0755} "${libdir}/$(basename ${package})" </dev/null
|
2020-10-19 09:12:39 +02:00
|
|
|
|
else
|
|
|
|
|
echo "$pkg in version $version not found"
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
remove)
|
2020-10-19 21:59:01 +02:00
|
|
|
|
if [ -n "${pkg}" ]; then
|
|
|
|
|
if [ -n "${version}" ]; then
|
|
|
|
|
echo remove $pkg in version ${version} from ${1}
|
|
|
|
|
ssh -T ${1} /bin/bash <<EOF
|
|
|
|
|
mkdir -p "${UNINSTALLDIR}" </dev/null
|
|
|
|
|
[ \$(find ${libdir} -name "*${pkg}-${version}.jar" </dev/null |wc -l) -gt 0 ] && \
|
|
|
|
|
mv \$(find ${libdir} -name "*${pkg}-${version}.jar") "${UNINSTALLDIR}". </dev/null
|
|
|
|
|
EOF
|
|
|
|
|
else
|
|
|
|
|
echo remove $pkg in all versions from ${1}
|
|
|
|
|
ssh -T ${1} /bin/bash <<EOF
|
|
|
|
|
mkdir -p "${UNINSTALLDIR}" </dev/null
|
|
|
|
|
[ \$(find ${libdir} -name "*${pkg}-*.jar" </dev/null |wc -l) -gt 0 ] && \
|
|
|
|
|
mv \$(find ${libdir} -name "*${pkg}-*.jar") "${UNINSTALLDIR}"/. </dev/null
|
|
|
|
|
EOF
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
echo pkg not set ignore line »${cmd} ${pkg} ${version}« from configfile
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "line not correct: $cmd $pkg $version"
|
2020-10-19 09:12:39 +02:00
|
|
|
|
;;
|
|
|
|
|
esac
|
2020-10-19 21:59:01 +02:00
|
|
|
|
unset cmd pkg version
|
2020-10-19 09:12:39 +02:00
|
|
|
|
done
|
2020-10-19 21:59:01 +02:00
|
|
|
|
echo "Start $app on ${1}"
|
|
|
|
|
ssh ${1} systemctl start ${app}.service </dev/null
|
2020-10-19 09:12:39 +02:00
|
|
|
|
else
|
|
|
|
|
echo "Configfile ${file} not found"
|
|
|
|
|
fi
|