do not set UUID

+ other fixes
This commit is contained in:
2021-04-27 14:10:39 +02:00
parent 8daa8ba6c3
commit 147bd4efa5
7 changed files with 17 additions and 40 deletions

View File

@ -10,7 +10,7 @@ import shutil
from glob import glob from glob import glob
from ipaddress import IPv4Interface from ipaddress import IPv4Interface
from configparser import ConfigParser from configparser import ConfigParser
from os.path import join, getmtime, exists from os.path import join, getmtime, exists, basename
os.chdir('/root/aputools/to_system') os.chdir('/root/aputools/to_system')
@ -41,7 +41,6 @@ def create_if(name, cfg, mac):
PROXY_METHOD='none', PROXY_METHOD='none',
BROWSER_ONLY='no', BROWSER_ONLY='no',
IPV4_FAILURE_FATAL='yes', IPV4_FAILURE_FATAL='yes',
UUID='58d61ced-05d2-4726-a8f7-%s' % ''.join(mac.split(':')),
IPV6INIT='no') IPV6INIT='no')
if cfg == 'off': if cfg == 'off':
result['ONBOOT']='no' result['ONBOOT']='no'
@ -154,7 +153,7 @@ def network(doit):
for ntry in range(1 + bool(doit)): for ntry in range(1 + bool(doit)):
with open('/etc/hostname') as f: with open('/etc/hostname') as f:
hostname = f.read().strip() hostname = f.read().strip()
if hostname == cfgfile[:-7]: # stripped apuid from cfgfile if cfgfile == CFGPATH % ('%s_%6.6x' % (hostname, apuid)):
break break
if doit: if doit:
if ntry == 0: if ntry == 0:
@ -163,7 +162,9 @@ def network(doit):
print('ERROR: can not set host name') print('ERROR: can not set host name')
return False return False
else: else:
print('host name does not match') if cfgfile:
print('host name does not match %r -> %r' % (hostname, basename(cfgfile).rpartition('_')[0]))
show.dirty = True
break break
if cfgfile is None: if cfgfile is None:
return False return False
@ -178,6 +179,7 @@ def network(doit):
todo = write_when_new('/etc/sysconfig/network-scripts/ifcfg-%s' % ifname, content, doit) todo = write_when_new('/etc/sysconfig/network-scripts/ifcfg-%s' % ifname, content, doit)
if todo: if todo:
print('change ', ifname) print('change ', ifname)
show.dirty = True
except Exception as e: except Exception as e:
print('ERROR: can not handle %s %s: %r' % (hostname, ifname, e)) print('ERROR: can not handle %s %s: %r' % (hostname, ifname, e))
return False return False

View File

@ -1,9 +1,9 @@
[NETWORK] [NETWORK]
address=00:0d:b9:59:1f:ac address=00:0d:b9:59:1f:ac
enp1s0=dhcp enp1s0=192.168.127.1/24
enp2s0=192.168.2.1/24 enp2s0=192.168.2.1/24
enp3s0=192.168.3.1/24 enp3s0=192.168.3.1/24
enp4s0=192.168.127.1/24 enp4s0=dhcp
[ROUTER] [ROUTER]
3000=/dev/ttyUSB0 3000=/dev/ttyUSB0

View File

@ -1,10 +1,14 @@
ETHNAME=$(cat /sys/class/net/enp1s0/address) ETHNAME=$(cat /sys/class/net/enp1s0/address)
FOUND=$(grep -H address=$ETHNAME /root/aputools/servercfg/*.cfg) ETHNAME=${ETHNAME//:/}
APUID=${ETHNAME: -6}
FOUND=( /root/aputools/servercfg/*_$APUID.cfg )
if [ -z "$FOUND" ]; then if [ -z "$FOUND" ]; then
ETHNAME=${ETHNAME//:/} HOSTNAME=apu$APUID
HOSTNAME=apu${ETHNAME:6:6}
else else
FOUND=$(basename $FOUND) # remove directory part FOUND=$(basename ${FOUND[0]}) # remove directory part
HOSTNAME=${FOUND%%.*} # remove extension and all the rest HOSTNAME=${FOUND%%.*} # remove extension
if [ $HOSTNAME != "apu$APUID" ]; then
HOSTNAME=${HOSTNAME%_*}
fi
fi fi
echo $HOSTNAME > /etc/hostname echo $HOSTNAME > /etc/hostname

View File

@ -1,8 +0,0 @@
TYPE=Ethernet
NAME=enp1s0
DEVICE=enp1s0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.2.1
NETMASK=255.255.255.0
PREFIX=24

View File

@ -1,8 +0,0 @@
TYPE=Ethernet
NAME=enp2s0
DEVICE=enp2s0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.2.2
NETMASK=255.255.255.0
PREFIX=24

View File

@ -1,8 +0,0 @@
TYPE=Ethernet
NAME=enp3s0
DEVICE=enp3s0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.2.3
NETMASK=255.255.255.0
PREFIX=24

View File

@ -1,5 +0,0 @@
TYPE=Ethernet
NAME=enp4s0
DEVICE=enp4s0
BOOTPROTO=dhcp
ONBOOT=yes