-
Notifications
You must be signed in to change notification settings - Fork 3
/
wocker
executable file
·87 lines (73 loc) · 1.52 KB
/
wocker
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
#!/bin/sh -e
PWD=$(pwd)
DIR=$(pwd)
while [ "${DIR}" != "/" -a ! -e "${DIR}/Vagrantfile" ]; do
cd ..
DIR=$(pwd)
done
SSH_CONFIG="${DIR}/.ssh_config"
cd "${PWD}"
wocker_cli() {
trap "rm -f '${SSH_CONFIG}'" ERR
if [ ! -e "${SSH_CONFIG}" ]; then
vagrant ssh-config > "${SSH_CONFIG}"
fi
ssh -F "${SSH_CONFIG}" wocker exit
trap "" ERR
echo wocker "$@" | ssh -F "${SSH_CONFIG}" wocker "bash -l"
}
case "$1" in
#
# Start a specific container with `vagrant up`
#
'up' )
if [[ "$2" && ! "$2" =~ ^-.*$ ]]; then
vagrant $1
vagrant ssh-config > "${SSH_CONFIG}"
wocker_cli start "$2"
else
vagrant "$@"
vagrant ssh-config > "${SSH_CONFIG}"
fi
;;
#
# Start a specific container with `vagrant reload`
#
'reload' )
if [[ "$2" && ! "$2" =~ ^-.*$ ]]; then
wocker_cli stop
vagrant $1
vagrant ssh-config > "${SSH_CONFIG}"
wocker_cli start "$2"
else
vagrant "$@"
vagrant ssh-config > "${SSH_CONFIG}"
fi
;;
#
# Stop all containers before `vagrant halt`
#
'halt' )
wocker_cli stop
vagrant $1
;;
#
# Commonly used vagrant commands
#
'halt' | 'reload' | 'resume' | 'ssh' | 'status' | 'suspend' | 'up' )
vagrant "$@"
;;
#
# WP-CLI and Wordmove integration
#
'image' | 'wp' | 'wordmove' )
WOCKER_COMMAND="wocker $@"
vagrant ssh -c "${WOCKER_COMMAND}"
;;
#
# Docker command aliases, Wocker original commands and others just pass through
#
* )
wocker_cli "$@"
;;
esac