This commit is contained in:
Olivier 2024-03-10 15:34:52 +01:00
parent 894e09ab0c
commit 64775066d6
5 changed files with 68 additions and 0 deletions

13
host.service Normal file
View File

@ -0,0 +1,13 @@
# 2024-03-04
[Unit]
Description=VM define env (host)NAME
Before=docker.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash -c 'echo "NAME=$(cat /etc/hostname)" > /etc/env/host'
ExecStart=/usr/bin/bash -c 'NAME=$(cat /etc/hostname) && echo "TITLE=$(tr \'[:lower:]\' \'[:upper:]\' <<< ${NAME:0:1})${NAME:1}" >> /etc/env/host'
[Install]
WantedBy=multi-user.target

14
lsb.service Normal file
View File

@ -0,0 +1,14 @@
# 2024-03-04
[Unit]
Description=VM define env LSB Infos
Before=docker.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash -c 'echo "DISTRIBUTOR=$( lsb_release -a |grep \'Distributor ID:\' |awk \'{print $3}\' )" > /etc/env/lsb'
ExecStart=/usr/bin/bash -c 'echo "RELEASE=$( lsb_release -a |grep \'Release\' |awk \'{print $2}\' )" >> /etc/env/lsb'
ExecStart=/usr/bin/bash -c 'echo "CODENAME=$( lsb_release -a |grep \'Codename\' |awk \'{print $2}\' )" >> /etc/env/lsb'
[Install]
WantedBy=multi-user.target

12
mem.service Normal file
View File

@ -0,0 +1,12 @@
# 2024-03-10
[Unit]
Description=VM define env MEM (Go)
Before=docker.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash -c 'MEMSIZE=$(LANG=en_US-8 && lsmem -b --summary=only | sed -ne "/online/s/.* //p" && LANG=fr_FR.UTF-8) && MEMSIZE=$(( MEMSIZE / 1024 / 1024 / 1024 )) && echo "MEMORY=$MEMSIZE" > /etc/env/memsize'
[Install]
WantedBy=multi-user.target

17
net.service Normal file
View File

@ -0,0 +1,17 @@
# 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

12
nproc.service Normal file
View File

@ -0,0 +1,12 @@
# 2024-03-04
[Unit]
Description=VM define env PROCESSORS
Before=docker.service
[Service]
Type=oneshot
ExecStart=/usr/bin/bash -c 'echo "PROCESSORS=$(nproc)" > /etc/env/nproc'
[Install]
WantedBy=multi-user.target