-
Notifications
You must be signed in to change notification settings - Fork 2
/
openshift
executable file
·63 lines (55 loc) · 1.26 KB
/
openshift
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
#!/bin/bash
# `set +e` is used to continue on errors throughout this script.
set -euo pipefail
IFS=$'\n\t'
if [ -f /.dockerenv ]; then
error "Inception error - you can't run $0 within a docker container."
exit
fi
BASE_DIR="/openshift/uni-shepherd"
export OPENSHIFT=$(ip addr show docker0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
openshift_start() {
if [ "${OPENSHIFT_TYPE}" == "minishift" ]; then
minishift start
if ! virsh net-list | grep default > /dev/null; then virsh net-start default; fi
else
oc cluster up --base-dir=${BASE_DIR} --public-hostname=${OPENSHIFT}
fi
echo "Now start shepherd with ./dsh"
}
openshift_stop() {
./dsh stop
if [ "${OPENSHIFT_TYPE}" == "minishift" ]; then
minishift stop
else
oc cluster down
fi
}
openshift_purge() {
./dsh purge
if [ "${OPENSHIFT_TYPE}" == "minishift" ]; then
minishift stop
minishift delete
else
oc cluster down
sudo rm -rf ${BASE_DIR}
sudo mkdir -p ${BASE_DIR}
sudo chown ${USER}:${USER} -R ${BASE_DIR}
fi
}
COMMAND=${1:-default}
case ${COMMAND} in
sta*)
openshift_start
;;
sto*)
openshift_stop
;;
p*)
openshift_purge
;;
*)
printf "Unknown command specified. Try:\n$0 [start|stop|purge].\n"
exit 0
;;
esac