#!/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="" PLAYBOOK="iiab-stages.yml" INVENTORY="ansible_hosts" CWD=`pwd` OS=`grep ^ID= /etc/*release|cut -d= -f2` OS=${OS//\"/} 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" REBOOT=`uname -a | grep 4.9.59-v7+ | wc -l` if [ $REBOOT != 1 ]; then echo "Please update your system with "apt update" then " echo ""apt dist-upgrade" and reboot to install latest kernel" exit 1 else echo "latest kernel installed - continuing" 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 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