-
Notifications
You must be signed in to change notification settings - Fork 6
/
ops-commands.sh
105 lines (79 loc) · 3.4 KB
/
ops-commands.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
ops-craft() {
cmd-doc "Run craft commands within ops more easily."
ops shell ./craft "$@"
}
ops-configure() {
cmd-doc "Interactively configure ops settings in your .env file."
PROJECT=$(ops project name)
DEFAULT=${DB_SERVER:-mariadb}
read -p "Database Server [$DEFAULT]: " INPUT
ops env DB_SERVER ${INPUT:-$DEFAULT}
DEFAULT=${PROJECT//[^a-zA-Z0-9]/_}
DEFAULT=${DB_DATABASE:-$DEFAULT}
read -p "Database Name [$DEFAULT]: " INPUT
ops env DB_DATABASE ${INPUT:-$DEFAULT}
read -p "Remote host [$OPS_PROJECT_REMOTE_HOST]: " INPUT
ops env OPS_PROJECT_REMOTE_HOST ${INPUT:-$OPS_PROJECT_REMOTE_HOST}
if [[ -n "$OPS_PROJECT_REMOTE_HOST" ]]; then
read -p "Remote user [$OPS_PROJECT_REMOTE_USER]: " INPUT
ops env OPS_PROJECT_REMOTE_USER ${INPUT:-$OPS_PROJECT_REMOTE_USER}
read -p "Remote path [$OPS_PROJECT_REMOTE_PATH]: " INPUT
ops env OPS_PROJECT_REMOTE_PATH ${INPUT:-$OPS_PROJECT_REMOTE_PATH}
read -p "Remote database name [$OPS_PROJECT_REMOTE_DB_NAME]: " INPUT
ops env OPS_PROJECT_REMOTE_DB_NAME ${INPUT:-$OPS_PROJECT_REMOTE_DB_NAME}
read -p "Sync dirs [$OPS_PROJECT_SYNC_DIRS]: " INPUT
ops env OPS_PROJECT_SYNC_DIRS ${INPUT:-$OPS_PROJECT_SYNC_DIRS}
fi
}
ops-padstone-install() {
cmd-doc "Run this only once per project to complete the Padstone install."
echo "Remove ignores from .gitignore..."
sed -i '/Remove these Ignores/Q' .gitignore
echo "Installing imarc-boilerplate..."
npm install imarc-boilerplate -y
echo "Running $(tput smul)npx imarc-boilerplate$(tput rmul)..."
npx imarc-boilerplate -y
ops install
}
ops-install() {
cmd-doc "Run this after cloning the project to setup the project for local development on Ops."
if [[ ! -e .env ]]; then
echo "Copying .env.example to .env..."
cp .env.example .env
fi
if [ -t 1 ]; then
echo "Calling $(tput smul)ops configure$(tput rmul)..."
ops configure
else
echo You may wish to run $(tput smul)ops configure$(tput rmul) after this.
fi
# get updated settings; unusual syntax for bash 3.2.57
source /dev/stdin <<<"$(ops env)"
if [[ -n "$DB_DATABASE" ]] && [[ -n "$OPS_PROJECT_REMOTE_DB_NAME" ]]; then
read -p "Run ops sync now [Yn]: " INPUT
if [[ $INPUT == 'Y' ]]; then
echo "Running $(tput smul)ops sync$(tput rmul)..."
ops sync
fi
elif [[ -e ./padstone.sql ]] && [[ -n "$DB_DATABASE" ]]; then
echo "Importing padstone.sql into $DB_DATABASE..."
ops mariadb import $DB_DATABASE < ./padstone.sql
echo "Running craft migrations..."
ops craft migrate/all --no-backup=1 --interactive=0
else
echo "Skipping syncing or importing padstone.sql..."
fi
if [[ -z "$SECURITY_KEY" ]] && [[ -n "$DB_DATABASE" ]]; then
echo "Running $(tput smul)ops craft setup/security-key$(tput rmul)..."
ops craft setup/security-key
else
echo "Skipping generating security key ($(tput smul)ops craft setup/security-key$(tput rmul)) because DB_DATABASE is not set."
fi
echo "Calling $(tput smul)composer install$(tput rmul)..."
composer install
echo "Calling $(tput smul)npm install$(tput rmul)..."
npm install
echo "Calling $(tput smul)npm run dev$(tput rmul)..."
npm run dev
echo -en "\nVisit your site at https://$(ops project name).imarc.io/\n"
}