Initial commit for infra daily scripts

We added a script fbsdinfo2csv.sh that should be run as root which
prints a CSV output with the following format
name,type,hostname,freebsd-version,ipaddr
This commit is contained in:
Charlie Root
2023-02-17 11:23:36 -05:00
commit ab33bcb45a
2 changed files with 36 additions and 0 deletions

12
README.md Normal file
View File

@ -0,0 +1,12 @@
# Daily Scripts
## fbsdinfo2csv.sh
this script will generate a csv file from the host and its jails.
The output looks like this
```csv
name,type,hostname,freebsd-version,ipaddr
dev3.bts.djb0,host,dev3.bts.djb0,12.3-RELEASE,10.35.0.203
jail10,jail,jail0,jail10.dev3.bts.djb0,12.2-RELEASE,10.35.0.200
```

24
fbsdinfo2csv.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/sh
printf "name,type,hostname,freebsd-version,ipaddr\n"
host_name=$(hostname)
_type="host"
_host_version=$(freebsd-version)
_ipaddress=$(ifconfig | grep 'inet ' | grep -v '127.0.0.1' | cut -w -f 3)
echo "${host_name},${_type},${host_name},${_host_version},${_ipaddress}"
_type="jail"
for j in $(jls name)
do
name="${j}"
host_name="$(jls -j ${j} host.hostname)"
_ipaddress="$(jexec ${j} ifconfig | grep 'inet ' | grep -v '127.0.0.1' | cut -w -f 3)"
_jail_version="$(jexec ${j} freebsd-version)"
echo "${host_name},${_type},${host_name},${_jail_version},${_ipaddress}"
done