install.sh 1.96 KB
Newer Older
bretello's avatar
bretello committed
1
#/bin/bash
sbiego's avatar
sbiego committed
2

bretello's avatar
bretello committed
3
if [ "$(whoami)" != "root" ]
sbiego's avatar
sbiego committed
4 5 6
	then echo "This script is not running as root... exiting" && exit 1
fi

sbiego's avatar
sbiego committed
7 8 9
if [ "$1" == "-u" ]
	then
		echo "Updating theme..."
sbiego's avatar
sbiego committed
10
		git pull
sbiego's avatar
sbiego committed
11 12
fi

sbiego's avatar
sbiego committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
echo "Checking transmission installation..."

if [ ! -d "$(find /usr/share/transmission/ -iname "web" -type d)" ]

	then echo "Installation folder not found."

	while : ; do
		echo -n "Please insert web directory installation path: "
		read installdir
		[ -d "$installdir" ] && break
		echo "Directory not found..."
	done

	echo "Installing in $installdir/web..."
	sleep 1

else
sbiego's avatar
sbiego committed
30
	installdir='/usr/share/transmission'
sbiego's avatar
sbiego committed
31 32 33 34 35 36
	echo "Directory found! Installing in $installdir/web..."
	sleep 1
fi

cp -rv ./web/* ${installdir}/web/

sbiego's avatar
sbiego committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
if [ "$1" != "-u" ]
	then
		echo -e "\nTransmission soft theme successfully installed!\n \nWould you like to apply a soft theme now?\nWARNING: if this is an UPDATE you have to skip this!\nNOTE: if you've already installed it, to change theme just modify the " $installdir "/web/index.html following the instructions on the wiki!\n"
		PS3=': '
		options=( "Dark" "Light" "Quit" )
		select opt in "${options[@]}"
		do
			case $opt in
		    "Dark")
						sed -i '21i\\t\t<link href="./style/transmission/soft-theme.min.css" type="text/css" rel="stylesheet" />\n\t\t<link href="style/transmission/soft-dark-theme.min.css" type="text/css" rel="stylesheet" />\n' ${installdir}/web/index.html;
		        echo "Soft dark theme successfully applied!";
						break;;
		    "Light")
		        sed -i '21i\\t\t<link href="./style/transmission/soft-theme.min.css" type="text/css" rel="stylesheet" />\n\t\t<link href="style/transmission/soft-light-theme.min.css" type="text/css" rel="stylesheet" />\n' ${installdir}/web/index.html;
		        echo "Soft light theme successfully applied!";
						break;;
		     "Quit")
				 		echo 'You can always install it following the https://git.eigenlab.org/sbiego/transmission-web-soft-theme/wikis/home';
		        break;;
		      *) echo 'invalid option'
					esac
		done
fi