new package OBS-URL: https://build.opensuse.org/request/show/1071115 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-generator-cron2timer?expand=0&rev=1
34 lines
742 B
Bash
34 lines
742 B
Bash
#!/bin/bash
|
|
# SPDX-License-Identifier: MIT
|
|
# SPDX-FileCopyrightText: Copyright 2022-2023 SUSE LLC
|
|
set -e
|
|
out="${1:?}"
|
|
shopt -s nullglob
|
|
mkdir -p "$out/timers.target.wants/"
|
|
for interval in hourly daily weekly monthly yearly; do
|
|
for script in /etc/cron."$interval"/*; do
|
|
f="${script##*/}"
|
|
cat > "$out/$interval-$f.timer" <<-EOF
|
|
[Unit]
|
|
Description=Timer created from $script
|
|
|
|
[Timer]
|
|
OnCalendar=$interval
|
|
AccuracySec=1h
|
|
Persistent=true
|
|
|
|
[Install]
|
|
WantedBy=timers.target
|
|
EOF
|
|
cat > "$out/$interval-$f.service" <<-EOF
|
|
[Unit]
|
|
Description=Service created from $script
|
|
ConditionACPower=true
|
|
|
|
[Service]
|
|
ExecStart=$script
|
|
EOF
|
|
ln -s "../$interval-$f.timer" "$out/timers.target.wants/$interval-$f.timer"
|
|
done
|
|
done
|