File: uninstall-lsnw.sh

package info (click to toggle)
nut 2.8.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 24,356 kB
  • sloc: ansic: 123,904; sh: 14,718; cpp: 12,558; makefile: 5,212; python: 1,114; perl: 855; xml: 47
file content (146 lines) | stat: -rwxr-xr-x 2,828 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/sh
# Script to detect and uninstall Lansafe / Netwatch

# AQU notes:
# - default install path: /usr/Powerware/LanSafe (for all systems)
# - may be expanded to PSP 

OS_NAME="`uname -s`"

detect_psp()
{
	case $OS_NAME in
		HP-UX)
			PSP_INITSCRIPT_FN="/sbin/init.d/ls.init"
			;;
		AIX)
			PSP_INITSCRIPT_FN="`grep psp /etc/inittab 2>/dev/null | cut -d':' -f4 | cut -d' ' -f1`"
			;;
		SunOS)
			PSP_INITSCRIPT_FN="/etc/init.d/ls.init"
			;;
		*)
			#echo "$OS_NAME is not managed!"
			return 1
			;;
	esac
}

detect_lansafe()
{
	case $OS_NAME in
		HP-UX)
			LS_INITSCRIPT_FN="/sbin/init.d/ls.init"
			;;
		AIX)
			LS_INITSCRIPT_FN="`grep LanSafe /etc/inittab 2>/dev/null | cut -d':' -f4 | sed 's/&//'`"
			;;
		SunOS)
			LS_INITSCRIPT_FN="/etc/init.d/ls.init"
			;;
		*)
			#echo "$OS_NAME is not managed!"
			return 1
			;;
	esac

	if [ -n "$LS_INITSCRIPT_FN" -a -f "$LS_INITSCRIPT_FN" ] ; then

			LS_INSTPATH="`grep instpath $LS_INITSCRIPT_FN | head -n1 | cut -d'=' -f2`"
			if [ -z "$LS_INSTPATH" ] ; then
				return 1
			#else
				#echo "LanSafe installation detected."
			fi
	else
		return 1
	fi

	# Lansafe is installed
	return 0
}

uninstall_lansafe()
{
	#echo "LanSafe installation detected. Proceeding to uninstallation."
	#echo "Calling $LS_INSTPATH/uninstall.sh"

	# Actual Lansafe uninstallation
	echo "y" | $LS_INSTPATH/uninstall.sh 2>&1 1> install.log
}


detect_netwatch()
{
	case $OS_NAME in
		HP-UX)
			NW_INITSCRIPT_FN="/sbin/init.d/netwatch.init"
			;;
		AIX)
			NW_INITSCRIPT_FN="`grep netwatch /etc/inittab 2>/dev/null | cut -d':' -f4 | cut -d' ' -f1`"
			;;
		SunOS)
			NW_INITSCRIPT_FN="/etc/init.d/netwatch.init"
			;;
		*)
			#echo "$OS_NAME is not managed!"
			return 1
			;;
	esac

	if [ -n "$NW_INITSCRIPT_FN" -a -f "$NW_INITSCRIPT_FN" ] ; then

		    NW_INSTPATH="`grep INSTALL_PATH $NW_INITSCRIPT_FN | head -n1 | cut -d'=' -f2 | sed 's/\"//g'`"
		    if [ -z "$NW_INSTPATH" ] ; then
				return 1
			#else
				#echo "Netwatch installation detected."
			fi
	else
		return 1
	fi

	# Netwatch is installed
	return 0
}

uninstall_netwatch()
{
	#echo "Netwatch installation detected. Proceeding to uninstallation."
	#echo "Calling $NW_INSTPATH/uninstall.sh"

	# Actual Netwatch uninstallation
	$NW_INSTPATH/uninstall.sh silent 2>&1 1> install.log

	# Workaround for buggy uninstall of Netwatch
	case $OS_NAME in
		HP-UX)
			rm -f /sbin/*.d/*netwatch*
			;;
		AIX)
			cat /etc/inittab | grep -v netwatch > /etc/inittab.upp
			mv /etc/inittab.upp /etc/inittab
			;;
		SunOS)
			rm -f /etc/*.d/*netwatch*
			;;
	esac
}

# Main entry point
# Check if Lansafe is installed
detect_lansafe
if [ $? -eq 0 ]; then
	# Proceed to uninstallation
	uninstall_lansafe
fi

# Check if Netwatch is installed
detect_netwatch
if [ $? -eq 0 ]; then
	# Proceed to uninstallation
	uninstall_netwatch
fi

#exit $RETVAL