瀏覽代碼

add error and check_internet functions to installer

Ryan Fortner 3 年之前
父節點
當前提交
640ddff58d
共有 1 個文件被更改,包括 21 次插入3 次删除
  1. 21 3
      install_docker.sh

+ 21 - 3
install_docker.sh

@@ -1,4 +1,22 @@
 #!/bin/sh
 #!/bin/sh
-curl -sSL https://get.docker.com | sh
-sudo usermod -aG docker $USER
-echo "remember to logoff to take effect"
+
+function error {
+  echo -e "\\e[91m$1\\e[39m"
+  exit 1
+}
+
+function check_internet() {
+  printf "Checking if you are online..."
+  wget -q --spider http://github.com
+  if [ $? -eq 0 ]; then
+    echo "Online. Continuing."
+  else
+    error "Offline. Go connect to the internet then run the script again."
+  fi
+}
+
+check_internet
+
+curl -sSL https://get.docker.com | sh || error "Failed to install Docker."
+sudo usermod -aG docker $USER || error "Failed to add user to the Docker usergroup."
+echo "Remember to logoff/reboot for the changes to take effect."