From 8431f6b55aac480d55ea566c6a400ffd6c86364a Mon Sep 17 00:00:00 2001 From: Young Joon Lee Date: Tue, 9 May 2023 13:20:29 +0900 Subject: [PATCH] fix(docker): add restart-docker-daemon task and executable This commit adds a new task `restart-docker-daemon` to the `Taskfile.dist.yaml` and an executable script to be able to restart the Docker daemon. It uses `systemctl` to restart the daemon in Linux systems and `service` if the system is WSL. --- chezmoi/Taskfile.dist.yaml | 5 +++++ .../bin/executable_restart-docker-daemon.tmpl | 10 ++++++++++ ...run_onchange_after_95-restart-docker-daemon.sh.tmpl | 9 +-------- 3 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 chezmoi/dot_local/bin/executable_restart-docker-daemon.tmpl diff --git a/chezmoi/Taskfile.dist.yaml b/chezmoi/Taskfile.dist.yaml index 6820227c..dacc2b9f 100644 --- a/chezmoi/Taskfile.dist.yaml +++ b/chezmoi/Taskfile.dist.yaml @@ -16,6 +16,11 @@ tasks: cmds: - watch -n 1 nvidia-smi + restart-docker-daemon: + desc: Restart the Docker daemon + cmds: + - restart-docker-daemon + # install-node: # desc: Install the latest LTS version of Node.js using nvm # cmds: diff --git a/chezmoi/dot_local/bin/executable_restart-docker-daemon.tmpl b/chezmoi/dot_local/bin/executable_restart-docker-daemon.tmpl new file mode 100644 index 00000000..560a8e8d --- /dev/null +++ b/chezmoi/dot_local/bin/executable_restart-docker-daemon.tmpl @@ -0,0 +1,10 @@ +#!/bin/bash +# {{ template "scripts-library" }} + +log_task "Restarting Docker daemon" +# {{ if .system.is_wsl }} +# service restart fails if the service was never started +c service docker restart || c service docker start || true +# {{ else }} +c systemctl restart docker +# {{ end }} diff --git a/rootmoi/.chezmoiscripts/run_onchange_after_95-restart-docker-daemon.sh.tmpl b/rootmoi/.chezmoiscripts/run_onchange_after_95-restart-docker-daemon.sh.tmpl index 1a0964b6..fe97a51a 100644 --- a/rootmoi/.chezmoiscripts/run_onchange_after_95-restart-docker-daemon.sh.tmpl +++ b/rootmoi/.chezmoiscripts/run_onchange_after_95-restart-docker-daemon.sh.tmpl @@ -3,11 +3,4 @@ log_task "95. Restarting Docker daemon" # daemon.json hash: {{ include "/etc/docker/daemon.json" | sha256sum }} - -log_task "Restarting Docker daemon" -# {{ if .system.is_wsl }} -# service restart fails if the service was never started -c service docker restart || c service docker start || true -# {{ else }} -c systemctl restart docker -# {{ end }} +"${HOME}/.local/bin/restart-docker-daemon"