Last active
February 28, 2022 05:14
-
-
Save gabbygobln/5ed4c3da351f628779cd63787b7d55cb to your computer and use it in GitHub Desktop.
My simple personal script for managing containerd & docker service.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 -e "\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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment