Archive:Compile Kodi on Fedora/Red Hat/CentOS: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Cookieboy
No edit summary
>Cookieboy
No edit summary
Line 55: Line 55:


Simply log into Gnome (or KDE) and open up a terminal and type 'xbmc' and it will load.
Simply log into Gnome (or KDE) and open up a terminal and type 'xbmc' and it will load.
<br>
----
<br>
<br>
=== Fedora Kickstart File ===
Here is the kickstart file created by Cookieboy that was used to create the Fedora 12 buildslave. You can use this to do a full install with all the required packages to build XBMC from Source. This kickstart file will grab the packages from the Internet. You can modify the kickstart file to grab all the packages it can from the CDROM install and then the Net for the other packages if you would like. Cookieboy created the file with a local fedora repo rsynced down on a local network. This file has been modified to download from the public Internet.
<br>
<br>
After this kickstart file is used, in the /source folder you will find two scripts. One will download the latest CrystalHD header files to compile against, as well as a simple script to download xbmc trunk to the /source folder. Run those if you wish, and you can edit them to suit your needs. The other thing this file does, is turn on yum-updatesd and has it run every 4 hours to keep the system as up to date as possible for the buildslave.
<br>
<br>
To learn more about Kickstart files, visit the [http://fedoraproject.org/wiki/Anaconda/Kickstart link here].
<pre>
###########################################
### Kickstart file created by Cookieboy ###
### Created Jan 25th 2010              ###
###########################################
install
url --url http://mirrors.xmission.com/fedora/releases/12/Fedora/i386/os/
lang en_US.UTF-8
keyboard us
### Network - DHCP
network --device eth0 --bootproto dhcp
### Network - Static
#network --bootproto=static --ip=10.0.5.25 --netmask=255.255.255.0 --gateway=10.0.5.1 --nameserver=10.0.5.1 --hostname=myxbmc.mylocal.net
#rootpw rootpasshere
firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone America/Denver
bootloader --location=mbr
#################################################
### REQUIRED REPOS FOR THE YUM PACKAGES BELOW ###
#################################################
repo --name=Fedora-Everything --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-12&arch=i386
repo --name=Fedora-Updates --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f12&arch=i386
repo --name=RPMFusion-Free --mirrorlist=http://mirrors.rpmfusion.org/free/fedora/12/i386
repo --name=RPMFusion-Free-Updates --mirrorlist=http://mirrors.rpmfusion.org/free/fedora/updates/12/i386
repo --name=RPMFusion-NonFree --mirrorlist=http://mirrors.rpmfusion.org/nonfree/fedora/12/i386
repo --name=RPMFusion-NonFree-Updates --mirrorlist=http://mirrors.rpmfusion.org/nonfree/fedora/updates/12/i386
#########################
### ADD THE XBMC USER ###
#########################
user --name=xbmcuser --password=xbmcuserpass
user --name=buildbot --password=buildbotpass
services --disabled=acpid,anacron,atd,bluetooth,cups,firstboot,ip6tables,iptables,mdmonitor,sendmail --enable=yum-updatesd
############################
### HARDDRIVE PARTITIONS ###
############################
#  Uncomment the lines below to auto format your HD...
#clearpart --all --drives=sda
#part /boot --fstype ext4 --size=200
#part swap --size=1024
#part / --fstype ext4 --size=100 --grow
####################
### Yum Packages ###
####################
%packages
@base
@base-x
@development-tools
@xfce-desktop
kernel-devel
kernel-headers
yum-updatesd
###  XBMC NEEDED RPMS  ###
subversion
git
gcc-c++
boost-devel
mesa-libGL-devel
glew-devel
libmad-devel
libjpeg-devel
libsamplerate-devel
libogg-devel
libvorbis-devel
freetype-devel
fontconfig-devel
bzip2-devel
fribidi-devel
sqlite-devel
mysql-devel
libpng-devel
pcre-devel
lzo-devel
libcdio-devel
libsmbclient-devel
SDL-devel
SDL_image-devel
SDL_mixer-devel
enca-devel
jasper-devel
libmms-devel
libXt-devel
libXtst-devel
libXmu-devel
libXinerama-devel
libcurl-devel
dbus-devel
hal-devel
pulseaudio-libs-devel
pulseaudio-libs-zeroconf
faac-devel
avahi-devel
ffmpeg-devel
a52dec-devel
libdca-devel
faad2-devel
mpeg2dec-devel
libass-devel
libmpcdec-devel
flac-devel
wavpack-devel
python-devel
cmake
gperf
unzip
make
libtool
flex
bison
libtiff-devel
buildbot
libvdpau
nasm
libvdpau-devel
lirc
lirc-devel
%end
reboot
%post
#####################################################################
### XFCE: create /etc/sysconfig/desktop (needed for installation) ###
#####################################################################
cat > /etc/sysconfig/desktop <<EOF
PREFERRED=/usr/bin/startxfce4
EOF
########################################
### Create Nesessary Changes / Setup ###
########################################
mkdir /source
mkdir -p /home/buildbot/buildslave
chown buildbot:buildbot /home/buildbot/buildslave
################################################################
### HERE IS WHERE WE SET UP THE AUTO-LOGIN FOR THE XBMC USER ###
################################################################
cat >> /etc/gdm/custom.conf <<EOF
[daemon]
TimedLoginEnable=true
TimedLogin=xbmcuser
TimedLoginDelay=2
EOF
###############################
### make XBMC user use Xfce ###
###############################
echo "startxfce4" > /home/xbmcuser/.Xclients
chmod a+x /home/xbmcuser/.Xclients
chown xbmcuser:xbmcuser /home/xbmcuser/.Xclients
#############################
### make XBMC dep scripts ###
#############################
#########################
OUTFILE=/source/setup-xbmc-crystalhd.sh
(
cat <<'EOF'
#!/bin/sh
# This script will SVN Export the needed libraries to compile crystalHD in XBMC
### Create folders and export CrystalHD Headers
mkdir -p /usr/local/include/libcrystalhd
svn export --force https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk/lib/libcrystalhd/ /usr/local/include/libcrystalhd/
EOF
) > $OUTFILE
if [ -f "$OUTFILE" ]
then
  chmod +x $OUTFILE
  # Make the generated file executable.
else
  echo "Problem in creating file: \"$OUTFILE\""
fi
###########################
OUTFILE=/source/setup-xbmc-trunk.sh
(
cat <<'EOF'
#!/bin/sh
# This script will SVN Export the needed libraries to compile crystalHD in XBMC
### Check out SVN Source to /source/xbmc
svn co https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk/ /source/xbmc/
EOF
) > $OUTFILE
if [ -f "$OUTFILE" ]
then
  chmod +x $OUTFILE
  # Make the generated file executable.
else
  echo "Problem in creating file: \"$OUTFILE\""
fi
############################
############################
### make buildbot init.d ###
############################
OUTFILE=/etc/init.d/buildbot
(
cat <<'EOF666'
#! /bin/bash
# initscript for buildbot
# chkconfig: 2345 50 08
### BEGIN INIT INFO
# Provides:          buildbot
# Required-Start:    $local_fs $network
# Should-Start:      $remote_fs
# Should-Stop:      $remote_fs
# Default-Start:    2 3 4 5
# Default-Stop:      K 0 1 6
# Short-Description: Buildbot
# Description:      Buildbot
### END INIT INFO
# Required-Stop:    $local_fs
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESC="Buildbot"
USER=buildbot
DAEMON=/usr/bin/buildbot
DNAME=buildbot
PROCNAME=$NAME
LOCKFILE=/var/lock/subsys/buildbot
[ -r /etc/default/buildbot ] && . /etc/default/buildbot
test -x ${DAEMON} || exit 0
. /lib/lsb/init-functions
check_config()
{
    errors=0
    for i in ${BB_NUMBER[@]}; do
        [ $i -ge 0 ] || continue
        if [ -z "${BB_NAME[$i]}" ]; then
            echo >&2 "buildbot $i: no name"
            errors=$(($errors+1))
        fi
        if [ -z "${BB_USER[$i]}" ]; then
            echo >&2 "buildbot $i: no user"
            errors=$(($errors+1))
        elif ! getent passwd ${BB_USER[$i]} >/dev/null; then
            echo >&2 "buildbot $i: unknown user ${BB_USER[$i]}"
            errors=$(($errors+1))
        fi
        if [ ! -d "${BB_BASEDIR[$i]}" ]; then
            echo >&2 "buildbot $i: no base directory ${BB_BASEDIR[$i]}"
            errors=$(($errors+1))
        fi
    done
    [ $errors -eq 0 ] || exit 1
}
check_config
start_buildbot() {
    NAME="$1"
    USER="$2"
    BASEDIR="$3"
    PREFIXCMD="$4"
    OPTIONS="$5"
    #START="--start --quiet --exec ${DAEMON} --name ${NAME} --pidfile ${BASEDIR}/twistd.pid"
    #[ -n "${USER}" ] && START="${START} --chuid ${USER}"
    #START="${START} -- start ${BASEDIR} ${OPTIONS}"
    #${PREFIXCMD} start-stop-daemon ${START} >/dev/null 2>&1
    ${PREFIXCMD} su -s /bin/bash -c "${DAEMON} start ${BASEDIR} ${OPTIONS}" - ${USER}
    ret=$?
    if [ $ret == "0" ]; then
        touch ${LOCKFILE}
    fi
    return $?
}
stop_buildbot() {
    NAME="$1"
    USER="$2"
    BASEDIR="$3"
    PREFIXCMD="$4"
    ${PREFIXCMD} su -s /bin/bash -c "${DAEMON} stop ${BASEDIR}" - ${USER}
    ret=$?
    if [ $ret == "0" ]; then
        rm ${LOCKFILE}
    fi
    return $?
}
reload_buildbot() {
    NAME="$1"
    USER="$2"
    BASEDIR="$3"
    PREFIXCMD="$4"
    ${PREFIXCMD} su -s /bin/bash -c "${DAEMON} sighup ${BASEDIR}" - ${USER}
    return $?
}
do_start () {
    errors=0
    for i in ${BB_NUMBER[@]}; do
        [ $i -ge 0 ] || continue
        echo "Starting buildbot ${BB_NAME[$i]}"
        if start_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
            "${BB_PREFIXCMD[$i]}" "${BB_OPTIONS[$i]}"
        then
            echo "started"
        else
            echo "not started"
            errors=$(($errors+1))
        fi
    done
    return $errors
}
do_stop () {
    errors=0
    for i in ${BB_NUMBER[@]}; do
        [ $i -ge 0 ] || continue
        echo "Stopping buildbot ${BB_NAME[$i]}"
        if stop_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
            "${BB_PREFIXCMD[$i]}"
        then
            echo "stopped"
        else
            echo "not stopped"
            errors=$(($errors+1))
        fi
    done
    return $errors
}
do_reload () {
    errors=0
    for i in ${BB_NUMBER[@]}; do
        [ $i -ge 0 ] || continue
        echo "Reload buildbot ${BB_NAME[$i]}"
        if reload_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
            "${BB_PREFIXCMD[$i]}"
        then
            echo "reloaded"
        else
            echo "not reloaded"
            errors=$(($errors+1))
        fi
    done
    return $errors
}
do_restart () {
    errors=0
    for i in ${BB_NUMBER[@]}; do
        [ $i -ge 0 ] || continue
        echo "Restarting buildbot ${BB_NAME[$i]}"
        stop_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
            "${BB_PREFIXCMD[$i]}" || true
        if start_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
            "${BB_PREFIXCMD[$i]}" "${BB_OPTIONS[$i]}"
        then
            echo "restarted"
        else
            echo "not restarted"
            errors=$(($errors+1))
        fi
    done
    return $errors
}
case "$1" in
  start)
        do_start
        exit $?
        ;;
  stop)
        do_stop
        exit $?
        ;;
  reload)
        do_reload
        exit $?
        ;;
  restart|force-reload)
        do_restart
        exit $?
        ;;
  *)
        log_warning_msg "Usage: $0 {start|stop|restart|reload|force-reload}"
        exit 1
        ;;
