Talk:FreeLinkomatix

From NAS-Central Buffalo - The Linkstation Wiki
Revision as of 01:14, 25 September 2006 by Ramuk (Talk | contribs)

Jump to: navigation, search
Linkstation-debdux.gif 89px-Francesco_Torniello_da_Novara_Letter_F_1517.png 100px-Francesco_Torniello_da_Novara_Letter_X_1517.png

Contents

FreeLinkomatix

#! /bin/bash
###############################################################################
#  ___                _    _       _                       _    _             #
# | __>_ _  ___  ___ | |  <_>._ _ | |_   ___ ._ _ _  ___ _| |_ <_>__          #
# | _>|  _>/ ._>/ ._>| |_ | || | || / / / . \| | | |<_> | | |  | |\ \/        #
# |_| |_|  \___.\___.|___||_||_|_||_\_\ \___/|_|_|_|<___| |_|  |_|/\_\        #
#                                                                             #
# FreeLinkomatix is a tool for the Debian version of Linux used on the        #
# Buffalo LinkStation called FreeLink. This tool is designed to automate      #
# the addition of applications, libraries, and the upgrade to a v2.6 kernel   #
# which is not provided directly in the FreeLink distribution                 #
#                                                                             #
# The script is kept on the LinkStation wiki in the talk page:                #  
#                                                                             #  
#        http://linkstationwiki.net/index.php?title=Talk:FreeLinkomatix       #
#                                                                             #
# A full Description of the Project is at:                                    #
#                                                                             #
#        http://linkstationwiki.net/index.php?title=FreeLinkomatix            #
###############################################################################


###############################################################################
#See if we are connected to the internet and DNS works                        #
###############################################################################
clear
echo 'Ping ns.internic.net to see if you are connected to the internet'
echo ' '
echo '**This may take a few moments so be patient**'
echo ' '
if ping -q -c 10 198.41.0.4 ; then
  echo ' use <host> on a.root-servers.net'
    if ! host a.root-servers.net | grep 198.41.0.4  ; then
      echo 'adding nameserver 217.115.138.24 to /etc/resolv.conf'
      echo 'nameserver 217.115.138.24'  >> /etc/resolv.conf
    else
      grep nameserver /etc/resolv.conf
      echo 'works fine'
    fi
else
  echo 'Are you connected to the internet?'
  exit 1
fi

###############################################################################
#First do a quick check to see that you are running a PPC or MIPS based       # 
#Linkstation.  Set some enviornment variables we can use later                #
###############################################################################

ERROR="0"
uname -m | grep -q ppc || ERROR="1"
uname -m | grep -q mips && ERROR="0"

if [ "$ERROR" == "1" ] ; then
        echo ""
        echo "FATAL: Currently, only MIPS and PPC-based Linkstations are supported."
        echo "--> Cannot continue."
        echo ""
        exit 1
fi

# Recognize and set processor variable
uname -m | grep -q ppc && PROCESSOR="ppc"
uname -m | grep -q mips && PROCESSOR="mips"
# Recognize Kernel 2.4 LinkStation Flavors 
uname -r | grep -q "2.4.17_mvl21-sandpoint" && FLAVOR="ls1"
uname -r | grep -q "2.4.20_mipsel_linkstation" && FLAVOR="ls2"
uname -r | grep -q "2.4.20_mvl31-ppc_linkstation" && FLAVOR="hg"
# Recognize Kernel 2.6 LinkStation Flavors 
uname -r | grep "2.6" | grep kurobox | grep -q -v HG && FLAVOR="ls1"
uname -r | grep "2.6" | grep kurobox | grep -q HG && FLAVOR="hg"

###############################################################################
#Then do a quick check to make sure you have apt-get this should weed out the #
#Openlink users too                                                           #
###############################################################################

apt-get -v | grep -q dpkg || ERROR="1"
if [ "$ERROR" == "1" ] ; then
        echo ""
        echo "FATAL: Do you have apt-get installed, is this Debian(FreeLink)?"
        echo "--> Cannot continue."
        echo ""
        exit 1
fi

