mirror of
https://github.com/iiab/iiab.git
synced 2025-02-13 11:42:08 +00:00
commit
93ca030861
1 changed files with 14 additions and 5 deletions
19
runrole
19
runrole
|
@ -5,6 +5,7 @@ LOCAL_VARS_FILE=/etc/iiab/local_vars.yml
|
||||||
IIAB_STATE_FILE=/etc/iiab/iiab_state.yml
|
IIAB_STATE_FILE=/etc/iiab/iiab_state.yml
|
||||||
ROLE_VAR=""
|
ROLE_VAR=""
|
||||||
INSTALL=false
|
INSTALL=false
|
||||||
|
ENABLED=false
|
||||||
REINSTALL=false
|
REINSTALL=false
|
||||||
CWD=`pwd`
|
CWD=`pwd`
|
||||||
ARGS="--extra-vars {" # bash forces {...} to '{...}' for Ansible, SEE BOTTOM
|
ARGS="--extra-vars {" # bash forces {...} to '{...}' for Ansible, SEE BOTTOM
|
||||||
|
@ -64,16 +65,24 @@ if $REINSTALL; then # Add '_' so '--reinstall calibre' doesn't zap calibreweb
|
||||||
grep "^${ROLE_VAR}_" $IIAB_STATE_FILE; echo
|
grep "^${ROLE_VAR}_" $IIAB_STATE_FILE; echo
|
||||||
sed -i "/^${ROLE_VAR}_/d" $IIAB_STATE_FILE
|
sed -i "/^${ROLE_VAR}_/d" $IIAB_STATE_FILE
|
||||||
else
|
else
|
||||||
echo -e "\e[1mERROR: $IIAB_STATE_FILE has no lines that begin with '${ROLE_VAR}_'\e[0m\n"
|
echo -e "\e[1mERROR: $IIAB_STATE_FILE has no line(s) that begin with '${ROLE_VAR}_'\e[0m\n"
|
||||||
echo -e "Try again without the '--reinstall' flag?\n"
|
echo -e "Try again without the '--reinstall' flag?\n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if grep -q "^${ROLE_VAR}_" $IIAB_STATE_FILE; then
|
if grep -q "^${ROLE_VAR}_" $IIAB_STATE_FILE; then
|
||||||
echo -e "\e[1mWARNING: $IIAB_STATE_FILE already has this/these line(s):\e[0m\n"
|
echo -e "\e[1mWARNING: $IIAB_STATE_FILE already has these line(s):\e[0m\n"
|
||||||
grep "^${ROLE_VAR}_" $IIAB_STATE_FILE; echo
|
grep "^${ROLE_VAR}_" $IIAB_STATE_FILE; echo
|
||||||
echo -e "To reinstall it, run: ./runrole --reinstall $1\n"
|
echo -e "If you prefer to reinstall it, run: ./runrole --reinstall $1\n"
|
||||||
echo -n "Or continue, e.g. to enable/disable it based on var '${ROLE_VAR}_enabled' ? [Y/n] "
|
|
||||||
|
grep -q "^${ROLE_VAR}_enabled:\s\+[Tt]rue\b" $DEFAULT_VARS_FILE && ENABLED=true
|
||||||
|
grep -q "^${ROLE_VAR}_enabled:\s\+[Ff]alse\b" $LOCAL_VARS_FILE && ENABLED=false
|
||||||
|
grep -q "^${ROLE_VAR}_enabled:\s\+[Tt]rue\b" $LOCAL_VARS_FILE && ENABLED=true
|
||||||
|
if $ENABLED; then
|
||||||
|
echo -n "Or just continue, to try to enforce var '${ROLE_VAR}_enabled: True' ? [Y/n] "
|
||||||
|
else
|
||||||
|
echo -n "Or just continue, to try to enforce var '${ROLE_VAR}_enabled: False' ? [Y/n] "
|
||||||
|
fi
|
||||||
read ans < /dev/tty
|
read ans < /dev/tty
|
||||||
echo
|
echo
|
||||||
[ "$ans" = "n" ] || [ "$ans" = "N" ] &&
|
[ "$ans" = "n" ] || [ "$ans" = "N" ] &&
|
||||||
|
@ -87,7 +96,7 @@ grep -q "^${ROLE_VAR}_install:\s\+[Tt]rue\b" $LOCAL_VARS_FILE && INSTALL=true
|
||||||
if ! $INSTALL; then
|
if ! $INSTALL; then
|
||||||
echo -e "\e[1m'${ROLE_VAR}_install: True' MUST BE SET!\e[0m\n"
|
echo -e "\e[1m'${ROLE_VAR}_install: True' MUST BE SET!\e[0m\n"
|
||||||
echo -e "Usually it's best to set variables in: $LOCAL_VARS_FILE\n"
|
echo -e "Usually it's best to set variables in: $LOCAL_VARS_FILE\n"
|
||||||
echo -n "Just for now, pass '${ROLE_VAR}_install: True' directly to Ansible? [Y/n] "
|
echo -n "Just for now, force '${ROLE_VAR}_install: True' directly to Ansible? [Y/n] "
|
||||||
read ans < /dev/tty
|
read ans < /dev/tty
|
||||||
echo
|
echo
|
||||||
[ "$ans" = "n" ] || [ "$ans" = "N" ] &&
|
[ "$ans" = "n" ] || [ "$ans" = "N" ] &&
|
||||||
|
|
Loading…
Reference in a new issue