IMPORTANT!
Explained scripts will not recieve more developments since I converted them to Ansible Playbooks. Please visit the Ansible Repository here.
It's currently only availabe in the development branch under Bash-Scripts to Ansible.
Containers
Start rootless and rootfull podman containers
Note about this script
This is a (by AI generated) tested script to start Podman Containers. I wouldn't recommend using it anymore sinced 1. You can just use Quadlets for it and 2. if starting them without a systemd unit, I'd recommend using the Ansible Playbook I created out of this.
Declaring variables
In this script, the BASE Directory points to the current users homelab folder in the home directory. If a different base directory is used, this must be changed.
Then we declare with Compose and root dirs the subfolders that contain the compose files and which one need to be started rootless and which ones rootfull.
Logic
for dir in "${COMPOSE_DIRS[@]}"; do
Iterates over every element in the COMPOSE_DIRS array, assigning each value one by one to the variable dir.
pushd "$BASE/$dir" >/dev/null
Changes the current directory to $BASE/$dir while saving the previous directory on the directory stack and suppressing the normal output.
podman compose up -d
Starts (or recreates) the containers defined in the compose file inside the current directory using Podman.
popd >/dev/null
Returns to the previous directory from the directory stack and suppresses the output of that directory change.
end
Stops the loop after it's finished.