###############################################################################
#Let's get started then.....                                                  #
###############################################################################
clear
echo "  ___                _    _       _                       _    _      "
echo " | __>_ _  ___  ___ | |  <_>._ _ | |_   ___ ._ _ _  ___ _| |_ <_>__   "
echo " | _>|  _>/ ._>/ ._>| |_ | || | || / / / . \| | | |<_> | | |  | |\ \/ "
echo " |_| |_|  \___.\___.|___||_||_|_||_\_\ \___/|_|_|_|<___| |_|  |_|/\_\ "
echo '  '
echo "FreeLinkomatix is a tool for the Debian version of Linux used on the"
echo "Buffalo LinkStation called FreeLink. This tool is designed to automate"
echo "the addition of applications, libraries, and the upgrade to a v2.6 kernel"
echo " "
echo "The following will automatically be installed:"
echo " 1. Update apt-repositories...."
echo " 2. Move /home /usr /var from hda1 to hda3 and create symlinks"
echo " 3. Install Samba and Webmin"
echo " 4. Troubleshooting Windows shares (samba) - guest access"
echo " 5. Allow all IPs for Webmin"
echo " 6. Install SSH SSHd and the associated Webmin module"
echo " 7. Install ProFTPd and Webmin module"
echo " 8. Install Rsync and download Webmin module rsyncmin"
echo " 9. Download StressFree Solutions Tiger Webmin Theme"
echo "10. Configure the time zone and use NTPdate"
echo "11. Install the Precompiled C development environment"
echo "12. Upgrade to Kernel 2.6 using Andre's web installer"
echo " "
echo -n "Proceed? (y/n)"
read -e ANSWER
if [ "$ANSWER" == "n" ] ; then
 exit 1
fi
###############################################################################
#Update apt-repositories....                                                  #
###############################################################################
clear
echo "Update apt-repositories"
echo "-----------------------"
echo " In Debian new programs can easily be added by using the APT repository"
echo " You will have to update this repository first over the internet"
echo " "
echo " "
echo "***This will be done automatically in a few moments***"
 sleep 2 
  apt-get update
# apt-get upgrade
  apt-get dist-upgrade -y 

###############################################################################
#Move /home /usr /var  from hda1 to hda3 and create symlinks                  #
###############################################################################
clear
echo " "
echo "Move /home /usr /var  from hda1 to hda3 and create symlinks"
echo "-----------------------------------------------------------"
echo " Eventually you will probably run out of hard drive space on hda1 "
echo " (the location of the OS, and the default location of installed programs)," 
echo " You can free up space by moving some of the files to hda3 "
echo " (the large partition containing the network shares) by moving:" 
echo " "
if [ "$PROCESSOR" == "ppc" ] ; then
   echo " /home to  /mnt/home" 
   echo " /usr  to  /mnt/usr" 
   echo " /var  to  /mnt/var" 
fi
if [ "$PROCESSOR" == "mips" ] ; then
   echo " /home to /mnt/hda/home"
   echo " /usr  to /mnt/hda/usr"
   echo " /var  to /mnt/hda/var"
fi
echo " "
echo " And creating symlinks. You will rapidly run out of space in debian" 
echo " unless you do something to free up space on hda1"
echo " "
echo " "
 sleep 2 
  if [ "$PROCESSOR" == "ppc" ] ; then
    cp -Rdp /home /mnt
    rm -R   /home
    ln -s /mnt/home /home
    cp -Rdp /usr /mnt
    rm -R   /usr
    ln -s /mnt/usr /usr
    cp -Rdp /var /mnt
    rm -R   /var
    ln -s /mnt/var /var
  fi
  if [ "$PROCESSOR" == "mips" ] ; then
    cp -Rdp /home /mnt/hda
    rm -R   /home
    ln -s /mnt/hda/home /home
    cp -Rdp /usr /mnt/hda
    rm -R   /usr
    ln -s /mnt/hda/usr /usr
    cp -Rdp /var /mnt/hda
    rm -R   /var
    ln -s /mnt/hda/var /var
  fi 


###############################################################################
#Enable the Debian unstable Branch                                            #
###############################################################################
#clear
#echo " "
#echo "Get access to packages from the Debian unstable branch"
#echo "------------------------------------------------------"
#echo " It is often useful to have access to the Debian unstable branch"
#echo " because it has some interesting packages like PHP5 and rTorrent"
#echo " Using the unstable packages saves you the time you would spend"
#echo " compiling, The good thing is you don't have to change your whole"
#echo " installation to unstable you can simply use your stable or testing"
#echo " repository and just use the packages not in there from the unstable"
#echo " repository."
#echo " "
#echo " "
#echo -n "Do you want to gain access to the Debian unstable branch? (y/n)"
#read -e ANSWER 
#if [ "$ANSWER" == "y" ] ; then
# echo 'APT::Default-Release' >> /etc/apt/apt.conf
# echo '"stable"; ' >> /etc/apt/apt.conf
# echo "deb http://http.us.debian.org/debian unstable main contrib non-free " >> /etc/apt/sources.list 
# echo "deb-src http://http.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list 
# apt-get update
#fi

