From ee88b48b764fd0252f2a6969688ee33bc25d39a3 Mon Sep 17 00:00:00 2001 From: "Buster \"Silver Eagle\" Neece" Date: Tue, 9 Jun 2020 05:10:07 -0500 Subject: [PATCH] Various tweaks to Ansible installs. --- install.sh | 57 +++---------------- update.sh | 40 ++----------- .../roles/azuracast-build/tasks/main.yml | 6 +- util/ansible/roles/dbip/tasks/main.yml | 2 +- 4 files changed, 19 insertions(+), 86 deletions(-) diff --git a/install.sh b/install.sh index 157d28d9d..f5c1b38f7 100644 --- a/install.sh +++ b/install.sh @@ -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" \ No newline at end of file +ansible-playbook util/ansible/deploy.yml --inventory=util/ansible/hosts --extra-vars "app_env=$APP_ENV" diff --git a/update.sh b/update.sh index a4f583538..5a610e329 100755 --- a/update.sh +++ b/update.sh @@ -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 diff --git a/util/ansible/roles/azuracast-build/tasks/main.yml b/util/ansible/roles/azuracast-build/tasks/main.yml index 70b27f7fb..0fd2ff97f 100644 --- a/util/ansible/roles/azuracast-build/tasks/main.yml +++ b/util/ansible/roles/azuracast-build/tasks/main.yml @@ -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" \ No newline at end of file + - "chown -R azuracast:www-data {{ www_base }}" + - "find {{ www_base }} -type d -exec chmod 755 {} \;" + - "find {{ www_base }} -type f -exec chmod 644 {} \;" \ No newline at end of file diff --git a/util/ansible/roles/dbip/tasks/main.yml b/util/ansible/roles/dbip/tasks/main.yml index c232bea96..95c044a9a 100644 --- a/util/ansible/roles/dbip/tasks/main.yml +++ b/util/ansible/roles/dbip/tasks/main.yml @@ -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"