1
|
#!/usr/local/bin/php -f
|
2
|
<?php
|
3
|
/*
|
4
|
$Id$
|
5
|
|
6
|
rc.banner
|
7
|
part of pfSense
|
8
|
Copyright (C) 2005 Scott Ullrich and Colin Smith
|
9
|
All rights reserved
|
10
|
|
11
|
Redistribution and use in source and binary forms, with or without
|
12
|
modification, are permitted provided that the following conditions are met:
|
13
|
|
14
|
1. Redistributions of source code must retain the above copyright notice,
|
15
|
this list of conditions and the following disclaimer.
|
16
|
|
17
|
2. Redistributions in binary form must reproduce the above copyright
|
18
|
notice, this list of conditions and the following disclaimer in the
|
19
|
documentation and/or other materials provided with the distribution.
|
20
|
|
21
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
22
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
23
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
24
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
25
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
26
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
27
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
28
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
29
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
30
|
POSSIBILITY OF SUCH DAMAGE.
|
31
|
*/
|
32
|
|
33
|
/* parse the configuration and include all functions used below */
|
34
|
require_once("config.inc");
|
35
|
require_once("functions.inc");
|
36
|
|
37
|
$version = trim(file_get_contents("{$g['etc_path']}/version"));
|
38
|
$platform = trim(file_get_contents("{$g['etc_path']}/platform"));
|
39
|
$hostname = $config['system']['hostname'];
|
40
|
$product = $g['product_name'];
|
41
|
|
42
|
print "\n*** Welcome to {$product} {$version}-{$platform} on {$hostname} ***\n";
|
43
|
|
44
|
/* get our initial interface list */
|
45
|
$vfaces = array(
|
46
|
'ppp',
|
47
|
'sl',
|
48
|
'gif',
|
49
|
'faith',
|
50
|
'lo',
|
51
|
'tun',
|
52
|
'pflog',
|
53
|
'pfsync',
|
54
|
'carp'
|
55
|
);
|
56
|
$iflist = get_interface_list("media", "physical", $vfaces);
|
57
|
|
58
|
foreach($iflist as $ifname => $ifinfo) {
|
59
|
/* skip interfaces that don't have a friendly name */
|
60
|
if($ifinfo['friendly'] != "") {
|
61
|
$friendly = strtoupper($ifinfo['friendly']);
|
62
|
/* point to this interface's config */
|
63
|
$ifconf =& $config['interfaces'][$ifinfo['friendly']];
|
64
|
/* look for 'special cases' */
|
65
|
switch($ifconf['ipaddr']) {
|
66
|
case "carpdev-dhcp":
|
67
|
$ifinfo['class'] = "(CarpDEV)";
|
68
|
break;
|
69
|
case "dhcp":
|
70
|
$ifinfo['class'] = "(DHCP)";
|
71
|
break;
|
72
|
case "pppoe":
|
73
|
$ifinfo['class'] = "(PPPoE)";
|
74
|
//$ifinfo['ipaddr'] = $iflist[$g['pppoe_interface']]['ipaddr'];
|
75
|
break;
|
76
|
case "pptp":
|
77
|
$ifinfo['class'] = "(PPTP)";
|
78
|
//$ifinfo['ipaddr'] = $iflist[$g['pppoe_interface']]['ipaddr'];
|
79
|
break;
|
80
|
}
|
81
|
$ifinfo['ipaddr'] = get_interface_ip($ifinfo['friendly']);
|
82
|
$tobanner = $friendly;
|
83
|
/* does this interface have an extra description? */
|
84
|
if($ifconf['descr']) {
|
85
|
$tobanner .= "({$ifconf['descr']})";
|
86
|
}
|
87
|
/* is the interface up? */
|
88
|
if($ifinfo['up']) {
|
89
|
$tobanner .= "*";
|
90
|
}
|
91
|
printf("\n %-25s->\t%s\t->\t%s%s",
|
92
|
$tobanner,
|
93
|
$ifname,
|
94
|
$ifinfo['ipaddr'] ? $ifinfo['ipaddr'] : "NONE",
|
95
|
$ifinfo['class']
|
96
|
);
|
97
|
}
|
98
|
}
|
99
|
?>
|