2016-05-17 03:31:02 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-02-21 18:48:43 +00:00
|
|
|
while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do
|
2021-01-21 20:37:21 +00:00
|
|
|
case $1 in
|
|
|
|
--dev)
|
|
|
|
APP_ENV="development"
|
|
|
|
;;
|
|
|
|
|
|
|
|
--full)
|
|
|
|
UPDATE_REVISION=0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
2020-02-21 18:48:43 +00:00
|
|
|
done
|
2018-12-18 04:23:52 +00:00
|
|
|
if [[ "$1" == '--' ]]; then shift; fi
|
2016-09-14 00:17:21 +00:00
|
|
|
|
2021-02-06 21:25:33 +00:00
|
|
|
. /etc/lsb-release
|
2020-06-09 10:10:07 +00:00
|
|
|
|
2021-02-06 21:25:33 +00:00
|
|
|
if [[ $DISTRIB_ID != "Ubuntu" ]]; then
|
|
|
|
echo "Ansible installation is only supported on Ubuntu distributions."
|
|
|
|
exit 0
|
|
|
|
fi
|
2016-09-11 04:33:30 +00:00
|
|
|
|
2021-02-06 21:25:33 +00:00
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install -q -y software-properties-common
|
|
|
|
|
|
|
|
if [[ $DISTRIB_CODENAME == "focal" ]]; then
|
|
|
|
sudo apt-get install -q -y ansible python3-pip python3-mysqldb
|
2018-02-19 23:35:43 +00:00
|
|
|
else
|
2021-02-06 21:25:33 +00:00
|
|
|
sudo add-apt-repository -y ppa:ansible/ansible
|
2021-01-21 20:37:21 +00:00
|
|
|
sudo apt-get update
|
2021-02-06 21:25:33 +00:00
|
|
|
|
|
|
|
sudo apt-get install -q -y python2.7 python-pip python-mysqldb ansible
|
2016-09-11 04:33:30 +00:00
|
|
|
fi
|
2016-05-17 03:31:02 +00:00
|
|
|
|
2021-02-06 21:25:33 +00:00
|
|
|
APP_ENV="${APP_ENV:-production}"
|
2021-07-21 21:45:22 +00:00
|
|
|
UPDATE_REVISION="${UPDATE_REVISION:-65}"
|
2021-02-06 21:25:33 +00:00
|
|
|
|
2017-12-14 00:24:18 +00:00
|
|
|
echo "Updating AzuraCast (Environment: $APP_ENV, Update revision: $UPDATE_REVISION)"
|
2016-10-10 10:34:50 +00:00
|
|
|
|
2020-02-21 18:48:43 +00:00
|
|
|
if [[ ${APP_ENV} == "production" ]]; then
|
2021-01-21 20:37:21 +00:00
|
|
|
if [[ -d ".git" ]]; then
|
|
|
|
git reset --hard
|
|
|
|
git pull
|
|
|
|
else
|
|
|
|
echo "You are running a downloaded release build. Any code updates should be applied manually."
|
|
|
|
fi
|
2016-10-10 10:34:50 +00:00
|
|
|
fi
|
|
|
|
|
2018-07-03 22:51:05 +00:00
|
|
|
ansible-playbook util/ansible/update.yml --inventory=util/ansible/hosts --extra-vars "app_env=$APP_ENV update_revision=$UPDATE_REVISION"
|