esac
exit 0
EOF666
) > $OUTFILE
if [ -f "$OUTFILE" ]
then
  chmod +x $OUTFILE
  # Make the generated file executable.
else
  echo "Problem in creating file: \"$OUTFILE\""
fi
#########################
### Buildbot Defaults ###
#########################
OUTFILE=/etc/default/buildbot
(
cat <<'EOF'
# buildbots to manage
# add a new set of variables for each buildbot to start
BB_NUMBER[0]=0                                  # index for the other values; negative disables the bot
BB_NAME[0]="xbmc-fedora"                      # short name printed on startup / stop
BB_USER[0]="buildbot"                          # user to run as
BB_BASEDIR[0]="/home/buildbot/buildslave"      # basedir argument to buildbot (absolute path)
BB_OPTIONS[0]=""                                # buildbot options
BB_PREFIXCMD[0]=""                              # prefix command, i.e. nice, linux32, dchroot
EOF
) > $OUTFILE
OUTFILE=
####################################################################
### Modify yum-updated to auto install any updates every 4 hours ###
####################################################################
sed -i -e 's/run_interval \= 3600/run_interval \= 14400/' /etc/yum/yum-updatesd.conf
sed -i -e 's/emit_via \= dbus/emit_via \= syslog/' /etc/yum/yum-updatesd.conf
sed -i -e 's/do_update \= no/do_update \= yes/' /etc/yum/yum-updatesd.conf
sed -i -e 's/do_download \= no/do_download \= yes/' /etc/yum/yum-updatesd.conf
sed -i -e 's/do_download_deps \= no/do_download_deps \= yes/' /etc/yum/yum-updatesd.conf
%end
</pre>





