#!/bin/bash
package_dir="/tmp"
wget -O "${package_dir}/GenericBeuUXv1_27_multi_language.tar.gz" "https://ufficiozero.mirror.garr.it/3rd-party-software/printers/KonicaMinolta/bizhub-5020i/GenericBeuUXv1_27_multi_language.tar.gz"
err="false"
[ "$?" -eq "1" ] && err="true"

[ "$err" == "false" ] && \
    tar --overwrite -C "${package_dir}" -zvxf "${package_dir}/GenericBeuUXv1_27_multi_language.tar.gz"
[ "$?" -eq "1" ] && err="true"

[ "$err" == "false" ] && \
    chmod +x "${package_dir}/GenericBeuUXv1_27_multi_language/install.pl"
[ "$?" -eq "1" ] && err="true"

cd "${package_dir}/GenericBeuUXv1_27_multi_language"
[ "$?" -eq "1" ] && err="true"

[ "$err" == "false" ] && "${package_dir}/GenericBeuUXv1_27_multi_language/install.pl"

sudo service cups restart
