Commit 39a7ae8c authored by Jondy Zhao's avatar Jondy Zhao

refine slapos-cleanup.sh with csih_inform

parent 0d0f797f
...@@ -32,9 +32,9 @@ readonly -f show_usage ...@@ -32,9 +32,9 @@ readonly -f show_usage
function slapos_kill_process() function slapos_kill_process()
{ {
name=$1 name=$1
echo "Try to kill all $name ..." csih_inform "Try to kill all $name ..."
for pid in $(ps | grep "$name" | gawk '{print $4}') ; do for pid in $(ps | grep "$name" | gawk '{print $4}') ; do
echo "Kill pid $pid" csih_inform "Kill pid $pid"
TASKKILL /F /T /PID $pid TASKKILL /F /T /PID $pid
done done
} }
...@@ -43,7 +43,7 @@ readonly -f slapos_kill_process ...@@ -43,7 +43,7 @@ readonly -f slapos_kill_process
# ----------------------------------------------------------- # -----------------------------------------------------------
# Start script # Start script
# ----------------------------------------------------------- # -----------------------------------------------------------
echo "Start cleanup slapos node ..." csih_inform "Start cleanup slapos node ..."
echo "" echo ""
while test $# -gt 0; do while test $# -gt 0; do
...@@ -73,16 +73,16 @@ done ...@@ -73,16 +73,16 @@ done
# #
for name in ${re6stnet_service_name} ${cron_service_name} \ for name in ${re6stnet_service_name} ${cron_service_name} \
${syslog_service_name} ${cygserver_service_name} ; do ${syslog_service_name} ${cygserver_service_name} ; do
echo "Removing service $name" csih_inform "Removing service $name"
cygrunsrv -R $name && echo OK. cygrunsrv -R $name && csih_inform "OK."
done done
# #
# Stop slapos # Stop slapos
# #
if [[ -x /opt/slapos/bin/slapos ]] ; then if [[ -x /opt/slapos/bin/slapos ]] ; then
echo "Stopping slapos node ..." csih_inform "Stopping slapos node ..."
/opt/slapos/bin/slapos node stop all && echo OK. /opt/slapos/bin/slapos node stop all && csih_inform "OK."
fi fi
slapos_kill_process /usr/bin/python2.7 slapos_kill_process /usr/bin/python2.7
...@@ -93,68 +93,68 @@ slapos_kill_process /usr/bin/python2.7 ...@@ -93,68 +93,68 @@ slapos_kill_process /usr/bin/python2.7
# #
# Remove virtual netcard installed by slapos # Remove virtual netcard installed by slapos
# #
echo "Removing network connection ${slapos_ifname}" csih_inform "Removing network connection ${slapos_ifname}"
ipwin remove *msloop ${slapos_ifname} && echo OK. ipwin remove *msloop ${slapos_ifname} && csih_inform "OK."
echo "Removing all Tap-Windows Drivers ..." csih_inform "Removing all Tap-Windows Drivers ..."
which devcon >/dev/null 2>&1 && devcon remove tap0901 && echo OK. which devcon >/dev/null 2>&1 && devcon remove tap0901 && csih_inform "OK."
# #
# Remove configure files # Remove configure files
# #
echo Removing /etc/opt/slapos csih_inform Removing /etc/opt/slapos
rm -rf /etc/opt/slapos/ && echo OK. rm -rf /etc/opt/slapos/ && csih_inform "OK."
echo Removing ~/.slapos csih_inform Removing ~/.slapos
rm -rf ~/.slapos && echo OK. rm -rf ~/.slapos && csih_inform "OK."
# #
# Remove crontab # Remove crontab
# #
_filename=/var/cron/tabs/${slapos_administrator} _filename=/var/cron/tabs/${slapos_administrator}
echo "Removing ${_filename}" csih_inform "Removing ${_filename}"
rm -rf ${_filename} && echo OK. rm -rf ${_filename} && csih_inform "OK."
# #
# Remove default instance root and software root, because they belong to # Remove default instance root and software root, because they belong to
# slapuser, and would not be removed by the windows uninstaller. # slapuser, and would not be removed by the windows uninstaller.
# #
[[ -f /srv/slapgrid ]] && echo "Removing /srv/slapgrid" && rm -rf /srv/slapgrid && echo OK. [[ -d /srv/slapgrid ]] && csih_inform "Removing /srv/slapgrid" && rm -rf /srv/slapgrid && csih_inform "OK."
[[ -f /opt/slapgrid ]] && echo "Removing /opt/slapgrid" && rm -rf /opt/slapgrid && echo OK. [[ -d /opt/slapgrid ]] && csih_inform "Removing /opt/slapgrid" && rm -rf /opt/slapgrid && csih_inform "OK."
# #
# Remove users installed by slapos # Remove users installed by slapos
# #
[[ -f /var/empty ]] && echo "Removing /var/empty" && rm -rf /var/empty && echo OK. [[ -d /var/empty ]] && csih_inform "Removing /var/empty" && rm -rf /var/empty && csih_inform "OK."
for _name in $(NET USER) ; do for _name in $(NET USER) ; do
if [[ "${_name}" == ${slapos_user_basename}* ]] ; then if [[ "${_name}" == ${slapos_user_basename}* ]] ; then
echo "Removing user: ${_name}" csih_inform "Removing user: ${_name}"
NET USER ${_name} /DELETE && echo OK. NET USER ${_name} /DELETE && csih_inform "OK."
elif echo "${_name}" | grep -q -E "(cyg_server)|(${slapos_administrator})" ; then elif echo "${_name}" | grep -q -E "(cyg_server)|(${slapos_administrator})" ; then
echo "Removing user: ${_name}" csih_inform "Removing user: ${_name}"
NET USER ${_name} /DELETE && echo OK. NET USER ${_name} /DELETE && csih_inform "OK."
fi fi
done done
echo "Creating /etc/passwd ..." csih_inform "Creating /etc/passwd ..."
mkpasswd -l > /etc/passwd && echo OK. mkpasswd -l > /etc/passwd && csih_inform "OK."
# #
# Remove local group installed by slapos node # Remove local group installed by slapos node
# #
for _name in $(NET LOCALGROUP | sed -n -e "s/^*//p" | sed -e "s/\\s//g") ; do for _name in $(NET LOCALGROUP | sed -n -e "s/^*//p" | sed -e "s/\\s//g") ; do
if [[ "${_name}" == grp_${slapos_user_basename}* ]] ; then if [[ "${_name}" == grp_${slapos_user_basename}* ]] ; then
echo "Removing localgroup: ${_name}" csih_inform "Removing localgroup: ${_name}"
NET LOCALGROUP ${_name} /DELETE && echo OK. NET LOCALGROUP ${_name} /DELETE && csih_inform "OK."
fi fi
done done
echo "Creating /etc/group ..." csih_inform "Creating /etc/group ..."
mkgroup -l > /etc/group && echo OK. mkgroup -l > /etc/group && csih_inform "OK."
# ----------------------------------------------------------- # -----------------------------------------------------------
# End script # End script
# ----------------------------------------------------------- # -----------------------------------------------------------
echo echo ""
echo Run pre-uninstall script complete. csih_inform Run pre-uninstall script complete.
echo echo ""
read -n 1 -t 60 -p "Press any key to exit..." read -n 1 -t 60 -p "Press any key to exit..."
exit 0 exit 0
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment