-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathdocker_start_up.bash
executable file
·42 lines (32 loc) · 1.06 KB
/
docker_start_up.bash
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
#!/bin/bash
#Author Omar BOUYKOURNE
#42login : obouykou
machine="default"
if [ $# -eq 0 ]
then
echo "No arguments supplied"
echo "Please, give name of the machine you want to create as an argument !"
exit 2
else
machine="$1"
fi
docker stop "$(docker ps -aq &>/dev/null)" &>/dev/null
if docker-machine kill "$machine" &>/dev/null; then
echo -e "\n$machine has been stopped\n"
fi
if docker-machine rm "$machine" -y &>/dev/null; then
echo -e "\n$machine has been removed\n"
fi
if ! ls "$HOME"/.docker/machine/cache/boot2docker.iso &>/dev/null; then
curl -Lo "$HOME"/.docker/machine/cache/boot2docker.iso https://github.com/boot2docker/boot2docker/releases/download/v18.09.1-rc1/boot2docker.iso &>/dev/null
fi
if docker-machine create --driver virtualbox "$machine" &>/dev/null; then
echo -e "\n$machine has been created successfully !\n"
fi
if docker-machine env "$machine" &>/dev/null; then
echo -e "\033[32m\nrun this command [ eval \$(docker-machine env $machine) ]\n\033[0m"
else
echo -e "\033[31m\nCould not complete your request :(\n\033[0m"
exit 1
fi
exit 0