Skip to content

Commit

Permalink
Revert "Don't start OMI service by default on Linux platform"
Browse files Browse the repository at this point in the history
This reverts commit d1d2263.

This turned out to have issues where, if OMI was installed and the
service was running, upgrading to OMI 1.1.0-0 would leave the service
unregistered.

Because there were no use cases for this in the end, we decided to
just revert the changes.
  • Loading branch information
jeffaco committed Aug 16, 2016
1 parent 93d85d0 commit 5afbd30
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 83 deletions.
33 changes: 29 additions & 4 deletions Unix/installbuilder/datafiles/Linux.data
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ ULINUX
SYSTEMD_UNIT_DIR=""
ResolveSystemdPaths()
{
# NOTE: This method is duplicated in both service_control.linux and in
# Linux.data. If this method is changed, change in both locations.

local UNIT_DIR_LIST="/usr/lib/systemd/system /lib/systemd/system"

if pidof systemd 1> /dev/null 2> /dev/null; then
Expand Down Expand Up @@ -126,6 +123,33 @@ RemoveOmiService() {
[ -f /etc/init.d/omid ] && rm /etc/init.d/omid
}

ConfigureOmiService() {
echo "Configuring OMI service ..."
pidof systemd 1> /dev/null 2> /dev/null
if [ $? -eq 0 ]; then
# systemd
ResolveSystemdPaths
cp /opt/omi/bin/support/omid.systemd ${SYSTEMD_UNIT_DIR}/omid.service
/bin/systemctl daemon-reload
/bin/systemctl enable omid
else
cp /opt/omi/bin/support/omid /etc/init.d/omid

if [ -x /usr/sbin/update-rc.d ]; then
update-rc.d omid defaults > /dev/null
elif [ -x /usr/lib/lsb/install_initd ]; then
/usr/lib/lsb/install_initd /etc/init.d/omid
elif [ -x /sbin/chkconfig ]; then
chkconfig --add omid > /dev/null
else
echo "Unrecognized Service Controller to configure OMI Service."
exit 1
fi
fi

${{SERVICE_CTL}} start
}

%Preinstall_10
#include OmiService_funcs

Expand All @@ -149,6 +173,8 @@ chmod 775 /opt/omi/lib /etc/opt/omi/conf/omiregister /var/opt/omi/omiusers
# Be certain that SSL linkages exist for OMI utilities
/opt/omi/bin/support/installssllinks

ConfigureOmiService

%Preuninstall_10
#include OmiService_funcs

Expand All @@ -159,7 +185,6 @@ fi

%Postuninstall_100
if ${{PERFORMING_UPGRADE_NOT}}; then
rm -f /etc/opt/omi/conf/.service_registered
rm -f /opt/omi/lib/libcrypto* /opt/omi/lib/libssl*
rmdir /opt/omi/lib > /dev/null 2>&1
rmdir /opt/omi > /dev/null 2>&1
Expand Down
79 changes: 0 additions & 79 deletions Unix/installbuilder/service_scripts/service_control.linux
Original file line number Diff line number Diff line change
Expand Up @@ -19,81 +19,6 @@
OMI_BIN=/opt/omi/bin/omiserver
PIDFILE=/var/opt/omi/run/omiserver.pid

#
# The service_control.linux script will now install the service on service
# start operations. This allows the actual installation to not start the
# service unless it's actually required.
#
# To do this, we need ResolveSystemdPaths and ConfigureOmiService
#

# Various distributions have different paths for systemd unit files ...

SYSTEMD_UNIT_DIR=""
ResolveSystemdPaths()
{
# NOTE: This method is duplicated in both service_control.linux and in
# Linux.data. If this method is changed, change in both locations.

local UNIT_DIR_LIST="/usr/lib/systemd/system /lib/systemd/system"

if pidof systemd 1> /dev/null 2> /dev/null; then
# Be sure systemctl lives where we expect it to
if [ ! -f /bin/systemctl ]; then
echo "FATAL: Unable to locate systemctl program" 1>&2
exit 1
fi

# Find systemd unit directory
for i in ${UNIT_DIR_LIST}; do
if [ -d $i ]; then
SYSTEMD_UNIT_DIR=${i}
return 0
fi
done

# Didn't fine unit directory, that's fatal
echo "FATAL: Unable to resolve systemd unit directory!" 1>&2
exit 1
else
return 1
fi
}

ConfigureOmiService()
{
if [ ! -f /etc/opt/omi/conf/.service_registered ]; then
echo "Configuring OMI service ..."
pidof systemd 1> /dev/null 2> /dev/null
if [ $? -eq 0 ]; then
# systemd
ResolveSystemdPaths
cp /opt/omi/bin/support/omid.systemd ${SYSTEMD_UNIT_DIR}/omid.service
/bin/systemctl daemon-reload
/bin/systemctl enable omid
else
cp /opt/omi/bin/support/omid /etc/init.d/omid

if [ -x /usr/sbin/update-rc.d ]; then
update-rc.d omid defaults > /dev/null
elif [ -x /usr/lib/lsb/install_initd ]; then
/usr/lib/lsb/install_initd /etc/init.d/omid
elif [ -x /sbin/chkconfig ]; then
chkconfig --add omid > /dev/null
else
echo "Unrecognized Service Controller to configure OMI Service."
exit 1
fi
fi

touch /etc/opt/omi/conf/.service_registered
fi
}

#
# Service registration stuff completed; back to our regular programming
#

verify_privileges()
{
if [ `id -u` -ne 0 ]; then
Expand Down Expand Up @@ -226,10 +151,6 @@ reload_omi()
fi
}

# Configure service if it's not already configured
# (We want this to always be done, so do so globally)
ConfigureOmiService

case "$1" in
functions)
;;
Expand Down

0 comments on commit 5afbd30

Please sign in to comment.