Initial tools.

This commit is contained in:
Edu4rdSHL 2021-03-14 00:58:19 -05:00
parent afe8bc8e54
commit b2115580a5
3 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,13 @@
# /etc/systemd/system/nspawn-generate-list.service
[Unit]
Description=Generate list of available machines for hub.nspawn.org
[Service]
Type=simple
WorkingDirectory=/var/www/html/storage
Restart=always
RestartSec=10
ExecStart=/usr/bin/nspawn-list-generator
[Install]
WantedBy=default.target

View file

@ -0,0 +1,10 @@
# /etc/systemd/system/nspawn-generate-list.timer
[Unit]
Description=Generate list of available images for hub.nspawn.org
[Timer]
OnUnitActiveSec=5m
[Install]
WantedBy=timers.target

7
nspawn-list-generator Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [ "$1" == "static" ]; then
find -maxdepth 3 -not -path '*/\.*' -not -empty -print |cut -c 3- |tr '/' ' ' |sort |awk 'NF == 3' |tr ' ' '/' | awk -F/ 'BEGIN {printf("%13s | %10s | %33s \n" ,"DISTRO", "VERSION", "INIT COMMAND")} {printf "%13s | %10s | nspawn -i %s/%s/%s\n", $1, $2, $1, $2, $3}' > list.txt
elif [ "$1" == "website" ]; then
find -maxdepth 3 -not -path '*/\.*' -not -empty -print |sort|cut -c 3- |tr '/' ' ' |awk 'NF == 3' |tr ' ' '/' | awk -F/ 'BEGIN {printf("| %13s | %10s | %25s | %20s |\n%13s | %10s | %25s | %20s |\n" ,"**Linux Distribution**", "**Version**", "**Init Command**", "**Download Link**", "--------------", "------------", "---------------------------", "--------------------")} {printf "| %13s | %10s | nspawn -i %s/%s/%s | [%s-%s](/storage/%s/%s/%s/image.%s.xz)|\n", toupper(substr($1,1,1))substr($1,2), $2, $1, $2, $3, $1, $3, $1, $2, $3, $3}'
fi