Sindbad~EG File Manager
Current Path : /var/lib/dpkg/info/ |
|
Current File : /var/lib/dpkg/info/omsagent.postinst |
#!/bin/sh
WriteInstallInfo() {
echo "1.12.15-0 20190910 Release_Build" > /etc/opt/microsoft/omsagent/sysconf/installinfo.txt
date +%Y-%m-%dT%T.0Z >> /etc/opt/microsoft/omsagent/sysconf/installinfo.txt
}
WriteInstallInfo
# Can't use normal mechanisms to create /var directories because they must be
# owned by omsagent account. So create them as part of Postinstall, after the
# service account is created.
mkdir -m 755 /var/opt/microsoft/omsagent 2> /dev/null || true
chown -R omsagent:omiusers /var/opt/microsoft/omsagent
# Same for plugin directory:
chown -R omsagent:root /opt/microsoft/omsagent/plugin
# Migrate to multi-homing config and structure, as well as update omsagent config files
/opt/microsoft/omsagent/bin/omsadmin.sh -U
if [ -f /etc/omsagent-onboard.conf ]; then
/opt/microsoft/omsagent/bin/omsadmin.sh
else
# Create a logrotate conf file for the Primary workspace if it does not already exist
# This is needed when upgrading from old omsagent to multi-homing enabled version
PRIMARY_WSID=`grep WORKSPACE_ID /etc/opt/microsoft/omsagent/conf/omsadmin.conf | cut -d= -f2` > /dev/null 2>&1
if [ "$PRIMARY_WSID" -a ! -f /etc/logrotate.d/omsagent-$PRIMARY_WSID ]; then
cat /etc/opt/microsoft/omsagent/sysconf/logrotate.conf | sed "s/%WORKSPACE_ID%/$PRIMARY_WSID/g" > /etc/logrotate.d/omsagent-$PRIMARY_WSID
fi
fi
# Set up a cron job to logrotate all omsagent-$WORKSPACE_ID every 5 minutes
if [ ! -f /etc/cron.d/omsagent ]; then
echo "*/5 * * * * root /usr/sbin/logrotate -s /var/lib/logrotate/omsagent-status /etc/logrotate.d/omsagent* >/dev/null 2>&1" > /etc/cron.d/omsagent
fi
RemoveSudoersSupport() {
# Unconfigure sudo configuration
#
# Just unconfigure everything we could have done so things are left in clean state
if [ -f /etc/sudoers.d/omsagent ]; then
rm -f /etc/sudoers.d/omsagent
fi
grep -q '# Begin sudo configuration for omsagent' /etc/sudoers
if [ $? -eq 0 ]; then
cp /etc/sudoers /etc/sudoers.bak
sed '/^# Begin sudo configuration for omsagent/,/# End sudo configuration for omsagent$/ d' /etc/sudoers.bak > /etc/sudoers
fi
}
SudoSupportsIncludeDirective() {
# Algorithm:
# If #includedir exists in /etc/sudoers AND /etc/sudoers.d exists,
# Then Use /etc/sudoers.d
# Else Append to /etc/sudoers
INCLUDEDIR=0
egrep -q "^#includedir" /etc/sudoers && INCLUDEDIR=1
if [ $INCLUDEDIR -eq 1 -a -d /etc/sudoers.d ]; then
return 0
else
return 1
fi
}
/opt/omi/bin/service_control reload
# Unconfigure sudo if it's already configured
RemoveSudoersSupport
# Configure sudo (either place in sudoers.d or append to sudoers configuration)
SudoSupportsIncludeDirective
if [ $? -eq 0 ]; then
cp /etc/opt/microsoft/omsagent/sysconf/sudoers /etc/sudoers.d/omsagent
chmod 440 /etc/sudoers.d/omsagent
else
cat /etc/opt/microsoft/omsagent/sysconf/sudoers >> /etc/sudoers
fi
chmod 440 /etc/opt/microsoft/omsagent/sysconf/sudoers
# Set group read permission on OMS cert and key files used by the primary workspace
OMS_CERTS_DIR="/etc/opt/microsoft/omsagent/certs"
if [ -d "$OMS_CERTS_DIR" ]; then
chmod -R 750 "$OMS_CERTS_DIR"
fi
# Remove NPM directory on purge
NPM_STATE_DIR=/var/opt/microsoft/omsagent/npm_state
if [ -d "$NPM_STATE_DIR" ]; then
rm -rf $NPM_STATE_DIR
fi
# Set up required states of all onboarded workspaces before starting their daemons
/opt/microsoft/omsagent/bin/omsadmin.sh -R
# Start all workspace-specific omsagent daemons
/opt/microsoft/omsagent/bin/service_control start
exit 0
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists