forked from Kitsu01/VivumLab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.sh
executable file
·94 lines (87 loc) · 2.36 KB
/
launch.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
#!/usr/bin/env bash
### Set VivumLab Version
VERSION=latest
SYSTEM=$(ps --no-headers -o comm 1)
#OS=
SSH_DIR="$HOME/.ssh/"
SETTINGS_DIR="$HOME/VivumLab_settings/"
INVENTORY_DIR="$HOME/VivumLab_settings/inventory/"
VAULT_DIR="$HOME/.vivumlab_vault/"
while getopts h:v option; do
case $option in
v) VERSION="${OPTARG}"
;;
h | *)
help #### !!!!!! ADD CUSTOM HELP !!!!!! ####
exit 0
;;
esac
done
### Check for docker group, and add user ###
if [[ "$OSTYPE" == "darwin"* ]]; then
:
else
if [ ! $(getent group docker) ]; then
printf "Creating Docker Group"
echo # (optional) move to a new line
sudo groupadd docker
printf "Adding user: $USER, to Docker Group"
echo # (optional) move to a new line
sudo usermod -aG docker $USER
echo # (optional) move to a new line
printf "Please reboot/re-login, and run ./launch.sh again."
echo # (optional) move to a new line
printf "Exiting in 15 Seconds"
sleep 15s
exit
else
if ! id -nG "$USER" | grep -qw "docker"; then
printf "Adding user: $USER, to Docker Group"
echo # (optional) move to a new line
sudo usermod -aG docker $USER
echo # (optional) move to a new line
printf "Please reboot/re-login and run ./launch.sh again."
echo # (optional) move to a new line
printf "Exiting in 15 Seconds"
sleep 15s
exit
fi
fi
fi
### Check Docker; run if it is not ###
if ! docker info > /dev/null 2>&1 ; then
printf "Starting Docker.."
echo # (optional) move to a new line
if [[ "$OSTYPE" == "darwin"* ]]; then
open -g -a Docker.app || exit
elif [[ "${SYSTEM}" == "systemctl" ]]; then
systemctl start docker
elif [[ "${SYSTEM}" == "init" ]]; then
service docker start
fi
fi
### Pull VivumLab ###
if [ "${VERSION}" == '' ]; then
docker pull vivumlab/vivumlab:latest
else
docker pull vivumlab/vivumlab:${VERSION}
fi
if [ ! -d "${SSH_DIR}" ]; then
mkdir "$SSH_DIR"
fi
if [ ! -d "${SETTINGS_DIR}" ]; then
mkdir "$SETTINGS_DIR"
fi
if [ ! -d "${INVENTORY_DIR}" ]; then
mkdir "$INVENTORY_DIR"
fi
if [ ! -d "${VAULT_DIR}" ]; then
mkdir "$VAULT_DIR"
fi
### Run VivumLab ###
docker run --rm -it -u $(id -u):$(id -g)\
-v "${SSH_DIR}":"/home/vlab/.ssh/":z \
-v "${SETTINGS_DIR}":"/home/vlab/VivumLab_settings/":z \
-v "${INVENTORY_DIR}":"/VivumLab/inventory/":z \
-v "${VAULT_DIR}":"/home/vlab/.vivumlab_vault/":z \
vivumlab/vivumlab:${VERSION} /bin/bash