###############################################################################
#Install Samba and Webmin                                                     #
###############################################################################
clear
echo " "
echo "Install Samba and Webmin"
echo "------------------------"
echo " Samba is a free software implementation of Microsoft's networking"
echo " protocol released under the GNU General Public License. As of version 3"
echo " Samba not only provides file and print services for various Microsoft"
echo " Windows clients"
echo " "
echo " Webmin is a system configuration tool for Unix-like systems. It"
echo " has a web-based interface (GUI) desktop environment independent, for"
echo " configuring some of the internals of the operating system."
echo " Webmin is largely based on Perl, and is running as its own process"
echo " and webserver. It usually uses TCP port 10000 for communicating "
echo " "
echo " "
 sleep 2 
 apt-get install samba smbfs
 apt-get install webmin webmin-core webmin-cpan webmin-inetd webmin-logrotate webmin-firewall
 apt-get install webmin-samba

###############################################################################
#Troubleshooting Windows shares (samba) - guest access                        #
###############################################################################
clear
echo " "
echo "Troubleshooting Windows shares (samba) - guest access"
echo "-----------------------------------------------------"
echo " This will pick a directory  /mnt/share and change the access" 
echo " permissions to make it readable and writable to everybody."
echo " "
echo " YOU MAY NOT WANT TO DO THIS AND INSTEAD WISH TO CONFIGURE"
echo " SAMBA WITH WEBMIN OR MANUALLY EDIT /etc/samba/smb.conf"
echo " YOUR smb.conf WILL BE MOVED TO smb.conf.backup"
echo " "
echo -n "Do you want to enable guest access for Samba? (y/n)"
read -e ANSWER 
if [ "$ANSWER" == "y" ] ; then
echo " "
echo -n "What is your windows workgroup name ie: MSHOME or WORKGROUP? "
read -e WORKGROUP
 mkdir /mnt/share
 chmod 777 /mnt/share
 mv -i /etc/samba/smb.conf /etc/samba/smb.conf.backup
 echo '' >> /etc/samba/smb.conf
 echo '[global] ' >> /etc/samba/smb.conf
 echo ' security = share ' >> /etc/samba/smb.conf
 echo ' workgroup =' $WORKGROUP >> /etc/samba/smb.conf
 echo ' create mode = 777 ' >> /etc/samba/smb.conf
 echo ' directory mode = 777 ' >> /etc/samba/smb.conf
 echo ' ' >> /etc/samba/smb.conf
 echo '[share] ' >> /etc/samba/smb.conf
 echo ' comment = LinkStation Share ' >> /etc/samba/smb.conf
 echo ' path = /mnt/share ' >> /etc/samba/smb.conf
 echo ' read only = no ' >> /etc/samba/smb.conf
 echo ' public = yes ' >> /etc/samba/smb.conf
 /etc/rc.d/init.d/samba restart
fi

###############################################################################
# Allow all IPs for Webmin                                                    #
###############################################################################
clear
echo " "
echo "Allow all IP addresses for Webmin"
echo "---------------------------------"
echo " By default Webmin will only allow 127.0.0.1 (localhost) to login."   
echo " You will have to change  /etc/webmin/miniserv.conf to allow at"  
echo " least one external computer access to log into webmin. "
echo " "
echo " This script will allow any external IP to login.  It's a big security" 
echo " hole though so after you login to webmin,  change the allowed IP"
echo " addresses by going to:"
echo " "
echo "            Webmin Configuration --> IP Access Control" 
echo " "
echo " OR you can just edit /etc/webmin/miniserv.conf and change the line:"
echo " "
echo "                       allow= 127.0.0.1"
echo " "
echo "    to what you need and answer no to the following prompt:"
echo " "
 sleep 2 
 cat /etc/webmin/miniserv.conf | grep -v allow= > tmp
 mv tmp /etc/webmin/miniserv.conf
 /etc/webmin/stop
 sleep 2 
 /etc/webmin/start
###############################################################################
#Install SSH SSHd and the associated Webmin module                            #
###############################################################################
clear
echo " "
echo "Install SSH SSHd and the associated Webmin module"
echo "-------------------------------------------------"
echo " SSH is a set of standards and an associated network protocol" 
echo " that allows establishing a secure channel between a local and"
echo " a remote computer. SSH is typically used to log into a remote"
echo " machine and execute commands, but it also supports tunneling,"
echo " forwarding arbitrary TCP ports and X11 connections; it can"
echo " transfer files using the associated SFTP or SCP protocols."
echo " An SSH server (SSHd), by default, listens on the standard" 
echo " TCP port 22."
echo " "
echo " By using SSHd on the LinkStation and a client such as PuTTY"
echo " you can create a secure replacement for Telnet, you can remove"
echo " Telnetd at a later time when you are sure that SSHd works with"
echo " the command:"
echo " "
echo "                apt-get remove telnetd"
echo " "
 sleep 2 
  apt-get install ssh webmin-sshd



