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

100 lines
2.3 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//\"/}
2020-05-29 16:59:28 +00:00
if [ -f /etc/rpi-issue ]; then
OS="raspbian"
fi
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
# Previously supported Linux distributions / versions:
#"fedora-18" | \
#"fedora-22" | \
#"debian-8" | \
#"debian-9" | \
#"ubuntu-16" | \
#"ubuntu-17" | \
#"ubuntu-18" | \
#"ubuntu-19" | \
#"centos-7" | \
#"raspbian-8" | \
#"raspbian-9" | \
case $OS_VER in
"debian-10" | \
"ubuntu-20" | \
"linuxmint-20" | \
2019-03-23 11:58:35 +00:00
"raspbian-10")
2020-08-20 16:51:17 +00:00
;;
*) OS_VER="OS_not_supported"
;;
esac
2020-08-20 16:51:17 +00:00
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
2020-08-20 16:51:17 +00:00
# the check is debian family only is_redhat would use NetworkManager as the
2017-11-23 02:38:46 +00:00
# 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