#!/bin/sh echo "Cleanning up existing dsc_hosts before uninstall..." kill $(ps -eo pid,cmd | grep '/opt/dsc/bin/dsc_host' | grep -v grep | tr -s ' ' | sed 's/^[ \t]*//' | cut -d' ' -f1) -9 2&>1 > /dev/null chmod -R 777 /opt/dsc # remove entire dsc folder incase of remove and purge echo "Deployment operation type :" $1 if [ "$1" = "0" -o "$1" = 0 -o "$1" = "remove" -o "$1" = "purge" ]; then echo "Cleanning directory /opt/dsc..." rm -rfv /opt/dsc fi rm -f /etc/opt/omi/conf/omsconfig/inventory_lock echo "Cleaned up existing dsc_hosts before uninstall..." # pythonVersion check must be repeated for each section version=$(python3 -V 2>&1 | grep -Po '(?<=Python )(.+)') if [ ! -z "$version" ]; then echo "Using python3" pythonVersion="python3" else version=$(python2 -V 2>&1 | grep -Po '(?<=Python )(.+)') if [ ! -z "$version" ]; then echo "Using python2" pythonVersion="python2" else echo "Python not found." fi fi # if this is a package removal, not an upgrade, remove the modules echo "Deployment operation type :" $1 if [ "$1" = "0" -o "$1" = 0 -o "$1" = "remove" -o "$1" = "purge" ]; then # Remove all DSC specific data if [ "$pythonVersion" = "python3" ]; then echo "Running python3" for module in `ls /opt/microsoft/omsconfig/modules`; do /opt/microsoft/omsconfig/Scripts/python3/RemoveModule.py $module done else echo "Running python2 in remove all DSC specific data python version is ", $pythonVersion for module in `ls /opt/microsoft/omsconfig/modules`; do /opt/microsoft/omsconfig/Scripts/RemoveModule.py $module done fi fi exit 0