##############################################################################
#Install ProFTPd and Webmin module                                           #
##############################################################################
clear
echo " "
echo "Install ProFTPd"
echo "---------------"
echo " ProFTPd is an FTP server. It is stable and secure when configured"
echo " properly.  This will also install the Webmin module that you can"
echo " use to configure ProFTPd from within Webmin"
echo " "
 sleep 2 
 apt-get install webmin-proftpd proftpd proftpd-common  proftpd-doc


###############################################################################
#Download StressFree Solutions Tiger Webmin Theme                             #
###############################################################################
clear
echo " "
echo "Download StressFree Solutions Tiger Webmin Theme"
echo "------------------------------------------------"
echo " The Tiger webmin theme features a completely new graphical look," 
echo " high colour icons, dropdown menus and an AJAX search tool for "
echo " locating Webmin modules quickly. It has been tested in Firefox," 
echo " Safari and Internet Explorer."
echo " "
echo "     Find out more here: http://www.stress-free.co.nz/webmin-theme"
echo " "
echo " Installation: To install open Webmin "
echo " "
echo " Go to:  Webmin -> Webmin Configuration -> Webmin Themes"
echo " "
echo " Select the downloaded archive from your local disk and press "
echo " the Install Theme button. Once installed change the Current Theme" 
echo " dropdown to StressFree Theme and press the Change button. "
echo " "
echo " "
 sleep 2 
  wget http://www.stress-free.co.nz/files/theme-stressfree.tar.gz

###############################################################################
#Configure the time zone and use NTPdate                                      #
###############################################################################
clear
echo " "
echo "Configure the time zone and use NTPdate"
echo "---------------------------------------"
echo " The ntpd (Network Time Protocol daemon) program is an operating"
echo " system daemon which sets and maintains the system time of day in"
echo " synchronism with time servers".
echo " First you will have to configure your time zone (tzconfig)" 
echo " This script with also make it a cron job to resynchronize"
echo " on an hourly basis"
echo " "
echo " "
 sleep 2 
 tzconfig
 apt-get install ntp ntp-simple ntp-server ntpdate
 /etc/init.d/ntpdate restart
 echo '17 *    * * *   root    /etc/init.d/ntpdate restart' >> /etc/crontab


###############################################################################
#Install the Precompiled C development environment                            #
###############################################################################
clear
echo " "
echo "Install Precompiled C development environment"
echo "---------------------------------------------"
echo " The LinkStation lacks virtually all necessary development tools" 
echo " such as binutils or gcc, making it quite difficult to natively compile"
echo " programs. This provides a complete package of precompiled development"
echo " tools and related libraries." 
echo " "
echo " These tools come from http://www.linkstationwiki.net"
echo " "
 sleep 2 
   if [ "$PROCESSOR" == "ppc" ] ; then
      mkdir tmpdevel
      cd tmpdevel
      wget http://downloads.linkstationwiki.net/development_tools/ppc-tools-2_1.tgz 
      mkdir devtools
      cd devtools
      tar xzvf ../ppc-tools-2_1.tgz
      ./install.sh
      if [ "$FLAVOR" == "hg" ] ; then
         wget http://downloads.linkstationwiki.net/kernel_headers/kernel-headers-2.4.20_hglan_htgl-2.0.tar.bz2
         tar -C / -xvjf kernel-headers-2.4.20_hglan_htgl-2.0.tar.bz2
      fi    
   fi
   if [ "$PROCESSOR" == "mips" ] ; then
      mkdir tmpdevel
      cd tmpdevel
      wget http://downloads.linkstationwiki.net/development_tools/mipsel-tools-2_1.tgz
      mkdir devtools
      cd devtools
      tar xzvf ../mipsel-tools-2_1.tgz
      ./install.sh
   fi
 cd ..
 cd ..
 rm -r tmpdevel


###############################################################################
#        Upgrade to Kernel 2.6 using Andre's web installer                    #
#                       System will REBOOT after this                         #
#               This should always be the last action of this script          #
###############################################################################
if [ "$PROCESSOR" == "ppc" ] ; then
clear
echo " "
echo "Upgrade to Kernel 2.6 using Andre's web installer"
echo "-------------------------------------------------"
echo " Upgrade from Buffalo's outdated kernel 2.4, currently included"
echo " in the Debian (FreeLink) release, on LS1, HG, HS, KuroBox, and"
echo " KuroHG. The 2.6 Kernel addresses virtually all shortcomings of"
echo " the LS stock kernels: Very good USB support, NFS, routing, quotas"
echo " lots more."
echo " The 550+ modules are optional -- you could delete them if you're"
echo " short of disk space, as the "LS core functions", support for mass"
echo " storage devices and printing, have been compiled into the kernel"
echo " "
echo " Find out more at: http://hvkls.dyndns.org/downloads/documentation/"
echo " "
echo "       *****YOU WILL HAVE TO REBOOT AFTER THIS*****"
echo " "
 sleep 2 
  wget --tries=3 --dns-cache=off --dns-timeout=8 --connect-timeout=8 --random-wait -c http://downloads.linkstationwiki.net/mirrors/hvkls.dyndns.org/latest-webinstaller.tar.gz
  wget --tries=3 --dns-cache=off --dns-timeout=8 --connect-timeout=8 --random-wait -c http://hvkls.dyndns.org/downloads/latest-webinstaller.tar.gz
  tar -C / -xvzf latest-webinstaller.tar.gz
  /usr/local/sbin/webinstaller-kernelinst.sh
