Skip to content
This repository was archived by the owner on Dec 3, 2022. It is now read-only.

Commit c309f43

Browse files
committed
add scripts to execute drush sql-sync/rsync via the docker images.
1 parent 67b5bff commit c309f43

File tree

7 files changed

+133
-0
lines changed

7 files changed

+133
-0
lines changed

scripts/common.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
3+
function drush8_sa() {
4+
docker-compose exec php drush sa
5+
}
6+
7+
function drush8_sql_sync() {
8+
docker-compose exec php drush -y sql-sync $1 @self
9+
fix_permission_for_drush8
10+
}
11+
12+
function drush8_rsync() {
13+
docker-compose exec php drush -y rsync $1:%files @self:%files
14+
fix_permission_for_drush8
15+
}
16+
17+
function drush8_cc() {
18+
docker-compose exec php drush -y cc all
19+
}
20+
21+
function drush9_sa() {
22+
docker-compose exec php vendor/bin/drush sa
23+
}
24+
25+
function drush9_sql_sync() {
26+
docker-compose exec php vendor/bin/drush -y sql:sync $1 @self
27+
fix_permission_for_drush9
28+
}
29+
30+
function drush9_rsync() {
31+
docker-compose exec php vendor/bin/drush -y rsync $1:%files @self:%files
32+
fix_permission_for_drush9
33+
}
34+
35+
function drush9_cc() {
36+
docker-compose exec php vendor/bin/drush -y cr
37+
}
38+
39+
function fix_permission_for_drush8() {
40+
if [[ $OSTYPE == linux* ]]; then
41+
docker-compose exec php chown -R www-data:www-data /var/www/html/sites/default/files
42+
fi
43+
}
44+
45+
function fix_permission_for_drush9() {
46+
if [[ $OSTYPE == linux* ]]; then
47+
docker-compose exec php chown -R www-data:www-data /var/www/html/web/sites/default/files
48+
fi
49+
}

scripts/drush8-rsync.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
source $(dirname $0)/common.sh
4+
5+
if [ $# -ne 1 ]; then
6+
cat <<_EOT_
7+
Usage:
8+
$0 source
9+
10+
Description:
11+
Do drush sql-sync to @self by drush v8.
12+
You can show available "source" by "drush8_sa.sh".
13+
If your project is created by the Drupal 7, please use drush8-sql-sync.sh.
14+
15+
_EOT_
16+
exit -1
17+
fi
18+
19+
drush8_rsync $1

scripts/drush8-sa.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
source $(dirname $0)/common.sh
4+
drush8_sa

scripts/drush8-sql-sync.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
source $(dirname $0)/common.sh
4+
5+
if [ $# -ne 1 ]; then
6+
cat <<_EOT_
7+
Usage:
8+
$0 source
9+
10+
Description:
11+
Do drush sql-sync to @self by drush v8.
12+
You can show available "source" by "drush8_sa.sh".
13+
If your project is created by the drupal-composer/drupal-project, please use drush9-sql-sync.sh.
14+
15+
_EOT_
16+
exit -1
17+
fi
18+
19+
drush8_sql_sync $1

scripts/drush9-rsync.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
source $(dirname $0)/common.sh
4+
5+
if [ $# -ne 1 ]; then
6+
cat <<_EOT_
7+
Usage:
8+
$0 source
9+
10+
Description:
11+
Do drush rsync to @self by drush v9.
12+
You can show available "source" by "drush9_sa.sh".
13+
If your project is created by the Drupal 7, please use drush8-rsync.sh.
14+
15+
_EOT_
16+
exit -1
17+
fi
18+
19+
drush9_rsync $1

scripts/drush9-sa.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
source $(dirname $0)/common.sh
4+
drush9_sa

scripts/drush9-sql-sync.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
source $(dirname $0)/common.sh
4+
5+
if [ $# -ne 1 ]; then
6+
cat <<_EOT_
7+
Usage:
8+
$0 source
9+
10+
Description:
11+
Do drush sql-sync to @self by drush v9.
12+
You can show available "source" by "drush9_sa.sh".
13+
If your project is created by the Drupal 7, please use drush8-sql-sync.sh.
14+
15+
_EOT_
16+
exit -1
17+
fi
18+
19+
drush9_sql_sync $1

0 commit comments

Comments
 (0)