Revision as of 01:40, 26 January 2010

Merge-arrow.gif
It has been suggested that this article or section be merged into ArchiveHOW-TO compile XBMC for Linux from source code. (Discuss)

Template:GoToParent

This is a tutorial on how to install XBMC on Fedora 8/9/10/11/12 & CentOS 5.2

Checkout from subversion

svn co Template:Svn XBMC

Install Packages

Fedora 8-12

rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

CentOS 5 (32)

rpm -Uvh http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

CentOS 5 (64)

rpm -Uvh http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

Cut & Paste Fun

yum install SDL* glew glew-devel libmad-devel tre tre-devel libogg libogg-devel libvorbis libvorbis-devel boost \
boost-devel bzip2-devel bzip2-libs fribidi* lzo lzo-devel mysql-libs mysql-devel jasper jasper-devel faac faac-devel \
enca enca-devel hal hal-devel hal-libs cmake gperf nasm libXmu-devel fontconfig-devel freetype-devel libXinerama-devel \
pcre-devel gcc-c++ sqlite-devel curl-devel mysql-devel libcdio-devel libmms-devel faad2-devel flac-devel libsmbclient-devel \
libXtst-devel libsamplerate-devel libtiff-devel pulseaudio-libs-devel avahi-devel


Configure

cd XBMC/
./bootstrap
./configure