fi

Post Install Script

###############################################################################
###############################################################################
clear
echo "FreeLinkomatix Post install script: "
echo " "
echo "This script is ment to be run after the upgrade to a v2.6 kernel"
echo "It will install additional apps some of which are dependant on kernel v2.6"
echo " "
echo "Operating System: " `uname -o`
echo "Kernel Release:   " `uname -r`
echo "Version:          " `uname -v`
echo "Processor:        " `uname -m`
echo " "
echo " 1. Add Kernel Network File System (NFS) and the Webmin Exports module"
echo " 2. Install Rsync and download Webmin module rsyncmin"
echo " 3. Add USB Automounting and CUPS Printer Support"
echo " 4. Macintosh Specific Netatalk and Howl Zeroconf DNS discovery service"
echo " 5. Add Firefly (mt-daapd) Media Server "
echo " 6. Install ccxstream XBMSP protocol for XBox Media Center "
echo " 7. KAID - XLink Kai online gaming for Xbox, 360, PS2 and PSP"
echo " "
echo -n "Do you want to add additional apps to your Linkstation? (y/n)"
read -e ANSWER
if [ "$ANSWER" == "n" ] ; then
exit 1
fi

###############################################################################
#First do a quick check to see that you are running a kernel 2.6 on your      #
#Linkstation and set some variables                                           #
###############################################################################

ERROR="0"
kernelversion | grep -q "2.6" || ERROR="1"
uname -m | grep -q ppc || ERROR="1"

if [ "$ERROR" == "1" ] ; then
        echo ""
        echo "FATAL: At present only PPC-based Linkstations running kernel v2.6 are supported."
        echo "--> Cannot continue."
        echo ""
        exit 1
fi
# Recognize Kernel 2.6 LinkStation Flavors 
uname -r | grep "2.6" | grep kurobox | grep -q -v HG && FLAVOR="ls1"
uname -r | grep "2.6" | grep kurobox | grep -q HG && FLAVOR="hg"

###############################################################################
#Install Rsync and download Webmin module rsyncmin                            #
###############################################################################
clear
echo " "
echo "Install Rsync and download Webmin module rsyncmin"
echo "-------------------------------------------------"
echo " rsync is a free software computer program for Unix systems which"
echo " synchronizes files and directories from one location to another" 
echo " while minimizing data transfer using delta encoding when" 
echo " appropriate. An important feature of rsync not found in most" 
echo " similar programs/protocols is that the mirroring takes place" 
echo " with only one transmission in each direction. rsync can copy" 
echo " or display directory contents and copy files, optionally using"
echo " compression and recursion."
echo " "
echo " This script will also download the webmin module Rsyncmin from"
echo " http://opensource.digisec.de/ which configures rsyncd.conf "
echo " "
echo "                        rsyncmin.wbm"
echo " "
echo " You will have to install the Rsyncmin module within Webmin yourself"
echo " "
echo " "
echo -n "Do you want to Install Rsync? (y/n)"
read -e ANSWER
if [ "$ANSWER" == "y" ] ; then
  apt-get install rsync
  wget http://opensource.digisec.de/webmin/rsyncmin.wbm
fi

###############################################################################
#Add USB Automounting and CUPS Printer Support                                #
###############################################################################
clear
echo " "
echo "Add USB Automounting and CUPS Printer Support"
echo "---------------------------------------------"
echo " This will add USB Drive automounting and mount USB"
echo " drives to /media/usb0,1,2,3 etc.  symbolic links"
echo " in /mnt/share will also be created usb0,usb1,usb2,usb3"
echo " so that they will be accessable via your samba share"
echo " Also CUPS (Common Unix Printing System) Support will"
echo " be added. You can configure this in Webmin"
echo " "
echo "  Webmin --> Hardware -->Printer Adminstration -->Module Config -->"
echo "  -->Printer Configuration Style -->[CUPS]"
echo " "
echo " "
echo -n "Do you want to add Kernel NFS and Webmin Exports? (y/n)"
read -e ANSWER
if [ "$ANSWER" == "y" ] ; then
 apt-get remove hotplug 
 apt-get install usbmount
