From: Frank Brehm Date: Sat, 2 Sep 2017 06:45:21 +0000 (+0200) Subject: Adding additional checks X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=748460398041817a8a347b387dc7b4745d62684e;p=my-stuff%2Ftools.git Adding additional checks --- diff --git a/bin/convert_movie.sh b/bin/convert_movie.sh index dea14b4..27294da 100755 --- a/bin/convert_movie.sh +++ b/bin/convert_movie.sh @@ -4,7 +4,7 @@ set -e set -u -VERSION="0.3.3" +VERSION="0.4.1" #------------------------------------------------------------------------------ DEBUG="n" @@ -364,6 +364,50 @@ get_cmd_options() { } +#------------------------------------------------------------------------------ +check_binary() { + + local binary="$1" + + debug "Überprüfe Existenz von Binary '${binary}' ..." + if [[ -x "${binary}" ]] ; then + debug "Binary '${binary}' ist ausführbar." + return 0 + fi + + if type -t "${binary}" >/dev/null ; then + local btype=$( type -t "${binary}" ) + if [[ "${btype}" == 'file' ]] ; then + debug "Binary '${binary}' ist aufrufbar unter '$( type -p "${binary}" )'." + else + debug "Binary '${binary}' ist ein '${btype}'." + fi + return 0 + else + error "Binary '${RED}${binary}${NORMAL}' existiert nicht." + return 3 + fi + +} + +#------------------------------------------------------------------------------ +check_for_binaries() { + + local cbinary= + local exists="y" + + for cbinary in rm ffmpeg mencoder ; do + if ! check_binary "${cbinary}" ; then + exists="n" + fi + done + + if [[ "${exists}" != "y" ]] ; then + exit 5 + fi + +} + #------------------------------------------------------------------------------ countdown() { @@ -420,8 +464,8 @@ preparing() { info "Vorbereitungen ..." local workdir=$( dirname "${TGT_MOVIE}" ) - TMP_MOVIE=$( mktemp --tmpdir="${workdir}" tmp.XXXXXXXX.avi ) - debug "Temporäre Film-Datei: '${TMP_MOVIE}'." + # TMP_MOVIE=$( mktemp --tmpdir="${workdir}" tmp.XXXXXXXX.avi ) + # debug "Temporäre Film-Datei: '${TMP_MOVIE}'." trap cleanup EXIT TERM HUP INT @@ -497,6 +541,12 @@ video_converting2() { main() { get_cmd_options "$@" + check_for_binaries + + if [[ ! -f "${SRC_MOVIE}" ]] ; then + error "Ausgangsdatei '${RED}${SRC_MOVIE}${NORMAL}' existiert nicht." + exit 1 + fi echo echo "####################################################################"