#!/bin/sh
#
# display file content from cache, used by linbo_gui to get the image description
# thomas@linuxmuster.net
# 20251110
#

# test options
[ -z "$1" ] && exit 1

# shift obsolete cache device name option given by linbo_gui
if [ -b "$1" -o "$1" = "/cache" ]; then
    shift
    GUI="yes"
fi

# test remaining option
[ -z "$1" ] && exit 1

descfile="/cache/$1"
if [ -f "$descfile" ]; then

    # display file content
    cat "$descfile" || exit 1

elif [ -n "$GUI" -a ! -e "$descfile" ]; then

    # display date in case of gui invokation and file does not exist
    echo "$(date): "

else

    # file does not exist or is no file
    exit 1

fi
