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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
|
#!/bin/sh
# shellcheck disable=SC2034
# We expand enable_* variables via eval
set -e
set -u
pkgconf="${PKG_CONFIG-pkgconf}"
# SC2016: the variable expansion is handled by Make
prefix='/usr'
# shellcheck disable=SC2016
bindir='$(prefix)/bin'
# shellcheck disable=SC2016
datadir='$(prefix)/share'
# shellcheck disable=SC2016
libdir='$(prefix)/lib'
# shellcheck disable=SC2016
libexecdir='$(prefix)/libexec'
statedir='/var/spool/cron'
# shellcheck disable=SC2016
mandir='$(datadir)/man'
# shellcheck disable=SC2016
docdir='$(datadir)/doc/systemd-cron'
# shellcheck disable=SC2016
unitdir="$($pkgconf systemd --variable=systemdsystemunitdir)" 2>/dev/null || \
unitdir='$(libdir)/systemd/system'
# shellcheck disable=SC2016
generatordir="$($pkgconf systemd --variable=systemdsystemgeneratordir)" 2>/dev/null || \
generatordir='$(libdir)/systemd/system-generators'
# shellcheck disable=SC2016
sysusersdir="$($pkgconf systemd --variable=sysusersdir)" 2>/dev/null || \
sysusersdir='$(libdir)/sysusers.d'
# shellcheck disable=SC2016
tmpfilesdir="$($pkgconf systemd --variable=tmpfilesdir)" 2>/dev/null || \
tmpfilesdir='$(libdir)/tmpfiles.d'
libmd="$($pkgconf --cflags --libs libmd)" 2>/dev/null || \
libmd='-lmd'
libsystemd="$($pkgconf --cflags --libs libsystemd)" 2>/dev/null || \
libsystemd='-lsystemd'
enable_runparts=no
use_loglevelmax=no
part2timer=/dev/null
crond2timer=/dev/null
pamname=
read -r version < VERSION
enable_boot=yes
enable_minutely=no
enable_hourly=yes
enable_daily=yes
enable_weekly=yes
enable_monthly=yes
enable_quarterly=no
enable_semi_annually=no
enable_yearly=yes
# TODO: roll back to straight OnSuccess= if we ever bump past the systemd ≥ 236 requirement (this is 249); cf. #165
have_onsuccess="$($pkgconf systemd --max-version=249 && echo no)" 2>/dev/null || \
have_onsuccess=yes
orig_args="$*"
ARGS=$(getopt -n "$(basename "${0}")" -o '' -l '
help::,
prefix:,
bindir:,
confdir:,
datadir:,
libdir:,
libexecdir:,
statedir:,
mandir:,
docdir:,
unitdir:,
generatordir:,
sysusersdir:,
tmpfilesdir:,
enable-boot::,
enable-minutely::,
enable-hourly::,
enable-daily::,
enable-weekly::,
enable-monthly::,
enable-quarterly::,
enable-semi_annually::,
enable-yearly::,
enable-runparts::,
use-loglevelmax::,
with-part2timer:,
with-crond2timer:,
with-pamname:,
with-version:,
' -- "${@}")
usage()
{
grep ^'### Configuration' README.md -A 50
}
# shellcheck disable=SC2181
if [ $? -ne 0 ]
then
usage
exit 1
fi
set_enable_flag()
{
if [ -z "${2}" ]
then
eval "enable_${1}=yes"
elif [ "${2}" = 'yes' ] || [ "${2}" = 'no' ]; then
eval "enable_${1}=${2}"
else
echo "ERROR: Unknown value for enable-${1}: '${2}'. Expected 'yes' or 'no'."
fi
}
eval set -- "${ARGS}"
while true;
do
case "${1}" in
'--help')
usage
exit 0;;
'--prefix')
prefix="${2}"
shift 2;;
'--bindir')
bindir="${2}"
shift 2;;
'--confdir')
echo "--confdir ${2} is ignored"
shift 2;;
'--datadir')
datadir="${2}"
shift 2;;
'--libdir')
libdir="${2}"
shift 2;;
'--libexecdir')
libexecdir="${2}"
shift 2;;
'--statedir')
statedir="${2}"
shift 2;;
'--mandir')
mandir="${2}"
shift 2;;
'--docdir')
docdir="${2}"
shift 2;;
'--unitdir')
unitdir="${2}"
shift 2;;
'--generatordir')
generatordir="${2}"
shift 2;;
'--sysusersdir')
sysusersdir="${2}"
shift 2;;
'--tmpfilesdir')
tmpfilesdir="${2}"
shift 2;;
'--libmd')
libmd="${2}"
shift 2;;
'--enable-boot')
set_enable_flag boot "${2}"
shift 2;;
'--enable-minutely')
set_enable_flag minutely "${2}"
shift 2;;
'--enable-hourly')
set_enable_flag hourly "${2}"
shift 2;;
'--enable-daily')
set_enable_flag daily "${2}"
shift 2;;
'--enable-weekly')
set_enable_flag weekly "${2}"
shift 2;;
'--enable-monthly')
set_enable_flag monthly "${2}"
shift 2;;
'--enable-quarterly')
set_enable_flag quarterly "${2}"
shift 2;;
'--enable-semi_annually')
set_enable_flag semi_annually "${2}"
shift 2;;
'--enable-yearly')
set_enable_flag yearly "${2}"
shift 2;;
'--enable-runparts')
set_enable_flag runparts "${2}"
shift 2;;
'--use-loglevelmax')
case "${2}" in
'alert'|'crit'|'err'|'warning'|'notice'|'info'|'debug')
use_loglevelmax="${2}";;
*)
echo "ERROR: Unknown value for use-loglevelmax: '${2}'. Expected 'alert', 'crit', 'err', 'warning', 'notice', 'info', or 'debug'.";;
esac
shift 2;;
'--with-part2timer')
part2timer="${2}"
shift 2;;
'--with-crond2timer')
crond2timer="${2}"
shift 2;;
'--with-pamname')
pamname="${2}"
shift 2;;
'--with-version')
version="${2}"
shift 2;;
'--')
shift
break;;
esac
done
check_sched_enabled()
{
if eval [ "\"\${enable_${1}}\"" = \'yes\' ]; then
schedules="${schedules} ${2}"
else
schedules_not="${schedules_not} ${2}"
fi
}
schedules=""
schedules_not=""
check_sched_enabled boot boot
check_sched_enabled minutely minutely
check_sched_enabled hourly hourly
check_sched_enabled daily daily
check_sched_enabled weekly weekly
check_sched_enabled monthly monthly
check_sched_enabled quarterly quarterly
check_sched_enabled semi_annually semi-annually
check_sched_enabled yearly yearly
exec 2>&1
set -x
sed "
1i\
# Generated by $0 ${orig_args}
s|@schedules@|${schedules}|g
s|@schedules_not@|${schedules_not}|g
s|@enable_runparts@|${enable_runparts}|g
s|@prefix@|${prefix}|g
s|@bindir@|${bindir}|g
s|@datadir@|${datadir}|g
s|@libdir@|${libdir}|g
s|@libexecdir@|${libexecdir}|g
s|@statedir@|${statedir}|g
s|@mandir@|${mandir}|g
s|@docdir@|${docdir}|g
s|@unitdir@|${unitdir}|g
s|@generatordir@|${generatordir}|g
s|@sysusersdir@|${sysusersdir}|g
s|@tmpfilesdir@|${tmpfilesdir}|g
s|@libmd@|${libmd}|g
s|@libsystemd@|${libsystemd}|g
s|@use_loglevelmax@|${use_loglevelmax}|g
s|@part2timer@|${part2timer}|g
s|@crond2timer@|${crond2timer}|g
s|@pamname@|${pamname}|g
s|@version@|${version}|g
s|@have_onsuccess@|${have_onsuccess}|g
" Makefile.in > Makefile
|