From b1b859a2e51fd705a36928b8b68e1398223b36c5 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 28 Mar 2018 11:33:43 +0200 Subject: [PATCH] Fix var perms --- .gitmodules | 2 +- dev/pull_data.sh | 15 ++++----------- dev/update.sh | 6 +----- misc/fix_var_perms.sh | 14 ++++++++++++++ prod/up.sh | 5 ++++- prod/upgrade.sh | 2 -- 6 files changed, 24 insertions(+), 20 deletions(-) create mode 100755 misc/fix_var_perms.sh diff --git a/.gitmodules b/.gitmodules index 1372a4d..de78f8d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "install"] path = install - url = git@github.com:yomguy/docker-composition-installer.git + url = https://github.com/yomguy/docker-composition-installer.git diff --git a/dev/pull_data.sh b/dev/pull_data.sh index 41936d9..e825dcc 100755 --- a/dev/pull_data.sh +++ b/dev/pull_data.sh @@ -1,10 +1,10 @@ #!/bin/bash -cd "$(dirname "$0")"/../../var +cd "$(dirname "$0")"/../../ -# We need to chown folders as they are docker's volumes -sudo chown -R $USER media -sudo chown -R $USER backup +bin/misc/fix_var_perms.sh + +cd "$(dirname "$0")"/../../var/ git pull @@ -12,10 +12,3 @@ git pull if [ "$1" = "--restore-db" ]; then docker-compose run db /srv/bin/dev/restore_db.sh fi - -# We need to chown folders as they are docker's volumes -# (do not work on OSX, hence the test) -if ! uname -a | grep Darwin > /dev/null; then - sudo chown -R www-data media - sudo chown -R root backup -fi diff --git a/dev/update.sh b/dev/update.sh index 8b8d466..b999a47 100755 --- a/dev/update.sh +++ b/dev/update.sh @@ -10,11 +10,7 @@ cd "$(dirname "$0")"/../../ -# We need to chown folders as they are docker's volumes -if ! uname -a | grep Darwin > /dev/null; then - sudo chown -R $USER var/media - sudo chown -R $USER var/backup -fi +bin/misc/fix_var_perms.sh # Update main project git pull diff --git a/misc/fix_var_perms.sh b/misc/fix_var_perms.sh new file mode 100755 index 0000000..09aff73 --- /dev/null +++ b/misc/fix_var_perms.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +cd "$(dirname "$0")"/../../ + +# We need to chown folders so that they can be used by the $USER (with an exception on Darwin) +if ! uname -a | grep Darwin > /dev/null; then + INFO=( $(stat -L -c "%a %G %U" var) ) + OWNER=${INFO[2]} + if [ "$OWNER" != "$USER" ]; then + sudo chown $USER var + sudo chown -R $USER var/media + sudo chown -R $USER var/backup + fi +fi diff --git a/prod/up.sh b/prod/up.sh index 07fa2c4..4c4f1f7 100755 --- a/prod/up.sh +++ b/prod/up.sh @@ -1,6 +1,9 @@ #!/bin/sh + options = "" + if [ "$1" = "-bg" ]; then options = $options "-d"; fi -docker-compose -f docker-compose.yml -f env/prod.yml up $options \ No newline at end of file + +docker-compose -f docker-compose.yml -f env/prod.yml up $options diff --git a/prod/upgrade.sh b/prod/upgrade.sh index fb9a797..a5f2382 100755 --- a/prod/upgrade.sh +++ b/prod/upgrade.sh @@ -2,8 +2,6 @@ cd "$(dirname "$0")"/../../ - - function usage() { echo "upgrade the Mezzo production instance with various options" echo "" -- 2.39.5