Revision c6ee5ce4
Added by Scott Ullrich almost 20 years ago
etc/rc.banner | ||
---|---|---|
1 | 1 |
#!/usr/local/bin/php -f |
2 | 2 |
<?php |
3 |
/* $Id$ */ |
|
4 | 3 |
/* |
4 |
$Id$ |
|
5 |
|
|
5 | 6 |
rc.banner |
6 | 7 |
part of pfSense |
7 |
Copyright (C) 2004 Scott Ullrich
|
|
8 |
Copyright (C) 2005 Scott Ullrich and Colin Smith
|
|
8 | 9 |
All rights reserved |
9 | 10 |
|
10 |
originally part of m0n0wall (http://m0n0.ch/wall) |
|
11 |
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>. |
|
12 |
All rights reserved. |
|
13 |
|
|
14 | 11 |
Redistribution and use in source and binary forms, with or without |
15 | 12 |
modification, are permitted provided that the following conditions are met: |
16 | 13 |
|
... | ... | |
35 | 32 |
|
36 | 33 |
/* parse the configuration and include all functions used below */ |
37 | 34 |
require_once("config.inc"); |
38 |
require_once("functions.inc"); |
|
39 | 35 |
|
40 |
$version = chop(file_get_contents("{$g['etc_path']}/version")); |
|
41 |
$buildtime = chop(file_get_contents("{$g['etc_path']}/version.buildtime")); |
|
42 |
$platform = chop(file_get_contents("{$g['etc_path']}/platform")); |
|
36 |
$version = trim(file_get_contents("{$g['etc_path']}/version")); |
|
37 |
$platform = trim(file_get_contents("{$g['etc_path']}/platform")); |
|
43 | 38 |
|
44 |
$banner = "\n*** Welcome to pfSense version {$version} - {$platform} ***\n";
|
|
39 |
print "\n*** Welcome to pfSense version {$version} - {$platform} ***\n";
|
|
45 | 40 |
|
41 |
/* get our initial interface list */ |
|
46 | 42 |
$iflist = get_interface_list("media"); |
47 | 43 |
|
48 | 44 |
foreach($iflist as $ifname => $ifinfo) { |
49 |
$friendly = strtoupper($ifinfo['friendly']); |
|
50 |
$ifconf =& $config['interfaces'][$ifinfo['friendly']]; |
|
51 | 45 |
/* skip interfaces that don't have a friendly name */ |
52 |
if($friendly != "") { |
|
46 |
if($ifinfo['friendly'] != "") { |
|
47 |
$friendly = strtoupper($ifinfo['friendly']); |
|
48 |
/* point to this interface's config */ |
|
49 |
$ifconf =& $config['interfaces'][$ifinfo['friendly']]; |
|
50 |
/* look for 'special cases' */ |
|
53 | 51 |
switch($ifconf['ipaddr']) { |
54 | 52 |
case "dhcp": |
55 |
$ifinfo['class'] = "DHCP";
|
|
53 |
$ifinfo['class'] = "(DHCP)";
|
|
56 | 54 |
break; |
57 | 55 |
case "pppoe": |
58 |
$ifinfo['class'] = "PPPoE";
|
|
56 |
$ifinfo['class'] = "(PPPoE)";
|
|
59 | 57 |
$ifinfo['ipaddr'] = $iflist['ng0']['ipaddr']; |
60 | 58 |
break; |
61 | 59 |
case "pptp": |
62 |
$ifinfo['class'] = "PPTP";
|
|
60 |
$ifinfo['class'] = "(PPTP)";
|
|
63 | 61 |
$ifinfo['ipaddr'] = $iflist['ng0']['ipaddr']; |
64 | 62 |
break; |
65 | 63 |
} |
66 |
/* print interface name */ |
|
67 |
$tobanner = "\n {$friendly}"; |
|
68 |
/* interface description */ |
|
64 |
$tobanner = $friendly; |
|
65 |
/* does this interface have an extra description? */ |
|
69 | 66 |
if($ifconf['descr']) { |
70 | 67 |
$tobanner .= "({$ifconf['descr']})"; |
71 | 68 |
} |
... | ... | |
73 | 70 |
if($ifinfo['up']) { |
74 | 71 |
$tobanner .= "*"; |
75 | 72 |
} |
76 |
/* pad banner to eliminate tab errors */ |
|
77 |
$banner .= str_pad($tobanner, 25, " ", STR_PAD_RIGHT); |
|
78 |
/* print physical if name */ |
|
79 |
$banner .= "->\t{$ifname}\t->\t"; |
|
80 |
/* do we have an IP? */ |
|
81 |
$banner .= $ifinfo['ipaddr'] ? $ifinfo['ipaddr'] : "NONE"; |
|
82 |
/* do we have an interface class? */ |
|
83 |
if($ifinfo['class']) { |
|
84 |
$banner .= "({$ifinfo['class']})"; |
|
85 |
} |
|
73 |
printf("\n %-25s->\t%s\t->\t%s%s", |
|
74 |
$tobanner, |
|
75 |
$ifname, |
|
76 |
$ifinfo['ipaddr'] ? $ifinfo['ipaddr'] : "NONE", |
|
77 |
$ifinfo['class'] |
|
78 |
); |
|
86 | 79 |
} |
87 | 80 |
} |
88 |
|
|
89 |
print $banner; |
|
90 |
|
|
91 | 81 |
?> |
Also available in: Unified diff
Sync with CVS HEAD.