With the above installed packages this should go smoothly :)

Build

make

Install

make install

When this completes you are done!

For Fedora 10-12, SELinux will prevent loading of some .so files due to potential security problems. To allow the loading of these files (thats what you probably want), simply open a terminal and as sudo (or as root) execute the following commands:

chcon -t textrel_shlib_t '/usr/local/share/xbmc/system/players/dvdplayer/avutil-50-i486-linux.so'
chcon -t textrel_shlib_t '/usr/local/share/xbmc/system/players/dvdplayer/avcodec-52-i486-linux.so'
chcon -t textrel_shlib_t '/usr/local/share/xbmc/system/players/dvdplayer/avformat-52-i486-linux.so'
chcon -t textrel_shlib_t '/usr/local/share/xbmc/system/players/dvdplayer/swscale-0.6.1-i486-linux.so'


Simply log into Gnome (or KDE) and open up a terminal and type 'xbmc' and it will load.





Fedora Kickstart File

Here is the kickstart file created by Cookieboy that was used to create the Fedora 12 buildslave. You can use this to do a full install with all the required packages to build XBMC from Source. This kickstart file will grab the packages from the Internet. You can modify the kickstart file to grab all the packages it can from the CDROM install and then the Net for the other packages if you would like. Cookieboy created the file with a local fedora repo rsynced down on a local network. This file has been modified to download from the public Internet.

After this kickstart file is used, in the /source folder you will find two scripts. One will download the latest CrystalHD header files to compile against, as well as a simple script to download xbmc trunk to the /source folder. Run those if you wish, and you can edit them to suit your needs. The other thing this file does, is turn on yum-updatesd and has it run every 4 hours to keep the system as up to date as possible for the buildslave.