sed -e 's@^FILESYSTEMS.*$@FILESYSTEMS="ext3 ext2 vfat"@ ; s@^MOUNTOPTIONS.*$@MOUNTOPTIONS="noexec,nodev,noatime"@' < /etc/usbmount/usbmount.conf > /tmp/file
 cat /tmp/file > /etc/usbmount/usbmount.conf
 ln -s /media/usb0/ /mnt/share
 ln -s /media/usb1/ /mnt/share
 ln -s /media/usb2/ /mnt/share
 ln -s /media/usb3/ /mnt/share
 apt-get install cupsys cupsys-bsd
fi

###############################################################################
#Add Kernel Network File System (NFS) and the Webmin Exports module           #
###############################################################################
clear
echo " "
echo "Add Kernel Network File System (NFS) and the Webmin Exports module"
echo "-----------------------------------------------------------------"
echo " Network File System (NFS) is a protocol originally developed"
echo " by Sun Microsystems in 1984, as a distributed file system which"
echo " allows a computer to access files over a network as easily as if"
echo " they were on its local disks. NFS is one of many protocols built"
echo " on the Open Network Computing Remote Procedure Call system"
echo " This script will install Kernel NFS server support, it will" 
echo " require Kernel 2.6 to have been installed. Also the NFS exports"
echo " control module for webmin will be installed allowing webmin"
echo " to manage NFS exports."
echo "  " 
echo " After you set up NFS exports with webmin or manually, you "
echo " will have to either restart your system or restart the NFS"
echo " daemon with" 
echo " "
echo "               /etc/init.d/nfs-kernel-server start"
echo " "
echo " "
echo -n "Do you want to add Kernel NFS and Webmin Exports? (y/n)"
read -e ANSWER
if [ "$ANSWER" == "y" ] ; then
   apt-get install nfs-kernel-server webmin-exports
fi

###############################################################################
#Macintosh Specific Netatalk and Howl Zeroconf DNS discovery service          #
###############################################################################
clear
echo " "
echo "Macintosh Specific Netatalk and Howl Zeroconf DNS discovery service"
echo "-------------------------------------------------------------------"
echo " Protocols that provide Native Mac OS X compatibility
echo " Netatalk is an open-source implementation of the AppleTalk suite"
echo " of protocols. It allows Unix-like operating systems to serve as "
echo " file, print and time servers for Macintosh computers."
echo " Howl -a multicast DNS service discovery is an open source"
echo " implementation of the Zeroconf specification a set of techniques"
echo " that automatically create a usable IP this allows unknowledgeable"
echo " users to connect computers, networked  printers, and other items"
echo " together and expect them to work. "
echo " Zeroconf was pioneered by Apple Computer in the company's move"
echo " from AppleTalk to IP."
echo " "
echo " "
echo " Binaries from: http://hvkls.dyndns.org/downloads/documentation/"
echo " "
echo -n "Native Mac OS X compatibility with NetaTalk and Howl? (y/n)"
read -e ANSWER
if [ "$ANSWER" == "y" ] ; then
#########################
#INSTALL NETATALK FIRST #
######################### 
 apt-get install cracklib-runtime libpam-cracklib netatalk 
 /etc/init.d/netatalk stop 
 wget --tries=3 --dns-cache=off --dns-timeout=8 --connect-timeout=8 --random-wait -c http://downloads.linkstationwiki.net/powerpc-hdhlan/binaries-that-need-kernel2.6/netatalk_2.0.3-4_powerpc.deb
 wget --tries=3 --dns-cache=off --dns-timeout=8 --connect-timeout=8 --random-wait -c http://hvkls.dyndns.org/downloads/netatalk_2.0.3-4_powerpc.deb

 dpkg -i netatalk_2.0.3-4_powerpc.deb 
 rm /etc/default/netatalk
 echo 'AFPD_MAX_CLIENTS=10 ' >> /etc/default/netatalk
 echo 'ATALK_NAME=`/bin/hostname` ' >> /etc/default/netatalk
 echo "ATALK_MAC_CHARSET='MAC_ROMAN' " >> /etc/default/netatalk
 echo "ATALK_UNIX_CHARSET='LOCALE' " >> /etc/default/netatalk
 echo 'AFPD_UAMLIST="-U uams_dhx.so" ' >> /etc/default/netatalk  
 echo 'AFPD_GUEST=nobody ' >> /etc/default/netatalk
 echo 'ATALKD_RUN=no ' >> /etc/default/netatalk
 echo 'PAPD_RUN=no ' >> /etc/default/netatalk
 echo 'CNID_METAD_RUN=yes ' >> /etc/default/netatalk
 echo 'AFPD_RUN=yes ' >> /etc/default/netatalk
 echo 'TIMELORD_RUN=no ' >> /etc/default/netatalk
 echo 'A2BOOT_RUN=no ' >> /etc/default/netatalk
 echo 'ATALK_BGROUND=yes ' >> /etc/default/netatalk
 echo 'export ATALK_MAC_CHARSET ' >> /etc/default/netatalk
 echo 'export ATALK_UNIX_CHARSET ' >> /etc/default/netatalk
 rm /etc/netatalk/afpd.conf
 echo '- -transall -uamlist uams_dhx.so -nosavepassword -noddp  ' >> /etc/netatalk/afpd.conf
 echo '/mnt/shared "shared" allow:linkstation ' >> /etc/netatalk/AppleVolumes.default
