#!/bin/bash # # @author Krautmaster based on Bram van Oploo # @date 2012-01-22 # @version 3.0.0 XBMC_USER="xbmc" THIS_FILE=$0 SCRIPT_VERSION="3.0.0" MAKEMKV_VERSION="1.7.10" VIDEO_DRIVER="" HOME_DIRECTORY="/home/$XBMC_USER/" TEMP_DIRECTORY=$HOME_DIRECTORY"temp/" ENVIRONMENT_FILE="/etc/environment" CRONTAB_FILE="/etc/crontab" DIST_UPGRADE_FILE="/etc/cron.d/dist_upgrade.sh" DIST_UPGRADE_LOG_FILE="/var/log/updates.log" XBMC_INIT_FILE="/etc/init.d/xbmc" XBMC_ADDONS_DIR=$HOME_DIRECTORY".xbmc/addons/" XBMC_USERDATA_DIR=$HOME_DIRECTORY".xbmc/userdata/" XBMC_KEYMAPS_DIR=$XBMC_USERDATA_DIR"keymaps/" XBMC_ADVANCEDSETTINGS_FILE=$XBMC_USERDATA_DIR"advancedsettings.xml" XBMC_INIT_CONF_FILE="/etc/init/xbmc.conf" XBMC_XSESSION_FILE="/home/xbmc/.xsession" XBMC_CUSTOM_EXEC="/usr/bin/runXBMC" UPSTART_JOB_FILE="/lib/init/upstart-job" XWRAPPER_FILE="/etc/X11/Xwrapper.config" GRUB_CONFIG_FILE="/etc/default/grub" GRUB_HEADER_FILE="/etc/grub.d/00_header" SYSTEM_LIMITS_FILE="/etc/security/limits.conf" INITRAMFS_SPLASH_FILE="/etc/initramfs-tools/conf.d/splash" INITRAMFS_MODULES_FILE="/etc/initramfs-tools/modules" XWRAPPER_CONFIG_FILE="/etc/X11/Xwrapper.config" MODULES_FILE="/etc/modules" REMOTE_WAKEUP_RULES_FILE="/etc/udev/rules.d/90-enable-remote-wakeup.rules" AUTO_MOUNT_RULES_FILE="/etc/udev/rules.d/media-by-label-auto-mount.rules" SYSCTL_CONF_FILE="/etc/sysctl.conf" POWERMANAGEMENT_DIR="/var/lib/polkit-1/localauthority/50-local.d/" DOWNLOAD_URL="ftp://night.dyndns.org/htpc/scripts/downloads/" FUNCTION_URL="ftp://night.dyndns.org/htpc/scripts/functions/" XBMC_PPA="ppa:wsnipex/xbmc-xvba-testing" HTS_TVHEADEND_PPA="ppa:jabbors/hts-stable" LOG_FILE=$HOME_DIRECTORY"xbmc_installation.log" DIALOG_WIDTH=90 SCRIPT_TITLE="XBMC installation script v$SCRIPT_VERSION for Ubuntu 12.04/12.10 by Krautmaster" GFX_CARD=$(lspci |grep VGA |awk -F: {' print $3 '} |awk {'print $1'} |tr [a-z] [A-Z]) ## ------ START functions --------- function showInfo() { CUR_DATE=$(date +%Y-%m-%d" "%H:%M) echo "$CUR_DATE - INFO :: $@" >> $LOG_FILE dialog --title "Installing & configuring..." --backtitle "$SCRIPT_TITLE" --infobox "\n$@" 5 $DIALOG_WIDTH } function showError() { CUR_DATE=$(date +%Y-%m-%d" "%H:%M) echo "$CUR_DATE - ERROR :: $@" >> $LOG_FILE dialog --title "Error" --backtitle "$SCRIPT_TITLE" --msgbox "$@" 8 $DIALOG_WIDTH } function showDialog() { dialog --title "XBMC installation script" \ --backtitle "$SCRIPT_TITLE" \ --msgbox "\n$@" 12 $DIALOG_WIDTH } function update() { sudo apt-get update > /dev/null 2>&1 } function createFile() { FILE="$1" IS_ROOT="$2" REMOVE_IF_EXISTS="$3" if [ -e "$FILE" ] && [ "$REMOVE_IF_EXISTS" == "1" ]; then sudo rm "$FILE" > /dev/null else if [ "$IS_ROOT" == "0" ]; then touch "$FILE" > /dev/null else sudo touch "$FILE" > /dev/null fi fi } function createDirectory() { DIRECTORY="$1" GOTO_DIRECTORY="$2" IS_ROOT="$3" if [ ! -d "$DIRECTORY" ]; then if [ "$IS_ROOT" == "0" ]; then mkdir -p "$DIRECTORY" > /dev/null 2>&1 else sudo mkdir -p "$DIRECTORY" > /dev/null 2>&1 fi fi if [ "$GOTO_DIRECTORY" == "1" ]; then cd $DIRECTORY fi } function handleFileBackup() { FILE="$1" BACKUP="$1.bak" IS_ROOT="$2" DELETE_ORIGINAL="$3" if [ -e "$BACKUP" ]; then if [ "$IS_ROOT" == "1" ]; then sudo rm "$FILE" > /dev/null 2>&1 sudo cp "$BACKUP" "$FILE" > /dev/null 2>&1 else rm "$FILE" > /dev/null 2>&1 cp "$BACKUP" "$FILE" > /dev/null 2>&1 fi else if [ "$IS_ROOT" == "1" ]; then sudo cp "$FILE" "$BACKUP" > /dev/null 2>&1 else cp "$FILE" "$BACKUP" > /dev/null 2>&1 fi fi if [ "$DELETE_ORIGINAL" == "1" ]; then sudo rm "$FILE" > /dev/null 2>&1 fi } function appendToFile() { FILE="$1" CONTENT="$2" IS_ROOT="$3" if [ "$IS_ROOT" == "0" ]; then echo "$CONTENT" | tee -a "$FILE" > /dev/null 2>&1 else echo "$CONTENT" | sudo tee -a "$FILE" > /dev/null 2>&1 fi } function addRepository() { REPOSITORY=$@ KEYSTORE_DIR=$HOME_DIRECTORY".gnupg/" createDirectory "$KEYSTORE_DIR" 0 0 sudo add-apt-repository -y $REPOSITORY > /dev/null 2>&1 if [ "$?" == "0" ]; then update showInfo "$REPOSITORY repository successfully added" echo 1 else showError "Repository $REPOSITORY could not be added (error code $?)" echo 0 fi } function isPackageInstalled() { PACKAGE=$@ sudo dpkg-query -l $PACKAGE > /dev/null 2>&1 if [ "$?" == "0" ]; then echo 1 else echo 0 fi } function aptInstall() { PACKAGE=$@ IS_INSTALLED=$(isPackageInstalled $PACKAGE) if [ "$IS_INSTALLED" == "1" ]; then showInfo "Skipping installation of $PACKAGE. Already installed." echo 1 else sudo apt-get -f install > /dev/null 2>&1 sudo apt-get -y install $PACKAGE > /dev/null 2>&1 if [ "$?" == "0" ]; then showInfo "$PACKAGE successfully installed" echo 1 else showError "$PACKAGE could not be installed (error code: $?)" echo 0 fi fi } function download() { URL="$@" wget -q "$URL" > /dev/null 2>&1 } function move() { SOURCE="$1" DESTINATION="$2" IS_ROOT="$3" if [ -e "$SOURCE" ]; then if [ "$IS_ROOT" == "0" ]; then mv "$SOURCE" "$DESTINATION" > /dev/null 2>&1 else sudo mv "$SOURCE" "$DESTINATION" > /dev/null 2>&1 fi if [ "$?" == "0" ]; then echo 1 else showError "$SOURCE could not be moved to $DESTINATION (error code: $?)" echo 0 fi else showError "$SOURCE could not be moved to $DESTINATION because the file does not exist" echo 0 fi } ##------------------------------ function installDependencies() { echo "-- Installing installation dependencies..." echo "" sudo apt-get -y install dialog software-properties-common p7zip avahi-daemon > /dev/null 2>&1 sudo apt-get -y install python-software-properties > /dev/null 2>&1 } function fixLocaleBug() { createFile $ENVIRONMENT_FILE handleFileBackup $ENVIRONMENT_FILE 1 appendToFile $ENVIRONMENT_FILE "LC_MESSAGES=\"C\"" appendToFile $ENVIRONMENT_FILE "LC_ALL=\"en_US.UTF-8\"" showInfo "Locale environment bug fixed" } function fixUsbAutomount() { handleFileBackup "$MODULES_FILE" 1 1 appendToFile $MODULES_FILE "usb-storage" createDirectory "$TEMP_DIRECTORY" 1 0 download $DOWNLOAD_URL"media-by-label-auto-mount.rules" if [ -e $TEMP_DIRECTORY"media-by-label-auto-mount.rules" ]; then IS_MOVED=$(move $TEMP_DIRECTORY"media-by-label-auto-mount.rules" "$AUTO_MOUNT_RULES_FILE") showInfo "USB automount successfully fixed" else showError "USB automount could not be fixed" fi } function applyXbmcNiceLevelPermissions() { createFile $SYSTEM_LIMITS_FILE appendToFile $SYSTEM_LIMITS_FILE "$XBMC_USER - nice -1" showInfo "Allowed XBMC to prioritize threads" } function addUserToRequiredGroups() { sudo adduser $XBMC_USER video > /dev/null 2>&1 sudo adduser $XBMC_USER audio > /dev/null 2>&1 sudo adduser $XBMC_USER users > /dev/null 2>&1 sudo adduser $XBMC_USER fuse > /dev/null 2>&1 sudo adduser $XBMC_USER cdrom > /dev/null 2>&1 sudo adduser $XBMC_USER dialout > /dev/null 2>&1 sudo adduser $XBMC_USER plugdev > /dev/null 2>&1 showInfo "XBMC user added to required groups" } function addXbmcPpa() { showInfo "Adding Wsnipex xbmc-xvba PPA..." sudo add-apt-repository -y $XBMC_PPA > /dev/null 2>&1 } function distUpgrade() { showInfo "Updating Ubuntu with latest packages (may take a while)..." update sudo apt-get -y dist-upgrade > /dev/null 2>&1 showInfo "Ubuntu installation updated" } function installXinit() { showInfo "Installing xinit..." IS_INSTALLED=$(aptInstall xinit) } function installPowerManagement() { showInfo "Installing power management packages..." createDirectory "$TEMP_DIRECTORY" 1 0 IS_INSTALLED=$(aptInstall policykit-1) IS_INSTALLED=$(aptInstall upower) IS_INSTALLED=$(aptInstall udisks) IS_INSTALLED=$(aptInstall acpi-support) download $DOWNLOAD_URL"custom-actions.pkla" createDirectory "$POWERMANAGEMENT_DIR" IS_MOVED=$(move $TEMP_DIRECTORY"custom-actions.pkla" "$POWERMANAGEMENT_DIR") } function installAudio() { showInfo "Installing audio packages....\n!! Please make sure no used channels are muted !!" IS_INSTALLED=$(aptInstall linux-sound-base) IS_INSTALLED=$(aptInstall alsa-base) IS_INSTALLED=$(aptInstall alsa-utils) IS_INSTALLED=$(aptInstall libasound2) sudo alsamixer } function installLirc() { clear echo "" echo "Installing lirc..." echo "" echo "------------------" echo "" sudo apt-get -y install lirc if [ "$?" == "0" ]; then showInfo "Lirc successfully installed" else showError "Lirc could not be installed (error code: $?)" fi } function allowRemoteWakeup() { showInfo "Allowing for remote wakeup (won't work for all remotes)..." createDirectory "$TEMP_DIRECTORY" 1 0 handleFileBackup "$REMOTE_WAKEUP_RULES_FILE" 1 1 download $DOWNLOAD_URL"remote_wakeup_rules" if [ -e $TEMP_DIRECTORY"remote_wakeup_rules" ]; then sudo mv $TEMP_DIRECTORY"remote_wakeup_rules" "$REMOTE_WAKEUP_RULES_FILE" > /dev/null 2>&1 showInfo "Remote wakeup rules successfully applied" else showError "Remote wakeup rules could not be downloaded" fi } function installTvHeadend() { showInfo "Adding jabbors hts-stable PPA..." addRepository "$HTS_TVHEADEND_PPA" clear echo "" echo "Installing tvheadend..." echo "" echo "------------------" echo "" sudo apt-get -y install tvheadend if [ "$?" == "0" ]; then showInfo "TvHeadend successfully installed" else showError "TvHeadend could not be installed (error code: $?)" fi } function installXbmc() { showInfo "Installing XBMC..." IS_INSTALLED=$(aptInstall xbmc) IS_INSTALLED=$(aptInstall xbmc-pvr-*) } function enableDirtyRegionRendering() { showInfo "Enabling XBMC dirty region rendering..." createDirectory "$TEMP_DIRECTORY" 1 0 handleFileBackup $XBMC_ADVANCEDSETTINGS_FILE 0 1 download $DOWNLOAD_URL"dirty_region_rendering.xml" createDirectory "$XBMC_USERDATA_DIR" 0 0 IS_MOVED=$(move $TEMP_DIRECTORY"dirty_region_rendering.xml" "$XBMC_ADVANCEDSETTINGS_FILE") if [ "$IS_MOVED" == "1" ]; then showInfo "XBMC dirty region rendering enabled" else showError "XBMC dirty region rendering could not be enabled" fi } function installXbmcAddonRepositoriesInstaller() { showInfo "Installing Addon Repositories Installer addon..." createDirectory "$TEMP_DIRECTORY" 1 0 download $DOWNLOAD_URL"plugin.program.repo.installer-1.0.5.tar.gz" createDirectory "$XBMC_ADDONS_DIR" 0 0 if [ -e $TEMP_DIRECTORY"plugin.program.repo.installer-1.0.5.tar.gz" ]; then tar -xvzf $TEMP_DIRECTORY"plugin.program.repo.installer-1.0.5.tar.gz" -C "$XBMC_ADDONS_DIR" > /dev/null 2>&1 if [ "$?" == "0" ]; then showInfo "Addon Repositories Installer addon successfully installed" else showError "Addon Repositories Installer addon could not be installed (error code: $?)" fi else showError "Addon Repositories Installer addon could not be downloaded" fi } function configureAtiDriver() { sudo aticonfig --initial -f > /dev/null 2>&1 sudo aticonfig --sync-vsync=on > /dev/null 2>&1 sudo aticonfig --set-pcs-u32=MCIL,HWUVD_H264Level51Support,1 > /dev/null 2>&1 } function disbaleAtiUnderscan() { sudo kill $(pidof X) > /dev/null 2>&1 sudo aticonfig --set-pcs-val=MCIL,DigitalHDTVDefaultUnderscan,0 > /dev/null 2>&1 showInfo "Underscan successfully disabled" } function enableAtiUnderscan() { sudo kill $(pidof X) > /dev/null 2>&1 sudo aticonfig --set-pcs-val=MCIL,DigitalHDTVDefaultUnderscan,1 > /dev/null 2>&1 showInfo "Underscan successfully enabled" } function installVideoDriver() { showInfo "Installing $GFX_CARD video drivers (may take a while)..." if [[ $GFX_CARD == NVIDIA ]]; then showInfo "Installing NVIDIA video drivers (may take a while)..." sudo apt-get install -y nvidia-current > /dev/null 2>&1 sudo nvidia-xconfig --color-space YCbCr444 elif [[ $GFX_CARD == ATI ]] || [[ $GFX_CARD == AMD ]] || [[ $GFX_CARD == ADVANCED ]]; then CARD=$(lspci |grep VGA |grep -E '[[:digit:]]{4}' -o) if [[ $CARD > 5000 ]]; then VIDEO_DRIVER="fglrx" showInfo "Installing AMD >HD5000 video drivers (may take a while)..." elif [[ $CARD < 5000 ]]; then VIDEO_DRIVER="fglrx-legacy" sudo add-apt-repository -y ppa:makson96/fglrx > /dev/null 2>&1 sudo apt-get update > /dev/null 2>&1 sudo apt-get upgrade -y > /dev/null 2>&1 sudo apt-get install -y fglrx-legacy > /dev/null 2>&1 showInfo "Installing AMD Legacy video drivers (may take a while)..." else showInfo "Installing AMD shit failed" exit fi elif [[ $GFX_CARD == INTEL ]]; then VIDEO_DRIVER="i965-va-driver" apt-get install -y i965-va-driver vainfo libmad0 gtk2-engines-pixbuf libva-dev > /dev/null 2>&1 elif [[ $GFX_CARD == VMWARE ]] || [[ $GFX_CARD == INNOTEK ]]; then VIDEO_DRIVER="open-vm-tools" apt-get install -y open-vm-tools > /dev/null 2>&1 else cleanUp clear echo "" echo "$(tput setaf 1)$(tput bold)Installation aborted...$(tput sgr0)" echo "$(tput setaf 1)Only NVIDIA, ATI/AMD or INTEL/VMWARE videocards are supported. Please install a compatible videocard and run the script again.$(tput sgr0)" echo "" echo "$(tput setaf 1)You have a $GFX_CARD videocard.$(tput sgr0)" echo "" exit fi IS_INSTALLED=$(aptInstall $VIDEO_DRIVER) if [[ $GFX_CARD == ATI ]] || [[ $GFX_CARD == AMD ]] || [[ $GFX_CARD == ADVANCED ]]; then configureAtiDriver dialog --title "Disable underscan" \ --backtitle "$SCRIPT_TITLE" \ --yesno "Do you want to disable underscan (removes black borders)? Do this only if you're sure you need it!" 7 $DIALOG_WIDTH RESPONSE=$? case ${RESPONSE//\"/} in 0) disbaleAtiUnderscan ;; 1) enableAtiUnderscan ;; 255) showInfo "ATI underscan configuration skipped" ;; esac fi showInfo "$GFX_CARD video drivers successfully installed and configured" } function installAutomaticDistUpgrade() { showInfo "Enabling automatic system upgrade..." createDirectory "$TEMP_DIRECTORY" 1 0 download $DOWNLOAD_URL"dist_upgrade.sh" IS_MOVED=$(move $TEMP_DIRECTORY"dist_upgrade.sh" "$DIST_UPGRADE_FILE" 1) if [ "$IS_MOVED" == "1" ]; then IS_INSTALLED=$(aptInstall cron) sudo chmod +x "$DIST_UPGRADE_FILE" > /dev/null 2>&1 handleFileBackup "$CRONTAB_FILE" 1 appendToFile "$CRONTAB_FILE" "0 */4 * * * root $DIST_UPGRADE_FILE >> $DIST_UPGRADE_LOG_FILE" else showError "Automatic system upgrade interval could not be enabled" fi } function removeAutorunFiles() { if [ -e "$XBMC_INIT_FILE" ]; then showInfo "Removing existing autorun script..." sudo update-rc.d xbmc remove > /dev/null 2>&1 sudo rm "$XBMC_INIT_FILE" > /dev/null 2>&1 if [ -e "$XBMC_INIT_CONF_FILE" ]; then sudo rm "$XBMC_INIT_CONF_FILE" > /dev/null 2>&1 fi if [ -e "$XBMC_CUSTOM_EXEC" ]; then sudo rm "$XBMC_CUSTOM_EXEC" > /dev/null 2>&1 fi if [ -e "$XBMC_XSESSION_FILE" ]; then sudo rm "$XBMC_XSESSION_FILE" > /dev/null 2>&1 fi showInfo "Old autorun script successfully removed" fi } function installXbmcInitScript() { removeAutorunFiles showInfo "Installing XBMC init.d autorun support..." createDirectory "$TEMP_DIRECTORY" 1 0 download $DOWNLOAD_URL"xbmc_init_script" if [ -e $TEMP_DIRECTORY"xbmc_init_script" ]; then if [ -e $XBMC_INIT_FILE ]; then sudo rm $XBMC_INIT_FILE > /dev/null 2>&1 fi IS_MOVED=$(move $TEMP_DIRECTORY"xbmc_init_script" "$XBMC_INIT_FILE") if [ "$IS_MOVED" == "1" ]; then sudo chmod a+x "$XBMC_INIT_FILE" > /dev/null 2>&1 sudo update-rc.d xbmc defaults > /dev/null 2>&1 if [ "$?" == "0" ]; then showInfo "XBMC autorun succesfully configured" else showError "XBMC autorun script could not be activated (error code: $?)" fi else showError "XBMC autorun script could not be installed" fi else showError "Download of XBMC autorun script failed" fi } function installXbmcRunFile() { showInfo "Installing custom XBMC startup executable..." createDirectory "$TEMP_DIRECTORY" 1 0 download $DOWNLOAD_URL"xbmc_run_script" if [ -e $TEMP_DIRECTORY"xbmc_run_script" ]; then IS_MOVED=$(move $TEMP_DIRECTORY"xbmc_run_script" "$XBMC_CUSTOM_EXEC") if [ "$IS_MOVED" == "1" ]; then sudo chmod a+x "$XBMC_CUSTOM_EXEC" > /dev/null 2>&1 showInfo "Installation of custom XBMC startup executable successfull" else showError "Installation of custom XBMC startup executable failed" fi else showError "Download of custom XBMC startup executable failed" fi } function installXbmcUpstartScript() { removeAutorunFiles showInfo "Installing XBMC upstart autorun support..." createDirectory "$TEMP_DIRECTORY" 1 0 download $DOWNLOAD_URL"xbmc_upstart_script_2" if [ -e $TEMP_DIRECTORY"xbmc_upstart_script_2" ]; then IS_MOVED=$(move $TEMP_DIRECTORY"xbmc_upstart_script_2" "$XBMC_INIT_CONF_FILE") if [ "$IS_MOVED" == "1" ]; then sudo ln -s "$UPSTART_JOB_FILE" "$XBMC_INIT_FILE" > /dev/null 2>&1 else showError "XBMC upstart configuration failed" fi else showError "Download of XBMC upstart configuration file failed" fi } function installNyxBoardKeymap() { showInfo "Applying Pulse-Eight Motorola NYXboard advanced keymap..." createDirectory "$TEMP_DIRECTORY" 1 0 download $DOWNLOAD_URL"nyxboard.tar.gz" createDirectory "$XBMC_KEYMAPS_DIR" 0 0 if [ -e $XBMC_KEYMAPS_DIR"keyboard.xml" ]; then handleFileBackup $XBMC_KEYMAPS_DIR"keyboard.xml" 0 1 fi if [ -e $TEMP_DIRECTORY"nyxboard.tar.gz" ]; then tar -xvzf $TEMP_DIRECTORY"nyxboard.tar.gz" -C "$XBMC_KEYMAPS_DIR" > /dev/null 2>&1 if [ "$?" == "0" ]; then showInfo "Pulse-Eight Motorola NYXboard advanced keymap successfully applied" else showError "Pulse-Eight Motorola NYXboard advanced keymap could not be applied (error code: $?)" fi else showError "Pulse-Eight Motorola NYXboard advanced keymap could not be downloaded" fi } function installXbmcBootScreen() { showInfo "Installing XBMC boot screen (please be patient)..." #IS_INSTALLED=$(aptInstall v86d) #IS_INSTALLED=$(aptInstall plymouth-label) sudo apt-get install -y plymouth-label v86d > /dev/null createDirectory "$TEMP_DIRECTORY" 1 0 download $DOWNLOAD_URL"plymouth-theme-xbmc-logo.deb" OS=$(lsb_release -rs) #while Intel is broken in 12.10 if [[ $GFX_CARD == INTEL ]] && [[ "$OS" == "12.10" ]]; then sed -i s/'GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash\"/\GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash i915.i915_enable_rc6=0\"/' /etc/default/grub update-grub fi if [ -e $TEMP_DIRECTORY"plymouth-theme-xbmc-logo.deb" ]; then sudo dpkg -i $TEMP_DIRECTORY"plymouth-theme-xbmc-logo.deb" > /dev/null 2>&1 update-alternatives --install /lib/plymouth/themes/default.plymouth default.plymouth /lib/plymouth/themes/xbmc-logo/xbmc-logo.plymouth 100 > /dev/null 2>&1 handleFileBackup "$INITRAMFS_SPLASH_FILE" 1 1 createFile "$INITRAMFS_SPLASH_FILE" 1 1 appendToFile "$INITRAMFS_SPLASH_FILE" "FRAMEBUFFER=y" showInfo "XBMC boot screen successfully installed" else showError "Download of XBMC boot screen package failed" fi } function applyScreenResolution() { RESOLUTION="$1" showInfo "Applying bootscreen resolution (will take a minute or so)..." handleFileBackup "$GRUB_HEADER_FILE" 1 0 sudo sed -i '/gfxmode=/ a\ set gfxpayload=keep' "$GRUB_HEADER_FILE" > /dev/null 2>&1 GRUB_CONFIG="nomodeset usbcore.autosuspend=-1 video=uvesafb:mode_option=$RESOLUTION-24,mtrr=3,scroll=ywrap" if [[ $GFX_CARD == INTEL ]]; then GRUB_CONFIG="usbcore.autosuspend=-1 video=uvesafb:mode_option=$RESOLUTION-24,mtrr=3,scroll=ywrap" fi handleFileBackup "$GRUB_CONFIG_FILE" 1 0 appendToFile "$GRUB_CONFIG_FILE" "GRUB_CMDLINE_LINUX=\"$GRUB_CONFIG\"" appendToFile "$GRUB_CONFIG_FILE" "GRUB_GFXMODE=$RESOLUTION" handleFileBackup "$INITRAMFS_MODULES_FILE" 1 0 appendToFile "$INITRAMFS_MODULES_FILE" "uvesafb mode_option=$RESOLUTION-24 mtrr=3 scroll=ywrap" sudo update-grub > /dev/null 2>&1 sudo update-initramfs -u > /dev/null if [ "$?" == "0" ]; then showInfo "Bootscreen resolution successfully applied" else showError "Bootscreen resolution could not be applied" fi } function installLmSensors() { showInfo "Installing temperature monitoring package (apply all defaults)..." aptInstall lm-sensors clear echo "" echo "$(tput setaf 2)$(tput bold)INSTALLATION INFO: Please confirm all questions with ENTER (applying the suggested option)." echo "$(tput setaf 2)The XBMC installation will continue automatically when finished.$(tput sgr0)" echo "" echo "" sudo sensors-detect if [ ! -e "$XBMC_ADVANCEDSETTINGS_FILE" ]; then createDirectory "$TEMP_DIRECTORY" 1 0 download $DOWNLOAD_URL"temperature_monitoring.xml" createDirectory "$XBMC_USERDATA_DIR" 0 0 IS_MOVED=$(move $TEMP_DIRECTORY"temperature_monitoring.xml" "$XBMC_ADVANCEDSETTINGS_FILE") if [ "$IS_MOVED" == "1" ]; then showInfo "Temperature monitoring successfully enabled in XBMC" else showError "Temperature monitoring could not be enabled in XBMC" fi fi showInfo "Temperature monitoring successfully configured" } function reconfigureXServer() { showInfo "Configuring X-server..." handleFileBackup "$XWRAPPER_FILE" 1 createFile "$XWRAPPER_FILE" 1 1 appendToFile "$XWRAPPER_FILE" "allowed_users=anybody" showInfo "X-server successfully configured" } function installBetaDrivers() { cmd=(dialog --backtitle "Beta Drivers" --radiolist "do you want to install newest beta drivers (newest GPU drivers and Kernels)?" 15 $DIALOG_WIDTH 3) options=(1 "no way" on 2 "sure, why not" off) choice=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) case ${choice//\"/} in 1) ;; 2) showInfo "upgrating to ppa:xorg-edgers/ppa packages " add-apt-repository -y ppa:xorg-edgers/ppa > /dev/null &2>1 ;; *) installBetaDrivers ;; esac } function selectXbmcStartupMethod() { cmd=(dialog --backtitle "XBMC autorun method" --radiolist "Please select the method used to start XBMC (default recommended):" 15 $DIALOG_WIDTH 3) options=(1 "init.d" on 2 "upstart (experimental)" off) choice=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) case ${choice//\"/} in 1) installXbmcInitScript ;; 2) installXbmcUpstartScript ;; *) selectStartupMethod ;; esac } function selectXbmcTweaks() { cmd=(dialog --title "Optional XBMC tweaks and additions" --backtitle "$SCRIPT_TITLE" --checklist "Plese select to install or apply:" 15 $DIALOG_WIDTH 6) options=(1 "Load preconfigured XBMC Config (Aeon Nox + Diffuese Skin & Firefox) - takes some time" on 2 "Enable dirty region rendering (improved performance)" on 3 "Enable temperature monitoring (confirm with ENTER)" on 4 "Install Addon Repositories Installer addon" on 5 "Apply improved Pulse-Eight Motorola NYXboard keymap" off) choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) for choice in $choices do case ${choice//\"/} in 1) setup "firefox" setup "xbmc_config" ;; 2) enableDirtyRegionRendering ;; 3) installLmSensors ;; 4) installXbmcAddonRepositoriesInstaller ;; 5) installNyxBoardKeymap ;; esac done } function selectScreenResolution() { cmd=(dialog --backtitle "Select bootscreen resolution (required)" --radiolist "Please select your screen resolution, or the one sligtly lower then it can handle if an exact match isn't availabel:" 15 $DIALOG_WIDTH 6) options=(1 "720 x 480 (NTSC)" off 2 "720 x 576 (PAL)" off 3 "1280 x 720 (HD Ready)" off 4 "1366 x 768 (HD Ready)" on 5 "1920 x 1080 (Full HD)" off) choice=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) case ${choice//\"/} in 1) applyScreenResolution "720x480" ;; 2) applyScreenResolution "720x576" ;; 3) applyScreenResolution "1280x720" ;; 4) applyScreenResolution "1366x768" ;; 5) applyScreenResolution "1920x1080" ;; *) selectScreenResolution ;; esac } function selectAdditionalPackages() { cmd=(dialog --title "Other optional packages and features" --backtitle "$SCRIPT_TITLE" --checklist "Plese select to install:" 15 $DIALOG_WIDTH 10) options=(1 "Lirc (IR remote support)" on 2 "Hts tvheadend (live TV backend)" off 3 "Oscam (live HDTV decryption tool)" on 4 "Automatic upgrades (every 4 hours)" off 5 "VDR/VNSI (live TV backend)" on 6 "Boblight Daemon (Ambilight)" off 7 "MakeMKV (BD decode support)" off 8 "Marashino (advanced webgui for xbmc)" off) choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) for choice in $choices do case ${choice//\"/} in 1) installLirc ;; 2) installTvHeadend ;; 3) setup "oscam" $DOWNLOAD_URL ;; 4) installAutomaticDistUpgrade ;; 5) installVDR ;; 6) installBoblight ;; 7) setup "makemkv" $MAKEMKV_VERSION ;; 8) setup "maraschino" ;; esac done } function optimizeInstallation() { showInfo "Optimizing installation..." sudo service apparmor stop > /dev/null &2>1 sudo service apparmor teardown > /dev/null &2>1 sudo apt-get -y remove apparmor > /dev/null &2>1 sudo chmod 777 -R $HOME_DIRECTORY &2>1 handleFileBackup "$SYSCTL_CONF_FILE" 1 0 createFile "$SYSCTL_CONF_FILE" 1 0 appendToFile "$SYSCTL_CONF_FILE" "dev.cdrom.lock=0" appendToFile "$SYSCTL_CONF_FILE" "vm.swappiness=10" } function cleanUp() { showInfo "Cleaning up..." sudo apt-get -y autoremove > /dev/null 2>&1 sudo apt-get -y autoclean > /dev/null 2>&1 sudo apt-get -y clean > /dev/null 2>&1 if [ -e "$TEMP_DIRECTORY" ]; then sudo rm -R "$TEMP_DIRECTORY" > /dev/null 2>&1 fi if [ -e "$HOME_DIRECTORY$THIS_FILE" ]; then rm "$HOME_DIRECTORY$THIS_FILE" > /dev/null 2>&1 fi } function rebootMachine() { showInfo "Rebooting system..." quit } function quit() { clear exit } control_c() { cleanUp echo "Installation aborted..." quit } function installVDR() { clear echo "" echo "Installing VDR with VNSI-Server.." echo "" echo "------------------" echo "" sudo apt-get -y install dvb-apps sudo apt-get -y install vdr setup "vdr_addons" rm /etc/default/vdr echo "ENABLED=1" >> /etc/default/vdr echo "ENABLE_SHUTDOWN=1" >> /etc/default/vdr echo "OPTIONS=\"-w 60 --lirc=/dev/null --video=/recordings\"" >> /etc/default/vdr mkdir /recordings chmod 777 /recordings # add samba share for recordings echo "" >> /etc/samba/smb.conf echo "[recordings]" >> /etc/samba/smb.conf echo "path = /recordings" >> /etc/samba/smb.conf echo "guest ok = yes" >> /etc/samba/smb.conf echo "writeable = yes" >> /etc/samba/smb.conf echo "browseable = yes" >> /etc/samba/smb.conf echo "create mode = 0777" >> /etc/samba/smb.conf echo "directory mode = 0777" >> /etc/samba/smb.conf clear # download TV Logos and backgrounds to home directory chmod 777 -R /home/xbmc showInfo "downloading TV Logos and background images to /home/xbmc..." cd /home/xbmc > /dev/null 2>&1 rm /home/xbmc/stuff.7z > /dev/null 2>&1 wget ftp://night.dyndns.org/htpc/files/logopack/stuff.7z > /dev/null 2>&1 p7zip -d stuff.7z > /dev/null 2>&1 mv /home/xbmc/stuff/* /home/xbmc > /dev/null 2>&1 rm -R /home/xbmc/stuff > /dev/null 2>&1 rm /home/xbmc/stuff.7z > /dev/null 2>&1 chmod 777 -R /home/xbmc > /dev/null 2>&1 if [ "$?" == "0" ]; then showInfo "VDR successfully installed" else showError "VDR could not be installed (error code: $?)" fi } function installSamba() { setup "samba" } function setup() { FUNCTION=$1 showInfo "installing $FUNCTION ... Please be patient... (press a key if screen turns black)" cd /tmp download $FUNCTION_URL""$FUNCTION".sh" bash "./"$FUNCTION".sh" $2 > /dev/null 2>&1 if [ "$?" == "0" ]; then showInfo "$FUNCTION successfully installed" # else # showError "$FUNCTION could not be installed (error code: $?)" fi rm $FUNCTION".sh" } function installBoblight() { if [[ $GFX_CARD == ATI ]] || [[ $GFX_CARD == AMD ]] || [[ $GFX_CARD == ADVANCED ]]; then showInfo "Installing Boblight Daemon for AMD - Use XBMC Addon for boblight" setup "boblight" # autostart boblight daemon echo "su - xbmc -c \"boblightd -c /etc/boblight/boblight.conf -f\"" >> /autorun/autorun.sh #x11 doenst work with AMD #echo "su - xbmc -c \"DISPLAY=:0.0 boblight-X11 -o gamma=2.0 -o speed=40 -o valuemin=0.004 -o value=1.5 -o saturation=1.1 -o threshold=20\" &" >> /autorun/autorun.sh else showInfo "Installing Boblight Daemon..." setup "boblight" # autostart boblight daemon echo "su - xbmc -c \"boblightd -c /etc/boblight/boblight.conf -f\"" >> /autorun/autorun.sh echo "su - xbmc -c \"DISPLAY=:0.0 boblight-X11 -o gamma=2.0 -o speed=40 -o valuemin=0.004 -o value=1.5 -o saturation=1.1 -o threshold=20\" &" >> /autorun/autorun.sh fi } function install_DVB_drivers() { showInfo "Some DVB cards need additional drivers" cmd=(dialog --backtitle "Driver" --checklist "Choose further drivers to install if needed.." 15 $DIALOG_WIDTH 2) options=(1 "Tevii Cards" on 2 "TechnoTrend S2 4100" off) choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) for choice in $choices do case ${choice//\"/} in 1) clear setup "tevii" ;; 2) clear setup "tt_s2_4100" ;; esac done } ## ------- END functions ------- clear createFile "$LOG_FILE" 0 1 echo "" installDependencies echo "Loading installer..." showDialog "Welcome to the XBMC minimal installation script. Some parts may take a while to install depending on your internet connection speed.\n\nPlease be patient..." trap control_c SIGINT installBetaDrivers fixLocaleBug fixUsbAutomount applyXbmcNiceLevelPermissions addUserToRequiredGroups addXbmcPpa distUpgrade installVideoDriver installXinit installXbmc selectXbmcStartupMethod installXbmcBootScreen selectScreenResolution reconfigureXServer installPowerManagement installAudio installSamba setup "autorun" selectXbmcTweaks selectAdditionalPackages install_DVB_drivers allowRemoteWakeup optimizeInstallation cleanUp rebootMachine