-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_podman_containers.sh
executable file
·46 lines (36 loc) · 1.09 KB
/
start_podman_containers.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Save current pwd
currentpath=$(pwd)
# Determine toolpath if not set already
relativepath="./" # Define relative path to go from this script to the root level of the tool
if [[ ! -v toolpath ]]; then scriptpath=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ); toolpath=$(realpath --canonicalize-missing ${scriptpath}/${relativepath}); fi
# Load functions
source ${toolpath}/functions.sh
# Define user
user=${1}
if [[ -v user ]]
then
user=$(whoami)
fi
# Get user homedir
userhomedir=$(get_homedir "${user}")
# Get Systemdconfigdir
systemdconfigdir=$(get_systemdconfigdir "${user}")
# Restart Systemd Container Services
cd ${systemdconfigdir} || exit
for service in container-*.service
do
# Get Service Name (without Path or "./")
servicename=$(basename "${service}")
# Start container
systemd_start "${user}" "${servicename}"
done
# Change back to currentpath
cd ${currentpath} || exit
# Stop Podman "standalone" Containers
mapfile -t list < <( podman ps --all --format="{{.Names}}" )
for container in "${list[@]}"
do
# Start Container
podman start ${container}
done