####################
#THEN INSTALL HOWL #
####################
 wget --tries=3 --dns-cache=off --dns-timeout=8 --connect-timeout=8 --random-wait -c http://downloads.linkstationwiki.net/powerpc-hdhlan/binaries-that-need-kernel2.6/howl_1.0.0-binaries-ppc.tar.gz
 wget --tries=3 --dns-cache=off --dns-timeout=8 --connect-timeout=8 --random-wait -c http://hvkls.dyndns.org/downloads/howl_1.0.0-binaries-ppc.tar.gz
 tar -C / -xvzf howl_1.0.0-binaries-ppc.tar.gz
#will have to alter /etc/howl/mDNSResponder.conf file to fit what we make and wget it in the future....
 /etc/init.d/howl start
fi

###############################################################################
#Add Firefly (mt-daapd) Media Server                                          #
###############################################################################
clear
echo " "
echo "Add Firefly (mt-daapd) Media Server"
echo "-----------------------------------"
echo " Firefly Media Server (formerly mt-daapd) is an open-source media"
echo " server (or daemon) for the Roku SoundBridge and iTunes. It serves"
echo " media files using Roku Server Protocol (RSP) and Digital Audio"
echo " Access Protocol (DAAP).Netatalk is an open-source implementation"
echo " of the AppleTalk suite"
echo " "
echo " Point your web browser to http://linkstation:3689 and login with: "
echo "                user:mt-daapd"
echo "                password:mt-daapd "
echo " "
echo " and set up the configuration in the web interface "
echo " "
echo " "
echo " Binaries from: http://hvkls.dyndns.org/downloads/documentation/"
echo " "
echo -n "Add Firefly (mt-daapd) Media Server? (y/n)"
read -e ANSWER
if [ "$ANSWER" == "y" ] ; then
 apt-get install libid3tag 
 wget --tries=3 --dns-cache=off --dns-timeout=8 --connect-timeout=8 --random-wait -c http://downloads.linkstationwiki.net/powerpc-hdhlan/binaries-that-need-kernel2.6/mtdaapd_0.2.4-binaries-ppc.tar.gz
 wget --tries=3 --dns-cache=off --dns-timeout=8 --connect-timeout=8 --random-wait -c http://hvkls.dyndns.org/downloads/mtdaapd_0.2.4-binaries-ppc.tar.gz
 tar -C / -xvzf mtdaapd_0.2.4-binaries-ppc.tar.gz 
#wget http://puzzle.dl.sourceforge.net/sourceforge/mt-daapd/mt-daapd-0.2.4.tar.gz
#tar -xvzf mt-daapd-0.2.4.tar.gz
#cd mt-daapd-0.2.4
#./configure --prefix=/usr/local --enable-browse --enable-query --enable-mdns --with-id3tag=/usr/local --sysconfdir=/etc 
#make
#make install
#mkdir /etc/mt-daapd
#cp contrib/mt-daapd.* /etc/mt-daapd/
 mv /etc/mt-daapd.SAMPLE /etc/mt-daapd 
 /etc/init.d/mt-daapd start
fi



