mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 03:32:12 +00:00
ee4df858b3
* move reboot early in install process for rpi9 only * sed regular expression, add space above message * has awk but not gawk * add in download of wifi driver - raspbian-9
106 lines
2.6 KiB
Bash
Executable file
106 lines
2.6 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# copy var files to /etc/iiab for subsequent use
|
|
mkdir -p /etc/iiab
|
|
if [ ! -f /etc/iiab/config_vars.yml ]; then
|
|
echo "{}" > /etc/iiab/config_vars.yml
|
|
fi
|
|
|
|
# if vars/local_vars.yml is missing, put a default one in place
|
|
if [ ! -f ./vars/local_vars.yml ]; then
|
|
OS=`grep ^ID= /etc/*release|cut -d= -f2`
|
|
OS=${OS//\"/}
|
|
|
|
case $OS in
|
|
OLPC)
|
|
cp ./vars/olpc.localvars ./vars/local_vars.yml
|
|
;;
|
|
fedora)
|
|
cp ./vars/olpc.localvars ./vars/local_vars.yml
|
|
;;
|
|
centos)
|
|
cp ./vars/centos.localvars ./vars/local_vars.yml
|
|
;;
|
|
debian)
|
|
cp ./vars/debian.localvars ./vars/local_vars.yml
|
|
;;
|
|
ubuntu)
|
|
cp ./vars/debian.localvars ./vars/local_vars.yml
|
|
;;
|
|
raspbian)
|
|
cp ./vars/debian.localvars ./vars/local_vars.yml
|
|
;;
|
|
*)
|
|
echo "Unknown OS -- no matching os.localvars -- exiting now..."
|
|
exit 0
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
if [ -f /etc/iiab/iiab.env ]
|
|
then
|
|
. /etc/iiab/iiab.env
|
|
cd $XSCE_DIR
|
|
else
|
|
XSCE_DIR=/opt/iiab/iiab
|
|
fi
|
|
|
|
if [ ! -f iiab.yml ]
|
|
then
|
|
echo "IIAB Playbook not found."
|
|
echo "Please run this command from the top level of the git repo."
|
|
echo "Exiting."
|
|
exit
|
|
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
|
|
|
|
# raspbian-9 changes network interface names to include mac address
|
|
# which defeats copying an image from one SD card to another
|
|
raspbian_ver=`./scripts/local_facts.fact|grep os_ver|awk -F '"' '{print $4}'`
|
|
if [ "$raspbian_ver" == "raspbian-9" ]; then
|
|
grep net.ifnames=0 /boot/cmdline.txt
|
|
if [ $? -ne 0 ]; then
|
|
sed -i -r 's/deadline +fsck/deadline net.ifnames=0 fsck/' /boot/cmdline.txt
|
|
echo
|
|
echo "Kernel cmdline changed. Will now reboot so that network interface names will"
|
|
echo " be same for all raspberry pi\'s. Hit enter, and then restart this script"
|
|
read var
|
|
reboot
|
|
fi
|
|
fi
|
|
|
|
PLAYBOOK="iiab.yml"
|
|
INVENTORY="ansible_hosts"
|
|
CWD=`pwd`
|
|
echo "Running local playbooks! "
|
|
|
|
XSDOMAIN=""
|
|
|
|
# Pass in Existing Domain
|
|
if [ -f /etc/sysconfig/xs_domain_name ]
|
|
then
|
|
XSDOMAIN=`cat /etc/sysconfig/xs_domain_name`
|
|
fi
|
|
|
|
# Or accept Domain on command line
|
|
if [ x"$1" != x ]
|
|
then
|
|
XSDOMAIN=$1
|
|
fi
|
|
|
|
# Pass in git location
|
|
if [ x"$XSDOMAIN" != x ]
|
|
then
|
|
ARGS="--extra-vars '{\"iiab_domain\":\"$XSDOMAIN\"}'"
|
|
else
|
|
ARGS=""
|
|
fi
|
|
|
|
export ANSIBLE_LOG_PATH="$XSCE_DIR/iiab-install.log"
|
|
ansible -m setup -i $INVENTORY localhost --connection=local >> /dev/null
|
|
|
|
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local
|