fabrica/packer/provisioning/eole/onecontext/net-99-eole

36 lines
1.2 KiB
Bash

#!/usr/bin/env bash
source /etc/one-context.d/loc-10-network
function CreoleForce {
name=$1
value=$2
jq -a ".$name = {\"owner\": \"creole_force\", \"val\": $value}" /etc/eole/config.eol > /etc/eole/config.eol.force
[ $? == 0 ] && mv -f /etc/eole/config.eol.force /etc/eole/config.eol
rm -f /etc/eole/config.eol.force
}
rm -f /etc/eole/config.eol.bak
cp -f /etc/eole/config.eol /etc/eole/config.eol.bak
CONTEXT_INTERFACES=$(get_context_interfaces)
for interface in $CONTEXT_INTERFACES; do
IFACE_NUM=$(echo "$UPCASE_DEV" | sed 's/^ETH//')
IP=$(get_ip)
NETWORK=$(get_network)
MASK=$(get_mask)
GATEWAY=$(get_gateway)
DNS=$(get_iface_var "DNS")
CreoleForce "eth${IFACE_NUM}_method" '"statique"'
[ "$GATEWAY" != "None" ] && CreoleForce "adresse_ip_gw" "\"$GATEWAY\""
[ "$GATEWAY" != "None" ] && CreoleForce "adresse_broadcast_eth$IFACE_NUM" "\"$GATEWAY\""
[ "$MASK" != "None" ] && CreoleForce "adresse_netmask_eth$IFACE_NUM" "\"$MASK\""
[ "$NETWORK" != "None" ] && CreoleForce "adresse_network_eth$IFACE_NUM" "\"$NETWORK\""
[ "$IP" != "None" ] && CreoleForce "adresse_ip_eth$IFACE_NUM" "\"$IP\""
[ "$DNS" != "None" ] && CreoleForce "adresse_ip_dns" "[\"$DNS\"]"
done