All pastes #365333 Raw Edit

Miscellany

public shellscript v1 · immutable
#365333 ·published 2007-02-20 21:40 UTC
rendered paste body
#!/bin/bashdestdir="/usr/lib/mozilla-firefox"FILE="$destdir/res/forms.css"BEGIN="/*** BEGIN EXTRA FIREFOX WIDGETS ***/"sed_BEGIN="$(echo "$BEGIN" | sed 's@\*@\\*@g')"END="/*** END EXTRA FIREFOX WIDGETS ***/"sed_END="$(echo "$END" | sed 's@\*@\\*@g')"install(){echo -e "\nWe are going to be installing the firefox widgets.This consists of widget images contained in the folder \"form-widgets\" as well as some code that will be added to your forms.css file in the firefox directory.----------------------------------Press enter to begin installation."read# Check if widgets have already been installedgrep "$sed_BEGIN" "$FILE" &> /dev/nullif [ "$?" = 0 ] ; then	echo "The text \"$BEGIN\" was found in $FILE."	echo "The CSS appears to have already been installed."	css=trueelse	css=falsefi# If the widget images are already installed...if [ -d "$destdir/res/form-widgets" ] ; then	widgets=true	loop=true	while [ "$loop" = true ] ; do		loop=false		echo "The directory "$destdir/res/form-widgets" already exists."		echo "The widget images appear to be installed."		echo "This directory will be overwritten in installation."		echo -n "Do you wish to overwrite this folder? (y/n) "		read widget_choice		case "$widget_choice" in 			y | Y | yes | Yes | YES )				:				;;			n | N | No | NO | no )				echo "Exiting installation."				exit 1				;;			* )				echo "Unknown option!"				loop=true				;;		esac	done			else	widgets=false	echo "Installing the widget images"	sudo cp -r form-widgets "$destdir"/resfi# Install the cssif [ "$css" = false ] ; then	# Create a backup if wanted	loop=true	while [ "$loop" = true ] ; do		echo "We are about to overwrite $FILE."		echo -n "Would you like to create a backup? (y/n) "		loop=false		read backup_choice		case "$backup_choice" in			y | Y | yes | Yes | YES ) 				echo "Creating backup $FILE.bak"				#sudo cp "$FILE" "$FILE".bak			;;			n | N | no | No | NO )				:				;;			* )				echo "Unknown option!"				loop=true			;;		esac	done	echo "Appending forms-extra.css to forms.css"	# append forms-extra.css to forms.css	temp="$(cat forms-extra.css)"	sudo echo "$temp" >> "$destdir"/res/forms.cssfiecho "Firefox widgets installed successfully."}		uninstall(){grep "$sed_BEGIN" "$FILE" &> /dev/nullif [ "$?" = 0 ] ; then	css=trueelse	echo "Text \"$BEGIN\" not found in $FILE"	echo "The CSS does not appear to be installed."	css=falsefi	if [ -d "$destdir/res/form-widgets" ] ; then	widgets=trueelse	echo "The directory "$destdir/res/form-widgets" does not exist."	echo "The widget images do not appear to be installed."	widgets=falsefidelete=falseif [ "$css" = true ] ; then	temp="$(cat "$FILE" | while read line; do		if [ "$line" = "$BEGIN" ]; then			delete=true		fi		if [ "$delete" = false ]; then			echo "$line"		fi		if [ "$delete" = true ] ; then			if [ "$line" = "$END" ] ; then				delete=false			fi		fi	done)"		echo "Restoring "$FILE""	echo "$temp" > "$FILE"fiif [ "$widgets" = true ] ; then	echo "Removing widget images."	sudo rm -r "$destdir/res/form-widgets"fiif [ "$widgets" = false -a "$css" = false ] ; then	echo "No actions taken.  Firefox widgets are not installed."else		echo "Firefox widgets successfully removed."fi}echo "1 ) Install Firefox Widgets"echo "2 ) Remove Firefox Widgets"echo -n "Select an Option: "loop=truewhile [ "$loop" = true ] ; do	read option	loop=false	case  "$option" in		1 ) 			install		;;		2 ) 			uninstall		;;		* ) 			echo "Unknown Option!"			loop=true		;;	esacdone