diff options
20 files changed, 71 insertions, 41 deletions
@@ -1,6 +1,25 @@ # ChangeLog for gentoo-vdr-scripts # $Id$ + 06 Jul 2008; Matthias Schwarzott <zzam@gentoo.org> + usr/share/vdr/shutdown/pre-shutdown-05-time-calculations.sh, + usr/share/vdr/shutdown/pre-shutdown-10-check-enabled.sh, + usr/share/vdr/rcscript/pre-start-10-chuid.sh, + usr/share/vdr/rcscript/pre-start-20-dvb-device.sh, + usr/share/vdr/rcscript/watchdog-restart-20-modules.sh, + usr/share/vdr/shutdown/pre-shutdown-30-check-logins.sh, + usr/share/vdr/rcscript/pre-start-30-parameter.sh, + usr/share/vdr/rcscript/pre-start-45-nptl-check.sh, + usr/share/vdr/shutdown/periodic-50-epgscan.sh, + usr/share/vdr/rcscript/pre-start-50-shutdown.sh, + usr/share/vdr/shutdown/pre-shutdown-99-periodic-thread.sh, etc/conf.d/vdr, + etc/init.d/vdr, usr/share/vdr/bin/vdrshutdown-gate.sh, + usr/share/vdr/inc/functions.sh, usr/share/vdr/inc/plugin-functions.sh, + usr/share/vdr/inc/rc-functions.sh, + usr/share/vdr/inc/shutdown-functions.sh, + usr/share/vdr/shutdown/wakeup-none.sh: + Use yesno from openrc, but provide replacement for older baselayout. + 04 Jul 2008; Matthias Schwarzott <zzam@gentoo.org> vdrplugin-rebuild/vdrplugin-rebuild: Add hack to use an existing checksum file if plugin-name != ebuild-name. diff --git a/etc/conf.d/vdr b/etc/conf.d/vdr index c4e43c6..9f799c3 100644 --- a/etc/conf.d/vdr +++ b/etc/conf.d/vdr @@ -211,7 +211,7 @@ PLUGIN_CHECK_PATCHLEVEL="yes" # for people who really know what they do # and who want to start vdr as user root -# allowed values: YES no +# allowed values: yes no # default: no #START_VDR_AS_ROOT="no" diff --git a/etc/init.d/vdr b/etc/init.d/vdr index cf87e07..a63a0a2 100755 --- a/etc/init.d/vdr +++ b/etc/init.d/vdr @@ -55,7 +55,7 @@ start_vdr() { local _openvt= openvt_opts= TERM_DEV=/dev/tty${TERMINAL} if [ -n "${TERMINAL}" -a -e "${TERM_DEV}" ]; then - [ "${SWITCH_TO_TERMINAL}" = "yes" ] && openvt_opts="-s" + yesno "${SWITCH_TO_TERMINAL}" && openvt_opts="-s" _openvt="openvt -c ${TERMINAL} ${openvt_opts} --" { @@ -105,7 +105,7 @@ stop_vdr() { } start_watchdog() { - [ "${ENABLE_EXTERNAL_WATCHDOG:-yes}" = "yes" ] || return 0 + yesno "${ENABLE_EXTERNAL_WATCHDOG:-yes}" || return 0 ebegin "Starting vdr watchdog" start-stop-daemon \ --start \ @@ -120,7 +120,7 @@ start_watchdog() { stop_watchdog() { - if [ "${ENABLE_EXTERNAL_WATCHDOG:-yes}" = "yes" ]; then + if yesno "${ENABLE_EXTERNAL_WATCHDOG:-yes}"; then ebegin "Stopping vdr watchdog" start-stop-daemon --stop --pidfile /var/run/vdrwatchdog.pid --name vdr-watchdogd eend $? "failed stopping watchdog" diff --git a/usr/share/vdr/bin/vdrshutdown-gate.sh b/usr/share/vdr/bin/vdrshutdown-gate.sh index 7b1d616..860b768 100644 --- a/usr/share/vdr/bin/vdrshutdown-gate.sh +++ b/usr/share/vdr/bin/vdrshutdown-gate.sh @@ -188,7 +188,7 @@ init_forced_shutdown() { fi NOW=$(date +%s) local DISTANCE=$(($NOW-$LAST_SHUTDOWN_ABORT)) - if [ "${DISTANCE}" -lt "${SHUTDOWN_FORCE_DETECT_INTERVALL}" ]; then + if [ "${DISTANCE}" -lt "${SHUTDOWN_FORCE_DETECT_INTERVALL:-60}" ]; then THIS_SHUTDOWN_IS_FORCED="1" fi diff --git a/usr/share/vdr/inc/functions.sh b/usr/share/vdr/inc/functions.sh index 67c5596..2289451 100644 --- a/usr/share/vdr/inc/functions.sh +++ b/usr/share/vdr/inc/functions.sh @@ -22,3 +22,25 @@ read_caps() [ -f "${capfile}" ] && . ${capfile} } +if ! type yesno >/dev/null 2>&1; then + +yesno() +{ + [ -z "$1" ] && return 1 + + case "$1" in + [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;; + [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;; + esac + + local value= + eval value=\$${1} + case "${value}" in + [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0;; + [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1;; + *) vewarn "\$${1} is not set properly"; return 1;; + esac +} +fi + + diff --git a/usr/share/vdr/inc/plugin-functions.sh b/usr/share/vdr/inc/plugin-functions.sh index 1ebfa20..fc7dc24 100644 --- a/usr/share/vdr/inc/plugin-functions.sh +++ b/usr/share/vdr/inc/plugin-functions.sh @@ -83,11 +83,10 @@ prepare_plugin_checks() { # needed for plugin patchlevel check vdr_checksum_dir="${plugin_dir%/plugins}/checksums" vdr_checksum="${PL_TMP}"/header-md5-vdr - PLUGIN_CHECK_MD5=no - if [ "${PLUGIN_CHECK_PATCHLEVEL:-yes}" = "yes" ] && \ - vdr-get-header-checksum > "${vdr_checksum}" - then - PLUGIN_CHECK_MD5=yes + + PLUGIN_CHECK_MD5=false + if yesno "${PLUGIN_CHECK_PATCHLEVEL:-yes}"; then + vdr-get-header-checksum > "${vdr_checksum}" && PLUGIN_CHECK_MD5=true fi } @@ -101,7 +100,7 @@ check_plugin() { fi local plugin_checksum_file=${vdr_checksum_dir}/header-md5-vdr-${PLUGIN} - if [ "${PLUGIN_CHECK_MD5}" = "yes" ] && [ -e "${plugin_checksum_file}" ]; then + if ${PLUGIN_CHECK_MD5} && [ -e "${plugin_checksum_file}" ]; then if ! cmp -s ${vdr_checksum} ${plugin_checksum_file}; then skip_plugin "${PLUGIN}" "PATCHLEVEL" return 1 diff --git a/usr/share/vdr/inc/rc-functions.sh b/usr/share/vdr/inc/rc-functions.sh index 30698f2..208b4d6 100644 --- a/usr/share/vdr/inc/rc-functions.sh +++ b/usr/share/vdr/inc/rc-functions.sh @@ -23,10 +23,8 @@ getvdrversion() APIVERSION=$(awk -F'"' '/define APIVERSION/ {print $2}' /usr/include/vdr/config.h) [ -z "${APIVERSION}" ] && APIVERSION="${VDRVERSION}" - case ${SHOW_VDR_VERSION:=no} in - yes) VDRNAME=vdr-${VDRVERSION} ;; - *) VDRNAME=vdr ;; - esac + VDRNAME=vdr + yesno "${SHOW_VDR_VERSION}" && VDRNAME=${VDRNAME}-${VDRVERSION} } [ -z "${VDR_BIN}" ] && VDR_BIN=/usr/bin/vdr diff --git a/usr/share/vdr/inc/shutdown-functions.sh b/usr/share/vdr/inc/shutdown-functions.sh index 101b7bb..66b79bf 100644 --- a/usr/share/vdr/inc/shutdown-functions.sh +++ b/usr/share/vdr/inc/shutdown-functions.sh @@ -8,8 +8,3 @@ shutdown_script_dir=/usr/share/vdr/shutdown shutdown_data_dir=/var/vdr/shutdown-data . /etc/conf.d/vdr.shutdown - -# set defaults -SHUTDOWN_ACTIVE="${SHUTDOWN_ACTIVE:-no}" -SHUTDOWN_FORCE_DETECT_INTERVALL="${SHUTDOWN_FORCE_DETECT_INTERVALL:-60}" - diff --git a/usr/share/vdr/rcscript/pre-start-10-chuid.sh b/usr/share/vdr/rcscript/pre-start-10-chuid.sh index f28278a..4a58526 100644 --- a/usr/share/vdr/rcscript/pre-start-10-chuid.sh +++ b/usr/share/vdr/rcscript/pre-start-10-chuid.sh @@ -1,11 +1,11 @@ # $Id$ addon_main() { - if [ "${START_VDR_AS_ROOT}" != "YES" ]; then - if [ -n "${CAP_CHUID}" -a "${FORCE_SETUID_OFF:-no}" = "no" ]; then - add_param "-u" "vdr" - else - add_daemonctrl_param --chuid vdr - fi + yesno "${START_VDR_AS_ROOT}" && return 0 + + if [ -n "${CAP_CHUID}" ] && ! yesno "${FORCE_SETUID_OFF}"; then + add_param "-u" "vdr" + else + add_daemonctrl_param --chuid vdr fi return 0 } diff --git a/usr/share/vdr/rcscript/pre-start-20-dvb-device.sh b/usr/share/vdr/rcscript/pre-start-20-dvb-device.sh index bdd3884..bc9442f 100644 --- a/usr/share/vdr/rcscript/pre-start-20-dvb-device.sh +++ b/usr/share/vdr/rcscript/pre-start-20-dvb-device.sh @@ -11,9 +11,7 @@ check_dvbdevice() { } addon_main() { - DEVICE_CHECK=${DEVICE_CHECK:-yes} - - if [ "${DEVICE_CHECK}" = "yes" ]; then + if yesno "${DEVICE_CHECK:-yes}"; then add_wait_condition check_dvbdevice fi return 0 diff --git a/usr/share/vdr/rcscript/pre-start-30-parameter.sh b/usr/share/vdr/rcscript/pre-start-30-parameter.sh index 6b1e9f6..db7c4e6 100644 --- a/usr/share/vdr/rcscript/pre-start-30-parameter.sh +++ b/usr/share/vdr/rcscript/pre-start-30-parameter.sh @@ -9,7 +9,7 @@ addon_main() { # parameters of vdr add_param "--watchdog=${INTERNAL_WATCHDOG:-60}" [ -n "${AC3_AUDIO}" ] && add_param "--audio=${AC3_AUDIO}" - [ "${MUTE}" = "yes" ] && add_param "--mute" + yesno "${MUTE}" && add_param "--mute" [ -n "${CONFIG}" ] && add_param "--config=${CONFIG}" [ -n "${DEVICE}" ] && for i in ${DEVICE}; do add_param "--device=${i}"; done [ -n "${EPGFILE}" ] && add_param "--epgfile=${EPGFILE}" @@ -32,7 +32,7 @@ addon_main() { esac fi - if [ -n "${CAP_VFAT_RUNTIME_PARAM}" ] && [ "${VFAT_FILENAMES}" = "yes" ]; then + if [ -n "${CAP_VFAT_RUNTIME_PARAM}" ] && yesno "${VFAT_FILENAMES}"; then add_param "--vfat" fi diff --git a/usr/share/vdr/rcscript/pre-start-45-nptl-check.sh b/usr/share/vdr/rcscript/pre-start-45-nptl-check.sh index 1a7eb4e..39943f4 100644 --- a/usr/share/vdr/rcscript/pre-start-45-nptl-check.sh +++ b/usr/share/vdr/rcscript/pre-start-45-nptl-check.sh @@ -1,6 +1,6 @@ # $Id$ addon_main() { - if [ "${FORCE_OLD_THREADS:-yes}" = "yes" ]; then + if yesno "${FORCE_OLD_THREADS:-yes}"; then # Test wheather force of old pthreads will work if LD_ASSUME_KERNEL=2.4.1 /bin/true 2>/dev/null; then export LD_ASSUME_KERNEL=2.4.1 diff --git a/usr/share/vdr/rcscript/pre-start-50-shutdown.sh b/usr/share/vdr/rcscript/pre-start-50-shutdown.sh index 7b4fe96..60d8156 100644 --- a/usr/share/vdr/rcscript/pre-start-50-shutdown.sh +++ b/usr/share/vdr/rcscript/pre-start-50-shutdown.sh @@ -2,7 +2,7 @@ addon_main() { include shutdown-functions - [ "${SHUTDOWN_ACTIVE}" = "no" ] && return 0 + yesno "${SHUTDOWN_ACTIVE}" || return 0 if [ -n "${USER_SHUTDOWN_SCRIPT}" ]; then add_param "--shutdown=${USER_SHUTDOWN_SCRIPT}" diff --git a/usr/share/vdr/rcscript/watchdog-restart-20-modules.sh b/usr/share/vdr/rcscript/watchdog-restart-20-modules.sh index 40b676f..a0ad331 100644 --- a/usr/share/vdr/rcscript/watchdog-restart-20-modules.sh +++ b/usr/share/vdr/rcscript/watchdog-restart-20-modules.sh @@ -5,7 +5,7 @@ # addon_main() { - if [ "${WATCHDOG_RELOAD_DVB_MODULES:-no}" = "yes" ]; then + if yesno "${WATCHDOG_RELOAD_DVB_MODULES}"; then dvb-reload-modules reload fi return 0 diff --git a/usr/share/vdr/shutdown/periodic-50-epgscan.sh b/usr/share/vdr/shutdown/periodic-50-epgscan.sh index 44aeff4..629b7bc 100644 --- a/usr/share/vdr/shutdown/periodic-50-epgscan.sh +++ b/usr/share/vdr/shutdown/periodic-50-epgscan.sh @@ -4,7 +4,7 @@ : ${PERIODIC_EPGSCAN:=no} : ${PERIODIC_EPGSCAN_DURATION:=10} -if [ ${PERIODIC_EPGSCAN} = "yes" ]; then +if yesno "${PERIODIC_EPGSCAN}"; then /usr/bin/svdrpsend.pl SCAN sleep ${PERIODIC_EPGSCAN_DURATION}m fi diff --git a/usr/share/vdr/shutdown/pre-shutdown-05-time-calculations.sh b/usr/share/vdr/shutdown/pre-shutdown-05-time-calculations.sh index 1e4a3d8..2b6992f 100644 --- a/usr/share/vdr/shutdown/pre-shutdown-05-time-calculations.sh +++ b/usr/share/vdr/shutdown/pre-shutdown-05-time-calculations.sh @@ -45,7 +45,7 @@ calculate_wakeup_timer () } catch_running_timer -if [ "${FIXED_WAKEUP:-no}" = "yes" ]; then +if yesno "${FIXED_WAKEUP}"; then calculate_wakeup_timer fi diff --git a/usr/share/vdr/shutdown/pre-shutdown-10-check-enabled.sh b/usr/share/vdr/shutdown/pre-shutdown-10-check-enabled.sh index e5e3ff8..e128e8f 100644 --- a/usr/share/vdr/shutdown/pre-shutdown-10-check-enabled.sh +++ b/usr/share/vdr/shutdown/pre-shutdown-10-check-enabled.sh @@ -1,4 +1,4 @@ # $Id$ -if is_auto_shutdown && [ "${AUTOMATIC_SHUTDOWN:-yes}" = "no" ]; then +if is_auto_shutdown && ! yesno "${AUTOMATIC_SHUTDOWN:-yes}"; then shutdown_abort_exit "automatic shutdown disabled" fi diff --git a/usr/share/vdr/shutdown/pre-shutdown-30-check-logins.sh b/usr/share/vdr/shutdown/pre-shutdown-30-check-logins.sh index 4df941a..c9c87c9 100644 --- a/usr/share/vdr/shutdown/pre-shutdown-30-check-logins.sh +++ b/usr/share/vdr/shutdown/pre-shutdown-30-check-logins.sh @@ -6,6 +6,6 @@ check_logins() { fi } -if [ "${VDR_CHECK_LOGINS:-yes}" = "yes" ]; then +if yesno "${VDR_CHECK_LOGINS:-yes}"; then check_logins fi diff --git a/usr/share/vdr/shutdown/pre-shutdown-99-periodic-thread.sh b/usr/share/vdr/shutdown/pre-shutdown-99-periodic-thread.sh index 4dc99d5..c20a5d8 100644 --- a/usr/share/vdr/shutdown/pre-shutdown-99-periodic-thread.sh +++ b/usr/share/vdr/shutdown/pre-shutdown-99-periodic-thread.sh @@ -7,8 +7,7 @@ PERIODIC_THREAD_ENDTIME=${shutdown_data_dir}/periodic_thread_last_ended check_periodic_thread() { # test if periodic thread is activated - : ${ENABLE_SHUTDOWN_PERIODIC_JOBS:=no} - [ "${ENABLE_SHUTDOWN_PERIODIC_JOBS}" = "yes" ] || return + yesno "${ENABLE_SHUTDOWN_PERIODIC_JOBS}" || return # when periodic-thread runs if pidof -x vdrshutdown-periodic-thread.sh >/dev/null; then diff --git a/usr/share/vdr/shutdown/wakeup-none.sh b/usr/share/vdr/shutdown/wakeup-none.sh index 9fd25d4..15aaacb 100644 --- a/usr/share/vdr/shutdown/wakeup-none.sh +++ b/usr/share/vdr/shutdown/wakeup-none.sh @@ -6,7 +6,7 @@ if [ "${VDR_WAKEUP_TIME}" != 0 ]; then # it is not possible to wakeup the system! - if [ "${NONE_WAKEUP_IGNORE_TIMER:-no}" = "yes" ]; then + if yesno "${NONE_WAKEUP_IGNORE_TIMER}"; then # ignoring set timers : else |