Kodi Community Forum

Full Version: HOW-TO: Automated efficient XBMC install - Ubuntu 12.10/13.04 mini based
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

Love the automation of this script, however whenever I start my computer xbmc first crashes then restarts, while it does appear to be working i'd like to get it to work the way it should. I used v2.61 to install, i'm also using the upstart process to auto start xbmc. XBMC crash log

http://pastebin.com/AtWKc6B6
Did you try running the script again (no need to do a new ubuntu installation) with all the same options but using init.d instead of upstart? It's more stable anyway, in my experience.
@Frozin

Its the drivers

12:08:43 T:3038320384 NOTICE: GL_VENDOR = VMware, Inc.
12:08:43 T:3038320384 NOTICE: GL_RENDERER = Gallium 0.4 on llvmpipe (LLVM 0x301)
12:08:43 T:3038320384 NOTICE: GL_VERSION = 2.1 Mesa 9.0.3
12:08:43 T:3038320384 NOTICE: GL_SHADING_LANGUAGE_VERSION = 1.20

Install proper drivers and it should work. some intel requires kernel 3.9 and newer.

uNi
Gave that a try, and now all that comes up is the xbmc blue bubble background, and nothing else...
Gave this script a shot after Openelec got really unstable on my hardware, XBMCBuntu is way to sluggish. The script idea is nice but i constantly run into one issue.

12.10 ubuntu minimal x64 coupled with the 2.6.1 script leaves me at a login page, control f8 brings me to xbmc. init.d was picked, not upstart.
13.04 ubuntu minimal x64 coupled with the 2.6.0 script leaves me at a login page, control f8 brings me to xbmc. init.d was picked, not upstart.

Is there any combination of ubuntu minimal with one of the two scripts that automaticly switches to the right output? I do not wish to press control f8 every boot so if this cannot be resolved its a big show stopper for this method.
Try the upstart method., and no nothing will be fixed because bram77 isnt doing anymore work on this. so as far as Im concerned this is dead.

uNi
(2013-04-30, 12:33)endymion2k4 Wrote: [ -> ]Gave this script a shot after Openelec got really unstable on my hardware, XBMCBuntu is way to sluggish. The script idea is nice but i constantly run into one issue.

12.10 ubuntu minimal x64 coupled with the 2.6.1 script leaves me at a login page, control f8 brings me to xbmc. init.d was picked, not upstart.
13.04 ubuntu minimal x64 coupled with the 2.6.0 script leaves me at a login page, control f8 brings me to xbmc. init.d was picked, not upstart.

Is there any combination of ubuntu minimal with one of the two scripts that automaticly switches to the right output? I do not wish to press control f8 every boot so if this cannot be resolved its a big show stopper for this method.

I've never had that problem. I've installed xbmc with both versions of the script on 12.10 and 13.04 numerous times. Maybe the ubuntu logs can provide some insight? What hardware are you using? Video card especially.
(2013-04-30, 14:30)Bram77 Wrote: [ -> ]I've never had that problem. I've installed xbmc with both versions of the script on 12.10 and 13.04 numerous times. Maybe the ubuntu logs can provide some insight? What hardware are you using? Video card especially.

New installation with 12.10 ubuntu minimal, x64, coupled with the 2.6.0 script (upstart job) yielded the same results.

It doesnt seem to load xorg/xbmc when booted automaticly, it will load once alt-f8 is pressed. This is clearly visable because the nvidia logo only then shows itself.

dmesg doesnt note anything worthy or crashy (shows nvidia is being loaded):
[ 15.890373] nvidia: module license 'NVIDIA' taints kernel.
[ 15.927387] NVRM: loading NVIDIA UNIX x86_64 Kernel Module 304.88 Wed Mar 27 14:26:46 PDT 2013

output from lspci:
00:00.0 Host bridge: Intel Corporation Atom Processor D4xx/D5xx/N4xx/N5xx DMI Bridge (rev 02)
00:1b.0 Audio device: Intel Corporation NM10/ICH7 Family High Definition Audio Controller (rev 02)
00:1c.0 PCI bridge: Intel Corporation NM10/ICH7 Family PCI Express Port 1 (rev 02)
00:1c.1 PCI bridge: Intel Corporation NM10/ICH7 Family PCI Express Port 2 (rev 02)
00:1c.2 PCI bridge: Intel Corporation NM10/ICH7 Family PCI Express Port 3 (rev 02)
00:1d.0 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #1 (rev 02)
00:1d.1 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #2 (rev 02)
00:1d.2 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #3 (rev 02)
00:1d.3 USB controller: Intel Corporation NM10/ICH7 Family USB UHCI Controller #4 (rev 02)
00:1d.7 USB controller: Intel Corporation NM10/ICH7 Family USB2 EHCI Controller (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev e2)
00:1f.0 ISA bridge: Intel Corporation NM10 Family LPC Controller (rev 02)
00:1f.2 IDE interface: Intel Corporation NM10/ICH7 Family SATA Controller [IDE mode] (rev 02)
00:1f.3 SMBus: Intel Corporation NM10/ICH7 Family SMBus Controller (rev 02)
01:00.0 USB controller: VIA Technologies, Inc. Device 3432 (rev 02)
02:00.0 Network controller: Atheros Communications Inc. AR9285 Wireless Network Adapter (PCI-Express) (rev 01)
03:00.0 VGA compatible controller: NVIDIA Corporation GT218 [ION] (rev a2)
03:00.1 Audio device: NVIDIA Corporation High Definition Audio Controller (rev a1)
04:0b.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8110SC/8169SC Gigabit Ethernet (rev 10)

Workaround: ??
Fiddled a bit more with it and got it to boot XBMC automaticly. Ive edited /boot/grub/grub.cfg, mainly the '$vt_handoff' variable. Ive placed a space behind the variable and from that point onward (3 reboots so far) it started to work. Im unsure if this is the good or the bad method, it works for this current setup and that is what counts for now Smile
Hi

After using this installation script, is there something else in addition that needs to be done for Optical Blu-ray discs to play? It doesn't seem to auto mount / play them.

I just enabled the option in the XBMC settings to auto play DVDs and that works OK, I insert a DVD disc and it plays.
I can play ripped Blu-ray ISOs fine from the file server OK as well but not discs.

A friend just suggested I may need MakeMKV from the OpenElec repository? To break the encryption on the optical Blu-ray discs.

Any tips?

Thanks
Thanks for your post endymion2k4.

I'm running on similar hardware (at least graphics-wise) and had the same problem. I'm on the following hardware/software:
  • Pentium 4 3.0 Ghz dual core
  • Intel motherboard
  • 2GB RAM
  • Nvidia GT 210 PCI-E video card
  • SoundBlaster Live 5.1 sound card
  • Ubuntu 13.10 32-bit Minimal Install
  • Script version 2.6.0 (init.d type startup, not upstart)

I was having the same problem (xbmc on tty8, not loading at startup) and adding those spaces to /etc/grub.d/10_linux fixed it for me. I chose to put it there so that the spaces would be automatically included when I ran 'sudo update-grub'. I don't know what update options others may have chosen, but if a new kernel is downloaded and installed, grub will regenerate the boot list entries, and your spaces in /boot/grub/grub.cfg will be lost. If the changes are made to /etc/grub.d/10_linux, they should persist through a kernel upgrade.

For future reference of others, here's exactly what I changed in /etc/grub.d/10_linux on line 215 (on my system, code snippet shows lines 211-220 for context):
Code:
cat << 'EOF'
function gfxmode {
        set gfxpayload="${1}"
        if [ "${1}" = "keep" ]; then
                set vt_handoff=vt.handoff=7
        else
                set vt_handoff=
        fi
}
EOF

to

Code:
cat << 'EOF'
function gfxmode {
        set gfxpayload="${1}"
        if [ "${1}" = "keep" ]; then
                set vt_handoff=vt.handoff=7 <------(there is a space after this number 7, which is what I added)
        else
                set vt_handoff=
        fi
}
EOF

Although I'm not sure why having a trailing space here would make any difference at all, it does seem to immediately resolve the issue. How odd. If anyone who knows more about the inner workings of grub wants to chime in, I'd love to know more.
This is my latest installation of XBMC with this script.
I post this to show it works as it should and errors found are most likely problems you will encounter with other types of installations.

Tested with NVIDIA graphic card, as uNiversal posted below, AMD/ATI have some issues with the orginal XMBC code.

My Hardware:
- Gigbyte P35-DS3R motherboard
- Intel Core2Duo 3Ghz
- 4GB memory
- Nvidia GL610SL 1GB HDMI output used.
- Skystar HD2 satelite PCI card without card reader.
- Realtek onboard sound output optical out.

Mini ISO installation 13.04 x64
- extra info : Upgrades = manual
- Extra installs : OpenSSH server and Samba file server.

Script used : prepare_install_2_6_1.sh
As it allows the boot logo on my setup, which 2.6.sh does not.

Script options used:
- Init.d startups.
- 1920x1080 ( full HD )
- on the mixer settings page a direct <ESC>
- Optional tweaks : temp.monitoring on andinstall addon repositories installer, Dirty regio NOT as it F&^%s up my playback.
- Temp monitor : all on default.
- Other Optional packages: LIRC - HTS - OSCAM
- LIRC setting: Windows Media Center transceivers + Microsoft Windows Media Center V2 (USB) : Direct TV Receiver.
- TVheadend (HTS) : setting username and password.
- Reboot system.

The good, the bad and the ugly: (in that order)
- Version check of TVheadend (HTS) shows the current version which is correct (3.4 at this time).
- Version check of XBMC reveals version 13.0 Alpha ( you need to change the "XBMC_PPA=ppa:team-xbmc/ppa" to the correct ppa.
- Reboot after the script droped me into single user mode as the xbmc.pid was not cleared, a reboot command fixed the issue.
The drop to single user happend after i rebooted the system through a ssh session, reboot through XBMC or direct on the system does the reboot just fine.



I changed the XBMC PPA in the script from: XBMC_PPA="ppa:wsnipex/xbmc-xvba" to :XBMC_PPA="ppa:team-xbmc/ppa"
This will install the 12.2 version not the 13.x Alpha.



Extra Actions:
- Added MC (Midnight Commander).
- Added Apache2 for usage of the tvheadend PHP channel editor script.

Hope this helps to figure out some of the problems you encounter.

/edit: Added the changed script 2.6.1.sh with the team-xbmc ppa reference.
Code:
#!/bin/bash
#
# @author   Bram van Oploo
# @date     2013-02-12
# @version  2.6.1
#

XBMC_USER="xbmc"
THIS_FILE=$0
SCRIPT_VERSION="2.6.1"
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"
RSYSLOG_FILE="/etc/init/rsyslog.conf"
POWERMANAGEMENT_DIR="/var/lib/polkit-1/localauthority/50-local.d/"
DOWNLOAD_URL="https://github.com/Bram77/xbmc-ubuntu-minimal/raw/master/12.10/download/"
XBMC_PPA="ppa:team-xbmc/ppa"
HTS_TVHEADEND_PPA="ppa:jabbors/hts-stable"
OSCAM_PPA="ppa:oscam/ppa"

LOG_FILE=$HOME_DIRECTORY"xbmc_installation.log"
DIALOG_WIDTH=70
SCRIPT_TITLE="XBMC installation script v$SCRIPT_VERSION for Ubuntu 12.10 by Bram van Oploo :: [email protected] :: www.sudo-systems.com"

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 > /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 plugdev > /dev/null 2>&1
        sudo adduser $XBMC_USER dialout > /dev/null 2>&1
    showInfo "XBMC user added to required groups"
}

function addXbmcPpa()
{
    showInfo "Adding Team XBMC PPA..."
    IS_ADDED=$(addRepository "$XBMC_PPA")
}

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 installOscam()
{
    showInfo "Adding oscam PPA..."
    addRepository "$OSCAM_PPA"

    showInfo "Installing oscam..."
    IS_INSTALLED=$(aptInstall oscam-svn)
}

