-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsail.sh
executable file
·46 lines (39 loc) · 1.03 KB
/
sail.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
#!/bin/bash
# https://github.com/dubniczky/Shell-Utilities
# Manage docker daemon
start_time=$(date +%s)
# Determine controller scripts
sysctl=$(command -v systemctl)
start_command=""
stop_command=""
if [ ! -z "$(command -v systemctl)" ]; then
# Linux mode (systemd)
start_command="sudo systemctl start docker"
stop_command="sudo systemctl stop docker"
elif [ ! -z "$(command -v service)" ]; then
# Linux mode (service)
start_command="sudo service docker start"
stop_command="sudo service docker stop"
else
# Mac mode
start_command="open --background -a Docker"
stop_command="killall Docker"
fi
# Run mode
if [ "$1" = "up" ]; then
echo "Starting Docker..."
$start_command
elif [ "$1" = "down" ]; then
echo "Docker Stopped."
$stop_command
exit 0
else
echo "Usage: docker [up|down]"
exit 0
fi
# Wait for start
while ! docker system info > /dev/null 2>&1; do sleep 1; done
# Print status
end_time=$(date +%s)
runtime=$((end_time-start_time))
echo "Docker daemon started in ${runtime}s"