mirror of
https://github.com/iiab/iiab.git
synced 2025-02-12 19:22:24 +00:00
90 lines
2.9 KiB
Bash
Executable file
90 lines
2.9 KiB
Bash
Executable file
#!/bin/bash -e
|
|
# running from a git repo
|
|
# Add cmdline options for passing to ansible
|
|
# todo add proper shift to gobble up --debug --reinstall
|
|
ARGS=""
|
|
OLD_RPI_KERN="4.9.41-v7+"
|
|
PLAYBOOK="iiab-stages.yml"
|
|
INVENTORY="ansible_hosts"
|
|
CWD=`pwd`
|
|
OS=`grep ^ID= /etc/*release|cut -d= -f2`
|
|
OS=${OS//\"/}
|
|
|
|
function version_gt() { [ "$(printf '%s\n' "$@" | sort -V | head -1)" != "$1" ]; }
|
|
|
|
export ANSIBLE_LOG_PATH="$CWD/iiab-install.log"
|
|
|
|
if [ ! -f $PLAYBOOK ]; then
|
|
echo "IIAB Playbook not found."
|
|
echo "Please run this command from the top level of the git repo."
|
|
echo "Exiting."
|
|
exit 1
|
|
fi
|
|
|
|
if [ $OS == "raspbian" ]; then
|
|
echo "Found Raspbian"
|
|
CURRENT_KERN=`uname -r`
|
|
if version_gt $CURRENT_KERN $OLD_RPI_KERN ; then
|
|
echo "Kernel looks ok - continuing"
|
|
else
|
|
echo "Kernel "$CURRENT_KERN" is too old. Before running './iiab-install' you first need"
|
|
echo "to update your system with 'apt update' then 'apt dist-upgrade' then reboot."
|
|
echo "INSTALL INSTRUCTIONS: https://github.com/iiab/iiab/wiki/IIAB-Installation"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [ ! -f /etc/ansible/facts.d/local_facts.fact ]; then
|
|
mkdir -p /etc/ansible/facts.d
|
|
fi
|
|
cp ./scripts/local_facts.fact /etc/ansible/facts.d/local_facts.fact
|
|
|
|
STAGE=""
|
|
|
|
if [ ! -f /etc/iiab/iiab.env ]; then
|
|
mkdir -p /etc/iiab
|
|
# ./scripts/ansible # needs discussion
|
|
else
|
|
OLD=`grep XSCE /etc/iiab/iiab.env | wc -l`
|
|
if [ "$OLD" != 0 ] || [ "$1" == "--reinstall" ]; then
|
|
echo "Found old XSCE install - re-installing from scratch"
|
|
rm /etc/iiab/iiab.env
|
|
# check ansible version here and force ansible upgrade if needed
|
|
else
|
|
source /etc/iiab/iiab.env
|
|
if [ "$1" == "--debug" ]; then
|
|
echo "Entering debug mode"
|
|
sed -i -e 's/^STAGE=.*/STAGE=2/' /etc/iiab/iiab.env
|
|
elif [ ! $STAGE == 9 ]; then
|
|
echo "Restarting *after* STAGE $STAGE..as soon as Stage 0 completes. Stage 9 comes last."
|
|
elif [ $STAGE == 9 ]; then
|
|
# place keeper add read response
|
|
# "offer 'Y' or stage number dialog box option to override"
|
|
echo "'iiab-install' has already been completed."
|
|
echo "Use --debug to override."
|
|
#echo "In demo mode not preventing second run"
|
|
echo "Exiting."
|
|
exit 1
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# if vars/local_vars.yml is missing, put a default one in place - First Run
|
|
if [ ! -f ./vars/local_vars.yml ]; then
|
|
case $OS in
|
|
OLPC | fedora)
|
|
cp ./vars/olpc.localvars ./vars/local_vars.yml
|
|
;;
|
|
centos | debian | ubuntu | raspbian)
|
|
cp ./vars/medium.localvars ./vars/local_vars.yml
|
|
;;
|
|
*)
|
|
echo "IIAB supports raspbian, debian, ubuntu, centos, and OLPC - exiting now..."
|
|
exit 1
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
echo "Running local playbooks!"
|
|
ansible -m setup -i $INVENTORY localhost --connection=local >> /dev/null
|
|
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local
|