Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the Linux service scripts to use systemd services instead of init.d #447

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function removeServiceFromStartup {
function removeServiceScript() {
echo "Removing files."
set -x
rm -f "/etc/init.d/${SERVICE_NAME}"
rm -f "/etc/systemd/${SERVICE_NAME}"
rm -f "/etc/default/${SERVICE_NAME}"
{ set +x; } > /dev/null 2>&1
}
Expand Down Expand Up @@ -132,13 +132,13 @@ echo ${EXECUTABLE}
if [[ $(type -P "service") ]]; then
serviceCmd="service ${SERVICE_NAME}"
else
serviceCmd="/etc/init.d/${SERVICE_NAME}"
serviceCmd="/etc/systemd/${SERVICE_NAME}"
fi

echo before uninstall $uninstall

if [ "$uninstall" != "true" ]; then
if [ -f "/etc/init.d/${SERVICE_NAME}" ]; then
if [ -f "/etc/systemd/${SERVICE_NAME}" ]; then
echo "Service $SERVICE_NAME already installed"
exit 1
fi
Expand All @@ -165,11 +165,11 @@ chown -R "${RX_USER}:${RX_GROUP}" "${rxDir}"
echo "Setting up pid folder /var/run${SERVICE_NAME} setting ownership to user=${RX_USER} group=${RX_GROUP}"
mkdir -p ${TOMCAT_RUN}
chown -R "${RX_USER}:${RX_GROUP}" "${TOMCAT_RUN}"
echo "Copying startup script ${CATALINA_HOME}/bin/catalina.sh /etc/init.d/${SERVICE_NAME}"
sed -e "s/\${PercussionProductionDTS_service}/$SERVICE_NAME/" ${CATALINA_HOME}/bin/catalina.sh >> /etc/init.d/${SERVICE_NAME}
sed -i "3 a CATALINA_HOME=${CATALINA_HOME}" /etc/init.d/${SERVICE_NAME}
sed -i "4 a JAVA_HOME=${JAVA_HOME}" /etc/init.d/${SERVICE_NAME}
chmod 755 "/etc/init.d/${SERVICE_NAME}"
echo "Copying startup script ${CATALINA_HOME}/bin/catalina.sh /etc/systemd/${SERVICE_NAME}"
sed -e "s/\${PercussionProductionDTS_service}/$SERVICE_NAME/" ${CATALINA_HOME}/bin/catalina.sh >> /etc/systemd/${SERVICE_NAME}
sed -i "3 a CATALINA_HOME=${CATALINA_HOME}" /etc/systemd/${SERVICE_NAME}
sed -i "4 a JAVA_HOME=${JAVA_HOME}" /etc/systemd/${SERVICE_NAME}
chmod 755 "/etc/systemd/${SERVICE_NAME}"


cat <<-EOF > /etc/default/${SERVICE_NAME}
Expand All @@ -184,7 +184,7 @@ cat <<-EOF > /etc/default/${SERVICE_NAME}
chown -R "${RX_USER}:${RX_GROUP}" "${TOMCAT_RUN}"
EOF

echo "Configuration for service ${SERVICE_NAME} in /etc/init.d/${SERVICE_NAME} must reinstall or update if paths change"
echo "Configuration for service ${SERVICE_NAME} in /etc/systemd/${SERVICE_NAME} must reinstall or update if paths change"

echo "************"
cat /etc/default/${SERVICE_NAME}
Expand All @@ -203,8 +203,8 @@ elif [[ $(type -P "update-rc.d") ]]; then
update-rc.d ${SERVICE_NAME} defaults
elif [ -d "/etc/rc2.d" ]; then
echo "Fall back to symbolic linking into /etc/rcx.d folders"
ln /etc/init.d/${SERVICE_NAME} /etc/rc2.d/S99${SERVICE_NAME}
ln /etc/init.d/${SERVICE_NAME} /etc/rc0.d/K99${SERVICE_NAME}
ln /etc/systemd/${SERVICE_NAME} /etc/rc2.d/S99${SERVICE_NAME}
ln /etc/systemd/${SERVICE_NAME} /etc/rc0.d/K99${SERVICE_NAME}
else
echo "Cannot find chkconfig or update-rc.d or /etc/rc2.d to run service on startup consult documentation for alternative"
echo ${distVersion}
Expand All @@ -219,16 +219,16 @@ echo "*************"
else #Unistall
checkForProductionDTSService

if [ ! -f "/etc/init.d/${SERVICE_NAME}" ]; then
echo "Service $SERVICE_NAME not installed in /etc/init.d/${SERVICE_NAME}"
if [ ! -f "/etc/systemd/${SERVICE_NAME}" ]; then
echo "Service $SERVICE_NAME not installed in /etc/systemd/${SERVICE_NAME}"
exit 1
fi

if cat "/etc/init.d/${SERVICE_NAME}" | grep -q "catalina"; then
echo "Found service installed to /etc/init.d/${SERVICE_NAME}"
if cat "/etc/systemd/${SERVICE_NAME}" | grep -q "catalina"; then
echo "Found service installed to /etc/systemd/${SERVICE_NAME}"
else
cat "/etc/init.d/${SERVICE_NAME}" | grep -q "catalina"
echo "Service installed to /etc/init.d/${SERVICE_NAME} is not a Percussion Production DTS service"
cat "/etc/systemd/${SERVICE_NAME}" | grep -q "catalina"
echo "Service installed to /etc/systemd/${SERVICE_NAME} is not a Percussion Production DTS service"
exit 1
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function removeServiceFromStartup {
function removeServiceScript() {
echo "Removing files."
set -x
rm -f "/etc/init.d/${SERVICE_NAME}"
rm -f "/etc/systemd/${SERVICE_NAME}"
rm -f "/etc/default/${SERVICE_NAME}"
{ set +x; } > /dev/null 2>&1
}
Expand Down Expand Up @@ -130,13 +130,13 @@ echo ${EXECUTABLE}
if [[ $(type -P "service") ]]; then
serviceCmd="service ${SERVICE_NAME}"
else
serviceCmd="/etc/init.d/${SERVICE_NAME}"
serviceCmd="/etc/systemd/${SERVICE_NAME}"
fi

echo before uninstall $uninstall

if [ "$uninstall" != "true" ]; then
if [ -f "/etc/init.d/${SERVICE_NAME}" ]; then
if [ -f "/etc/systemd/${SERVICE_NAME}" ]; then
echo "Service $SERVICE_NAME already installed"
exit 1
fi
Expand Down Expand Up @@ -164,11 +164,11 @@ chown -R "${RX_USER}:${RX_GROUP}" "${rxDir}"
echo "Setting up pid folder /var/run/${SERVICE_NAME} setting ownership to user=${RX_USER} group=${RX_GROUP}"
mkdir -p ${TOMCAT_RUN}
chown -R "${RX_USER}:${RX_GROUP}" "${TOMCAT_RUN}"
echo "Copying startup script ${CATALINA_HOME}/bin/catalina.sh /etc/init.d/${SERVICE_NAME}"
sed -e "s/\${PercussionStagingDTS_service}/$SERVICE_NAME/" ${CATALINA_HOME}/bin/catalina.sh >> /etc/init.d/${SERVICE_NAME}
sed -i "3 a CATALINA_HOME=${CATALINA_HOME}" /etc/init.d/${SERVICE_NAME}
sed -i "4 a JAVA_HOME=${JAVA_HOME}" /etc/init.d/${SERVICE_NAME}
chmod 755 "/etc/init.d/${SERVICE_NAME}"
echo "Copying startup script ${CATALINA_HOME}/bin/catalina.sh /etc/systemd/${SERVICE_NAME}"
sed -e "s/\${PercussionStagingDTS_service}/$SERVICE_NAME/" ${CATALINA_HOME}/bin/catalina.sh >> /etc/systemd/${SERVICE_NAME}
sed -i "3 a CATALINA_HOME=${CATALINA_HOME}" /etc/systemd/${SERVICE_NAME}
sed -i "4 a JAVA_HOME=${JAVA_HOME}" /etc/systemd/${SERVICE_NAME}
chmod 755 "/etc/systemd/${SERVICE_NAME}"


cat <<-EOF > /etc/default/${SERVICE_NAME}
Expand All @@ -179,7 +179,7 @@ cat <<-EOF > /etc/default/${SERVICE_NAME}
CATALINA_PID="${TOMCAT_RUN}/PercussionStagingDTS.pid"
EOF

echo "Configuration for service ${SERVICE_NAME} in /etc/init.d/${SERVICE_NAME} must reinstall or update if paths change"
echo "Configuration for service ${SERVICE_NAME} in /etc/systemd/${SERVICE_NAME} must reinstall or update if paths change"

echo "************"
cat /etc/default/${SERVICE_NAME}
Expand All @@ -198,8 +198,8 @@ elif [[ $(type -P "update-rc.d") ]]; then
update-rc.d ${SERVICE_NAME} defaults
elif [ -d "/etc/rc2.d" ]; then
echo "Fall back to symbolic linking into /etc/rcx.d folders"
ln /etc/init.d/${SERVICE_NAME} /etc/rc2.d/S99${SERVICE_NAME}
ln /etc/init.d/${SERVICE_NAME} /etc/rc0.d/K99${SERVICE_NAME}
ln /etc/systemd/${SERVICE_NAME} /etc/rc2.d/S99${SERVICE_NAME}
ln /etc/systemd/${SERVICE_NAME} /etc/rc0.d/K99${SERVICE_NAME}
else
echo "Cannot find chkconfig or update-rc.d or /etc/rc2.d to run service on startup consult documentation for alternative"
echo ${distVersion}
Expand All @@ -214,16 +214,16 @@ echo "*************"
else #Uninstall
checkForStagingDTSService

if [ ! -f "/etc/init.d/${SERVICE_NAME}" ]; then
echo "Service $SERVICE_NAME not installed in /etc/init.d/${SERVICE_NAME}"
if [ ! -f "/etc/systemd/${SERVICE_NAME}" ]; then
echo "Service $SERVICE_NAME not installed in /etc/systemd/${SERVICE_NAME}"
exit 1
fi

if cat "/etc/init.d/${SERVICE_NAME}" | grep -q "catalina"; then
echo "Found service installed to /etc/init.d/${SERVICE_NAME}"
if cat "/etc/systemd/${SERVICE_NAME}" | grep -q "catalina"; then
echo "Found service installed to /etc/systemd/${SERVICE_NAME}"
else
cat "/etc/init.d/${SERVICE_NAME}" | grep -q "catalina"
echo "Service installed to /etc/init.d/${SERVICE_NAME} is not a Percussion Staging DTS service"
cat "/etc/systemd/${SERVICE_NAME}" | grep -q "catalina"
echo "Service installed to /etc/systemd/${SERVICE_NAME} is not a Percussion Staging DTS service"
exit 1
fi

Expand Down
36 changes: 18 additions & 18 deletions system/Tools/jetty/service/install-jetty-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ function checkForJbossService() {
while read -r line; do
service=$(basename ${line})
echo "Found JBoss service $service in $line"
serviceHome=$(grep "^SERVER_DIR=" /etc/init.d/${service} | cut -d "=" -f 2)
serviceHome=$(grep "^SERVER_DIR=" /etc/systemd/${service} | cut -d "=" -f 2)
echo $serviceHome
if [ "$serviceHome" == "$rxDir" ]; then
currentService=$service
fi
done < <(grep -l /etc/init.d/* -e 'RhythmyxD')
done < <(grep -l /etc/systemd/* -e 'RhythmyxD')

if [ ! -z "$currentService" ];
then
if [ "$cleanupJBoss" != "true" ]; then
echo "Warning Jboss startup /etc/init.d/${currentService} for this instance ${rxDir} exists use to remove"
echo "Warning Jboss startup /etc/systemd/${currentService} for this instance ${rxDir} exists use to remove"
usage
fi
echo "Cleaning up JBoss init scripts"
Expand Down Expand Up @@ -96,7 +96,7 @@ function removeServiceScript() {

echo "removing files"
set -x
rm -f "/etc/init.d/${1}"
rm -f "/etc/systemd/${1}"
rm -f "/etc/default/${1}"
rm -rf "$JETTY_RUN"
rm -f "$JETTY_BASE/${SERVICE_NAME}.state"
Expand All @@ -121,14 +121,14 @@ JETTY_RUN=/var/run/rxjetty/${SERVICE_NAME}
if [[ $(type -P "service") ]]; then
serviceCmd="service ${SERVICE_NAME}"
else
serviceCmd="/etc/init.d/${SERVICE_NAME}"
serviceCmd="/etc/systemd/${SERVICE_NAME}"
fi
echo before uninstall $uninstall
if [ "$uninstall" != "true" ];then
echo in uninstall


if [ -f "/etc/init.d/${SERVICE_NAME}" ];then
if [ -f "/etc/systemd/${SERVICE_NAME}" ];then
echo "Service $SERVICE_NAME already installed"
exit 1
fi
Expand Down Expand Up @@ -176,10 +176,10 @@ echo in uninstall
chown -R "${RX_USER}:${RX_GROUP}" "${JETTY_RUN}"
chmod -R ugo+rw /var/run/rxjetty/${SERVICE_NAME}

echo "copying startup script ${JETTY_DEFAULTS}/bin/jetty.sh /etc/init.d/${SERVICE_NAME}"
echo "copying startup script ${JETTY_DEFAULTS}/bin/jetty.sh /etc/systemd/${SERVICE_NAME}"

sed -e "s/\${rxjetty_service}/$SERVICE_NAME/" ${JETTY_DEFAULTS}/bin/rxjetty.sh > /etc/init.d/${SERVICE_NAME}
chmod 755 "/etc/init.d/${SERVICE_NAME}"
sed -e "s/\${rxjetty_service}/$SERVICE_NAME/" ${JETTY_DEFAULTS}/bin/rxjetty.sh > /etc/systemd/${SERVICE_NAME}
chmod 755 "/etc/systemd/${SERVICE_NAME}"

cat <<-EOF > /etc/default/${SERVICE_NAME}
JAVA_HOME=${JAVA_HOME}
Expand All @@ -199,7 +199,7 @@ echo in uninstall
chmod -R ugo+rw /var/run/rxjetty/${SERVICE_NAME}
EOF

echo "configuration for service ${SERVICE_NAME} in /etc/init.d/${SERVICE_NAME} must reinstall or update if paths change"
echo "configuration for service ${SERVICE_NAME} in /etc/systemd/${SERVICE_NAME} must reinstall or update if paths change"

echo "**********"
cat /etc/default/${SERVICE_NAME}
Expand All @@ -220,8 +220,8 @@ EOF
update-rc.d ${SERVICE_NAME} defaults
elif [ -d "/etc/rc2.d" ]; then
echo "Fall back to symbolic linking into /etc/rcx.d folders e.g. Solaris 9"
ln /etc/init.d/${SERVICE_NAME} /etc/rc2.d/S99${SERVICE_NAME}
ln /etc/init.d/${SERVICE_NAME} /etc/rc0.d/K99${SERVICE_NAME}
ln /etc/systemd/${SERVICE_NAME} /etc/rc2.d/S99${SERVICE_NAME}
ln /etc/systemd/${SERVICE_NAME} /etc/rc0.d/K99${SERVICE_NAME}
else
echo "Cannot find chkconfig or update-rc.d or /etc/rc2.d to run service on startup consult documentation on alternatives for your distro"
echo ${distVersion}
Expand All @@ -237,16 +237,16 @@ else # Uninstall
echo checking for jetty service
checkForJettyService

if [ ! -f "/etc/init.d/${SERVICE_NAME}" ];then
echo "Service $SERVICE_NAME not installed in /etc/init.d/${SERVICE_NAME}"
if [ ! -f "/etc/systemd/${SERVICE_NAME}" ];then
echo "Service $SERVICE_NAME not installed in /etc/systemd/${SERVICE_NAME}"
exit 1
fi

if cat "/etc/init.d/${SERVICE_NAME}" | grep -q "jetty"; then
echo "Found service installed to /etc/init.d/${SERVICE_NAME}"
if cat "/etc/systemd/${SERVICE_NAME}" | grep -q "jetty"; then
echo "Found service installed to /etc/systemd/${SERVICE_NAME}"
else
cat "/etc/init.d/${SERVICE_NAME}" | grep -q "jetty"
echo "Service installed to /etc/init.d/${SERVICE_NAME} is not a Rhythmyx Jetty Service"
cat "/etc/systemd/${SERVICE_NAME}" | grep -q "jetty"
echo "Service installed to /etc/systemd/${SERVICE_NAME} is not a Rhythmyx Jetty Service"
exit 1
fi
if ${serviceCmd} status | grep "Jetty running" ; then
Expand Down