1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/scripts/local_facts.fact

93 lines
2.2 KiB
Text
Raw Normal View History

2017-05-27 18:09:50 +00:00
#!/bin/bash
# upgrades return found, clean installs return 0
# interruptions return last stage number recorded (1-9)
if [ -f /etc/iiab/iiab.env ]; then
source /etc/iiab/iiab.env
STAGE=$STAGE
else
STAGE=0
fi
OS=`grep ^ID= /etc/*elease|cut -d= -f2`
2017-05-27 18:09:50 +00:00
OS=${OS//\"/}
VERSION_ID=`grep VERSION_ID /etc/*elease | cut -d= -f2`
VERSION_ID=${VERSION_ID//\"/}
VERSION_ID=${VERSION_ID%%.*}
OS_VER=$OS-$VERSION_ID
2017-11-19 03:08:11 +00:00
DHCPCD_PATH=`which dhcpcd`
2017-11-23 02:38:46 +00:00
NM_PATH=`which NetworkManager`
2017-05-27 18:09:50 +00:00
case $OS_VER in
2019-03-23 11:58:35 +00:00
"fedora-18" | \
"fedora-22" | \
"debian-8" | \
"debian-9" | \
"debian-10" | \
"ubuntu-16" | \
"ubuntu-17" | \
"ubuntu-18" | \
"ubuntu-19" | \
2020-03-15 07:10:27 +00:00
"ubuntu-20" | \
2019-03-23 11:58:35 +00:00
"centos-7" | \
"raspbian-8" | \
"raspbian-9" | \
"raspbian-10")
;;
*) OS_VER="OS_not_supported"
;;
esac
2017-05-27 18:09:50 +00:00
# get current version
BRANCH=`git rev-parse --abbrev-ref HEAD`
COMMIT=`git rev-parse --verify HEAD`
if [ -d /usr/lib64/php ]; then
PHPLIB_DIR=/usr/lib64/php
2017-05-27 18:09:50 +00:00
else
if [ -d /usr/lib/php5 ]; then
PHPLIB_DIR=/usr/lib/php5
else
PHPLIB_DIR=/usr/lib/php
fi
2017-05-27 18:09:50 +00:00
fi
if [ -f /proc/device-tree/mfg-data/MN ]; then
XO_VERSION=`cat /proc/device-tree/mfg-data/MN`
2017-05-27 18:09:50 +00:00
else
XO_VERSION="none"
2017-05-27 18:09:50 +00:00
fi
2020-03-04 23:02:01 +00:00
if [ -f /proc/device-tree/model ]; then
RPI_VERSION=`cat /proc/device-tree/model`
else
RPI_VERSION="none"
fi
2017-05-27 18:09:50 +00:00
ANSIBLE_VERSION=$(ansible --version|head -n 1|cut -f 2 -d " ")
2017-11-19 03:08:11 +00:00
if [ ! x$DHCPCD_PATH = x ]; then
DHCPCD=`systemctl is-enabled dhcpcd`
2017-11-19 03:08:11 +00:00
fi
2017-11-23 02:38:46 +00:00
# the check is debian family only is_redhad would use NetworkManager as the
# service name.
if [ ! x$NM_PATH = x ]; then
NM=`systemctl is-enabled network-manager`
2017-11-23 02:38:46 +00:00
fi
SYSD_NETD=`systemctl is-enabled systemd-networkd`
2017-05-27 18:09:50 +00:00
cat <<EOF
{"phplib_dir" : "$PHPLIB_DIR",
2017-10-28 16:31:32 +00:00
"stage" : "$STAGE",
"dhcpcd" : "$DHCPCD",
2017-11-23 02:38:46 +00:00
"network_manager" : "$NM",
"systemd_networkd" : "$SYSD_NETD",
"iiab_branch" : "$BRANCH",
"iiab_commit" : "$COMMIT",
2017-05-27 18:09:50 +00:00
"xo_model" : "$XO_VERSION",
2020-03-04 23:02:01 +00:00
"rpi_model" : "$RPI_VERSION",
"ansible_version" : "$ANSIBLE_VERSION",
2017-05-27 18:09:50 +00:00
"os" : "$OS",
2017-07-04 22:39:45 +00:00
"os_ver" : "$OS_VER"}
2017-05-27 18:09:50 +00:00
EOF