To learn more about Kickstart files, visit the link here.


###########################################
### Kickstart file created by Cookieboy ###
### Created Jan 25th 2010               ###
###########################################

install
url --url http://mirrors.xmission.com/fedora/releases/12/Fedora/i386/os/
lang en_US.UTF-8
keyboard us

### Network - DHCP
network --device eth0 --bootproto dhcp

### Network - Static
#network --bootproto=static --ip=10.0.5.25 --netmask=255.255.255.0 --gateway=10.0.5.1 --nameserver=10.0.5.1 --hostname=myxbmc.mylocal.net

#rootpw rootpasshere

firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone America/Denver
bootloader --location=mbr

#################################################
### REQUIRED REPOS FOR THE YUM PACKAGES BELOW ###
#################################################

repo --name=Fedora-Everything --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-12&arch=i386
repo --name=Fedora-Updates --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=updates-released-f12&arch=i386
repo --name=RPMFusion-Free --mirrorlist=http://mirrors.rpmfusion.org/free/fedora/12/i386
repo --name=RPMFusion-Free-Updates --mirrorlist=http://mirrors.rpmfusion.org/free/fedora/updates/12/i386
repo --name=RPMFusion-NonFree --mirrorlist=http://mirrors.rpmfusion.org/nonfree/fedora/12/i386
repo --name=RPMFusion-NonFree-Updates --mirrorlist=http://mirrors.rpmfusion.org/nonfree/fedora/updates/12/i386


#########################
### ADD THE XBMC USER ###
#########################

user --name=xbmcuser --password=xbmcuserpass
user --name=buildbot --password=buildbotpass

services --disabled=acpid,anacron,atd,bluetooth,cups,firstboot,ip6tables,iptables,mdmonitor,sendmail --enable=yum-updatesd


############################
### HARDDRIVE PARTITIONS ###
############################

#  Uncomment the lines below to auto format your HD...
#clearpart --all --drives=sda
#part /boot --fstype ext4 --size=200
#part swap --size=1024
#part / --fstype ext4 --size=100 --grow


####################
### Yum Packages ###
####################

%packages

@base
@base-x
@development-tools
@xfce-desktop
kernel-devel
kernel-headers
yum-updatesd
###  XBMC NEEDED RPMS  ###
subversion
git
gcc-c++
boost-devel
mesa-libGL-devel
glew-devel
libmad-devel
libjpeg-devel
libsamplerate-devel
libogg-devel
libvorbis-devel
freetype-devel
fontconfig-devel
bzip2-devel
fribidi-devel
sqlite-devel
mysql-devel
libpng-devel
pcre-devel
lzo-devel
libcdio-devel
libsmbclient-devel
SDL-devel
SDL_image-devel
SDL_mixer-devel
enca-devel
jasper-devel
libmms-devel
libXt-devel
libXtst-devel
libXmu-devel
libXinerama-devel
libcurl-devel
dbus-devel
hal-devel
pulseaudio-libs-devel
pulseaudio-libs-zeroconf
faac-devel
avahi-devel
ffmpeg-devel
a52dec-devel
libdca-devel
faad2-devel
mpeg2dec-devel
libass-devel
libmpcdec-devel
flac-devel
wavpack-devel
python-devel
cmake
gperf
unzip
make
libtool
flex
bison
libtiff-devel
buildbot
libvdpau
nasm
libvdpau-devel
lirc
lirc-devel

%end

reboot

%post

#####################################################################
### XFCE: create /etc/sysconfig/desktop (needed for installation) ###
#####################################################################

cat > /etc/sysconfig/desktop <<EOF
PREFERRED=/usr/bin/startxfce4
EOF

########################################
### Create Nesessary Changes / Setup ###
########################################

mkdir /source
mkdir -p /home/buildbot/buildslave
chown buildbot:buildbot /home/buildbot/buildslave

################################################################
### HERE IS WHERE WE SET UP THE AUTO-LOGIN FOR THE XBMC USER ###
################################################################

cat >> /etc/gdm/custom.conf <<EOF
[daemon]
TimedLoginEnable=true
TimedLogin=xbmcuser
TimedLoginDelay=2
EOF

###############################
### make XBMC user use Xfce ###
###############################

