How to make /etc/sysconfig/network/route-eth0 static

@filippo_carletti; Thanks for your intervention.
I have sent you an email, I have updated your script but in the test VM, it had not done because there are a lot of problems to see before, look here:

I have specified you the steps (but it does not work in Cockpit, look all screenshots which show you errors) in previous links.
The goal is to integrate without any commands for users (installer, and cockpit)


Recall, 2 weeks ago: I have done several tests, I give you the process:

1/ Bug with Cockpit Dashboard Network: Impossible to select the good IP Address / Netmask / Gateway ( Validation failed: IP address can't be the network or broadcast address. ) and other options (there is only IP address / Netmask / Gateway / Label (optional)).

2/ Bug with the core: The /etc/sysconfig/network-scripts/route-ensXX1 manually route file is removed, I have found to add a “manual” action but it must be “automatic”.

In ESXI, for the NethServer VM:
2 virtual network cards, one for WAN with MAC Address, one for LAN.

Install NethServer “without connection”, after it, connect with root account in console.

WAN:

db networks set ensXX1 ethernet role red hwaddr AB:CD:EF:GH:IJ:KL
 ipaddr XXX.XXX.XXX.XXX netmask 255.255.255.255 gateway YYY.YYY.YYY.254
 onboot yes bootproto none nm_controlled no userctl no
 ipv6init no peerdns no arp yes
 name ensXX1 defroute yes

signal-event interface-update

LAN:

db networks set ensXX2 ethernet role green
 ipaddr 192.168.1.1 netmask 255.255.255.0 gateway 192.168.1.254
 name ensXX2

signal-event interface-update

There is a problem: ip route show:

default via 192.168.1.254 dev ensXX2
192.168.1.0/24 dev ensXX2 proto kernel scope link src 192.168.1.1

It is in the code:

I have done for ensXX1 configuration: defroute yes .

Now, I must to create an action, the ip route del default must not be in this file…

vi /etc/e-smith/events/actions/ovh-route

#!/bin/bash

ip route del default

GATEWAY_VM=YYY.YYY.YYY.254
INTERFACE=ensXX1

cat > /etc/sysconfig/network-scripts/route-$INTERFACE << EOF
$GATEWAY_VM dev $INTERFACE
default via $GATEWAY_VM dev $INTERFACE
EOF

ln -sf /etc/e-smith/events/actions/ovh-route /etc/e-smith/events/static-routes-save/S33ovh-route

chmod 0554 /etc/e-smith/events/static-routes-save/S33ovh-route
chown root:root /etc/e-smith/events/static-routes-save/S33ovh-route

signal-event interface-update

ip route show:

default via YYY.YYY.YYY.254 dev ensXX1
YYY.YYY.YYY.254 dev ensXX1 scope link
192.168.1.0/24 dev ensXX2 proto kernel scope link src 192.168.1.1

First Cockpit Dashboard connection:
→ FQDN
→ Organization settings
→ Updates