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

cmdline tweeks

This commit is contained in:
Jerry Vonau 2019-10-16 10:37:33 -05:00
parent 29b28d8393
commit 36defde4ae
2 changed files with 44 additions and 13 deletions

View file

@ -4,11 +4,42 @@ INVENTORY="ansible_hosts"
PLAYBOOK="iiab-from-cmdline.yml"
CWD=`pwd`
APPS=/etc/iiab/config_vars2.yml
ENV=/etc/iiab/iiab.env
if [ ! -f $PLAYBOOK ]; then
echo "Exiting: IIAB Playbook not found."
echo "Please run this in /opt/iiab/iiab (top level of the git repo)."
echo -e "\nExiting: IIAB Playbook not found."
echo -e "\nPlease run this in /opt/iiab/iiab (top level of the git repo)."
exit 1
fi
if [ -f $ENV ]; then
STAGE=0
if grep -q STAGE= /etc/iiab/iiab.env ; then
source /etc/iiab/iiab.env
echo -e "\nExtracted STAGE="$STAGE" (counter) from /etc/iiab/iiab.env"
if ! [ "$STAGE" -eq "$STAGE" ] 2> /dev/null; then
echo -e "\nEXITING: STAGE (counter) value == "$STAGE" is non-integer"
exit 1
elif [ "$STAGE" -lt 0 ] || [ "$STAGE" -gt 9 ]; then
echo -e "\nEXITING: STAGE (counter) value == "$STAGE" is out-of-range"
exit 1
elif [ "$STAGE" -lt 3 ]; then
echo -e "\nEXITING: STAGE (counter) value == "$STAGE""
echo -e "\nIIAB stage 3 not complete"
echo -e "\nPlease run iiab-install"
exit 1
fi
else
echo -e "\nEXITING: STAGE (counter) not found"
echo -e "\nIIAB not installed"
echo -e "\nPlease run iiab-install"
exit 1
fi
else
echo -e "\nEXITING: /etc/iiab/iiab.env not found"
echo -e "\nIIAB not installed"
echo -e "\nPlease run iiab-install"
exit 1
fi
# workaround for image go away later
if grep -q sugar $APPS; then
if ! grep -q mongodb $APPS; then
echo "mongodb_installed: True" >> $APPS

22
runrole
View file

@ -4,6 +4,7 @@ INVENTORY="ansible_hosts"
PLAYBOOK="run-one-role.yml"
ARGS=""
CWD=`pwd`
APPS=/etc/iiab/config_vars2.yml
if [ ! -f $PLAYBOOK ]; then
echo "Exiting: IIAB Playbook not found."
echo "Please run this in /opt/iiab/iiab (top level of the git repo)."
@ -18,19 +19,25 @@ if [[ $# -eq 0 ]] ; then
exit 0
fi
# needed for stage 1-3 if not installed yet
if [ ! -f $APPS ]; then
mkdir -p /etc/iiab
touch $APPS
fi
if [ "$1" == "--reinstall" ]; then
ARGS="$ARGS --extra-vars reinstall=True"
if [ ! $2 == "internetarchive" ]; then # special handling
if [ $2 == "calibre-web" ]; then # role directory & installed marker differ
sed -i -e '/^calibreweb/d' /etc/iiab/config_vars2.yml
sed -i -e '/^calibreweb/d' $APPS
fi
if [ $2 == "captive-portal" ]; then # role directory & installed marker differ
sed -i -e '/^captiveportal/d' /etc/iiab/config_vars2.yml
sed -i -e '/^captiveportal/d' $APPS
fi
if [ $2 == "bluetooth" ]; then # role directory & installed marker differ
sed -i -e '/^pan_bluetooth/d' /etc/iiab/config_vars2.yml
sed -i -e '/^pan_bluetooth/d' $APPS
fi
sed -i -e "/^$2/d" /etc/iiab/config_vars2.yml
sed -i -e "/^$2/d" $APPS
fi
shift 1
fi
@ -41,12 +48,5 @@ else
export ANSIBLE_LOG_PATH="$CWD/iiab-debug.log"
fi
# Is the following stanza nec?
if [ ! -f /etc/iiab/config_vars2.yml ]; then
mkdir -p /etc/iiab
echo "{}" > /etc/iiab/config_vars2.yml
fi
ansible -m setup -i $INVENTORY localhost ${ARGS} --connection=local | grep python
ansible-playbook -i $INVENTORY $PLAYBOOK ${ARGS} --connection=local -e "role_to_run=$1"