echo "startxfce4" > /home/xbmcuser/.Xclients
chmod a+x /home/xbmcuser/.Xclients
chown xbmcuser:xbmcuser /home/xbmcuser/.Xclients

#############################
### make XBMC dep scripts ###
#############################

#########################
OUTFILE=/source/setup-xbmc-crystalhd.sh
(
cat <<'EOF'
#!/bin/sh
# This script will SVN Export the needed libraries to compile crystalHD in XBMC

### Create folders and export CrystalHD Headers
mkdir -p /usr/local/include/libcrystalhd
svn export --force https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk/lib/libcrystalhd/ /usr/local/include/libcrystalhd/
EOF
) > $OUTFILE

if [ -f "$OUTFILE" ]
then
  chmod +x $OUTFILE
  # Make the generated file executable.
else
  echo "Problem in creating file: \"$OUTFILE\""
fi

###########################
OUTFILE=/source/setup-xbmc-trunk.sh
(
cat <<'EOF'
#!/bin/sh
# This script will SVN Export the needed libraries to compile crystalHD in XBMC

### Check out SVN Source to /source/xbmc
svn co https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk/ /source/xbmc/
EOF
) > $OUTFILE

if [ -f "$OUTFILE" ]
then
  chmod +x $OUTFILE
  # Make the generated file executable.
else
  echo "Problem in creating file: \"$OUTFILE\""
fi
############################


############################
### make buildbot init.d ###
############################
OUTFILE=/etc/init.d/buildbot
(
cat <<'EOF666'
#! /bin/bash
# initscript for buildbot

# chkconfig: 2345 50 08
### BEGIN INIT INFO
# Provides:          buildbot
# Required-Start:    $local_fs $network
# Should-Start:      $remote_fs
# Should-Stop:       $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      K 0 1 6
# Short-Description: Buildbot
# Description:       Buildbot
### END INIT INFO

# Required-Stop:     $local_fs
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESC="Buildbot"

USER=buildbot

DAEMON=/usr/bin/buildbot
DNAME=buildbot
PROCNAME=$NAME
LOCKFILE=/var/lock/subsys/buildbot

[ -r /etc/default/buildbot ] && . /etc/default/buildbot

test -x ${DAEMON} || exit 0

. /lib/lsb/init-functions

check_config()
{
    errors=0
    for i in ${BB_NUMBER[@]}; do
        [ $i -ge 0 ] || continue
        if [ -z "${BB_NAME[$i]}" ]; then
            echo >&2 "buildbot $i: no name"
            errors=$(($errors+1))
        fi
        if [ -z "${BB_USER[$i]}" ]; then
            echo >&2 "buildbot $i: no user"
            errors=$(($errors+1))
        elif ! getent passwd ${BB_USER[$i]} >/dev/null; then
            echo >&2 "buildbot $i: unknown user ${BB_USER[$i]}"
            errors=$(($errors+1))
        fi
        if [ ! -d "${BB_BASEDIR[$i]}" ]; then
            echo >&2 "buildbot $i: no base directory ${BB_BASEDIR[$i]}"
            errors=$(($errors+1))
        fi
    done
    [ $errors -eq 0 ] || exit 1
}

check_config

start_buildbot() {
    NAME="$1"
    USER="$2"
    BASEDIR="$3"
    PREFIXCMD="$4"
    OPTIONS="$5"

    #START="--start --quiet --exec ${DAEMON} --name ${NAME} --pidfile ${BASEDIR}/twistd.pid"
    #[ -n "${USER}" ] && START="${START} --chuid ${USER}"
    #START="${START} -- start ${BASEDIR} ${OPTIONS}"
    #${PREFIXCMD} start-stop-daemon ${START} >/dev/null 2>&1
    ${PREFIXCMD} su -s /bin/bash -c "${DAEMON} start ${BASEDIR} ${OPTIONS}" - ${USER}
    ret=$?
    if [ $ret == "0" ]; then
        touch ${LOCKFILE}
    fi
    return $?
}

stop_buildbot() {
    NAME="$1"
    USER="$2"
    BASEDIR="$3"
    PREFIXCMD="$4"

    ${PREFIXCMD} su -s /bin/bash -c "${DAEMON} stop ${BASEDIR}" - ${USER}
    ret=$?
    if [ $ret == "0" ]; then
        rm ${LOCKFILE}
    fi
    return $?
}

reload_buildbot() {
    NAME="$1"
    USER="$2"
    BASEDIR="$3"
    PREFIXCMD="$4"

    ${PREFIXCMD} su -s /bin/bash -c "${DAEMON} sighup ${BASEDIR}" - ${USER}
    return $?
}

do_start () {
    errors=0
    for i in ${BB_NUMBER[@]}; do
        [ $i -ge 0 ] || continue
        echo "Starting buildbot ${BB_NAME[$i]}"
        if start_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
            "${BB_PREFIXCMD[$i]}" "${BB_OPTIONS[$i]}"
        then
            echo "started"
        else
            echo "not started"
            errors=$(($errors+1))
        fi
    done
    return $errors
}

do_stop () {
    errors=0
    for i in ${BB_NUMBER[@]}; do
        [ $i -ge 0 ] || continue
        echo "Stopping buildbot ${BB_NAME[$i]}"
        if stop_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
            "${BB_PREFIXCMD[$i]}"
        then
            echo "stopped"
        else
            echo "not stopped"
            errors=$(($errors+1))
        fi
    done
    return $errors
}

do_reload () {
    errors=0
    for i in ${BB_NUMBER[@]}; do
        [ $i -ge 0 ] || continue
        echo "Reload buildbot ${BB_NAME[$i]}"
        if reload_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
            "${BB_PREFIXCMD[$i]}"
        then
            echo "reloaded"
        else
            echo "not reloaded"
            errors=$(($errors+1))
        fi
    done
    return $errors
}

do_restart () {
    errors=0
    for i in ${BB_NUMBER[@]}; do
        [ $i -ge 0 ] || continue
        echo "Restarting buildbot ${BB_NAME[$i]}"
        stop_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
            "${BB_PREFIXCMD[$i]}" || true
        if start_buildbot "${BB_NAME[$i]}" "${BB_USER[$i]}" "${BB_BASEDIR[$i]}" \
            "${BB_PREFIXCMD[$i]}" "${BB_OPTIONS[$i]}"
        then
            echo "restarted"
        else
            echo "not restarted"
            errors=$(($errors+1))
        fi
    done
    return $errors
}

case "$1" in
  start)
        do_start
        exit $?
        ;;
  stop)
        do_stop
        exit $?
        ;;
  reload)
        do_reload
        exit $?
        ;;
  restart|force-reload)
        do_restart
        exit $?
        ;;
  *)
        log_warning_msg "Usage: $0 {start|stop|restart|reload|force-reload}"
        exit 1
        ;;
