#!/bin/bash # goValknut - Script Valknut Trunk - by ompolicy # # Email: ompolicy@gmail.com # Site: http://ompolicy.altervista.org # which zenity if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ]; then sudo -S apt-get install -y zenity fi namedir="" title="goValknut:" ver_valk="1.8" author_ompo="ompolicy" email_ompo="ompolicy@gmail.com" log_install="$HOME/.nude/log/valknut_log_install" log_apt="$HOME/.nude/log/valknut_log_apt" log_svn="$HOME/.nude/log/valknut_log_svn" name_prog="valknut" svnurl="https://wxdcgui.svn.sourceforge.net/svnroot/wxdcgui/branches/valknut-qt4" svn_valk2="https://wxdcgui.svn.sourceforge.net/svnroot/wxdcgui/trunk/dclib" svn_valk3="https://wxdcgui.svn.sourceforge.net/svnroot/wxdcgui/trunk/plugin" n_prog2="dclib" n_prog3="plugin" function Error100 { zenity --info --text="Errore #100 APT-GET / DPKG nell'installazione dei pacchetti!" zenity --text-info --filename="$log_apt" --text="Errore!" sudo -k exit } function MessageLog { zenity --info --text="Errore durante la compilazione!" zenity --text-info --filename="$log_install" --text="Se verificato un errore!" sudo -k exit } function ChooseDirectory { if [ ! -f $HOME/.nude/dirprog ] then touch $HOME/.nude/dirprog fi namedir=`cat $HOME/.nude/dirprog | grep "$name_prog" | cut -d" " -f 2` if [ "$namedir" != "" ] then if [ -d "$namedir/$name_prog" ] then zenity --warning --text="Il programma è già installato!" Start sudo -k exit 0 else Install $namedir fi fi zenity --info --text="Scegli la directory per l'installazione! La directory del programma \"$name_prog\" verrà creata nel percorso specificato" namedir=`zenity --file-selection --directory --title="Scegli la directory di installazione"` if [ "$namedir" == "" ] then Start sudo -k exit 0 fi if [ -O "$namedir" ] then echo $namedir | grep "$name_prog" if [ `echo ${PIPESTATUS[*]} | cut -d" " -f 2` -ne 0 ] then cat $HOME/.nude/dirprog | grep "$name_prog" if [ `echo ${PIPESTATUS[*]} | cut -d" " -f 2` -ne 0 ] then echo "$name_prog $namedir" >> $HOME/.nude/dirprog else sed -e "s%^$name_prog\ .*%$name_prog\ $namedir%" $HOME/.nude/dirprog > $HOME/tmp mv $HOME/tmp $HOME/.nude/dirprog fi Install $namedir else namedir=`dirname $namedir` cat $HOME/.nude/dirprog | grep "$name_prog" if [ `echo ${PIPESTATUS[*]} | cut -d" " -f 2` -ne 0 ] then echo "$name_prog $namedir" >> $HOME/.nude/dirprog else sed -e "s%^$name_prog\ .*%$name_prog\ $namedir%" $HOME/.nude/dirprog > $HOME/tmp mv $HOME/tmp $HOME/.nude/dirprog fi #echo "$name_prog $namedir" >> $HOME/.nude/dirprog fi else zenity --error --text="La cartella non è scrivibile dall'utente" --title="$title" ChooseDirectory fi } function Password { if [ "$pass" == "" ] then pass=`zenity --entry --hide-text --text="Insert Root Password .:"` if [ $? -eq 1 ] then sudo -k exit 1 fi echo "$pass" | sudo -S -l if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 2` -ne 0 ] then pass="" Password fi export $pass fi } function KillSvn { RUNNING=0 while [ $RUNNING -eq 0 ] do if [ -z "$(pidof svn)" ] then sleep 1 RUNNING=1 pkill zenity else if [ -z "$(pidof zenity)" ] then sleep 1 pkill svn exit fi fi done } function DownSvn { echo "Downloading program..." case "$1" in "CO") echo "p" | svn co $svnurl $namedir/$name_prog 2> $log_svn | awk '{print "File " $2;fflush();}' & KillSvn ;; "UP") echo "p" | svn up $namedir/$name_prog 2> $log_svn | awk '{print "File " $2;fflush();}' & KillSvn ;; "EX") echo "p" | svn export $svnurl $namedir/$name_prog 2> $log_svn | awk '{print "File " $2;fflush();}' & KillSvn ;; esac } function ControllOther { namedir=`cat $HOME/.nude/dirprog | grep "$name_prog" | cut -d" " -f 2` ## Controllo se esiste il PATH su dirprog! if [ "$namedir" == "" ] then choose=`zenity --list --text="Il programma sembra non essere installato con NuDe, vuoi importarlo?" --column="Scelta" Si No` if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then Start exit fi case "$choose" in "Si") ChooseDirectory ;; "No") Start sudo -k exit 0 ;; esac else ## Controllo se il PATH esiste fisicamente! if [ ! -d "$namedir/$name_prog" ] then zenity --warning --text="Attenzione! Il programma non è installato per procedere avanti bisogna installarlo!" Start sudo -k exit 0 fi fi } function Development { cat /etc/apt/sources.list | grep "#deb http://it.archive.ubuntu.com/ubuntu/ intrepid-backports main restricted universe multiverse" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 2` -eq 0 ] then echo $pass| sudo -S cat "deb http://it.archive.ubuntu.com/ubuntu/ intrepid-backports main restricted universe multiverse" >> /etc/apt/sources.list fi echo $pass | sudo -S aptitude update | zenity --progress --pulsate --text="Aggiornamento lista.." echo $pass | sudo -S apt-get install -y --force-yes subversion build-essential libaudio2 libbz2-1.0 libc6 libfontconfig1 libfreetype6 libgcc1 libice6 libjpeg62 libpng12-0 libqt4-webkit libqt4-xml libqt4-core libqt4-gui uim-qt libsm6 libssl0.9.8 libstdc++6 libx11-6 libxcursor1 libxext6 libxft2 libxi6 libxinerama1 libxml2 libxrandr2 libxrender1 libxt6 zlib1g automake autoconf libtool 2> $log_apt | zenity --progress --auto-close --pulsate --text="Download ed installazione delle librerie e dei compilatori" --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 2` -ne 0 ] then Error100 fi } function Install { DownSvn "CO" | zenity --text-info --width 700 --height 400 --title="$title Download.." name_prog="$n_prog2" svnurl="$svn_valk2" DownSvn "CO" | zenity --text-info --width 700 --height 400 --title="$title Download.." name_prog="$n_prog3" svnurl="$svn_valk3" DownSvn "CO" | zenity --text-info --width 700 --height 400 --title="$title Download.." cd $namedir/dclib autoreconf --verbose --install 2> $log_install | zenity --progress --auto-close --percentage="11" --text="dclib-svn.." --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then MessageLog fi ./configure --prefix=/usr/share/valknut-svn --enable-static --disable-shared --enable-debug 2> $log_install | zenity --progress --auto-close --percentage="33" --text="dclib-svn..configurazione" --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then MessageLog fi make 2> $log_install | zenity --progress --auto-close --percentage="66" --text="dclib-svn..costruzione" --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then MessageLog fi echo $pass | sudo -S make install 2> $log_install | zenity --progress --auto-close --percentage="99" --text="dclib-svn..installazione" --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 2` -ne 0 ] then MessageLog fi cd $namedir/plugin autoreconf --verbose --install 2> $log_install | zenity --progress --auto-close --percentage="11" --text="dclib-http-plugin-svn.." --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then MessageLog fi ./configure --prefix=/usr/share/valknut-svn --enable-debug --enable-pretend-command PKG_CONFIG_PATH=/usr/share/valknut-svn/lib/pkgconfig 2> $log_install | zenity --progress --auto-close --percentage="33" --text="dclib-http-plugin-svn..configurazione" --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then MessageLog fi make 2> $log_install | zenity --progress --auto-close --percentage="66" --text="dclib-http-plugin-svn..costruzione" --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then MessageLog fi echo $pass | sudo -S make install | zenity --progress --auto-close --percentage="99" --text="dclib-http-plugin-svn..installazione" --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 2` -ne 0 ] then MessageLog fi cd $namedir/valknut autoreconf --verbose --install 2> $log_install | zenity --progress --auto-close --percentage="11" --text="valknut-qt4-svn.." --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then MessageLog fi ./configure --prefix=/usr/share/valknut-svn/qt4 --enable-debug --enable-pretend-command PKG_CONFIG_PATH=/usr/share/valknut-svn/lib/pkgconfig 2> $log_install | zenity --progress --auto-close --percentage="33" --text="valknut-qt4-svn..configurazione" --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then MessageLog fi make 2> $log_install | zenity --progress --auto-close --percentage="66" --text="valknut-qt4-svn..costruzione" --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then MessageLog fi echo $pass | sudo -S make install | zenity --progress --auto-close --percentage="99" --text="valknut-qt4-svn..installazione" --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 2` -ne 0 ] then MessageLog fi cat << .end > $HOME/valknut-qt4.desktop [Desktop Entry] Name=Valknut-Qt4 (Unstable) GenericName=Valknut-Qt4 (Unstable) Comment=DirectConnect client (Unstable) Exec=/usr/share/valknut-svn/qt4/bin/valknut StartupNotify=false Icon=/usr/share/valknut-svn/qt4/share/icons/hicolor/128x128/apps/valknut.png Terminal=false Type=Application Categories=Network;P2P; .end echo "$pass" | sudo -S mv $HOME/valknut-qt4.desktop /usr/share/applications/ zenity --info --title="$title" --text="Installazione completata!" } function CaseUninstall { uninstall=`zenity --title="$title Uninstall Valknut" --text="Sei sicuro?" --list --column="Scegli" Si No` if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then Start exit fi case "$uninstall" in "Si") Uninstall | zenity --progress --text="Uninstall In Corso.." --title="$title" --auto-close ;; "No") Start ;; esac } function Uninstall { namedir=`cat $HOME/.nude/dirprog | grep "$name_prog" | cut -d" " -f 2` cd $namedir/dclib make clean 2> $log_install | zenity --progress --auto-close --pulsate --text="Rimozione.." --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then MessageLog fi echo "$pass" | sudo -S make uninstall 2> $log_install | zenity --progress --auto-close --pulsate --text="Rimozione.." --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 2` -ne 0 ] then MessageLog fi rm -fr $namedir/dclib cd $namedir/plugin make clean 2> $log_install | zenity --progress --auto-close --pulsate --text="Rimozione.." --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then MessageLog fi echo "$pass" | sudo -S make uninstall 2> $log_install | zenity --progress --auto-close --pulsate --text="Rimozione.." --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 2` -ne 0 ] then MessageLog fi rm -fr $namedir/plugin cd $namedir/valknut make clean 2> $log_install | zenity --progress --auto-close --pulsate --text="Rimozione.." --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then MessageLog fi echo "$pass" | sudo -S make uninstall 2> $log_install | zenity --progress --auto-close --pulsate --text="Rimozione.." --title="$title" if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 2` -ne 0 ] then MessageLog fi rm -fr $namedir/valknut echo "$pass" | sudo -S rm /usr/share/applications/valknut-qt4.desktop sed -e "/^$name_prog\ .*/d" $HOME/.nude/dirprog > $HOME/tmp mv $HOME/tmp $HOME/.nude/dirprog zenity --info --text="Rimozione completata!" --title="$title" } #inserisce il repository per hardy ed installa function InHardy { sudo -S cat << .end >> /tmp/philips.list ### Philip Johnsson - goValknut ### deb http://philip.magicalforest.se/ hardy extra deb-src http://philip.magicalforest.se/ hardy extra .end sudo -S mv /tmp/philips.list /etc/apt/sources.list.d/ sudo -S aptitude update | zenity --progress --pulsate --text="Aggiornamento della lista.." --auto-close sudo -S apt-get install -y --force-yes valknut 2> $log_apt if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then Error100 fi zenity --info --text="Valknut installato con successo!" --title="$title" Start } #inserisce il repository per intrepid ed install function InIntrepid { sudo -S cat << .end >> /tmp/philips.list ### Philip Johnsson - goValknut ### deb http://philip.magicalforest.se/ intrepid extra deb-src http://philip.magicalforest.se/ intrepid extra .end sudo -S mv /tmp/philips.list /etc/apt/sources.list.d/ sudo -S aptitude update | zenity --progress --pulsate --text="Aggiornamento della lista.." --auto-close sudo -S apt-get install -y --force-yes valknut 2> $log_apt if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then Error100 fi zenity --info --text="Valknut installato con successo!" --title="$title" Start } function uStable { uninstall=`zenity --title="$title Uninstall Valknut" --text="Sei sicuro?" --list --column="Scegli" Si No` if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then Start exit fi case "$uninstall" in "Si") sudo -S aptitude purge valknut 2> $log_apt | zenity --progress --title="$title" --text="Rimozione.." --pulsate --auto-close if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 2` -ne 0 ] then Error100 fi sudo -S rm /etc/apt/sources.list.d/philips.list zenity --info --title="$title" --text="Rimozione completata!" ;; "No") Start ;; esac } function Start { choose=`zenity --height=265 --width=300 --title="$title Menù principale" --text="Fai la tua scelta:" --list --column= "Installazione SVN" "Rimozione SVN" "Pacchetti stabili" "Rimozione pacchetti" Esci ` case "$choose" in "Installazione SVN") Password ChooseDirectory Development ;; "Rimozione SVN") ControllOther Password CaseUninstall ;; "Pacchetti stabili") Password choose=`zenity --height=280 --width=300 --title="$title" --text="Scegli la tua distribuzione:" --list --column="" "Hardy 8.04" "Intrepid 8.10"` if [ `echo ${PIPESTATUS[*]} | cut -d " " -f 1` -ne 0 ] then Start exit fi case "$choose" in "Hardy 8.04") InHardy ;; "Intrepid 8.10") InIntrepid ;; esac ;; "Rimozione pacchetti") Password uStable ;; "Esci") sudo -k exit ;; esac } #Controllo esecuzione script con sudo o da root if [ "$(id -u)" == "0" ]; then zenity --info --text="Lancia lo script senza SUDO!" --title=$title exit 1 fi if [ -d "$HOME/.nude" ]; then echo "" else mkdir $HOME/.nude mkdir $HOME/.nude/svn mkdir $HOME/.nude/log touch $HOME/.nude/control fi if [ -d "$HOME/.nude/log" ]; then echo "" else mkdir $HOME/.nude/log fi if [ -d "$HOME/.nude/svn" ]; then echo "" else mkdir $HOME/.nude/svn fi zenity --info --text="goValknut [by $author_ompo]\n\n Installazione facilitata per\n Valknut - Client DirectConnect\n\n $email_ompo\n\n Versione: $ver_valk" --title="$title Info" Start