function installXbmc()
{
    showInfo "Installing XBMC..."
    IS_INSTALLED=$(aptInstall xbmc)
}

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
        VIDEO_DRIVER="nvidia-current"
    elif [[ $GFX_CARD == ATI ]] || [[ $GFX_CARD == AMD ]] || [[ $GFX_CARD == ADVANCED ]]; then
        VIDEO_DRIVER="fglrx"
    elif [[ $GFX_CARD == INTEL ]]; then
        VIDEO_DRIVER="i965-va-driver"
    elif [[ $GFX_CARD == VMWARE ]]; then
        VIDEO_DRIVER="i965-va-driver"
    else
        cleanUp
        clear
        echo ""
        echo "$(tput setaf 1)$(tput bold)Installation aborted...$(tput sgr0)"
        echo "$(tput setaf 1)Only NVIDIA, ATI/AMD or INTEL 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 [ "$IS_INSTALLED" == "1"]; then
        if [ "$GFX_CARD" == "ATI" ] || [ "$GFX_CARD" == "AMD" ]; 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"
    fi
}

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"
    
    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 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 "Enable dirty region rendering (improved performance)" on
            2 "Enable temperature monitoring (confirm with ENTER)" on
            3 "Install Addon Repositories Installer addon" on
            4 "Apply improved Pulse-Eight Motorola NYXboard keymap" off)
            
    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices
    do
        case ${choice//\"/} in
            1)
                enableDirtyRegionRendering
                ;;
            2)
                installLmSensors
                ;;
            3)
                installXbmcAddonRepositoriesInstaller
                ;;
            4)
                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 6)
        
    options=(1 "Lirc (IR remote support)" off
            2 "Hts tvheadend (live TV backend)" off
            3 "Oscam (live HDTV decryption tool)" off
            4 "Automatic upgrades (every 4 hours)" off)
            
    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices
    do
        case ${choice//\"/} in
            1)
                installLirc
                ;;
            2)
                installTvHeadend
                ;;
            3)
                installOscam
                ;;
            4)
                installAutomaticDistUpgrade
                ;;
        esac
    done
}

function optimizeInstallation()
{
    showInfo "Optimizing installation..."
    sudo service apparmor stop > /dev/null &2>1
    sudo service apparmor teardown > /dev/null &2>1
    sudo update-rc.d -f apparmor remove > /dev/null &2>1    
    sudo apt-get remove --purge apparmor -y > /dev/null &2>1
    
    createDirectory "$TEMP_DIRECTORY" 1 0
    handleFileBackup $RSYSLOG_FILE 0 1
    download $DOWNLOAD_URL"rsyslog.conf"
    move $TEMP_DIRECTORY"rsyslog.conf" "$RSYSLOG_FILE" 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 "Reboot system..."
    dialog --title "Installation complete" \
        --backtitle "$SCRIPT_TITLE" \
        --yesno "Do you want to reboot now?" 7 $DIALOG_WIDTH

    case $? in
        0)
            showInfo "Installation complete. Rebooting..."
            clear
            echo ""
            echo "Installation complete. Rebooting..."
            echo ""
            sudo reboot now > /dev/null 2>&1
            ;;
        1)
            showInfo "Installation complete. Not rebooting."
            quit
            ;;
        255)
            showInfo "Installation complete. Not rebooting."
            quit
            ;;
    esac
}

function quit()
{
    clear
    exit
}

control_c()
{
    cleanUp
    echo "Installation aborted..."
    quit
}

## ------- 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

fixLocaleBug
fixUsbAutomount
applyXbmcNiceLevelPermissions
addUserToRequiredGroups
addXbmcPpa
distUpgrade
installVideoDriver
installXinit
installXbmc
selectXbmcStartupMethod
installXbmcBootScreen
selectScreenResolution
reconfigureXServer
installPowerManagement
installAudio
selectXbmcTweaks
selectAdditionalPackages
allowRemoteWakeup
optimizeInstallation
cleanUp
rebootMachine
@Sevennl Yes that's great but anyone with ATI cards best use the xvba-frodo ppa else mainline is fine.

uNi
Ah ok, i did not know that as i use Nvidia ( i know of the limitations of AMD/ATI HDMI output ).
I still love to use this script for my re-installing as it is much faster ( daily usage ) than all others i tried ( OpenELEC etc. )
I know you don't support the script anymore, which is a shame Smile , but if you find yourself wondering what to do , maybe a pre-select screen would be grand to add to this script.
At the start just tag what you want to install and let the script run so you can grab coffee, sit in the sun.
Pitty i am so bad in writing code, else i would do it myself.
Bram is the author and supporter of script, I helped as far as I could even adding own fixes and help out here.
However since bram is not interested in working on the script anymore (because he has something else on), unfortunately, I wont be doing it by myself so it is what it is and wont be something else. Unless of course someone want to take over. There are a few github forks of the project but none going anywhere.

uNi
Hi

Was this the correct way to upgrade XBMC to version 12.2 ?

I just ran these commands:

Code:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install xbmc xbmc-bin

Image

Image

Appears to have gone OK and now says version 12.2 in the XBMC Settings - System area.

Thanks