issue2: which_is() repariert, sodass fehlendes executable erkannt wird. Art der Rückgabe geändert: jetzt als Referenz. Diverse if mit zuweisungen statt vergleich repariert.

This commit is contained in:
Stephan
2023-03-09 23:00:08 +01:00
parent b1f4fde65d
commit cc69f0e624
2 changed files with 77 additions and 28 deletions

BIN
Jannikas Zahn.JPG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 MiB

View File

@@ -4,8 +4,9 @@
## Vom Bild wird eine angepasste Version für das Blog erzeugt, auf Wunsch auch ein großes.
## Zeitlich einsortiert wird es mit Hilfe der Exif-Daten. Ein Link zum Einfügen ins Blog
## wird in der Zwischenablage abgelegt.
## Author swg, knapp80ps.de, November 2013
## Author swg, janeemussja.de, November 2013
## letzte Änderungen
## - März 2023, Version 1.07, which_is Funktion repariert
## - Juni 2021, Version 1.06, Progress bar eingebaut
## - Januar 2021, Version 1.05, Test auf fehlende Software geändert.
## - Oktober 2019, Version 1.03, Das extrahieren des Vorschaubildes aus Exif war in Version 1.02 verloren gegangen -> ist wieder drin
@@ -47,55 +48,98 @@ exec 4>&-
}
function which_is() {
EXECUTABLE=$1;
WITHFULLPATH=$(which ${EXECUTABLE} 2>/dev/null);
if [ -x ${WITHFULLPATH} ];
then
echo ${WITHFULLPATH};
else
$(logger $ERROR "${EXECUTABLE} not found! abort.");
exit 1;
fi
declare -n RETVAL=$1;
EXECUTABLE=$2;
WITHFULLPATH=$(which ${EXECUTABLE} 2>/dev/null);
if [ -x "$WITHFULLPATH" ];
then
RETVAL="$WITHFULLPATH";
return 0;
else
RETVAL="$EXECUTABLE not found!";
return 1;
fi
}
# Was wir am Anfang brauchen
PATH=$PATH:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/global/bin:/global-common/scripts:/usr/sfw/bin:/opt/sfw/bin:/usr/ccs/bin:/usr/xpg4/bin:/opt/SUNWspro/bin:/usr/dt/bin:/usr/openwin/bin:/usr/ucb:/opt/bin
## Prüfen der notwendigen Software auf Existenz und Ausführbarkeit
# zenity
MSGDIALOG=$(which_is "zenity");
which_is MSGDIALOG 'zenity';
if [[ "$?" != "0" ]];
then
echo "$MSGDIALOG not found, aborting";
exit 1;
fi
# imagemagick
CONVERT=$(which_is "convert");
which_is CONVERT 'convert';
if [[ "$?" != "0" ]];
then
echo "$CONVERT not found, aborting";
exit 1;
fi
IMGDISPLAY=$(which_is "display");
# imagemagick
which_is IMGDISPLAY 'display';
if [[ "$?" != "0" ]];
then
echo "$IMGDISPLAY not found, aborting";
exit 1;
fi
# date
DATE=$(which_is "date");
which_is DATE 'date';
if [[ "$?" != "0" ]];
then
echo "$DATE not found, aborting";
exit 1;
fi
# exiftool
EXIFTOOL=$(which_is "exiftool");
which_is EXIFTOOL 'exiftool';
if [[ "$?" != "0" ]];
then
echo "$EXIFTOOL not found, aborting";
exit 1;
fi
# xclip
XCLIP=$(which_is "xclip");
which_is XCLIP 'xclip';
if [[ "$?" != "0" ]];
then
echo "$XCLIP not found, aborting";
exit 1;
fi
# printf
PRINTF=$(which_is "printf");
which_is PRINTF 'printf';
if [[ "$?" != "0" ]];
then
echo "$PRINTF not found, aborting";
exit 1;
fi
# sed
SED=$(which_is "sed");
which_is SED 'sed';
if [[ "$?" != "0" ]];
then
echo "$SED not found, aborting";
exit 1;
fi
SCRIPTNAME=$(echo $0 | sed -e 's/.*\///g');
VERSION="1.06";
VERS=1.06;
VERSION="1.07";
VERS=1.07;
ME=$(whoami);
TMPPFAD=/tmp;
MYHOME=$(echo ~);
USTRICH="_";
exec 3> >($MSGDIALOG --notification --listen);
exec 3> >($MSGDIALOG --notification --listen)
# The PID of zenity is needed to kill the process at the end of the script
ZenityPID=$!;
#((ZenityPID=ZenityPID+1)) # this is a workaround as I don't know how to get the PID of zenity (but get the one of exec)
@@ -151,7 +195,8 @@ MAX_INP_C=$INP_C;
for((INP_C=0;INP_C<${#FILE[*]};INP_C++));
do
#echo "Bearbeite: ${FILE[$INP_C]}";
# Mögliches Vorschaubild aus exif holen
#echo "Preview: $local_blog_path/preview.jpg";
# Mögliches Vorschaubild aus exif holen und anzeigen
$EXIFTOOL -b -W "$local_blog_path/preview.jpg" -preview:PreviewImage "${FILE[$INP_C]}";
if [ -f "$local_blog_path/preview.jpg" ]; then # Wenn exifvorschau existierte: Anzeigen
origOrient=$($EXIFTOOL -s -s -s -n -Orientation "${FILE[$INP_C]}");
@@ -177,8 +222,9 @@ do
## Lokalen Speicherpfad erzeugen
if [ ! -d "$local_blog_path/${OUT_PATH_Y}/${OUT_PATH_M}" ]; then
mkdir -p "$local_blog_path/${OUT_PATH_Y}/${OUT_PATH_M}";
if [ ! $? == 0 ]; then
echo "tooltip: erzeuge lokalen Speicherpfad $local_blog_path/${OUT_PATH_Y}/${OUT_PATH_M}." >&3
mkdir "$local_blog_path/${OUT_PATH_Y}/${OUT_PATH_M}";
if [ "$?" -ne "0" ]; then
echo "tooltip:Konnte lokalen Speicherpfad $local_blog_path/${OUT_PATH_Y}/${OUT_PATH_M} für Bilder nicht erzeugen!" >&3
kill $IMGDISPLAYPID;
CleanUp;
@@ -186,12 +232,15 @@ do
fi
fi
## Wartezeit, während Vorschaubild geladen wird, damit es nicht das dialogfeld überlagert
sleep 5;
## Dateinamen erfragen
FILENAME="";
while [ -z "${FILENAME}" ]
do
FILENAME=$($MSGDIALOG --entry --title "Dateiname" --text "Welchen Dateinamen soll das Bild bekommen?" --entry-text="$OUT_DAY$USTRICH" 2> /dev/null);
if [ "$?" = "1" ]; then # Es wurde Abbruch geklickt, Script endet:
if [ "$?" -eq "1" ]; then # Es wurde Abbruch geklickt, Script endet:
kill $IMGDISPLAYPID;
CleanUp;
exit 1;
@@ -214,7 +263,7 @@ do
## Soll ein großes Bild erzeugt werden?
$MSGDIALOG --question --title "Großes Bild" --text "Soll ein großes Bild erzeugt werden?" 2> /dev/null;
if [ "$?" == "0" ]; then ## Großes Bild erzeugen
if [ "$?" -eq "0" ]; then ## Großes Bild erzeugen
$PRINTF "<a href=\"%s/%s/%s/%s.jpg\" data-fancybox=\"\" data-caption=\"\"><img src=\"%s/%s/%s/%s_.jpg\" class=\"aligncenter\" alt=\"\"></a>" ${blog_address} ${OUT_PATH_Y} ${OUT_PATH_M} ${FILENAME} ${blog_address} ${OUT_PATH_Y} ${OUT_PATH_M} ${FILENAME} | $XCLIP; # Linkadresse in die Zwischenablage legen
$CONVERT "${FILE[$INP_C]}" -auto-orient -rotate $ROTATE -resize "${w_blog_img}x${h_blog_img}" -quality 95 -unsharp 1.5x1.0+1.5+0.02 "${OUTFILE_}" &
CONVERTPID=$!;