Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
daa5462f
Commit
daa5462f
authored
Jul 01, 2015
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
config: clean up the code and horrible usage of temp files; #5
parent
5ddbfd16
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
47 deletions
+29
-47
config.console.inc
src/etc/inc/config.console.inc
+10
-18
util.inc
src/etc/inc/util.inc
+5
-16
rc.bootup
src/etc/rc.bootup
+12
-12
rc.initial.setports
src/etc/rc.initial.setports
+2
-1
No files found.
src/etc/inc/config.console.inc
View file @
daa5462f
<?php
<?php
/*
/*
Copyright (C) 2004-2010 Scott Ullrich
Copyright (C) 2015 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
Copyright (C) 2004-2010 Scott Ullrich <sullrich@gmail.com>
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
Redistribution and use in source and binary forms, with or without
...
@@ -29,9 +30,7 @@
...
@@ -29,9 +30,7 @@
function
set_networking_interfaces_ports
()
function
set_networking_interfaces_ports
()
{
{
global
$noreboot
;
global
$config
;
global
$config
;
global
$fp
;
$fp
=
fopen
(
'php://stdin'
,
'r'
);
$fp
=
fopen
(
'php://stdin'
,
'r'
);
$yes_no_prompt
=
'[y|n]? '
;
$yes_no_prompt
=
'[y|n]? '
;
...
@@ -84,7 +83,7 @@ EOD;
...
@@ -84,7 +83,7 @@ EOD;
}
}
if
(
in_array
(
$key
,
array
(
'y'
,
'Y'
)))
{
if
(
in_array
(
$key
,
array
(
'y'
,
'Y'
)))
{
vlan_setup
();
vlan_setup
(
$iflist
,
$fp
);
}
}
if
(
isset
(
$config
[
'vlans'
][
'vlan'
]))
{
if
(
isset
(
$config
[
'vlans'
][
'vlan'
]))
{
...
@@ -198,7 +197,7 @@ Error: you cannot assign the same interface name twice!
...
@@ -198,7 +197,7 @@ Error: you cannot assign the same interface name twice!
EOD;
EOD;
fclose
(
$fp
);
fclose
(
$fp
);
return
;
return
false
;
}
}
}
}
}
}
...
@@ -347,15 +346,10 @@ EODD;
...
@@ -347,15 +346,10 @@ EODD;
fclose
(
$fp
);
fclose
(
$fp
);
if
(
file_exists
(
"/var/run/booting"
))
return
true
;
return
;
echo
gettext
(
"One moment while we reload the settings..."
);
echo
gettext
(
" done!"
)
.
"
\n
"
;
touch
(
'/tmp/assign_complete'
);
}
}
return
false
;
}
}
function
autodetect_interface
(
$ifname
,
$fp
)
function
autodetect_interface
(
$ifname
,
$fp
)
...
@@ -382,14 +376,12 @@ EOD;
...
@@ -382,14 +376,12 @@ EOD;
return
null
;
return
null
;
}
}
function
vlan_setup
()
function
vlan_setup
(
$iflist
,
$fp
)
{
{
global
$
iflist
,
$config
,
$fp
;
global
$
config
;
$yes_no_prompt
=
'[y|n]? '
;
$yes_no_prompt
=
'[y|n]? '
;
$iflist
=
get_interface_list
();
if
(
is_array
(
$config
[
'vlans'
][
'vlan'
])
&&
count
(
$config
[
'vlans'
][
'vlan'
]))
{
if
(
is_array
(
$config
[
'vlans'
][
'vlan'
])
&&
count
(
$config
[
'vlans'
][
'vlan'
]))
{
echo
<<<EOD
echo
<<<EOD
...
...
src/etc/inc/util.inc
View file @
daa5462f
...
@@ -1409,30 +1409,19 @@ function is_interface_mismatch()
...
@@ -1409,30 +1409,19 @@ function is_interface_mismatch()
$do_assign
=
false
;
$do_assign
=
false
;
$i
=
0
;
$i
=
0
;
$missing_interfaces
=
array
();
if
(
is_array
(
$config
[
'interfaces'
]))
{
if
(
is_array
(
$config
[
'interfaces'
]))
{
foreach
(
$config
[
'interfaces'
]
as
$ifname
=>
$ifcfg
)
{
foreach
(
$config
[
'interfaces'
]
as
$ifname
=>
$ifcfg
)
{
if
(
preg_match
(
"/^enc|^cua|^tun|^tap|^l2tp|^pptp|^ppp|^ovpn|^gif|^gre|^lagg|^bridge|vlan|_wlan/i"
,
$ifcfg
[
'if'
]))
{
if
(
preg_match
(
"/^enc|^cua|^tun|^tap|^l2tp|^pptp|^ppp|^ovpn|^gif|^gre|^lagg|^bridge|vlan|_wlan/i"
,
$ifcfg
[
'if'
]))
{
/
/ Do not check these interfaces.
/
* Do not check these interfaces */
$i
++
;
$i
++
;
continue
;
continue
;
}
}
elseif
(
does_interface_exist
(
$ifcfg
[
'if'
])
==
false
)
{
else
if
(
does_interface_exist
(
$ifcfg
[
'if'
])
==
false
)
{
$missing_interfaces
[]
=
$ifcfg
[
'if'
];
$do_assign
=
true
;
$do_assign
=
true
;
}
else
}
else
{
$i
++
;
$i
++
;
}
}
}
}
if
(
file_exists
(
'/tmp/assign_complete'
))
{
$do_assign
=
false
;
}
if
(
!
empty
(
$missing_interfaces
)
&&
$do_assign
)
{
file_put_contents
(
'/tmp/missing_interfaces'
,
implode
(
' '
,
$missing_interfaces
));
}
else
{
@
unlink
(
'/tmp/missing_interfaces'
);
}
}
return
$do_assign
;
return
$do_assign
;
...
...
src/etc/rc.bootup
View file @
daa5462f
...
@@ -139,22 +139,22 @@ echo "done.\n";
...
@@ -139,22 +139,22 @@ echo "done.\n";
* and ask the user to reassign interfaces. This will
* and ask the user to reassign interfaces. This will
* avoid a reboot and thats a good thing.
* avoid a reboot and thats a good thing.
*/
*/
while
(
is_interface_mismatch
()
==
true
)
{
if
(
is_interface_mismatch
())
{
led_assigninterfaces
();
echo
PHP_EOL
.
gettext
(
'Default interfaces not found -- Running interface assignment option.'
)
.
PHP_EOL
;
if
(
isset
(
$config
[
'revision'
]))
{
if
(
file_exists
(
'/tmp/missing_interfaces'
))
{
echo
"Warning: Configuration references interfaces that do not exist: "
.
file_get_contents
(
'/tmp/missing_interfaces'
)
.
"
\n
"
;
}
echo
"
\n
Network interface mismatch -- Running interface assignment option.
\n
"
;
}
else
echo
"
\n
Default interfaces not found -- Running interface assignment option.
\n
"
;
$ifaces
=
get_interface_list
();
$ifaces
=
get_interface_list
();
if
(
is_array
(
$ifaces
))
{
if
(
is_array
(
$ifaces
))
{
foreach
(
$ifaces
as
$iface
=>
$ifdata
)
foreach
(
$ifaces
as
$iface
=>
$ifdata
)
{
interfaces_bring_up
(
$iface
);
interfaces_bring_up
(
$iface
);
}
}
set_networking_interfaces_ports
();
}
$done
=
false
;
do
{
led_assigninterfaces
();
$done
=
set_networking_interfaces_ports
();
led_kitt
();
led_kitt
();
}
while
(
!
$done
);
}
}
/* convert config and clean backups */
/* convert config and clean backups */
...
...
src/etc/rc.initial.setports
View file @
daa5462f
...
@@ -37,6 +37,7 @@ require_once("vpn.inc");
...
@@ -37,6 +37,7 @@ require_once("vpn.inc");
require_once
(
"captiveportal.inc"
);
require_once
(
"captiveportal.inc"
);
require_once
(
"rrd.inc"
);
require_once
(
"rrd.inc"
);
set_networking_interfaces_ports
();
/* configure until valid */
while
(
!
set_networking_interfaces_ports
());
reload_interfaces_sync
();
reload_interfaces_sync
();
enable_rrd_graphing
();
enable_rrd_graphing
();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment