Sindbad~EG File Manager
Current Path : /var/lib/dpkg/info/ |
|
Current File : /var/lib/dpkg/info/omsconfig.postinst |
#!/bin/sh
OMI_HOME=/opt/omi
OMI_REGISTER_DIR=/etc/opt/omi/conf/omiregister/
CONFIG_SYSCONFDIR=/etc/opt/omi/conf
CONFIG_DATADIR=$OMI_HOME/share
OMI_LIB=$OMI_HOME/lib
mkdir -p $CONFIG_SYSCONFDIR/omsconfig
mkdir -p $CONFIG_SYSCONFDIR/omsconfig/InventoryReports
mkdir -p $CONFIG_SYSCONFDIR/omsconfig/configuration
mkdir -p $CONFIG_SYSCONFDIR/omsconfig/configuration/schema
mkdir -p $CONFIG_SYSCONFDIR/omsconfig/configuration/schema/MSFT_LogResource
mkdir -p $CONFIG_SYSCONFDIR/omsconfig/configuration/baseregistration
mkdir -p $CONFIG_SYSCONFDIR/omsconfig/configuration/registration
mkdir -p $CONFIG_SYSCONFDIR/omsconfig/configuration/registration/MSFT_LogResource
mkdir -p $CONFIG_SYSCONFDIR/omsconfig/configuration/BuiltinProvCache
mkdir -p $CONFIG_DATADIR/omsconfig
mkdir -p $CONFIG_DATADIR/omsconfig/configuration
mkdir -p $CONFIG_DATADIR/omsconfig/configuration/schema
mkdir -p $CONFIG_DATADIR/omsconfig/configuration/registration
chmod 700 $CONFIG_SYSCONFDIR/omsconfig
# Set up logging directory
mkdir -p /var/opt/microsoft/omsconfig
chown omsagent /var/opt/microsoft/omsconfig
chgrp omsagent /var/opt/microsoft/omsconfig
chmod 755 /var/opt/microsoft/omsconfig
# Set up log file
if [ ! -f /var/opt/microsoft/omsconfig/omsconfig.log ]; then
touch /var/opt/microsoft/omsconfig/omsconfig.log
fi
chown omsagent /var/opt/microsoft/omsconfig/omsconfig.log
chgrp omsagent /var/opt/microsoft/omsconfig/omsconfig.log
chmod 644 /var/opt/microsoft/omsconfig/omsconfig.log
# Set up detailed log file
if [ ! -f /var/opt/microsoft/omsconfig/omsconfigdetailed.log ]; then
touch /var/opt/microsoft/omsconfig/omsconfigdetailed.log
fi
chown omsagent /var/opt/microsoft/omsconfig/omsconfigdetailed.log
chgrp omsagent /var/opt/microsoft/omsconfig/omsconfigdetailed.log
chmod 644 /var/opt/microsoft/omsconfig/omsconfigdetailed.log
# Set up dsc_host use switch
if [ ! -f /opt/dsc/dsc_host_ready ]; then
touch /opt/dsc/dsc_host_ready
fi
chown omsagent /opt/dsc/dsc_host_ready
chgrp omsagent /opt/dsc/dsc_host_ready
chmod 644 /opt/dsc/dsc_host_ready
# Create links in omi's directories for DSC data
mkdir -p $OMI_REGISTER_DIR/root-oms
chmod 755 $OMI_REGISTER_DIR/root-oms
cp -f /opt/microsoft/omsconfig/etc/*.reg $OMI_REGISTER_DIR/root-oms
cp -f /opt/microsoft/omsconfig/etc/omsconfig.reg $OMI_REGISTER_DIR/root-oms
ln -fs /opt/microsoft/omsconfig/lib/libomsconfig.so $OMI_HOME/lib/libomsconfig.so
ln -fs /opt/microsoft/omsconfig/bin/OMSConsistencyInvoker $OMI_HOME/bin/OMSConsistencyInvoker
cp -f /opt/microsoft/omsconfig/mof/OMI_BaseResourceUE.mof $CONFIG_SYSCONFDIR/omsconfig/configuration/baseregistration/baseresource.schema.mof
cp -f /opt/microsoft/omsconfig/mof/MSFT_DSCMetaConfiguration.mof $CONFIG_SYSCONFDIR/omsconfig/configuration/baseregistration/MSFT_DSCMetaConfiguration.mof
cp -f /opt/microsoft/omsconfig/mof/MSFT_LogResource.registration.mof $CONFIG_SYSCONFDIR/omsconfig/configuration/registration/MSFT_LogResource
cp -f /opt/microsoft/omsconfig/mof/MSFT_LogResource.schema.mof $CONFIG_SYSCONFDIR/omsconfig/configuration/schema/MSFT_LogResource
chmod a+rx $CONFIG_SYSCONFDIR/omsconfig/
chmod a+rx $CONFIG_SYSCONFDIR/omsconfig/configuration
chmod -R a+rx $CONFIG_SYSCONFDIR/omsconfig/configuration/schema
chmod -R a+rx $CONFIG_SYSCONFDIR/omsconfig/configuration/baseregistration
chmod -R a+rx $CONFIG_SYSCONFDIR/omsconfig/configuration/registration
chown -R omsagent /opt/microsoft/omsconfig/modules
chown -R omsagent $OMI_REGISTER_DIR/root-oms
chown -R omsagent /etc/opt/omi/conf/omsconfig
chown -R omsagent /opt/microsoft/omsagent/plugin
# If this is ever changed/removed, coordinate with nxOMSAuditdPlugin author/maintainer(s)
chown -R omsagent /opt/microsoft/omsconfig/Scripts
# Set up built-in resource modules for OMS DSC
su - omsagent -c "/opt/microsoft/omsconfig/Scripts/InstallModule.py /opt/microsoft/omsconfig/module_packages/nx_1.0.zip 0"
su - omsagent -c "/opt/microsoft/omsconfig/Scripts/InstallModule.py /opt/microsoft/omsconfig/module_packages/nxOMSPerfCounter_2.2.zip 0"
su - omsagent -c "/opt/microsoft/omsconfig/Scripts/InstallModule.py /opt/microsoft/omsconfig/module_packages/nxOMSSyslog_2.4.zip 0"
su - omsagent -c "/opt/microsoft/omsconfig/Scripts/InstallModule.py /opt/microsoft/omsconfig/module_packages/nxOMSSudoCustomLog_2.7.zip 0"
su - omsagent -c "/opt/microsoft/omsconfig/Scripts/InstallModule.py /opt/microsoft/omsconfig/module_packages/nxOMSKeyMgmt_1.0.zip 0"
su - omsagent -c "/opt/microsoft/omsconfig/Scripts/InstallModule.py /opt/microsoft/omsconfig/module_packages/nxFileInventory_1.3.zip 0"
# Set up a built-in resource module for DIY DSC that was removed during OMS Agent update
# This is a temporary workaround to prevent DIY DSC from breaking after the OMS Agent is updated from version 1.4.4-210 or below
# This section can be removed when telemetry shows that customers no longer need to update from version 1.4.4-210 or below
# Check if DIY DSC install module script is present on the machine
if [ -f /opt/microsoft/dsc/Scripts/InstallModule.py ]; then
# Check if nx module package is available in DIY DSC
if [ -f /opt/microsoft/dsc/module_packages/nx_1.0.zip ]; then
/opt/microsoft/dsc/Scripts/InstallModule.py /opt/microsoft/dsc/module_packages/nx_1.0.zip 0
fi
fi
# Ensure .reg files all have correct permissions
chmod 644 $OMI_REGISTER_DIR/root-oms/*.reg
if [ -f "/etc/opt/omi/conf/omsconfig/agentid" ]; then chown omsagent:omiusers "/etc/opt/omi/conf/omsconfig/agentid"; fi
if [ -f "/etc/opt/omi/conf/omsconfig/generated_meta_config.mof" ]; then chown omsagent:omiusers "/etc/opt/omi/conf/omsconfig/generated_meta_config.mof"; fi
if [ -d "/etc/opt/omi/conf/omsconfig/.gnupg" ]; then chown omsagent:omiusers "/etc/opt/omi/conf/omsconfig/.gnupg"; fi
if [ -f "/etc/opt/omi/conf/omsconfig/inventory_lock" ]; then chown omsagent:omiusers "/etc/opt/omi/conf/omsconfig/inventory_lock"; fi
if [ -f "/etc/opt/omi/conf/omsconfig/keymgmtring.gpg" ]; then chown omsagent:omiusers "/etc/opt/omi/conf/omsconfig/keymgmtring.gpg"; fi
if [ -f "/etc/opt/omi/conf/omsconfig/keyring.gpg" ]; then chown omsagent:omiusers "/etc/opt/omi/conf/omsconfig/keyring.gpg"; fi
if [ -f "/etc/opt/omi/conf/omsconfig/last_statusreport" ]; then chown omsagent:omiusers "/etc/opt/omi/conf/omsconfig/last_statusreport"; fi
if [ -d "/var/opt/microsoft/omsconfig" ]; then chown -R omsagent:omiusers /var/opt/microsoft/omsconfig/*; fi
if [ -d "/etc/opt/omi/conf/omsconfig" ]; then chown -R omsagent:omiusers /etc/opt/omi/conf/omsconfig/*; fi
if [ -d $OMI_LIB/Scripts ]; then
rm -rf $OMI_LIB/Scripts
fi
cp -R /opt/microsoft/omsconfig/Scripts $OMI_LIB/Scripts
# create symlink from /opt/omi/lib/libcurl.so.4 to wherever libcurl.so is on the system
CURL_PATH=`which curl`
LIBCURL_SO=`ldd ${CURL_PATH} | grep libcurl.so | awk '{print $3}'`
# if libcurl was not found (in case of libcurl-gnutls-dev package) let use ldconfig intead.
if [ -z "$LIBCURL_SO" ]; then
echo "Warning: Unable to find libcurl.so using curl CMD: '${CURL_PATH}'. Trying again with ldconfig."
LIBCURL_SO=`ldconfig -p | grep "libcurl" | awk -F ">" '{print $2}' | awk -F " " '{print $1; exit 0}'`
if [ -z "$LIBCURL_SO" ]; then
echo "Error: Unable to find libcurl in ldconfig. Please install curl."
exit 1
fi
fi
ln -fs $LIBCURL_SO /opt/omi/lib/libcurl.so.3
ln -fs $LIBCURL_SO /opt/omi/lib/libcurl.so.4
chown -R omsagent /opt/microsoft/omsconfig/Scripts
su - omsagent -c "/opt/microsoft/omsconfig/Scripts/ImportGPGKey.sh /opt/microsoft/omsconfig/keys/msgpgkey.asc keymgmtring.gpg"
su - omsagent -c "/opt/microsoft/omsconfig/Scripts/ImportGPGKey.sh /opt/microsoft/omsconfig/keys/dscgpgkey.asc keyring.gpg"
# Set up a dsc cron job to run the ConsistencyInvoker every 30 minutes which is default freq, this is to fix dsc github issue no 322.
# It is a temporary workaround to create dsc DYI cron job as omsconfig upgrade removes dsc cron job.
# check if dsc consistency invoker is present on the machine
if [ -f /opt/omi/bin/ConsistencyInvoker ]; then
# check if we do not have dsc cron file on the box then create one.
if [ ! -f /etc/cron.d/dsc ]; then
echo "*/30 * * * * root /opt/omi/bin/ConsistencyInvoker" > /etc/cron.d/dsc
fi
fi
/opt/omi/bin/service_control restart
# If omsadmin.conf exists, let's apply the metaconfig
if [ -f /etc/opt/microsoft/omsagent/conf/omsadmin.conf ]; then
su - omsagent -c "/opt/microsoft/omsconfig/Scripts/OMS_MetaConfigHelper.py"
fi
cp -f /opt/microsoft/omsconfig/etc/Inventory.mof /etc/opt/omi/conf/omsconfig/configuration/Inventory.mof
chown omsagent /etc/opt/omi/conf/omsconfig/configuration/Inventory.mof
chgrp omsagent /etc/opt/omi/conf/omsconfig/configuration/Inventory.mof
exit 0
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists