Search
Clear search
Close search
Google apps
Main menu

Creating init script to run adaptor at startup

To run a connector every time its server is booted you need to create a custom init file.

The init file can be organized differently depending on the distribution used and the init systems the distribution adopts.

System V

This can still be found in old systems but the new distribution will use one of the two systems described below.

Upstart

Create a new configuration file in /etc/init/ with a name like adaptor.conf and copy the following code inside. Modify the directory according to your system.

# Example Adaptor - run adaptor as a daemon
#
# Adaptor for Sharepoint/fileserver/AD/... that sends feeds to a GSA

description "runs adaptor at start time"
env JAVADIR=/usr/lib/java
start on runlevel [2345]
stop on runlevel [!2345]

expect fork
respawn

script
cd /dir/with/adaptor/files
$JAVADIR/bin/java -Djava.util.logging.config.file=logging.properties -jar adaptor-sharepoint-4.1.0-withlib.jar
end script

You can check if the script has any sort of syntax error using the command:

init-checkconf /etc/init/adaptor.conf/etc/init.d/rc

and then start the script using:

sudo start adaptor

systemd

Create a new file in the directory:

/etc/systemd/system/

and copy the following code to /etc/systemd/system/ (changing the directory according to your system, /etc/init.d/rc)

[Unit]
Description=Run adaptor at start time

[Service]Type=forking
ExecStart=/bin/sh -c "cd /dir/with/adaptor/files && /dir/with/java/binary/java -Djava.util.logging.config.file=logging.properties -jar adaptor-sharepoint-4.1.0-withlib.jar
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target

In the console, run the following commands:

sudo systemctl daemon-reload

sudo systemctl start adaptor.service

The first command lets the system know that a new service is available. The second command starts the service.

Was this article helpful?
How can we improve it?