1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-12 11:12:06 +00:00
iiab/iiab-install

88 lines
2.7 KiB
Text
Raw Normal View History

2017-10-30 18:05:19 +00:00
#!/bin/bash -e
# running from a git repo
# Add cmdline options for passing to ansible
# todo add proper shift to gobble up --debug --reinstall
2017-10-30 18:05:19 +00:00
ARGS=""
2017-11-05 04:33:15 +00:00
PLAYBOOK="iiab-stages.yml"
INVENTORY="ansible_hosts"
CWD=`pwd`
OS=`grep ^ID= /etc/*release|cut -d= -f2`
OS=${OS//\"/}
2017-10-30 18:05:19 +00:00
export ANSIBLE_LOG_PATH="$CWD/iiab-install.log"
2017-11-05 04:41:41 +00:00
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
2017-11-05 04:33:15 +00:00
if [ $OS = "raspbian" ]; then
echo "found"
REBOOT=`uname -a | grep 4.9.59-v7+ | wc -l`
if [ $REBOOT != 1 ]; then
2017-11-05 04:53:44 +00:00
echo "Please update your system with "apt update" then "
echo ""apt dist-upgrade" and reboot to install latest kernel"
2017-11-05 04:33:15 +00:00
exit 1
else
echo "latest kernel installed - continuing"
fi
fi
2017-10-30 18:05:19 +00:00
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
2017-11-05 04:53:44 +00:00
./scripts/ansible
else
2017-10-30 18:05:19 +00:00
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
2017-11-02 04:45:38 +00:00
if [ "$1" = "--debug" ]; then
2017-10-30 18:05:19 +00:00
echo "Entering debug mode"
sed -i -e 's/^STAGE=.*/STAGE=2/' /etc/iiab/iiab.env
elif [ ! $STAGE == 9 ]; then
2017-10-31 04:45:45 +00:00
echo "Restarting *after* STAGE $STAGE..as soon as Stage 0 completes. Stage 9 comes last."
2017-11-02 04:45:38 +00:00
elif [ $STAGE == 9 ]; then
2017-10-30 18:05:19 +00:00
# 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"
2017-10-30 20:19:09 +00:00
echo "Exiting."
exit 1
2017-10-30 18:05:19 +00:00
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)
2017-11-05 16:03:17 +00:00
cp ./vars/olpc.localvars ./vars/local_vars.yml
;;
2017-10-30 18:05:19 +00:00
centos | debian | ubuntu | raspbian)
2017-11-05 16:03:17 +00:00
cp ./vars/medium.localvars ./vars/local_vars.yml
;;
2017-10-30 18:05:19 +00:00
*)
2017-11-05 16:03:17 +00:00
echo "IIAB supports raspbian, debian, ubuntu, centos, and OLPC - exiting now..."
exit 1
;;
2017-10-30 18:05:19 +00:00
esac
fi
echo "Running local playbooks! "
ansible -m setup -i $INVENTORY localhost --connection=local >> /dev/null
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local