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

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

diesys's avatar
diesys committed
7 8 9 10 11 12 13 14
if [ "$1" == "-u" ]
	then
		echo "Updating theme..."
		# mkdir .transmission-web-soft-theme-tmp
		# cd .transmission-web-soft-theme-tmp
		git pull https://git.eigenlab.org/sbiego/transmission-web-soft-theme.git
fi

diesys's avatar
diesys committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
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
diesys's avatar
diesys committed
32
	installdir='/usr/share/transmission'
diesys's avatar
diesys committed
33 34 35 36 37 38
	echo "Directory found! Installing in $installdir/web..."
	sleep 1
fi

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

diesys's avatar
diesys committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
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