This repository has been archived by the owner on Jul 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
gitman_init.sh
executable file
·49 lines (39 loc) · 2.65 KB
/
gitman_init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
set -eu
# Move to realpath
cd $(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)
SOURCE_NAME="${PWD##*/}" # Use the current directory name
GITMAN_ROOT="../../"
PERSIST_DIR="${GITMAN_ROOT}" # Use gitman root
GITMAN_LOCATION=$(cd $(pwd -P)/../;echo ${PWD##*/})
SOURCE_DIR_FROM_PERSIST_DIR="${GITMAN_LOCATION}/${SOURCE_NAME}"
# Link from source directory to persistent directory
[[ -L persistent ]] || ln -s ${PERSIST_DIR} persistent
# Link from persistent directory to source
[[ -L persistent/source ]] || ln -s ${SOURCE_DIR_FROM_PERSIST_DIR} persistent/source
# Create symlinks in persistent to source files
[[ -L persistent/Vagrantfile ]] || ln -s source/Vagrantfile persistent/Vagrantfile
[[ -L persistent/devenv ]] || ln -s source/devenv_shortcuts.sh persistent/devenv
# Copy sample files to persistent directory if they do not exist yet.
[[ -f persistent/.gitignore ]] || cp .gitignore.sample persistent/.gitignore
[[ -f persistent/Vagrantfile.config.rb ]] || cp Vagrantfile.config.rb.sample persistent/Vagrantfile.config.rb
[[ -f persistent/Vagrantfile.local.rb ]] || cp Vagrantfile.local.rb.sample persistent/Vagrantfile.local.rb
[[ -f persistent/devenv_vars.config.yml ]] || cp provisioning/devenv_vars.config.yml.sample persistent/devenv_vars.config.yml
[[ -f persistent/mutagen.yml ]] || cp mutagen.yml.sample persistent/mutagen.yml
[[ -f persistent/devenv_playbook.config.yml ]] || cp provisioning/devenv_playbook.config.yml.sample persistent/devenv_playbook.config.yml
[[ -f persistent/README.md ]] || cp README.md.project.sample persistent/README.md
[[ -f persistent/ansible.cfg ]] || cp provisioning/ansible.cfg.sample persistent/ansible.cfg
[[ -f persistent/templates/nginx/conf.d/map.conf ]] \
|| ( \
mkdir -p persistent/templates/nginx/conf.d \
&& cp provisioning/templates.sample/nginx/conf.d/map.conf persistent/templates/nginx/conf.d/map.conf \
)
# 'bin' directory with bin/devenv for shortcuts commands for common devenv actions
[[ -d persistent/bin ]] || ( mkdir -p persistent/bin && ln -s ../source/devenv_shortcuts.sh persistent/bin/devenv && ln -s ../source/bin/magento persistent/bin/magento )
# Create symlinks in source to persistent files
[[ -L provisioning/devenv_vars.config.yml ]] || ln -s ../persistent/devenv_vars.config.yml provisioning/devenv_vars.config.yml
# Rebuild all symlinks inside repo (for Windows/WSL support)
# find . -type l -ls
# [[ -L provisioning/roles/elastic.elasticsearch/test/integration/xpack-upgrade-trial ]] \
# && rm provisioning/roles/elastic.elasticsearch/test/integration/xpack-upgrade-trial \
# && ln -s xpack-upgrade provisioning/roles/elastic.elasticsearch/test/integration/xpack-upgrade-trial