Sindbad~EG File Manager

Current Path : /var/lib/dpkg/info/
Upload File :
Current File : /var/lib/dpkg/info/omsagent.preinst

#!/bin/sh

# The OMS_SERVICE script will not be present on a fresh install
[ -f /opt/microsoft/omsagent/bin/service_control ] && /opt/microsoft/omsagent/bin/service_control disable

# Add the 'omsagent' group if it does not already exist
# (Can't use useradd with -U since that doesn't exist on older systems)
egrep -q "^omsagent:" /etc/group
if [ $? -ne 0 ]; then
    echo "Creating omsagent group ..."
    groupadd -r omsagent
fi

# Add the 'omsagent' service account if it does not already exist
egrep -q "^omsagent:" /etc/passwd
if [ $? -ne 0 ]; then
    echo "Creating omsagent service account ..."
    useradd -r -c "OMS agent" -d /var/opt/microsoft/omsagent/run -g omsagent -s /bin/bash omsagent
fi

# Ensure omsagent is in the omiusers group, but leave omsagent as a group
/usr/sbin/usermod -g omiusers omsagent 1> /dev/null 2> /dev/null

# Add the 'nxautomation' group if it does not already exist
# (Can't use useradd with -U since that doesn't exist on older systems)
egrep -q "^nxautomation:" /etc/group
if [ $? -ne 0 ]; then
    echo "Creating nxautomation group ..."
    groupadd -r nxautomation
fi

# create the 'nxautomation' home directory directory if it does not already exist
NXAUTOMATION_RUN_DIR=/home/nxautomation/run
if [ ! -d "$NXAUTOMATION_RUN_DIR" ]; then
    mkdir -p "$NXAUTOMATION_RUN_DIR"
fi

# Add the 'nxautomation' service account if it does not already exist
egrep -q "^nxautomation:" /etc/passwd
if [ $? -ne 0 ]; then
    echo "Creating nxautomation service account ..."
    useradd -r -c "nxOMSAutomation" -d $NXAUTOMATION_RUN_DIR -g nxautomation -s /bin/bash nxautomation
fi

# set appropriate permissions on the nxautomation home directory
NXAUTOMATION_HOME_DIR=/home/nxautomation
chown -R nxautomation:omiusers $NXAUTOMATION_HOME_DIR
chmod -R 750 $NXAUTOMATION_HOME_DIR

# Ensure nxautomation is in the nxautomation group (primary), omsagent group (secondary) and omiusers group (secondary)
/usr/sbin/usermod -g nxautomation -a -G omsagent,omiusers nxautomation 1> /dev/null 2> /dev/null

exit 0

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists