Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 124724
Collapse All | Expand All

(-)./apache2 (-1 / +49 lines)
Lines 2-8 Link Here
2
# Copyright 1999-2005 Gentoo Foundation
2
# Copyright 1999-2005 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
3
# Distributed under the terms of the GNU General Public License v2
4
4
5
opts="${opts} reload configtest"
5
opts="${opts} reload configtest check"
6
6
7
# this next comment is important, don't remove it - it has to be somewhere in 
7
# this next comment is important, don't remove it - it has to be somewhere in 
8
# the init script to kill off a warning that doesn't apply to us
8
# the init script to kill off a warning that doesn't apply to us
Lines 92-94 Link Here
92
		eend $?
92
		eend $?
93
	fi
93
	fi
94
}
94
}
95
96
check() {
97
	# get listening sockets
98
	local listen=$(lsof -c apache2 -a -Pni tcp -Fn 2>/dev/null \
99
		| grep '^n' | grep -v -- '->' | cut -c 2- \
100
		| sort -n | uniq)
101
	if [ -z "${listen}" ]; then
102
		ewarn "Apache2 not listening on any address :-("
103
	else
104
		einfo "Apache2 listening on:"
105
		eindent
106
		# loop through ip+port list
107
		for ip_port in ${listen}; do
108
			einfon "${ip_port}, "
109
			local ip=${ip_port%:*}
110
			local port=${ip_port#*:}
111
			case ${port} in
112
				# known HTTP ports
113
				80|81|8080)
114
					echo -n 'trying HTTP: '
115
					local res=$(echo -en "HEAD ${CHECK_URI:-/} HTTP/1.0\n\n" \
116
						| nc -w 3 ${ip} ${port} 2>/dev/null \
117
						| head -n 1)
118
					;;
119
				# known HTTPS ports
120
				443)
121
					echo -n 'trying HTTPS: '
122
					local res=$(echo -en "HEAD ${CHECK_URI:-/} HTTP/1.0\n\n" \
123
						| openssl s_client -quiet -connect ${ip_port} 2>/dev/null \
124
						| head -n 1)
125
					;;
126
				# unknown ports
127
				*)
128
					echo -n "no idea how to handle port ${port}"
129
					;;
130
			esac
131
			# did we get a result?
132
			if [ -n "${res}" ]; then
133
				echo "${res}"
134
				eend 0
135
			else
136
				echo ":-("
137
				eend 1
138
			fi
139
		done
140
		eoutdent
141
	fi
142
}

Return to bug 124724