#!/bin/bash

if [ ! -f /etc/init.d/transition-service ]; then
    echo
    echo "Checking whether the transition-service (NetApp 7-Mode Transition Tool server) is already present on the system."
    echo "Entry does not exist for transition-service (NetApp 7-Mode Transition Tool server)."
    echo
    exit 1
fi

echo
echo "Ensuring that the transition-service (NetApp 7-Mode Transition Tool server) is stopped."
service transition-service stop

echo
echo "Disabling runlevel for the transition-service (NetApp 7-Mode Transition Tool server)."
chkconfig --level 2345 transition-service off

echo
echo "Unregistering transition-service (NetApp 7-Mode Transition Tool server) from Linux service."
chkconfig --del transition-service

echo
echo "Removing the transition-service (NetApp 7-Mode Transition Tool server) script from the /etc/init.d/ directory."
rm /etc/init.d/transition-service

echo
echo "Removing the 7-Mode Transition Tool path from the ~/.bashrc file."
grep -v "NetApp_7ModeTransitionTool/bin" ~/.bashrc > temp_bashrc
cat temp_bashrc > ~/.bashrc
rm -f temp_bashrc

echo
echo "Reloading bashrc."
source ~/.bashrc
echo
