File debian.postinst of Package zoom-appimage

#!/bin/bash
# --- Variables ---
TITLE="Zoom AppImage"
pkgver=PACKAGEVERSION # not really needed anymore if latest_app points to the correct file
executable=zoom
executable_tag=appimage
launcher=${executable}-${executable_tag}
#architecture=$(uname -m)
architecture=$(lscpu | awk '/Architecture:/{print $2}')
webDir="https://download.opensuse.org/repositories/home:/kimi:/zoom/AppImage/"
APPIMAGE="${webDir}zoom-latest-${architecture}.AppImage"
# --- End variables ---
# Download Zoom AppImage file to the correct location
echo "Closing ${executable}.AppImage ..."
pkill AppRun.wrapped
killall ${launcher}
echo "wait a few seconds to terminate ${executable}.AppImage ..."
sleep 5s
# Remove traces of unfinished downloads
rm -f /opt/appimages/*.AppImage.part*
# Download Zoom AppImage file to the correct location
file="/opt/appimages/${executable}.AppImage"
minimumsize=90
if [ -f "$file" ]; then
    echo "found $file"
    actualsize=$(du -k "$file" | cut -f 1)
    if [ $actualsize -ge $minimumsize ]; then
        #echo size is over $minimumsize kilobytes
        echo "appimageupdatetool $file"
        sleep 1
        appimageupdatetool "$file"
        iFiles=`ls /opt/appimages | grep '${executable}.*\.AppImage' | wc -l`
        if [ $iFiles -gt 1 ]; then
            rm -f $file
            mv /opt/appimages/${executable}*.AppImage $file
        fi
    else
        #echo size is under $minimumsize kilobytes
        echo "Downloading ${executable}.AppImage..."
        sleep 1
        wget -O "$file" ${APPIMAGE}
    fi
else
    echo "Downloading ${executable}.AppImage..."
    sleep 1
    wget -O "$file" ${APPIMAGE}
fi
if [ -f "$file" ]; then
    chmod 755 "$file"
fi
# Users on the system
USERS=$(awk -F':' '{ print $1 }' /etc/passwd)
# echo USERS=$USERS
for user in $USERS; do
    # In zoom version 5.17.5 an issue was detected that may reoccur in subsequent releases
    # due to mismatch in user configuration files. Those files need to be removed.
    if [ -d "/home/$user/.zoom" ]; then
        rm -rf /home/$user/.zoom
    fi
    if [ -d "/home/$user/.cache" ]; then
        rm -rf /home/$user/.cache
    fi
    if [ -d "/home/$user/.config" ]; then
        rm -f /home/$user/.config/zoom*
    fi
done

exit 0
openSUSE Build Service is sponsored by