-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_podman_autostart_service.sh
executable file
·67 lines (58 loc) · 2.17 KB
/
setup_podman_autostart_service.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# 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
if [[ -z "${user}" ]]
then
# user=${1:-'podman'}
user=$(whoami)
fi
# Define mode
if [[ -z "${schedulemode}" ]]
then
# schedulemode=${2:-'cron'}
schedulemode='systemd'
fi
# Get homedir
homedir=$(get_homedir "${user}")
# Get Systemdconfigdir
systemdconfigdir=$(get_systemdconfigdir "${user}")
# Remove old files / with old name
#rm -f /etc/...
systemd_delete "${user}" "podman-setup-service-autostart.service"
systemd_delete "${user}" "podman-setup-service-autostart.timer"
# Setup new Scheme
if [[ "${schedulemode}" == "cron" ]]
then
# Setup CRON to automatically generate updated Systemd Service files for Podman
# Disabled for now
#destination="/etc/cron.d/podman-service-reconfigure-autostart"
#cp "cron/podman-service-autostart" "${destination}"
#chmod +x "${destination}"
#eplace_text "${destination}" "toolpath" "${homedir}/podman-tools" "user" "${user}"
dummyvar=1
elif [[ "${schedulemode}" == "systemd" ]]
then
# Copy Systemd Service File
servicefile="podman-service-reconfigure-autostart.service"
destination="${systemdconfigdir}/${servicefile}"
cp "systemd/services/${servicefile}" "${destination}"
chmod +x "${destination}"
chown "${user}:${user}" "${destination}"
replace_text "${destination}" "toolpath" "${homedir}/podman-tools" "user" "${user}"
systemd_reload_enable "${user}" "${servicefile}"
# Copy Systemd Timer File
timerfile="podman-service-reconfigure-autostart.timer"
destination="${systemdconfigdir}/${timerfile}"
cp "systemd/timers/${timerfile}" "${destination}"
chmod +x "${destination}"
chown "${user}:${user}" "${destination}"
replace_text "${destination}" "toolpath" "${homedir}/podman-tools" "user" "${user}"
systemd_reload_enable "${user}" "${timerfile}"
else
# Error
schedule_mode_not_supported "${schedulemode}"
fi