#!/bin/bash -e # running from a git repo PLAYBOOK="iiab-steps.yml" INVENTORY="ansible_hosts" CWD=`pwd` # Add cmdline options for passing to ansible # todo add proper shift to gobble up --debug --reinstall ARGS="" export ANSIBLE_LOG_PATH="$CWD/iiab-install.log" 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 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 [ $STAGE == 9 ] && [ "$1" = "--debug" ]; then echo "Entering debug mode" sed -i -e 's/^STAGE=.*/STAGE=2/' /etc/iiab/iiab.env elif [ ! $STAGE == 9 ]; then echo "Restarting from STAGE $STAGE" else # 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 [ ! -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 vars/local_vars.yml is missing, put a default one in place - First Run if [ ! -f ./vars/local_vars.yml ]; then OS=`grep ^ID= /etc/*release|cut -d= -f2` OS=${OS//\"/} 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