esac

exit 0
EOF666
) > $OUTFILE

if [ -f "$OUTFILE" ]
then
  chmod +x $OUTFILE
  # Make the generated file executable.
else
  echo "Problem in creating file: \"$OUTFILE\""
fi

#########################
### Buildbot Defaults ###
#########################
OUTFILE=/etc/default/buildbot
(
cat <<'EOF'
# buildbots to manage
# add a new set of variables for each buildbot to start

BB_NUMBER[0]=0                                  # index for the other values; negative disables the bot
BB_NAME[0]="xbmc-fedora"           	            # short name printed on startup / stop
BB_USER[0]="buildbot"                           # user to run as
BB_BASEDIR[0]="/home/buildbot/buildslave"       # basedir argument to buildbot (absolute path)
BB_OPTIONS[0]=""                                # buildbot options
BB_PREFIXCMD[0]=""                              # prefix command, i.e. nice, linux32, dchroot
EOF
) > $OUTFILE

OUTFILE=

####################################################################
### Modify yum-updated to auto install any updates every 4 hours ###
####################################################################

sed -i -e 's/run_interval \= 3600/run_interval \= 14400/' /etc/yum/yum-updatesd.conf
sed -i -e 's/emit_via \= dbus/emit_via \= syslog/' /etc/yum/yum-updatesd.conf
sed -i -e 's/do_update \= no/do_update \= yes/' /etc/yum/yum-updatesd.conf
sed -i -e 's/do_download \= no/do_download \= yes/' /etc/yum/yum-updatesd.conf
sed -i -e 's/do_download_deps \= no/do_download_deps \= yes/' /etc/yum/yum-updatesd.conf


%end