mirror of
https://github.com/unraid/webgui.git
synced 2026-01-05 17:20:04 -06:00
Docker / VM: avoid unnecessary writes to flash device
This commit is contained in:
@@ -48,9 +48,12 @@ $port = file_exists('/sys/class/net/br0') ? 'BR0' : (file_exists('/sys/class/net
|
||||
|
||||
// Docker configuration file - guaranteed to exist
|
||||
$docker_cfgfile = '/boot/config/docker.cfg';
|
||||
if (file_exists($docker_cfgfile) && exec("grep -Pom1 '_{$port}(_[0-9]+)?=' $docker_cfgfile")=='') {
|
||||
# interface has changed, update configuration
|
||||
exec("sed -ri 's/_(BR0|BOND0|ETH0)(_[0-9]+)?=/_{$port}\\2=/' $docker_cfgfile");
|
||||
if (file_exists($docker_cfgfile)) {
|
||||
exec("grep -Pom2 '_SUBNET_|_{$port}(_[0-9]+)?=' $docker_cfgfile",$cfg);
|
||||
if (isset($cfg[0]) && $cfg[0]=='_SUBNET_' && empty($cfg[1])) {
|
||||
# interface has changed, update configuration
|
||||
exec("sed -ri 's/_(BR0|BOND0|ETH0)(_[0-9]+)?=/_{$port}\\2=/' $docker_cfgfile");
|
||||
}
|
||||
}
|
||||
|
||||
$defaults = (array)@parse_ini_file("$docroot/plugins/dynamix.docker.manager/default.cfg");
|
||||
|
||||
@@ -47,7 +47,8 @@ if [[ -f $DOCKER_CFG ]]; then
|
||||
elif [[ -e $SYSTEM/${NIC/eth/bond} ]]; then
|
||||
NIC=${NIC/eth/bond}
|
||||
fi
|
||||
if ! grep -qPm1 "_${NIC^^}(_[0-9]+)?=" $DOCKER_CFG; then
|
||||
CFG=($(grep -Pom2 "_SUBNET_|_${NIC^^}(_[0-9]+)?=" $DOCKER_CFG))
|
||||
if [[ ${CFG[0]} == _SUBNET_ && -z ${CFG[1]} ]]; then
|
||||
# interface has changed, update configuration
|
||||
X=${NIC//[^0-9]/}
|
||||
sed -ri "s/_(BR|BOND|ETH)$X(_[0-9]+)?=/_${NIC^^}\2=/; s/(br|bond|eth)$X(\.[0-9]+)? /$NIC\2 /g" $DOCKER_CFG
|
||||
|
||||
@@ -180,16 +180,25 @@ libvirtd_start(){
|
||||
log "$DAEMON... Already started."
|
||||
return 1
|
||||
fi
|
||||
# convert libvirt 1.3.1 w/ eric's hyperv vendor id patch to how libvirt does it in libvirt 1.3.3+
|
||||
sed -ri "s/<vendor id='none'\/>/<vendor_id state='on' value='none'\/>/g" /etc/libvirt/qemu/*.xml 2>/dev/null
|
||||
# remove <locked/> from xml because libvirt + virlogd + virlockd has an issue with locked
|
||||
sed -ri "/<locked\/>/d" /etc/libvirt/qemu/*.xml 2>/dev/null
|
||||
# Remove "<watchdog model='itco' action='reset'/>" if reverting from later release.
|
||||
for file in /etc/libvirt/qemu/*.xml; do
|
||||
done
|
||||
. /etc/unraid-version
|
||||
[[ $(version $version) -le $(version "6.12") ]] && sed -ri "/<watchdog model='itco' action='reset'\/>/d" /etc/libvirt/qemu/*.xml 2>/dev/null
|
||||
[[ $(version $version) -le $(version "6.12") ]] && LEGACY=1 || LEGACY=
|
||||
# update interface section((s) of VM configuration files
|
||||
for XML in /etc/libvirt/qemu/*.xml; do
|
||||
[[ -f "$XML" ]] || continue
|
||||
if grep -qm1 "<vendor_id='none'/>" "$XML"; then
|
||||
# convert libvirt 1.3.1 w/ eric's hyperv vendor id patch to how libvirt does it in libvirt 1.3.3+
|
||||
sed -ri "s/<vendor id='none'\/>/<vendor_id state='on' value='none'\/>/g" "$XML"
|
||||
fi
|
||||
if grep -qm1 "<locked/>" "$XML"; then
|
||||
# remove <locked/> from xml because libvirt + virlogd + virlockd has an issue with locked
|
||||
sed -ri "/<locked\/>/d" "$file"
|
||||
fi
|
||||
if [[ -n $LEGACY ]] && grep -qm1 "<watchdog model='itco' action='reset'/>" "$XML"; then
|
||||
# Remove "<watchdog model='itco' action='reset'/>" if reverting from later release.
|
||||
sed -ri "/<watchdog model='itco' action='reset'\/>/d" "$XML"
|
||||
fi
|
||||
# get all interface sections
|
||||
ROW=($(grep -nhP '<interface type=' "$XML" | grep -Pom1 '^[0-9]+'))
|
||||
# get all source sections
|
||||
|
||||
Reference in New Issue
Block a user