Various tweaks to Ansible installs.

This commit is contained in:
Buster "Silver Eagle" Neece 2020-06-09 05:10:07 -05:00
parent abba7af8e5
commit ee88b48b76
No known key found for this signature in database
GPG key ID: 6D9E12FF03411F4E
4 changed files with 19 additions and 86 deletions

View file

@ -1,57 +1,16 @@
#!/usr/bin/env bash
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
ask() {
# https://djm.me/ask
local prompt default reply
while true; do
if [[ "${2:-}" = "Y" ]]; then
prompt="Y/n"
default=Y
elif [[ "${2:-}" = "N" ]]; then
prompt="y/N"
default=N
else
prompt="y/n"
default=
fi
# Ask the question (not using "read -p" as it uses stderr not stdout)
echo -n "$1 [$prompt] "
read reply
# Default?
if [[ -z "$reply" ]]; then
reply=${default}
fi
# Check if the reply is valid
case "$reply" in
Y*|y*) return 0 ;;
N*|n*) return 1 ;;
esac
done
}
while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do case $1 in
while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do
case $1 in
--dev)
APP_ENV="development"
shift
;;
esac; shift; done
esac
shift
done
if [[ "$1" == '--' ]]; then shift; fi
if ask "Use Docker installation method? (Recommended)" Y; then
bash docker.sh install
exit 0
fi
. /etc/lsb-release
if [[ $DISTRIB_ID != "Ubuntu" ]]; then
@ -59,7 +18,7 @@ if [[ $DISTRIB_ID != "Ubuntu" ]]; then
exit 0
fi
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' ansible|grep "install ok installed")
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' ansible | grep "install ok installed")
echo "Checking for Ansible: $PKG_OK"
if [[ "" == "$PKG_OK" ]]; then
@ -71,7 +30,7 @@ if [[ "" == "$PKG_OK" ]]; then
else
sudo add-apt-repository -y ppa:ansible/ansible
sudo apt-get update
sudo apt-get install -q -y python2.7 python-pip python-mysqldb ansible
fi
fi
@ -79,4 +38,4 @@ fi
APP_ENV="${APP_ENV:-production}"
echo "Installing AzuraCast (Environment: $APP_ENV)"
ansible-playbook util/ansible/deploy.yml --inventory=util/ansible/hosts --extra-vars "app_env=$APP_ENV"
ansible-playbook util/ansible/deploy.yml --inventory=util/ansible/hosts --extra-vars "app_env=$APP_ENV"

View file

@ -1,17 +1,11 @@
#!/usr/bin/env bash
release_update=0
while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do
case $1 in
--dev)
APP_ENV="development"
;;
-r | --release)
release_update=1
;;
--full)
UPDATE_REVISION=0
;;
@ -20,6 +14,9 @@ while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do
done
if [[ "$1" == '--' ]]; then shift; fi
APP_ENV="${APP_ENV:-production}"
UPDATE_REVISION="${UPDATE_REVISION:-55}"
PKG_OK=$(dpkg-query -W --showformat='${Status}\n' ansible | grep "install ok installed")
echo "Checking for Ansible: $PKG_OK"
@ -34,39 +31,14 @@ else
sudo apt-get install -q -y ansible python-mysqldb
fi
APP_ENV="${APP_ENV:-production}"
UPDATE_REVISION="${UPDATE_REVISION:-55}"
echo "Updating AzuraCast (Environment: $APP_ENV, Update revision: $UPDATE_REVISION)"
if [[ ${APP_ENV} == "production" ]]; then
if [[ -d ".git" ]]; then
if [[ $release_update == 1 ]]; then
current_hash=$(git rev-parse HEAD)
current_tag=$(git describe --abbrev=0 --tags)
git fetch --tags
latest_tag=$(git describe --abbrev=0 --tags)
git reset --hard
if [[ $current_tag == $latest_tag ]]; then
echo "You are already on the latest version (${current_tag})!"
else
echo "Updating codebase from ${current_tag} to ${latest_tag}..."
git pull
git reset --hard $latest_tag
fi
else
echo "Updating to the latest rolling-release version..."
echo "Tip: use the '--release' flag to update to tagged releases only."
git reset --hard
git pull
fi
git reset --hard
git pull
else
echo "You are running a release build. Any code updates should be applied manually."
echo "You are running a downloaded release build. Any code updates should be applied manually."
fi
fi

View file

@ -27,6 +27,8 @@
chdir: "{{ www_base }}/frontend"
- name: Set permissions of generated frontend content
file: path="{{ item }}" state=directory recurse=yes owner=azuracast group=www-data
shell: "{{ item }}"
with_items:
- "{{ www_base }}/web/static/dist"
- "chown -R azuracast:www-data {{ www_base }}"
- "find {{ www_base }} -type d -exec chmod 755 {} \;"
- "find {{ www_base }} -type f -exec chmod 644 {} \;"

View file

@ -5,7 +5,7 @@
dest: "{{ app_base }}/dbip/dbip-city-lite.mmdb.gz"
- name: Extract DBIP Database
shell: "gunzip dbip-city-lite.mmdb.gz"
shell: "gunzip -f dbip-city-lite.mmdb.gz"
args:
chdir: "{{ app_base }}/dbip"