As a continuation of this question, I would like a second review from you.
Here is the updated sh
script:
#!/bin/sh set -e spath="/home/<user>/<dir>/" sname="<scriptname>.sh" if [ $# -eq 0 ] then sh "${spath}${sname}" "logging" 2>&1 | tee -a "${spath}log_$(date +%F_%T_%N).txt" exit fi cd $spath # This three commands for logging... pwd date whoami docker compose down # To go sure, docker is down and file operations are complete sleep 5 sudo sh -c "apt update && DEBIAN_FRONTEND=noninteractive apt upgrade -y && apt autoremove -y && apt autoclean" # To go sure, upgrades are done sleep 5 if [ -f /var/run/reboot-required ] then # To go sure, system is up again after reboot at now + 2 minute -f "${spath}${sname}" sudo reboot else docker compose pull docker compose build --pull docker compose up -d # To go sure, docker is running again sleep 5 docker system prune -a -f # Just for information/debug logging purposes, everything is up sleep 5 docker system df docker stats --no-stream | sort -k 2 fi
The requirements are almost the same. I think it's safer to user sh
instead of bash
because I use the at
command.