mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-07 01:54:16 +01:00
upgrade scripts with -y
This commit is contained in:
parent
8a47af6d2c
commit
894c54068f
@ -1,11 +1,27 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
parseparams()
|
||||||
|
{
|
||||||
|
while getopts "hy" opt; do
|
||||||
|
case "${opt}" in
|
||||||
|
y)
|
||||||
|
Y=true
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
}
|
||||||
|
|
||||||
config()
|
config()
|
||||||
{
|
{
|
||||||
|
YES_ALL=${Y:-false}
|
||||||
if [ "$(whoami)" = "root" ]
|
if [ "$(whoami)" = "root" ]
|
||||||
then
|
then
|
||||||
echo "It is not recommended to run this script as root. As a normal user, elevation will be prompted if needed."
|
echo "It is not recommended to run this script as root. As a normal user, elevation will be prompted if needed."
|
||||||
read -rp "Continue anyway? (Y/n) " confirm </dev/tty
|
[[ "$YES_ALL" = "true" ]] && confirm="y" || read -rp "Continue anyway? (Y/n) " confirm </dev/tty
|
||||||
if [[ "$confirm" = "n" ]]; then exit 1; fi
|
if [[ "$confirm" = "n" ]]; then exit 1; fi
|
||||||
else
|
else
|
||||||
if ! groups | grep docker; then
|
if ! groups | grep docker; then
|
||||||
@ -17,7 +33,7 @@ config()
|
|||||||
fi
|
fi
|
||||||
FM_PATH=$(pwd)
|
FM_PATH=$(pwd)
|
||||||
TYPE="NOT-FOUND"
|
TYPE="NOT-FOUND"
|
||||||
read -rp "Is Fab-manager installed at \"$FM_PATH\"? (y/N) " confirm </dev/tty
|
[[ "$YES_ALL" = "true" ]] && confirm="y" || read -rp "Is Fab-manager installed at \"$FM_PATH\"? (y/N) " confirm </dev/tty
|
||||||
if [ "$confirm" = "y" ]; then
|
if [ "$confirm" = "y" ]; then
|
||||||
test_docker_compose
|
test_docker_compose
|
||||||
if [[ "$TYPE" = "NOT-FOUND" ]]
|
if [[ "$TYPE" = "NOT-FOUND" ]]
|
||||||
@ -65,6 +81,15 @@ docker_up()
|
|||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usage()
|
||||||
|
{
|
||||||
|
printf "Usage: %s [OPTIONS]
|
||||||
|
Options:
|
||||||
|
-h Print this message and quit
|
||||||
|
-y Answer yes to all questions\n" "$(basename "$0")" 1>&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
function trap_ctrlc()
|
function trap_ctrlc()
|
||||||
{
|
{
|
||||||
echo "Ctrl^C, exiting..."
|
echo "Ctrl^C, exiting..."
|
||||||
@ -73,8 +98,9 @@ function trap_ctrlc()
|
|||||||
|
|
||||||
upgrade_redis()
|
upgrade_redis()
|
||||||
{
|
{
|
||||||
|
parseparams "$@"
|
||||||
config
|
config
|
||||||
read -rp "Continue with upgrading? (y/N) " confirm </dev/tty
|
[[ "$YES_ALL" = "true" ]] && confirm="y" || read -rp "Continue with upgrading? (y/N) " confirm </dev/tty
|
||||||
if [[ "$confirm" = "y" ]]; then
|
if [[ "$confirm" = "y" ]]; then
|
||||||
trap "trap_ctrlc" 2 # SIGINT
|
trap "trap_ctrlc" 2 # SIGINT
|
||||||
docker_down
|
docker_down
|
||||||
|
@ -76,7 +76,11 @@ upgrade()
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
for SCRIPT in "${SCRIPTS[@]}"; do
|
for SCRIPT in "${SCRIPTS[@]}"; do
|
||||||
\curl -sSL "https://raw.githubusercontent.com/sleede/fab-manager/master/scripts/$SCRIPT.sh" | bash
|
if [[ "$YES_ALL" = "true" ]]; then
|
||||||
|
\curl -sSL "https://raw.githubusercontent.com/sleede/fab-manager/master/scripts/$SCRIPT.sh" | bash -s -- -y
|
||||||
|
else
|
||||||
|
\curl -sSL "https://raw.githubusercontent.com/sleede/fab-manager/master/scripts/$SCRIPT.sh" | bash
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
docker-compose down
|
docker-compose down
|
||||||
docker-compose run --rm "$SERVICE" bundle exec rake db:migrate
|
docker-compose run --rm "$SERVICE" bundle exec rake db:migrate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user