Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Axway Synchrony Activator Linux/Unix SysVinit Script v1.0
#!/bin/bash
### BEGIN INIT INFO
# Provides: axwayactivator
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start / Stop / Restart / Status Axway Synchrony Activator
# Description: starts, stops, restarts or shows status of an Axway Synchrony Activator installation
### END INIT INFO
# Author: Martin Seener <martin@seener.de>
# Axway Synchrony Activator defaults
# Adjust the installation path and user only - the rest will be built on that
INSTALLPATH=/opt/Axway/Synchrony/Activator
RUNUSER=axway
# Nothing to modify here
STARTSERVER=$INSTALLPATH/bin/startServer
STOPSERVER=$INSTALLPATH/bin/stopServer
PIDFILE=$INSTALLPATH/logs/`uname -n`_server.pid
# Actions
case "$1" in
start)
# Check for a .pid file, otherwise run that sh..cript
echo -n "Starting Axway Synchrony Activator: "
if [ -f $PIDFILE ]; then
# .pid exists. Now we check if the process is dead
/bin/ps aux | grep "`cat $PIDFILE`" | grep -v grep > /dev/null 2>&1
if [ $? -eq 0 ]; then
# Process is running... Aborting.
echo -e "\e[0;32mAxway Synchrony Activator is still running. Aborting.\e[00m"
exit 0
else
# Process is dead... Aborting.
echo -e "\e[0;33m$PIDFILE exists but Process not running. Deleting pid and restarting.\e[00m"
rm -f $PIDFILE && su - $RUNUSER -c "$STARTSERVER"
if [ $? -eq 0 ]; then
exit 0
else
echo -e "\e[0;31mUnable to restart Axway Synchrony Activator. Aborting.\e[00m"
exit 1
fi
fi
else
# No .pid - we`re starting Axway Synchrony Activator.
su - $RUNUSER -c "$STARTSERVER"
if [ $? -eq 0 ]; then
echo -e "\e[0;32mdone.\e[00m"
exit 0
else
echo -e "\e[0;31mUnable to restart Axway Synchrony Activator. Aborting.\e[00m"
exit 1
fi
fi
;;
stop)
# Stopping Axway Synchrony Activatora if its running
echo -n "Stopping Axway Synchrony Activator: "
if [ -f $PIDFILE ]; then
# .pid is in place. checking if process is there
/bin/ps aux | grep "`cat $PIDFILE`" | grep -v grep > /dev/null 2>&1
if [ $? -eq 0 ]; then
# Process is there too. Let us stop it
su - $RUNUSER -c "$STOPSERVER"
if [ $? -eq 0 ]; then
echo -e "\e[0;32mdone.\e[00m"
exit 0
else
echo -e "\e[0;31mUnable to stop process with PID: `cat $PIDFILE`\e[00m"
exit 1
fi
else
# No Process found
echo -n -e "\e[0;32mNothing to stop.\e[00m Trying to delete old pid file for you: "
rm -f $PIDFILE
if [ $? -eq 0 ]; then
echo -e "\e[0;32mdone.\e[00m"
exit 0
else
echo -e "\e[0;31mUnable to delete old pid file. Aborting.\e[00m"
exit 1
fi
fi
else
# No .pid found. Nothing to stop
echo -e "\e[0;32mNothing to stop.\e[00m"
exit 3
fi
;;
restart)
# Restarting Axway Synchrony Activator
echo -n "Restarting Axway Synchrony Activator: "
if [ -f "$PIDFILE" ]; then
# .pid is in place. checking if process is there
/bin/ps aux | grep "`cat $PIDFILE`" | grep -v grep > /dev/null 2>&1
if [ $? -eq 0 ]; then
# Process is there too. Let us stop it
su - $RUNUSER -c "$STOPSERVER"
if [ $? -eq 0 ]; then
echo -n -e "\e[0;32mdone.\e[00m Restarting: "
else
echo -e "\e[0;31mUnable to stop process with PID: `cat $PIDFILE`\e[00m"
exit 1
fi
su - $RUNUSER -c "$STARTSERVER"
if [ $? -eq 0 ]; then
echo -e "\e[0;32mdone. \e[00m"
exit 0
else
echo -e "\e[0;31mUnable to start Axway Synchrony Activator. Aborting.\e[00m"
exit 1
fi
else
# No Process found
echo -e "\e[0;31mNothing to restart. Please delete old $PIDFILE.\e[00m"
exit 1
fi
else
# No .pid found. Starting Axway Synchrony Activator
echo -n -e "\e[0;33mNothing to stop.\e[00m Starting Axway Synchrony Activator: "
su - $RUNUSER -c "$STARTSERVER"
if [ $? -eq 0 ]; then
echo -e "\e[0;32mstarted.\e[00m"
exit 0
else
echo -e "\e[0;31mUnable to start Axway Synchrony Activator. Aborting.\e[00m"
exit 1
fi
fi
;;
status)
# Getting the status of Axway Synchrony Activator
echo -n "Axway Synchrony Activator is: "
if [ -f "$PIDFILE" ]; then
# .pid is in place. checking if process is there
/bin/ps aux | grep "`cat $PIDFILE`" | grep -v grep > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo -e "\e[0;32mrunning. PID File in place.\e[00m"
exit 0
else
echo -e "\e[0;31mnot running. PID File in place.\e[00m"
exit 1
fi
else
echo -e "\e[0;33mnot running.\e[00m"
exit 3
fi
;;
esac
# Close Script
exit 0
@martinseener

This comment has been minimized.

Copy link
Owner Author

@martinseener martinseener commented Aug 7, 2014

Installation?

  1. Write that file to /etc/init.d/axwayactivator
  2. Run chmod +x /etc/init.d/axwayactivator
  3. Execute update-rc.d axwayactivator defaults
  4. Edit this file and change the INSTALLPATH and RUNUSER variables at the top

How to run?

Just use service axwayactivator (start|stop|restart|status) or the old-styled /etc/init.d/axwayactivator (start|stop|restart|status)

Tested?

Tested with Axway Synchrony Activator 5.x.x on Debian Squeeze but should work on other distros as well

How to run it with /bin/sh instead?

If you need to run this with sh instead of bash, do the following

  • Change Shabang from /bin/bash to /bin/sh
  • Change all "echo -e" to just "echo"
  • Remove all unicode-color directives like "\e[0;31m" or "\e[00m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment