#!/bin/bash -e echo "Please consider ./iiab-install instead of the lesser-supported ./runansible" PLAYBOOK="iiab.yml" INVENTORY="ansible_hosts" # Pass cmdline options for ansible ARGS="$@" # 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 # copy var files to /etc/iiab for subsequent use # If iiab.env exists, on second or upgrade run, check for stale variables # iiab.env gets created at the end of stage-4 on First Run if [ -f /etc/iiab/iiab.env ] then OLD=`grep XSCE /etc/iiab/iiab.env | wc -l` if [ "$OLD" -gt 0 ] then rm /etc/iiab/iiab.env else . /etc/iiab/iiab.env cd $IIAB_DIR fi else mkdir -p /etc/iiab echo "{}" > /etc/iiab/config_vars.yml fi CWD=`pwd` 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 [ ! -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 echo "Running local playbooks! " export ANSIBLE_LOG_PATH="$CWD/iiab-install.log" ansible -m setup -i $INVENTORY localhost --connection=local >> /dev/null ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local