aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-extended/webmin/webmin-notice/webmin-notice.sh
blob: fa493ef0ef0c7241e322bbb1c3b6861425dea847 (plain)
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
#!/bin/sh
# Webmin connect info report script
# Copyright (C) 2011 Intel Corporation
# Distributed under the MIT license

if ! [ -f /var/webmin/miniserv.pid ] ; then
	echo "Webmin not started or failed to start"
	exit
elif ! [ -d /proc/`cat /var/webmin/miniserv.pid` ] ; then
        echo "Webmin not started or failed to start"
        exit
fi

if [ "`pidof avahi-daemon`" != "" ] ; then
	host=`grep "^host-name=" /etc/avahi/avahi-daemon.conf | sed 's/host-name=//'`
	if [ "$host" = "" ] ; then
	        host=`hostname`
	fi
	domain=`grep "^domain-name=" /etc/avahi/avahi-daemon.conf | sed 's/domain-name=//'`
	if [ "$domain" = "" ] ; then
		domain="local"
	fi
	avahiaddr="$host.$domain"
fi

port=`grep "^port=" /etc/webmin/miniserv.conf | sed 's/port=//'`
ssl=`grep "^ssl=" /etc/webmin/miniserv.conf | sed 's/ssl=//'`
if [ "$ssl" = "1" ] ; then
	proto="https"
else
	proto="http"
fi
ipaddr=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`

addr="$proto://$ipaddr:$port"
if [ "$avahiaddr" != "" ] ; then
	addr="$proto://$avahiaddr:$port  or  $addr"
fi
echo
echo "Web administration interface is now available at:"
echo "  $addr"