#!/bin/bash # INSTALL-Script for oRainge gDesklets and dependencies # Markus Schmidt 2008 # USAGE: # # Make this script executable # a) via filebrowser (nautilus) -> rightclick -> properties # b) via terminal:$ chmod u+x /path/to/file/install_oRainge-gDesklets # # Run as superuser using "sudo" # sudo /path/to/script/install_oRainge-gDesklets # CONFIGURATION gdeskletsDir="/usr/share/gdesklets/" server="http://mein-neues-blog.de/files/oRainge/" file1="oRainge_gdesklets.tar.gz" file2="oRainge_gdesklets_controls.tar.gz" file3="text2speech.tar.gz" alsamod="\n; ALSA-wrapper\n(Parameter.set 'Audio_Command \"aplay -q -c 1 -t raw -f s16 -r \$SR \$FILE\")\n(Parameter.set 'Audio_Method 'Audio_Command)" alsanew="; Festival-Config\n(voice_kal_diphone)\n; ALSA-wrapper\n(Parameter.set 'Audio_Command \"aplay -q -c 1 -t raw -f s16 -r \$SR \$FILE\")\n(Parameter.set 'Audio_Method 'Audio_Command)" # ARE U SUPERCOW? if [ $UID != 0 ] || [ "$SUDO_USER" = "" ] ; then echo "### ERROR: Please run this script as a superuser (sudo) within your general useraccount" echo "### exiting..." exit 1 fi # SHUTDOWN GDESKLETS IF RUNNING gdpid=$(ps -e -o pid,args | grep [g]desklets-daemon) if [ "$gdpid" != "" ] && [ "$(echo $gdpid | cut -d \ -f 2)" != "grep" ]; then gdid=$(echo $gdpid | cut -d \ -f 1) kill -9 $gdid sleep 1 gdpid1=$(ps -e -o pid,args | grep [g]desklets-daemon) if [ "$gdpid1" != "" ] && [ "$(echo $gdpid1 | cut -d \ -f 2)" != "grep" ] ; then echo "### ERROR: Stopping the gdesklets-daemon failed. You have to restart manually after installation." echo "... No reason for exit, going on..." else echo "... Killed gdesklets-daemon process and going on..." gdesklets=True fi fi # INSTALL GDESKLETS echo "... Checking for gDesklets and installing it if needed..." apt-get -q -y --force-yes install gdesklets gdesklets-data 2>&1 > /dev/null if [ "$?" -ne "0" ] ; then echo "### ERROR: Installation of gDesklets failed." echo "### exiting..." exit 1 else echo "... gDesklets installed, going on..." fi # GET THE FILES NEEDED: echo "... Begin download..." wget -q $server$file1 2>&1 > /dev/null wget -q $server$file2 2>&1 > /dev/null wget -q $server$file3 2>&1 > /dev/null if [ -s $file1 ] && [ -s $file2 ] && [ -s $file3 ] ; then echo "... All packets recieved. going on..." else echo "### ERROR: one or more files not recieved successfully, trying cleanup..." if [ -f $file1 ] ; then rm $file1 ; fi if [ -f $file2 ] ; then rm $file2 ; fi if [ -f $file3 ] ; then rm $file3 ; fi echo "### An error occured during download with no solution yet. exiting..." exit 1 fi # INSTALL FESTIVAL AND ACCESSORIES echo "... Checking for festival and a male voice and installing them if needed..." apt-get -q -y --force-yes install festival festvox-kallpc16k 2>&1 > /dev/null if [ "$?" -ne "0" ] ; then echo "### ERROR: Installation of festival text to speech failed." echo "### The speaking-clock in gDesklets will not be able to talk." echo "### Try the installation of 'festival' and 'festvox-kallpc16k' manually." echo "... No reason for exit, going on..." else echo "... Festival and an american male voice are installed. going on..." # ALSA FOR FESTIVAL echo "... Creating alsa-wrapper for festival..." if [ -f "/home/$SUDO_USER/.festivalrc" ] ; then # .festivalrc already existent echo "... Configfile for festival found, searching for ALSA-entry..." alsafest=$(grep -i "\"aplay " /home/$SUDO_USER/.festivalrc 2>&1 /dev/null) if [ "$alsafest" = "" ] ; then # make backup echo "... No ALSA-entry found, backing up..." cp /home/$SUDO_USER/.festivalrc /home/$SUDO_USER/.festivalrc.backup if [ -f /home/$SUDO_USER/.festivalrc.backup ] ; then # backup successful, add lines echo "... Backup successful. file is now known as .festivalrc.backup" echo "... Adding needed lines to .festivalrc..." echo -e $alsamod >> /home/$SUDO_USER/.festivalrc if [ "$?" != "0" ] ; then # adding lines failed echo "### ERROR: Setup of alsa-wrapper for festival failed!" echo "### the file ~/.festivalrc has to be modified manually." echo "### Otherwise the clock won't speak if any other programm needs the soundcard." echo "### The lines to add to the file are:" echo -e $alsamod echo "... No reason for exit, going on..." else # lines added echo "... ALSA-support added successfully, going on..." fi else # backup failed echo "### ERROR: Backup failed! Will NOT try to add lines!" echo "### ERROR: Setup of alsa-wrapper for festival failed!" echo "### the file ~/.festivalrc has to be modified manually." echo "### Otherwise the clock won't speak if any other programm needs the soundcard." echo "### The lines to add to the file are:" echo -e $alsamod echo "... No reason for exit, going on..." fi else # ALSA already added echo "... ALSA already added to festival, no modification neccessary." fi else # no .festivalrc found echo "... No Config for festival found in homedirectory. Trying to add..." touch "/home/"$SUDO_USER"/.festivalrc" 2>&1 /dev/null chown $SUDO_USER "/home/"$SUDO_USER"/.festivalrc" 2>&1 /dev/null echo -e $alsanew > /home/$SUDO_USER/.festivalrc if [ -s /home/$SUDO_USER/.festivalrc ] ; then echo "... The ALSA-wrapper was created successfully. Going on..." else echo "### ERROR: Setup of alsa-wrapper for festival failed!" echo "### Please make shure you have the file .festivalrc in your homedirectory." echo "### It has to contain some lines for adding alsa-support to festival." echo "### Otherwise the clock won't speak if any other programm needs the soundcard." echo "### The lines are:" echo -e $alsanew echo "... No reason for exit, going on..." fi fi # TEXT2SPEECH # backing up text2speech if [ -s "/usr/bin/text2speech" ] ; then mv "/usr/bin/text2speech" "/usr/bin/text2speech.backup" fi tar -C /usr/bin -xzf $file3 if [ "$?" -ne "0" ] ; then # text2speech failed echo "### ERROR: Unpacking of text2speech wrapperscript failed!" if [ -s "/usr/bin/text2speech.backup" ] ; then echo "... Trying restore of old version..." mv "/usr/bin/text2speech.backup" "/usr/bin/text2speech" if [ "$?" = "0" ] ; then echo "... Text2speech-wrapper restored to old version." else echo "### ERROR: Restoring old text2speech-wrapper failed." echo "### Try renaming /usr/bin/text2speech.backup to /usr/bin/text2speech manually." fi else echo "### The speaking-clock in gDesklets will not be able to talk." fi echo "### Try unpacking 'text2speech.tar.gz' to '/usr/bin' as root manually." echo "... No reason to exit, going on..." else #text2speech installed echo "... Text2speech wrapper installed, cleaning up..." rm $file3 echo -n "??? Do you want to test the functionality of text2speech? [n]" read -s -n1 -t 10 testfest echo "" case "$testfest" in "y" | "Y" | "j" | "J" ) text2speech "holy shitt - its a linix talking! - or like the german says: himmel uhrsch oond tzwirn, da shprichd ein linooks! okay times sounds better i think" 2>&1 /dev/null ;; esac fi fi # INSTALL LM-SENSORS echo "... Checking for lm-sensors and installing it if needed..." apt-get -q -y install lm-sensors 2>&1 > /dev/null if [ "$?" -ne "0" ] ; then echo "### ERROR: Installation of lm-sensors failed." echo "... No reason to exit, going on..." else echo "... lm-sensors installed, going on..." echo "... If lm-sensors wasn't installed we have to detect the sensors in your machine." echo -n "??? Do you want to run the detection now? [y]" read -s -n1 -t 10 testsens echo "" case "$testsens" in "y" | "Y" | "j" | "J" ) echo "... Detecting sensors, please accept the following questions with [yes]..." sensors-detect if [ "$?" -ne "0" ] ; then echo "### ERROR: Detection of sensors failed. " echo "### gDesklets won't be able to show sensor-data." echo "### Please refer to http://www.lm-sensors.org/ for help." echo "... No reason to exit, going on..." else echo "... Sensors detected, going on..." echo "### Perhaps you have to reboot for kernelmodules to load." fi ;; esac fi # INSTALL CONTROLS echo "... Time for installing the controls for gDesklets..." if [ -d $gdeskletsDir"Controls/Evolution" ] ; then mv $gdeskletsDir"Controls/Evolution" $gdeskletsDir"Controls/Evolution_backup" fi if [ -d $gdeskletsDir"Controls/LMSensors" ] ; then mv $gdeskletsDir"Controls/LMSensors" $gdeskletsDir"Controls/LMSensors_backup" fi tar -C $gdeskletsDir"Controls" -xzf $file2 if [ "$?" = "0" ] ; then if [ -f "/home/"$SUDO_USER"/.gdesklets/registry/controls.reg" ] ; then rm "/home/"$SUDO_USER"/.gdesklets/registry/controls.reg" if [ "$?" != "0" ] ; then echo "### ERROR: Removing old controls.reg failed." echo "### Try removing /home"$SUDO_USER"/.gdesklets/registry/controls.reg manually and restart gDesklets-daemon afterwards." fi fi echo "... Evolution- and LMSensors-integration installed, cleaning up..." if [ -d $gdeskletsDir"Controls/Evolution_backup" ] ; then rm -r $gdeskletsDir"Controls/Evolution_backup" fi if [ -d $gdeskletsDir"Controls/LMSensors_backup" ] ; then rm -r $gdeskletsDir"Controls/LMSensors_backup" fi rm $file2 else # installation failed echo "### ERROR: Installation of Evolution- and LMSensors-integration failed." if [ -d $gdeskletsDir"Controls/Evolution_backup" ] ; then # backup available echo "... Restoring the old Evolution-integration..." mv $gdeskletsDir"Controls/Evolution_backup" $gdeskletsDir"Controls/Evolution" if [ "$?" = "0" ] ; then # backed up echo "... Your evolution-integration is reset to old status." else # restore failed echo "### ERROR: Restore failed. Try renaming /usr/share/gdesklets/Controls/Evolution_backup manually to /usr/share/gdesklets/Controls/Evolution" echo "### The calendar in gDesklets will not be able to show events of evolution." fi fi if [ -d $gdeskletsDir"Controls/LMSensors_backup" ] ; then # backup available echo "... Restoring the old LMSensors-integration..." mv $gdeskletsDir"Controls/LMSensors_backup" $gdeskletsDir"Controls/LMSensors" if [ "$?" = "0" ] ; then # backed up echo "... Your LMSensors-integration is reset to old status." else # restore failed echo "### ERROR: Restore failed. Try renaming /usr/share/gdesklets/Controls/LMSensors_backup manually to /usr/share/gdesklets/Controls/LMSensors" echo "### The sensor-gauges in gDesklets will not be able to show some sensordata." fi fi echo "### Try the extraction of 'oRainge_gdesklets_controls.tar.gz' to /usr/share/gdesklets/Controls manually." echo "... No reason for exit, going on..." fi # INSTALL ORAINGE - GDESKLETS if [ -d $gdeskletsDir"Displays/oRainge" ] ; then mv $gdeskletsDir"Displays/oRainge" $gdeskletsDir"Displays/oRainge_backup" fi tar -C $gdeskletsDir"Displays" -xzf $file1 if [ "$?" = "0" ] ; then echo "... oRainge-gDesklets installed, cleaning up..." if [ -d $gdeskletsDir"Displays/oRainge_backup" ] ; then rm -r $gdeskletsDir"Displays/oRainge_backup" fi rm $file1 else # installation failed echo "### ERROR: Installation of oRainge gDesklets failed." if [ -d $gdeskletsDir"Displays/oRainge_backup" ] ; then # backup available echo "... Restoring the old oRainge gDesklets..." mv $gdeskletsDir"Displays/oRainge_backup" $gdeskletsDir"Displays/oRainge" if [ "$?" = "0" ] ; then # backed up echo "... Your oRainge gDesklets are reset to old status." else # restore failed echo "### ERROR: Restore failed. Try renaming /usr/share/gdesklets/Displays/oRainge_backup manually to /usr/share/gdesklets/Displays/oRainge" echo "### The gDesklets will not be available." fi else # no backup available echo "### The gDesklets will not be available." fi echo "### Try the extraction of 'oRainge_gdesklets.tar.gz' to /usr/share/gdesklets/Displays manually." echo "... No reason for exit, going on..." fi # GDESKLETS-AUTOSTART GNOME gdauto=$(rgrep -i Exec=gdesklets /home/$SUDO_USER/.config/autostart/ 2>&1 /dev/null) if [ "$gdauto" = "" ] ; then echo "... No autostart-entry found in your config." echo -n "??? Do you want your gDesklets to start automatically with your Desktop? [n]" read -s -n1 -t 10 gdautoent echo "" case "$gdautoent" in "y" | "Y" | "j" | "J" ) touch /home/$SUDO_USER/.config/autostart/gdesklets.desktop echo ' [Desktop Entry] Type=Application Encoding=UTF-8 Version=1.0 Name=gDesklets Name[de_DE]=gDesklets Comment[de_DE]=Praktische Applets für Deinen Desktop Comment=useful applets for your desktop Exec=gdesklets X-GNOME-Autostart-enabled=true ' > /home/$SUDO_USER/.config/autostart/gdesklets.desktop chown $SUDO_USER /home/$SUDO_USER/.config/autostart/gdesklets.desktop if [ -s /home/$SUDO_USER/.config/autostart/gdesklets.desktop ] ; then echo "... Your autostart-entry was created successfully. Going on..." else echo "### ERROR: Installation of autostart-entry failed!" echo "### Please add a new entry through the sessions-management under settings-menu." echo "### The command for the new entry is 'gdesklets'" echo "... No reason for exit, going on..." fi ;; esac fi echo "=== Installation finished." echo "=== If there are any errors please check their solutions manually." # RESTART GDESKLETS if [ $gdesklets ] ; then echo "... Starting gDesklets again..." su $SUDO_USER -c "gdesklets > /dev/null &" 2>&1 /dev/null else echo -n "??? Do you want to start gDesklets now? [n]" read -s -n1 -t 10 startgd echo "" case "$startgd" in "y" | "Y" | "j" | "J" ) su $SUDO_USER -c "gdesklets > /dev/null &" 2>&1 /dev/null ;; esac fi exit 0