2017-05-27 18:09:50 +00:00
|
|
|
#!/bin/bash
|
2018-04-28 16:27:32 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2017-07-04 20:07:47 +00:00
|
|
|
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
|
2017-07-04 20:07:47 +00:00
|
|
|
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
|
|
|
|
2017-07-04 20:07:47 +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")
|
2018-04-28 16:27:32 +00:00
|
|
|
;;
|
|
|
|
*) OS_VER="OS_not_supported"
|
2017-07-04 20:07:47 +00:00
|
|
|
;;
|
|
|
|
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`
|
|
|
|
|
2018-04-28 16:27:32 +00:00
|
|
|
if [ -d /usr/lib64/php ]; then
|
|
|
|
PHPLIB_DIR=/usr/lib64/php
|
2017-05-27 18:09:50 +00:00
|
|
|
else
|
2018-04-28 16:27:32 +00:00
|
|
|
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
|
|
|
|
|
2018-04-28 16:27:32 +00:00
|
|
|
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
|
2018-04-28 16:27:32 +00:00
|
|
|
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
|
|
|
|
2018-04-28 16:27:32 +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.
|
2018-04-28 16:27:32 +00:00
|
|
|
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",
|
2017-11-10 19:01:22 +00:00
|
|
|
"dhcpcd" : "$DHCPCD",
|
2017-11-23 02:38:46 +00:00
|
|
|
"network_manager" : "$NM",
|
|
|
|
"systemd_networkd" : "$SYSD_NETD",
|
2017-06-09 23:25:56 +00:00
|
|
|
"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",
|
2017-11-10 19:01:22 +00:00
|
|
|
"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-07-04 20:07:47 +00:00
|
|
|
|
2017-05-27 18:09:50 +00:00
|
|
|
EOF
|