diff --git a/host.service b/host.service new file mode 100644 index 0000000..8553ae1 --- /dev/null +++ b/host.service @@ -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 diff --git a/lsb.service b/lsb.service new file mode 100644 index 0000000..bcc70e3 --- /dev/null +++ b/lsb.service @@ -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 diff --git a/mem.service b/mem.service new file mode 100644 index 0000000..e8e25b8 --- /dev/null +++ b/mem.service @@ -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 diff --git a/net.service b/net.service new file mode 100644 index 0000000..430dbff --- /dev/null +++ b/net.service @@ -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 diff --git a/nproc.service b/nproc.service new file mode 100644 index 0000000..ee8df02 --- /dev/null +++ b/nproc.service @@ -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