From: Guillaume Pellerin Date: Tue, 6 Mar 2018 16:34:47 +0000 (+0100) Subject: pull before update submodules X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=1f41411429defb3561d87d56a3062e7cac1102d4;p=docker-django-scripts.git pull before update submodules --- diff --git a/build/local/setup_lib.sh b/build/local/setup_lib.sh new file mode 100755 index 0000000..87bd14e --- /dev/null +++ b/build/local/setup_lib.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +ls /srv/lib/ +for module in `ls /srv/lib/`; do + cd /srv/lib/$module + if [ -f 'requirements.txt' ]; then + pip install -r requirements.txt + else + python setup.py develop + fi +done diff --git a/build/readme.sh b/build/readme.sh index b73a032..6515727 100755 --- a/build/readme.sh +++ b/build/readme.sh @@ -1,4 +1,6 @@ -#!/bin/sh +#!/bin/bash + +cd "$(dirname "$0")"/../../ cat doc/src/overview.rst doc/src/architecture.rst doc/src/install.rst doc/src/development.rst doc/src/maintenance.rst doc/src/copyright.rst doc/src/license.rst > README.rst echo "Build finished. The README.rst file is up to date." diff --git a/build/setup_lib.sh b/build/setup_lib.sh deleted file mode 100755 index 87bd14e..0000000 --- a/build/setup_lib.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -ls /srv/lib/ -for module in `ls /srv/lib/`; do - cd /srv/lib/$module - if [ -f 'requirements.txt' ]; then - pip install -r requirements.txt - else - python setup.py develop - fi -done diff --git a/dev/pull.sh b/dev/pull.sh index 19dc2df..556e135 100755 --- a/dev/pull.sh +++ b/dev/pull.sh @@ -6,11 +6,8 @@ cd "$(dirname "$0")"/../../ sudo chown -R $USER var/media sudo chown -R $USER var/backup -# Update main project -git pull - -# Update submodules -./bin/dev/update_submodules.sh +# Update main project and submodules +./bin/dev/update.sh # Restore database if [ "$1" = "--restore-db" ]; then diff --git a/dev/update.sh b/dev/update.sh new file mode 100755 index 0000000..e0235af --- /dev/null +++ b/dev/update.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# The script detect the right main project branch, then update the submodule function of branch-[mainProjectBranch] +# For example, if you define these variables in .gitmodules : +# - branch-dev +# - branch-master +# If you are on dev branch in main project, the script will update submodule functions of branch-dev you've defined +# In main project, if you are in another branch than master or dev, it will take by default dev branch +# If you don't define any branches for you submodule, the script will update from master + +cd "$(dirname "$0")"/../../ + +# Update main project +git pull + +curr_branch=$(git symbolic-ref --short HEAD) + +echo $curr_branch +if [ $curr_branch != "master" ] && [ $curr_branch != "dev" ]; +then + curr_branch="dev" +fi + +function update_git_urls { + find ./ -type f \( -name ".gitmodules" -o -name "config" \) -exec sed -i $REGEX {} + +} + +REGEX='s/https:\/\/github.com\//git@github.com:/g' +update_git_urls + +# checkout new submodule +git submodule update --init +# Synchronizes submodules' remote URL configuration setting to the value specified in .gitmodules +git submodule sync +# Checkout all submodules on right branches specified in .gitmodules, by default the branch is master +git submodule foreach --recursive 'git checkout $(git config -f $toplevel/.gitmodules submodule.$name.branch-'$curr_branch' || echo master)' +# Pull all submodules on right branches specified in .gitmodules, by default the branch is master +git submodule foreach --recursive 'git pull origin $(git config -f $toplevel/.gitmodules submodule.$name.branch-'$curr_branch' || echo master)' diff --git a/dev/update_submodules.sh b/dev/update_submodules.sh deleted file mode 100755 index fbd4bd4..0000000 --- a/dev/update_submodules.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# The script detect the right main project branch, then update the submodule function of branch-[mainProjectBranch] -# For example, if you define these variables in .gitmodules : -# - branch-dev -# - branch-master -# If you are on dev branch in main project, the script will update submodule functions of branch-dev you've defined -# In main project, if you are in another branch than master or dev, it will take by default dev branch -# If you don't define any branches for you submodule, the script will update from master - -curr_branch=$(git symbolic-ref --short HEAD) - -echo $curr_branch -if [ $curr_branch != "master" ] && [ $curr_branch != "dev" ]; -then - curr_branch="dev" -fi - -function update_git_urls { - find ./ -type f \( -name ".gitmodules" -o -name "config" \) -exec sed -i $REGEX {} + -} - -REGEX='s/https:\/\/github.com\//git@github.com:/g' -update_git_urls - -# checkout new submodule -git submodule update --init -# Synchronizes submodules' remote URL configuration setting to the value specified in .gitmodules -git submodule sync -# Checkout all submodules on right branches specified in .gitmodules, by default the branch is master -git submodule foreach --recursive 'git checkout $(git config -f $toplevel/.gitmodules submodule.$name.branch-'$curr_branch' || echo master)' -# Pull all submodules on right branches specified in .gitmodules, by default the branch is master -git submodule foreach --recursive 'git pull origin $(git config -f $toplevel/.gitmodules submodule.$name.branch-'$curr_branch' || echo master)' diff --git a/prod/push.sh b/prod/push.sh index fc7a2eb..8f06240 100755 --- a/prod/push.sh +++ b/prod/push.sh @@ -1,9 +1,14 @@ #!/bin/bash +cd "$(dirname "$0")"/../../ + echo "----------------------------" echo `date +\%Y\%m\%d-\%H-\%M-\%S` + docker-compose run db /srv/bin/prod/backup_db.sh + cd var + git add . git commit -a -m "update DB and media" git pull diff --git a/prod/update.sh b/prod/update.sh new file mode 100755 index 0000000..4a684e9 --- /dev/null +++ b/prod/update.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +# The script detect the right main project branch, then update the submodule function of branch-[mainProjectBranch] +# For example, if you define these variables in .gitmodules : +# - branch-dev +# - branch-master +# If you are on dev branch in main project, the script will update submodule functions of branch-dev you've defined +# In main project, if you are in another branch than master or dev, it will take by default dev branch +# If you don't define any branches for you submodule, the script will update from master + +cd "$(dirname "$0")"/../../ + +# Update main project +git pull + +curr_branch=$(git symbolic-ref --short HEAD) + +echo $curr_branch +if [ $curr_branch != "master" ] && [ $curr_branch != "dev" ]; +then + curr_branch="dev" +fi + +function update_git_urls { + find ./ -type f \( -name ".gitmodules" -o -name "config" \) -exec sed -i $REGEX {} + +} + +REGEX='s/git@github.com:/https:\/\/github.com\//g' +update_git_urls + +# checkout new submodule +git submodule update --init +# Synchronizes submodules' remote URL configuration setting to the value specified in .gitmodules +git submodule sync +# Checkout all submodules on right branches specified in .gitmodules, by default the branch is master +git submodule foreach --recursive 'git checkout $(git config -f $toplevel/.gitmodules submodule.$name.branch-'$curr_branch' || echo master)' +# Pull all submodules on right branches specified in .gitmodules, by default the branch is master +git submodule foreach --recursive 'git pull origin $(git config -f $toplevel/.gitmodules submodule.$name.branch-'$curr_branch' || echo master)' diff --git a/prod/update_submodules.sh b/prod/update_submodules.sh deleted file mode 100755 index fb27679..0000000 --- a/prod/update_submodules.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# The script detect the right main project branch, then update the submodule function of branch-[mainProjectBranch] -# For example, if you define these variables in .gitmodules : -# - branch-dev -# - branch-master -# If you are on dev branch in main project, the script will update submodule functions of branch-dev you've defined -# In main project, if you are in another branch than master or dev, it will take by default dev branch -# If you don't define any branches for you submodule, the script will update from master - -curr_branch=$(git symbolic-ref --short HEAD) - -echo $curr_branch -if [ $curr_branch != "master" ] && [ $curr_branch != "dev" ]; -then - curr_branch="dev" -fi - -function update_git_urls { - find ./ -type f \( -name ".gitmodules" -o -name "config" \) -exec sed -i $REGEX {} + -} - -REGEX='s/git@github.com:/https:\/\/github.com\//g' -update_git_urls - -# checkout new submodule -git submodule update --init -# Synchronizes submodules' remote URL configuration setting to the value specified in .gitmodules -git submodule sync -# Checkout all submodules on right branches specified in .gitmodules, by default the branch is master -git submodule foreach --recursive 'git checkout $(git config -f $toplevel/.gitmodules submodule.$name.branch-'$curr_branch' || echo master)' -# Pull all submodules on right branches specified in .gitmodules, by default the branch is master -git submodule foreach --recursive 'git pull origin $(git config -f $toplevel/.gitmodules submodule.$name.branch-'$curr_branch' || echo master)' diff --git a/prod/upgrade.sh b/prod/upgrade.sh index 43f8591..0450646 100755 --- a/prod/upgrade.sh +++ b/prod/upgrade.sh @@ -2,11 +2,8 @@ cd "$(dirname "$0")"/../../ -# Update main project -git pull - -# Update submodules -./bin/update_submodules.sh +# Update main project and submodules +./bin/prod/update.sh # Apply migrations if [ "$1" = "--migrate" ]; then