Estou tentando adaptar esse código-fonte, esse código funciona, bem, só preciso adaptar as partes que realmente preciso.
#!/bin/bash
kde_download() {
arch=$(uname -m)
case "$arch" in
x86) arch="x86" ;;
i?86) arch="x86" ;;
amd64) arch="amd64" ;;
x86_64) arch="amd64" ;;
* ) echo "Your Arch '$arch' -> Its not supported." ;;
esac
ThisDIR="$PWD"
TempDir="/tmp"
TITLE="Team Speak 3 Linux Client"
TS3DIR="/opt/TeamSpeak3/Client"
version=$(curl -s http://dl.4players.de/ts/releases/ | grep -Po '(?<=href=")[0-9]+(\.[0-9]+){2,3}(?=/")' | sort -Vr | head -1)
URLICON="https://dl.dropboxusercontent.com/u/3164499/Linux/Iconos/TeamSpeak3.png"
TS3FILE="TeamSpeak3-Client-linux_$arch-$version.run"
TS3CURL="http://dl.4players.de/ts/releases/$version"
TS3CF="http://dl.4players.de/ts/releases/$version/TeamSpeak3-Client-linux_$arch-$version.run"
TARGET="/opt/Utilidades/Prueba"
J=0
# download with output to dialog progress bar
KDIALOG="'kdialog --title "$TITLE" --progressbar "Downloading:<br>$TS3FILE<br>into<br>$TARGET"'"
if grep "^org.kde.kdialog" <<< "$KDIALOG" > /dev/null; then
# KDE4 kdialog and dbus control
autoclose="qdbus $KDIALOG org.freedesktop.DBus.Properties.Set org.kde.kdialog.ProgressDialog autoClose true"
showcancel="qdbus $KDIALOG org.kde.kdialog.ProgressDialog.showCancelButton false"
setprogress="qdbus $KDIALOG org.freedesktop.DBus.Properties.Set org.kde.kdialog.ProgressDialog value"
manualclose="qdbus $KDIALOG org.kde.kdialog.ProgressDialog.close"
wascancelled="qdbus $KDIALOG org.kde.kdialog.ProgressDialog.wasCancelled"
else
# KDE3 kdialog and dcop control
# cut beginning
KDIALOG="${KDIALOG//DCOPRef\(/}"
# cut end
KDIALOG="${KDIALOG//,ProgressDialog\)/}"
autoclose="dcop $KDIALOG ProgressDialog setAutoClose true"
setprogress="dcop $KDIALOG ProgressDialog setProgress"
showcancel="dcop $KDIALOG ProgressDialog showCancelButton false"
manualclose="dcop $KDIALOG ProgressDialog close"
wascancelled="dcop $KDIALOG ProgressDialog wasCancelled"
fi
$autoclose
$showcancel
cd "$TempDir"
( wget "$TS3CF" -o /dev/stdout | while read I ; do
I="${I//*.......... .......... .......... .......... .......... /}"
I="${I%%%*}"
# report changes only
if [ "$I" ] && [ "$J" != "$I" ]; then
$setprogress $I
J="$I"
fi
done ; $manualclose ; cd "$ThisDIR" ) &
pid="$!"
while [ -d "/proc/$pid/" ]; do
if [ "'$wascancelled'" = true ]; then
kill $pid
kill 'ps aux | grep "wget $TS3FILE -o /dev/stdout" | grep -v grep | tr -s ' ' ' ' | cut -f2 -d\ '
$manualclose
if [ "$?" != 0 ]; then
echo "Installation interrupted."
exit 255
fi
fi
sleep 1
done
wait
}
kde_download