Docker fixes for custom networks

This commit is contained in:
bergware
2018-02-27 02:45:40 +01:00
parent a1936ced0f
commit 3f1b65ecb8
3 changed files with 48 additions and 20 deletions

View File

@@ -37,8 +37,8 @@ if (file_exists($realfile)) {
}
}
unset($custom,$other);
exec("ls /sys/class/net|grep -P '^br[0-9]'",$custom);
exec("ls /sys/class/net|grep -P '^(bond|eth)[0-9]'",$other);
exec("ls --indicator-style=none /sys/class/net|grep -P '^br[0-9]'",$custom);
exec("ls --indicator-style=none /sys/class/net|grep -P '^(bond|eth)[0-9]'",$other);
foreach ($other as $network) {
if (substr($network,0,4)=='bond') {
$br = str_replace('bond','br',$network);
@@ -133,9 +133,10 @@ span.disabled{color:#404040}
<form markdown="1" id="settingsForm" name="settingsForm" method="POST" action="/update.php" target="progressFrame" onsubmit="prepareDocker(this)">
<input type="hidden" name="#file" value="<?=$docker_cfgfile?>">
<input type="hidden" name="#include" value="/plugins/dynamix.docker.manager/include/PruneConfig.php">
<input type="hidden" name="#command" value="/plugins/dynamix/scripts/emhttpd_update">
<input type="hidden" name="#cleanup" value="true">
<input type="hidden" name="DOCKER_CUSTOM_NETWORKS" value="<?=$dockercfg['DOCKER_CUSTOM_NETWORKS']?>">
<input type="hidden" name="DOCKER_CUSTOM_NETWORKS" value="<?=implode(' ',$unset)?>">
Enable Docker:
: <select id="DOCKER_ENABLED" name="DOCKER_ENABLED" class="narrow">
<?=mk_option($dockercfg['DOCKER_ENABLED'], 'no', 'No')?>
@@ -699,17 +700,6 @@ function customDHCP(id,ip) {
function changeCustom(id,ip) {
var checked = $('#'+id).prop('checked');
var device = id.substr(0,id.length-5).split('_').splice(2,2).join('.').toLowerCase();
var user = $('input:hidden[name="DOCKER_CUSTOM_NETWORKS"]');
if (ip==4) {
var other = $('#'+id.replace('CUSTOM','CUSTOM6')).prop('checked');
} else {
var other = $('#'+id.replace('CUSTOM6','CUSTOM')).prop('checked');
}
if (checked || other) {
if (user.val().indexOf(device)<0) user.val(user.val()+device+' ');
} else {
user.val(user.val().replace(device+' ',''));
}
id = '#'+id.substr(0,id.length-4);
$(id+'net').prop('disabled',!checked);
$(id+'mask').prop('disabled',!checked);

View File

@@ -0,0 +1,44 @@
<?PHP
/* Copyright 2005-2018, Lime Technology
* Copyright 2012-2018, Bergware International.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*/
?>
<?
function ports_only($key) {
return preg_match('/_(ETH|BR|BOND)[0-9]/',$key);
}
$ports = array_filter($_POST,'ports_only',ARRAY_FILTER_USE_KEY);
$purge = [];
foreach ($ports as $port => $val) {
$port = explode('_',$port,3)[2];
if (!in_array($port,$purge)) $purge[] = $port;
}
foreach ($purge as $port) {
switch (substr($port,0,2)) {
case 'ET':
$A1 = str_replace('ETH','BR',$port);
$A2 = str_replace('ETH','BOND',$port);
break;
case 'BR':
$A1 = str_replace('BR','ETH',$port);
$A2 = str_replace('BR','BOND',$port);
break;
case 'BO':
$A1 = str_replace('BOND','BR',$port);
$A2 = str_replace('BOND','ETH',$port);
break;
}
unset($keys["DOCKER_AUTO_$A1"], $keys["DOCKER_AUTO_$A2"]);
unset($keys["DOCKER_DHCP_$A1"], $keys["DOCKER_DHCP6_$A1"], $keys["DOCKER_DHCP_$A2"], $keys["DOCKER_DHCP6_$A2"]);
unset($keys["DOCKER_SUBNET_$A1"], $keys["DOCKER_SUBNET6_$A1"], $keys["DOCKER_SUBNET_$A2"], $keys["DOCKER_SUBNET6_$A2"]);
unset($keys["DOCKER_GATEWAY_$A1"], $keys["DOCKER_GATEWAY6_$A1"], $keys["DOCKER_GATEWAY_$A2"], $keys["DOCKER_GATEWAY6_$A2"]);
unset($keys["DOCKER_RANGE_$A1"], $keys["DOCKER_RANGE6_$A1"], $keys["DOCKER_RANGE_$A2"], $keys["DOCKER_RANGE6_$A2"]);
}
?>

View File

@@ -1,8 +1,2 @@
#!/bin/bash
# Invoked after docker image loopback mounted but before docker is started
if [[ -f /boot/config/docker.cfg ]]; then
. /boot/config/docker.cfg
# file deletion is disabled, not compatible with docker 18.02
# [[ "$DOCKER_USER_NETWORKS" != "preserve" ]] && rm -f /var/lib/docker/network/files/local-kv.db
fi