Skip to content

Instantly share code, notes, and snippets.

@gabbygobln
Last active February 28, 2022 05:14
Show Gist options
  • Save gabbygobln/5ed4c3da351f628779cd63787b7d55cb to your computer and use it in GitHub Desktop.
Save gabbygobln/5ed4c3da351f628779cd63787b7d55cb to your computer and use it in GitHub Desktop.

Revisions

  1. gabbygobln revised this gist Feb 28, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion dockutil.sh
    Original file line number Diff line number Diff line change
    @@ -26,7 +26,7 @@ dockoff () {
    sleep 1
    echo -e "\nDocker (and services) stopped [✔]\n"
    else
    echo "\nUh oh, something went wrong.. [✗]\n"
    echo -e "\nUh oh, something went wrong.. [✗]\n"
    fi
    }

  2. gabbygobln revised this gist Feb 28, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion dockutil.sh
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ docker_state=$(systemctl is-active docker)

    dockon () {
    sudo systemctl start containerd && sudo systemctl start docker
    if (($containerd_state== "active")) && (($docker_state == "active"))
    if (($containerd_state == "active")) && (($docker_state == "active"))
    then
    clear
    sleep 1
  3. gabbygobln created this gist Feb 28, 2022.
    54 changes: 54 additions & 0 deletions dockutil.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,54 @@
    #!/bin/bash

    # My simple bash script to turn on, off, and check state of docker and containerd
    # by dn0r

    containerd_state=$(systemctl is-active containerd)
    docker_state=$(systemctl is-active docker)

    dockon () {
    sudo systemctl start containerd && sudo systemctl start docker
    if (($containerd_state== "active")) && (($docker_state == "active"))
    then
    clear
    sleep 1
    echo -e "\nSuccess [✔]\n"
    else
    echo -e \n"Failed [✗]\n"
    fi
    }

    dockoff () {
    sudo systemctl stop containerd && sudo systemctl stop docker
    if (($containerd_state == "inactive")) && (($docker_state == "inactive"))
    then
    clear
    sleep 1
    echo -e "\nDocker (and services) stopped [✔]\n"
    else
    echo "\nUh oh, something went wrong.. [✗]\n"
    fi
    }

    dockstat () {
    echo -e "\nContainerd: ${containerd_state}"
    echo -e "\nDocker: ${docker_state}\n"
    }


    commands () {
    echo -e "\nList of commands:"
    echo "----------------"
    echo -e "\non - turns on containerd & docker"
    echo -e "\noff - turns off containerd & docker"
    echo -e "\nstat - returns service status of docker & containred\n"

    }

    case "$1" in
    $null | "") echo "For commands, use the flag 'help'";;
    "help") commands;;
    "on") dockon;;
    "off") dockoff;;
    "stat") dockstat;;
    esac