systemd/net.service
2024-03-10 15:34:52 +01:00

18 lines
767 B
Desktop File

# 2024-03-04
[Unit]
Description=VM define env NET(work)
Before=docker.service
After=network-online.target
After=systemd-networkd-wait-online.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash -c 'IFACE=$(ip r |head -1 |awk \'{print $5}\') && echo "IFACE=$IFACE" > /etc/env/net'
ExecStart=/usr/bin/bash -c 'IFACE=$(ip r |head -1 |awk \'{print $5}\') && echo "SUBNET=$(ere_match_ip="[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" && read ip < <(grep -oP $ere_match_ip <<< $(ip r |grep $IFACE |head -1 |awk \'{print $3}\')) && echo $ip)" >> /etc/env/net'
ExecStart=/usr/bin/bash -c 'IFACE=$(ip r |head -1 |awk \'{print $5}\') && echo "IP=$(ip r |grep $IFACE |tail -1 |awk \'{print $9}\')" >> /etc/env/net'
[Install]
WantedBy=network-online.target
WantedBy=multi-user.target