mirror of
https://github.com/unraid/webgui.git
synced 2026-05-04 16:59:27 -05:00
New vhost network for both containers and VMs
This commit is contained in:
@@ -47,13 +47,13 @@ $host = ipaddr($ethX);
|
||||
$driver = DockerUtil::driver();
|
||||
|
||||
// determine active port name
|
||||
$port = file_exists('/sys/class/net/br0') ? 'BR' : (file_exists('/sys/class/net/bond0') ? 'BOND' : 'ETH');
|
||||
$port = file_exists('/sys/class/net/br0') ? 'BR0' : (file_exists('/sys/class/net/bond0') ? 'BOND0' : 'ETH0');
|
||||
|
||||
// Docker configuration file - guaranteed to exist
|
||||
$docker_cfgfile = '/boot/config/docker.cfg';
|
||||
if (file_exists($docker_cfgfile) && exec("grep -Pom1 '_{$port}[0-9]+(_[0-9]+)?=' $docker_cfgfile")=='') {
|
||||
if (file_exists($docker_cfgfile) && exec("grep -Pom1 '_{$port}(_[0-9]+)?=' $docker_cfgfile")=='') {
|
||||
# interface has changed, update configuration
|
||||
exec("sed -ri 's/_(BR|BOND|ETH)([0-9]+(_[0-9]+)?)=/_{$port}\\2=/' $docker_cfgfile");
|
||||
exec("sed -ri 's/_(BR0|BOND0|ETH0)(_[0-9]+)?=/_{$port}\\2=/' $docker_cfgfile");
|
||||
}
|
||||
|
||||
$defaults = @parse_ini_file("$docroot/plugins/dynamix.docker.manager/default.cfg") ?: [];
|
||||
|
||||
+5
-6
@@ -33,11 +33,10 @@ TMP=/var/tmp/network.tmp
|
||||
|
||||
# Set defaults used by the docker daemon
|
||||
if [[ -f $DOCKER_CFG ]]; then
|
||||
INT=${PORT:0:-1}
|
||||
if ! grep -qPm1 "_${INT^^}[0-9]+(_[0-9]+)?=" $DOCKER_CFG; then
|
||||
if ! grep -qPm1 "_${PORT^^}(_[0-9]+)?=" $DOCKER_CFG; then
|
||||
# interface has changed, update configuration
|
||||
sed -ri "s/_(BR|BOND|ETH)([0-9]+(_[0-9]+)?)=/_${INT^^}\2=/" $DOCKER_CFG
|
||||
sed -ri "s/(br|bond|eth)([0-9]+\.[0-9]+ )/$INT\2/g" $DOCKER_CFG
|
||||
sed -ri "s/_(BR0|BOND0|ETH0)(_[0-9]+)?=/_${PORT^^}\2=/" $DOCKER_CFG
|
||||
sed -ri "s/(br0|bond0|eth0)(\.[0-9]+ )/$PORT\2/g" $DOCKER_CFG
|
||||
fi
|
||||
# Read (updated) unRAID docker configuration file
|
||||
. $DOCKER_CFG
|
||||
@@ -238,9 +237,9 @@ start_network(){
|
||||
if [[ -n $XMLFILE ]]; then
|
||||
REBUILD=
|
||||
# update custom network reference (if changed)
|
||||
REF=$(grep -Pom1 '<Network>\K(br|bond|eth)[0-9]' $XMLFILE)
|
||||
REF=$(grep -Pom1 '<Network>\K(br0|bond0|eth0)' $XMLFILE)
|
||||
if [[ -n $REF && $REF != $PORT ]]; then
|
||||
sed -ri "s/<Network>(br|bond|eth)([0-9]+(.[0-9]+)?)<\/Network>/<Network>${PORT:0:-1}\2<\/Network>/" $XMLFILE
|
||||
sed -ri "s/<Network>(br0|bond0|eth0)(\.[0-9]+)?<\/Network>/<Network>$PORT\2<\/Network>/" $XMLFILE
|
||||
# flag container for later rebuild
|
||||
REBUILD=1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user