###############################################################################
#Install ccxstream XBMSP protocol for XBox Media Center                       #
###############################################################################
clear
echo " "
echo "Install ccxstream XBMSP protocol for XBox Media Center"
echo "------------------------------------------------------"
echo " XBMSP (XBox Media Stream Protocol) or XBMS for short is another way"
echo " of sharing media, supposedy it is faster than Samba. It is capable"
echo " of streaming all types of media and gives the option of sharing"
echo " individual folders or entire drives. XBMS is very bandwith efficient."
echo " Once you install ccXStream on your LinkStation all you have to do"
echo " is configure your XMBC to use the media share."
echo " ccxstream is a part of the XBox Media Center Project"
echo "http://www.xboxmediacenter.com/"
echo " "
echo " It will share /mnt/share by default"
echo " "
echo -n "Do you want to install ccxstream - XBMSP? (y/n)"
read -e ANSWER 
if [ "$ANSWER" == "y" ] ; then
  wget http://osdn.dl.sourceforge.net/sourceforge/xbplayer/ccxstream-1.0.15.tar.gz
  tar -xvzf ccxstream-1.0.15.tar.gz
  cd ccxstream-1.0.15
  make
  cp ccxstream /usr/local/bin
  cp ccxtest /usr/local/bin
  mkdir /usr/doc/ccxstream
  cp  COPYRIGHT /usr/doc/ccxstream/
  cp  ChangeLog /usr/doc/ccxstream/
  cp  PORTING /usr/doc/ccxstream/
  cp  README /usr/doc/ccxstream/
  cp  TODO /usr/doc/ccxstream/
  cp  xbmsp-xml.txt /usr/doc/ccxstream/
  cp  xbmsp.txt /usr/doc/ccxstream/
  echo '#! /bin/sh' >> /etc/init.d/ccxstream
  echo '#' >> /etc/init.d/ccxstream
  echo '# CCXSTREAM - see /usr/doc/ccxstream/README for options' >> /etc/init.d/ccxstream
  echo '#' >> /etc/init.d/ccxstream
  echo '# Set SHAREDIR to directory you want to share' >> /etc/init.d/ccxstream
  echo '# Set OPTIONS to other command line options you want' >> /etc/init.d/ccxstream
  echo 'SHAREDIR=/mnt/share' >> /etc/init.d/ccxstream
  echo 'OPTIONS="-f -F /var/run/ccxstream.pid"' >> /etc/init.d/ccxstream
  echo '#' >> /etc/init.d/ccxstream
  echo '  if [ -n "`pidof ccxstream`" ] ; then' >> /etc/init.d/ccxstream
  echo '     killall ccxstream 2>/dev/null' >> /etc/init.d/ccxstream
  echo '  fi' >> /etc/init.d/ccxstream
  echo '  sleep 2' >> /etc/init.d/ccxstream
  echo '  /usr/local/bin/ccxstream -r $SHAREDIR  $OPTIONS' >> /etc/init.d/ccxstream
  chmod a+x /etc/init.d/ccxstream
  cd /etc/rc.d/rc2.d
  ln -s ../init.d/ccxstream S75ccxstream
  cd ../rc0.d
  ln -s ../init.d/ccxstream K02ccxstream
  cd ../rc6.d
  ln -s ../init.d/ccxstream K02ccxstream
  /etc/init.d/ccxstream
fi

###############################################################################
#KAID - XLink Kai online gaming for Xbox, 360, PS2 and PSP                    #
###############################################################################
clear
echo " "
echo "KAID - XLink Kai online gaming for Xbox, 360, PS2 and PSP"
echo "---------------------------------------------------------"
echo " Xlink Kai: Evolution VII lets you connect with other console users"
echo " around the world, and play online games for free. XLink Kai: Evo VII"
echo " tricks your console into thinking that the other users it is connecting"
echo " to over the Internet, are actually part of a Local Area Network. This"
echo " is the basis of system-link gaming, where friends would gather around"
echo " in the same house and play over 2 or more consoles. With XLink Kai: Evo VII"
echo " you now have the option to test your skills out with anybody in the world."
echo " you will need a XTAG (username) and Password for this service."
echo " Xlink Kai is developed by Team Xlink - http://www.teamxlink.co.uk/"
echo " "
echo -n "Do you want to install X-link KAID? (y/n)"
read -e ANSWER 
if [ "$ANSWER" == "y" ] ; then
 echo -n "Enter your Xlink username:"
 read -e USERNAME
 echo -n "Enter your password:"
 read -e PASSWORD
 wget http://www.teamxlink.co.uk/binary/kaid-ppc-static-libc-2.3.zip
 unzip kaid-*
 mv kaid-static* kaid
 mv kaid /usr/local/sbin
 chmod 755 /usr/local/sbin/kaid
 wget http://downloads.linkstationwiki.net/freelinkomatix/kaid
 mv kaid /etc/init.d/kaid
 chmod 755 /etc/init.d/kaid  
# ln -s /etc/init.d/kaid /etc/rc.d/rc0.d/K99kaid
# ln -s /etc/init.d/kaid /etc/rc.d/rc2.d/S99kaid
# ln -s /etc/init.d/kaid /etc/rc.d/rc6.d/K99kaid
 wget http://downloads.linkstationwiki.net/freelinkomatix/kaid.conf
 echo 'Username = ' $USERNAME  >> kaid.conf
 echo 'Password = ' $PASSWORD  >> kaid.conf
 mv kaid.conf /etc/kaid.conf
fi