#!/bin/bash ### # Gentoox "magic" patch system # Copyright (C) Thomas "ShALLaX" Pedley (gentoox@shallax.com) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ### ### # IF PATCHES ARE DEPENDENT ON OTHER PATCHES BEING INSTALLED, THE DEPENDENCY # MUST BE CHECKED FIRST OTHERWISE INVALID INFORMATION WILL BE ADDED TO # MAGIC-DATABASE!!!!!! ### ### # General notes: # exit 1 == error occurred - cleans up before exit. # exit == no error - cleans up before exit. ### ### # Secondary wget definition incase its not been defined in the root # magic programme (i.e. it hasn't been updated yet) ### if [ -z `echo $wget | awk '{ print $1 }'` ]; then wget="wget -T 30 -t 5 " fi ### # This cleans up all temporary files ### cleanup() { rm -rf ~/patches* rm -rf ~/magic.md5* rm -rf ~/*.b0x rm -rf /tmp/.shutupled* rm -rf ~/motd.gentoox* rm -rf /tmp/serverdown rm -rf /tmp/patches.md5* } ### # First, start in /tmp. Nothing should ever go before this! ### cd /tmp $downloading $wget --limit-rate=${limitrate} $gentooxurl/magicscript/patches.md5 1> /dev/null 2> /dev/null if [ $? != "0" ]; then clear $error echo -e "Downloading magic [${bluetxt}patches.md5${normaltxt}] failed, please try again later." echo -ne "${redtxt}Press enter to quit...${normaltxt}" read cleanup exit 1 fi $busy if [ `cat patches.md5 | awk '{ print $1 }'` != `md5sum ~/patches | awk '{ print $1 }'` ]; then clear echo "Patch file corrupt, please rerun magic to correct this error." cleanup exit 1 fi ### # Second, compatibility issues! Older versions of magic did not set # these variables, so if they are of zero length, they are assigned # defaults here. ### if [ -z ${limitrate} ]; then export limitrate=5120 fi if [ -z ${gentooxurl} ]; then export gentooxurl="http://gentoox.shallax.com" fi ### # Next thing to do is setup the patch serial number, and the includes ### export gentooxpatchesversion=`grep -m1 "NewVersion" /bin/magic | awk '{ print $3 }'` ### # Again, more compatibility issues, older magic versions didnt contain "NewVersion" ### if [ -z $gentooxpatchesversion ]; then export gentooxpatchesversion="XXXXXXXXXXX" fi ### # Yet more compatibility issues. These SHOULD be handled in the main "magic" # script, but older versions dont... so it has to be accounted for here. ### if [ ! -f /etc/functions.magic ] || [ ! -f /etc/patches.magic ]; then $wget --limit-rate=${limitrate} $gentooxurl/magicscript/functions.magic 1> /dev/null 2> /dev/null if [ $? != 0 ]; then clear echo -e "Downloading magic [${bluetxt}functions.magic${normaltxt}] failed, please try again later." echo -ne "${redtxt}Press enter to quit...${normaltxt}" read rm -rf /etc/functions.magic rm -rf /tmp/functions.magic cleanup exit 1 fi rm -rf /etc/functions.magic mv /tmp/functions.magic /etc/functions.magic chmod 644 /etc/functions.magic $wget --limit-rate=${limitrate} $gentooxurl/magicscript/patches.magic 1> /dev/null 2> /dev/null if [ $? != 0 ]; then clear echo -e "Downloading magic [${bluetxt}patches.magic${normaltxt}] failed, please try again later." echo -ne "${redtxt}Press enter to quit...${normaltxt}" read rm -rf /etc/patches.magic rm -rf /tmp/patches.magic cleanup exit 1 fi rm -rf /etc/patches.magic mv /tmp/patches.magic /etc/patches.magic chmod 644 /etc/patches.magic fi source /etc/functions.magic source /etc/patches.magic $wget --limit-rate=5120 $gentooxurl/magicscript/limitrate 1> /dev/null 2> /dev/null failCheck download $busy export limithuman=`grep kbps /tmp/limitrate | awk '{ print $2 }'` export sum="`grep kbps /tmp/limitrate | awk '{ print $2 }'`*1024" rm -rf /tmp/limitrate* ### # "5120" is a default limit, and has to be hardcoded in some places. # So if it so happens that the rate has been changed to something other than 5120 by ME # but it gets hardcode set back to 5120, then this should not punish the user ### if [ ${limitrate} != `echo $sum | bc` ] && [ ${limitrate} != "5120" ]; then clear echo "Speedcap hacker! Byebye." exit 1 fi $good ### # patchcounter for available) ### export patchcounter="0" clear $busy ### # Passify the user whilst final checks/ tasks are being executed ### clear welcomeToMagic VER_NAME=`cat /etc/gentoox_version | sed "s/[0-9]\.[0-9]//"` VER_NUM=`cat /etc/gentoox_version | sed "s/[A-z]//g" | sed "s/\.//g"` ### # Deprecated warning check. ### if [ `echo $VER_NAME | tr A-Z a-z` == "home" ]; then if [ $VER_NUM -lt `echo $DEPRECATED_TO_HOME | sed "s/\.//g"` ]; then deprecatedWarning "Home" "v$DEPRECATED_TO_HOME" fi elif [ `echo $VER_NAME | tr A-Z a-z` == "pro" ]; then if [ $VER_NUM -lt `echo $DEPRECATED_TO_PRO | sed "s/\.//g"` ]; then deprecatedWarning "Pro" "v$DEPRECATED_TO_PRO" fi fi ### # Fix mySQL borkage... ### if [ ! -d /var/log/mysql ]; then mkdir /var/log/mysql 1> /dev/null 2> /dev/null chown mysql:mysql /var/log/mysql 1> /dev/null 2> /dev/null chmod 755 /var/log/mysql 1> /dev/null 2> /dev/null fi ### # Fix lastlog borkage... ### if [ ! -f /var/log/lastlog ]; then touch /var/log/lastlog fi ### # Forgot to include a version file with Gentoox Pro 1, this makes one based on # the fact that it is not any of the other versions (all other versions do have # this file). ### if [ ! -f /etc/gentoox_version ]; then echo "pro1" > /etc/gentoox_version fi ### # Force update the magic script for all versions that havent been updated yet. # Needed to update all old versions. ### if [ ! -f /etc/conf.d/oneshotmagicupdate ]; then cd /tmp rm -rf /tmp/magic $downloading $wget --limit-rate=5120 $gentooxurl/magic 1> /dev/null 2> /dev/null if [ $? == "0" ]; then $busy rm -rf /bin/magic mv /tmp/magic /bin/magic chown root:root /bin/magic chmod 755 /bin/magic echo "dont ever delete this" > /etc/conf.d/oneshotmagicupdate else clear echo "Download failed, please try again later" exit 1 fi magicUpdated /bin/magic $1 $2 exit 0 fi ### # Update magic to use the database! ### if [ ! -f /etc/conf.d/magic-database ]; then clear $important cd ~/ $wget --limit-rate=${limitrate} $gentooxurl/magicscript/initdatabase failCheck download sh ~/initdatabase && rm -rf ~/initdatabase clear export patchname="keyboardtoggle1" && delDatabase export patchname="displaytools1" && delDatabase magicUpdated /bin/magic $1 $2 exit 0 fi ### # Database maintenance ### export patchname="$maintain" && queryDatabase if [ $patchinstalled == "false" ]; then delDatabaseOld clear $important cd ~/ $wget --limit-rate=${limitrate} $gentooxurl/magicscript/maintaindatabase failCheck download sh ~/maintaindatabase && rm -rf ~/maintaindatabase clear addDatabase magicUpdated /bin/magic $1 $2 exit 0 fi ### # Delete the deprecated e-drive, f-drive and newfs scripts from local storage ### rm -rf /bin/e-drive rm -rf /bin/f-drive rm -rf /bin/newfs ### # This fixes an issue with kde, xserver, xvkbd patches which would return # errors because the user 'gentoox' does not exist in the pro edition. # This creates the user and asks for a password. Run automatically and only # once. ### export patchname="useradded1" && queryDatabase if [ `cat /etc/gentoox_version` == "pro1" ] && [ $patchinstalled == "false" ]; then clear $input echo "It is necessary to add a user named 'gentoox' to add full functionality" echo "to your distribution" echo -e echo "Please enter a password for this user" $busy useradd gentoox passwd gentoox mkdir /home/gentoox chown -R gentoox:wheel /home/gentoox chmod -R 755 /home/gentoox usermod -d /home/gentoox gentoox usermod -G wheel,users,audio,video,games gentoox echo "All done, you will not be prompted to do this again" $good sleep 5 clear export patchname="useradded1" && addDatabase fi $busy ### # General cleaning rules here ### ### # Original Gentoox versions had magic in /root, its now in /bin # so move it over! ### mv ~/magic /bin/magic 2> /dev/null 1> /dev/null chmod 755 /bin/magic ### # Set the default editor to "nano -w" ### export patchname="editor1" && queryDatabase if [ $patchinstalled == "false" ]; then grep -vi EDITOR /etc/env.d/00basic > /etc/env.d/00basic.tmp echo "EDITOR=\"nano -w\"" >> /etc/env.d/00basic.tmp mv /etc/env.d/00basic.tmp /etc/env.d/00basic chown root:root /etc/env.d/00basic chmod 644 /etc/env.d/00basic addDatabase fi ### # THIS MUST ALWAYS BE THE LAST THING IN THE INITIALISATION SEQUENCE! # Set the current directory to the user's home directory (i.e. /root) ### cd ~/ ### # Get the MOTD ### rm -rf ~/motd.gentoox $downloading $wget --limit-rate=${limitrate} $gentooxurl/magicscript/motd.gentoox 1> /dev/null 2> /dev/null failCheck download $busy ### # Fix the groups ### export patchname="group1" && queryDatabase if [ $patchinstalled == "false" ]; then usermod -G wheel,users,games,cron gentoox addDatabase fi ### # Get rid of joyd ### export patchname="$joyd" && queryDatabase if [ $patchinstalled == "true" ]; then echo "" echo " Removing JoyD due to extreme buggyness" sleep 5 rc-update del joyd default 1> /dev/null 2> /dev/null rm -rf /etc/conf.d/joyd rm -rf /etc/init.d/joyd rm -rf /etc/joydrc.xbox rm -rf /bin/joyd delDatabase fi ### # Get rid of openMosix ### export patchname="$openmosix" && queryDatabase if [ $patchinstalled == "true" ]; then echo "" echo " Removing openMosix due to extreme buggyness and kernel incompatibility." echo " Please be patient as this can take a while." sleep 5 echo -n " Disabling openMosix.... " export patchname="opendisable1" && delDatabase export patchname="openenable1" && delDatabase export patchname="$openmosix" && delDatabase rc-update del openmosix default 1> /dev/null 2> /dev/null /etc/init.d/openmosix stop 1> /dev/null 2> /dev/null echo "done." echo -n " Removing openMosix source.... " emerge -C sys-kernel/openmosix-sources-2.4.22 1> /dev/null 2> /dev/null emerge -C openmosix-user 1> /dev/null 2> /dev/null echo "done." echo -n " Removing mosixtoggle script.... " rm -rf /bin/mosixtoggle rm -rf /etc/openmosix.map* rm -rf /etc/conf.d/openmosix rm -rf /etc/init.d/openmosix echo "done." sleep 2 delDatabase fi ### # Tell the user that final checks have been done and we're # ready to roll ### $good clear prelaunchComplete ### # Begin the welcome screen! ### clear displayVersion ### # First read any arguments that may have been provided. ### case "$1" in ### # 'newfs'. This allows the user to make more linux storage space. ### newfs) cd ~/ $downloading $wget --limit-rate=${limitrate} $gentooxurl/b0x/newfs.b0x failCheck download $busy sh ~/newfs.b0x ;; uhoh) clear $input echo "This will replace the following files with Gentoox defaults:" echo "" echo "/etc/conf.d/gpm" echo "/etc/conf.d/net" echo "/etc/fstab" echo "/etc/modules.autoload.d/kernel-2.4" echo "/etc/sudoers" echo "/etc/make.conf" echo "(Note: Originals will be backed up with the extention '.uhoh')" echo "" echo -n "Are you sure you want to do this? (y/n): " read uhoh if [ `echo $uhoh | tr A-Z a-z` == "y" ] || [ `echo $uhoh | tr A-Z a-z` == "yes" ]; then $downloading rm -rf /tmp/uhoh* mkdir /tmp/uhoh cd /tmp/uhoh $wget --limit-rate=${limitrate} $gentooxurl/patch-files/uhoh.tbz2 failCheck download $busy tar -jxf /tmp/uhoh/uhoh.tbz2 failCheck decompress ### # Backup originals ### echo -n "Fix gpm? (y/n): " read uhohfix if [ `echo $uhohfix | tr A-Z a-z` == "y" ] || [ `echo $uhohfix | tr A-Z a-z` == "yes" ]; then mv /etc/conf.d/gpm /etc/conf.d/gpm.uhoh mv ./gpm /etc/conf.d/gpm fi echo -n "Fix net? (y/n): " read uhohfix if [ `echo $uhohfix | tr A-Z a-z` == "y" ] || [ `echo $uhohfix | tr A-Z a-z` == "yes" ]; then mv /etc/conf.d/net /etc/conf.d/net.uhoh mv ./net /etc/conf.d/net fi echo -n "Fix fstab? (y/n): " read uhohfix if [ `echo $uhohfix | tr A-Z a-z` == "y" ] || [ `echo $uhohfix | tr A-Z a-z` == "yes" ]; then mv /etc/fstab /etc/fstab.uhoh mv ./fstab /etc/fstab fi echo -n "Fix modules.autoload.d/kernel-2.4? (y/n): " read uhohfix if [ `echo $uhohfix | tr A-Z a-z` == "y" ] || [ `echo $uhohfix | tr A-Z a-z` == "yes" ]; then mv /etc/modules.autoload.d/kernel-2.4 /etc/modules.autoload.d/kernel-2.4.uhoh mv ./kernel-2.4 /etc/modules.autoload.d/kernel-2.4 fi echo -n "Fix sudoers? (y/n): " read uhohfix if [ `echo $uhohfix | tr A-Z a-z` == "y" ] || [ `echo $uhohfix | tr A-Z a-z` == "yes" ]; then mv /etc/sudoers /etc/sudoers.uhoh mv ./sudoers /etc/sudoers fi echo -n "Fix make.conf? (y/n): " read uhohfix if [ `echo $uhohfix | tr A-Z a-z` == "y" ] || [ `echo $uhohfix | tr A-Z a-z` == "yes" ]; then mv /etc/make.conf /etc/make.conf.uhoh mv ./make.conf /etc/make.conf fi chown root:root /etc/conf.d/gpm chown root:root /etc/conf.d/net chown root:root /etc/fstab chown root:root /etc/modules.autoload.d/kernel-2.4 chown root:root /etc/sudoers chown root:root /etc/make.conf chmod 644 /etc/conf.d/gpm chmod 644 /etc/conf.d/net chmod 644 /etc/fstab chmod 644 /etc/modules.autoload.d/kernel-2.4 chmod 440 /etc/sudoers chmod 644 /etc/make.conf clear cd ~/ rm -rf /tmp/uhoh $good export patchname="displaytools" && delDatabase echo -n "Reinstalling displaytools patch" export patchname="$displaytools" && queryDatabase export friendlyname="displaytools" delDatabaseOld dots export filename="displaytools.b0x" doPatch addDatabase xbvsetUpdate ### # Deprecated patch ### export patchname="xbv-patch1" && delDatabase ### # Force displaytools to be run ### export patchname="xbvsetupdate1" && delDatabase $important clear echo -e "\n\n\n xbvset has been updated..." echo -e "" echo " You MUST run xbvset now or your system may not boot" echo " correctly next time. After xbvset has been run, your" echo " Xbox may reset." echo -e "" ding echo -ne " ${greentxt}Press enter to run xbvset...${normaltxt}" read ### # Clean up first ### rm -rf ~/*.b0x rm -rf ~/patches* cleanup clear /bin/xbvset exit else clear echo "Uhoh cancelled" $error exit fi exit ;; ### # update) forces magic to delete the *.magic files in /etc and redownload them # upon next execution ### update) cd /tmp echo "" echo "" echo "" echo " Downloading latest magic script..." $wget --limit-rate=${limitrate} $gentooxurl/magicscript/magic 1> /dev/null 2> /dev/null if [ $? != 0 ]; then clear failCheck download rm -rf /tmp/magic cleanup exit 1 fi mv /tmp/magic /bin/magic chown root:root /bin/magic chmod 755 /bin/magic rm -rf /etc/patches.magic rm -rf /etc/functions.magic magicUpdated /bin/magic exit 0 ;; ### # Begin the huge list of available patches # As you can see, the script checks the database for patches # If it finds them, it highlights them in blue to indicate # that it is installed. These are kept in order of installation ### available) ### # Colour code inserted only once to colour everything ### $busy echo -e "\n\n\n ${redtxt}Patches available:${normaltxt} (${greentxt}Upgrade, ${bluetxt}Downgrade, ${normaltxt}Up-to-date)\n" echo -e " ${normaltxt}/------------------------------------------------------------------\\" echo -e " ${normaltxt}| Patch name\t ${normaltxt}| Available Version \t| Installed version |" echo -e " ${normaltxt}--------------------------------------------------------------------" export patchname="$portage" && queryDatabase && export patchfriendly="portage" && installedCheck export patchname="$joymouse" && queryDatabase && export patchfriendly="joymouse" && installedCheck export patchname="$gpm" && queryDatabase && export patchfriendly="gpm" && installedCheck export patchname="$raincoat" && queryDatabase && export patchfriendly="raincoat" && installedCheck export patchname="$xserver" && queryDatabase && export patchfriendly="xserver" && installedCheck export patchname="$gdm" && queryDatabase && export patchfriendly="gdm" && installedCheck export patchname="$xvkbd" && queryDatabase && export patchfriendly="xvkbd" && installedCheck export patchname="$blink" && queryDatabase && export patchfriendly="blink" && installedCheck export patchname="$xfce" && queryDatabase && export patchfriendly="xfce" && installedCheck export patchname="$mkfsfatx" && queryDatabase && export patchfriendly="mkfsfatx" && installedCheck export patchname="$sudo" && queryDatabase && export patchfriendly="sudo" && installedCheck export patchname="$monitors" && queryDatabase && export patchfriendly="monitors" && installedCheck export patchname="$eject" && queryDatabase && export patchfriendly="eject" && installedCheck export patchname="$libxbox" && queryDatabase && export patchfriendly="libxbox" && installedCheck export patchname="$kernel" && queryDatabase && export patchfriendly="kernel" && installedCheck export patchname="$loader" && queryDatabase && export patchfriendly="loader" && installedCheck export patchname="$displaytools" && queryDatabase && export patchfriendly="displaytools" && installedCheck export patchname="$fstab" && queryDatabase && export patchfriendly="fstab" && installedCheck export patchname="$keyboardtoggle" && queryDatabase && export patchfriendly="keyboardtoggle" && installedCheck ### # End colour code and end of patches! ### echo -e " ${normaltxt}\\------------------------------------------------------------------/\n" $good ;; ### # The fix) command is used to move the system to a "safe" state to # reinstall the selected patch. It is by no means a system for # uninstalling certain patches! When something is fixed, it will be # redownloaded upon the next execution of magic ### fix) $busy if [ "$2" == "keyboardtoggle" ]; then export patchname="$keyboardtoggle" && delDatabase echo "You may now run magic to reinstall keyboardtoggle." $good exit fi if [ "$2" == "fstab" ]; then export patchname="$fstab" && delDatabase echo "You may now run magic to reinstall fstab." $good exit fi if [ "$2" == "gdm" ]; then export patchname="$gdm" && delDatabase export patchname="$displaytools" && delDatabase echo "You may now run magic to reinstall gdm." $good exit fi if [ "$2" == "displaytools" ]; then export patchname="$displaytools" && delDatabase rm -rf /usr/X11R6/lib/modules/extensions/vnc.so* rm -rf /bin/xbvset* rm -rf /etc/nv_drv.o.works rm -rf /etc/XF86Config-* rm -rf /etc/X11/XF86Config echo "You may now run magic to reinstall $2." $good exit fi if [ "$2" == "loader" ]; then echo "Sorry, $2 cannot be fixed." $good exit fi if [ "$2" == "kernel" ]; then export patchname="$kerneldownloaded" && delDatabase export patchname="$kernel" && delDatabase echo "You may now run magic to reinstall $2." $good exit fi if [ "$2" == "libxbox" ]; then export patchname="$libxbox" && delDatabase cd /usr/share rm -rf ./libxbox* rm -rf /usr/local/lib/libxbox* rm -rf /usr/include/libxbox* rm -rf /usr/include/xboxi2c-dev.h echo "You may now run magic to reinstall $2." $good exit fi if [ "$2" == "eject" ]; then export patchname="$eject" && delDatabase rm -rf /bin/eject echo "You may now run magic to reinstall $2." $good exit fi if [ "$2" == "monitors" ]; then export patchname="$monitors" && delDatabase rm -rf /bin/fanctl rm -rf /bin/xboxtemp rm -rf /bin/testi2c rm -rf /bin/loadmonitor rm -rf /etc/conf.d/fanctl rm -rf /etc/init.d/fanctl echo "You may now run magic to reinstall $2." $good exit fi if [ "$2" == "sudo" ]; then export patchname="$sudo" && delDatabase echo "You may now run magic to reinstall $2." $good exit fi if [ "$2" == "mkfsfatx" ]; then export patchname="$mkfsfatx" && delDatabase rm -rf /bin/mkfs.fatx echo "You may now run magic to reinstall $2." $good exit fi if [ "$2" == "raincoat" ]; then export patchname="$raincoat" && delDatabase echo "You may now run magic to reinstall $2." $good exit fi if [ "$2" == "xfce" ]; then export patchname="$xfce" && delDatabase rm -rf /bin/toxfce* rm -rf /home/gentoox/.xfce4 rm -rf /root/.xfce4 rm -rf /etc/skel/.xfce4 sed "s/startxfce4/twm/" /etc/skel/.xinitrc > /tmp/xinitrc && rm -rf /etc/skel/.xinitrc && mv /tmp/xinitrc /etc/skel/.xinitrc && chmod 644 /etc/skel/.xinitrc sed "s/startxfce4/twm/" /home/gentoox/.xinitrc > /tmp/xinitrc && rm -rf /home/gentoox/.xinitrc && mv /tmp/xinitrc /home/gentoox/.xinitrc && chmod 644 /home/gentoox/.xinitrc && chown gentoox:users /home/gentoox/.xinitrc sed "s/startxfce4/twm/" /root/.xinitrc > /tmp/xinitrc && rm -rf /root/.xinitrc && mv /tmp/xinitrc /root/.xinitrc && chmod 644 /root/.xinitrc chmod 755 /home/gentoox/.xinitrc chmod 755 /root/.xinitrc chmod 755 /etc/skel/.xinitrc export patchname="$xfce" echo "You may now run magic to reinstall $2." $good exit fi if [ "$2" == "blink" ]; then export patchname="$blink" && delDatabase rm -rf /bin/randblink rm -rf /bin/blink rm -rf /bin/led echo "You may now run magic to reinstall $2." $good exit fi if [ "$2" == "xvkbd" ]; then ### # This ones quite complex, its first checked that its activated, then # the lines are removed from the .xinitrc files. The only issue with this # is that it does not remember the geometry values, it is therefore # suggested that the user runs xbvset after reinstalling this patch! ### grep -v xvkbd /etc/skel/.xinitrc > /etc/skel/.xinitrcold grep -v xvkbd /home/gentoox/.xinitrc > /home/gentoox/.xinitrcold grep -v xvkbd /root/.xinitrc > /root/.xinitrcold mv /etc/skel/.xinitrcold /etc/skel/.xinitrc mv /home/gentoox/.xinitrcold /home/gentoox/.xinitrc mv /root/.xinitrcold /root/.xinitrc chown gentoox:wheel /home/gentoox/.xinitrc chmod 755 /home/gentoox/.xinitrc chmod 755 /root/.xinitrc chmod 755 /etc/skel/.xinitrc export patchname="$xvkbd" && delDatabase export patchname="noxvkbd1" && delDatabase export patchname="onxvkbd1" && delDatabase echo "You may now run magic to reinstall $2." $good exit fi if [ "$2" == "gpm" ]; then echo "Sorry, $2 cannot be fixed." $good exit fi if [ "$2" == "joymouse" ]; then export patchname="$joymouse" && delDatabase echo "You may now run magic to reinstall $2." $good exit fi if [ "$2" == "xserver" ]; then echo "Sorry, $2 cannot be fixed." $good exit fi if [ "$2" == "portage" ]; then export patchname="$portage" && delDatabase echo "You may now run magic to reinstall $2." $good exit fi echo -e "This patch is either not installed or does not exist.\nPlease check your spelling." exit 1 ;; ### # LED screen - what the led patterns mean! ### leds) if [ ! -f /bin/led ]; then echo "You must install the blink1 patch first - run magic" exit fi clear echo "LED pattern meanings:" sleep 2 echo -e `echo $good | awk '{ print $2 }'` "- All good" $good sleep 5 echo -e `echo $important | awk '{ print $2 }'` "- Important information" $important sleep 5 echo -e `echo $error | awk '{ print $2 }'` "- Error" $error sleep 5 echo -e `echo $downloading | awk '{ print $2 }'` "- Downloading" $downloading sleep 5 echo -e `echo $busy | awk '{ print $2 }'` "- Busy" $busy sleep 5 ;; ### # The usage screen - note that certain items only appear when they are # available and depending on which version of Gentoox you have ### usage) $good echo -e "\n\n\n ${redtxt}Usage${normaltxt}:" echo -e " - To install available patches, run '${redtxt}magic${normaltxt}'" echo -e " - To list available patches, run '${redtxt}magic available${normaltxt}'" echo -e " - To fix a failed patch installation, first run '${redtxt}magic available${normaltxt}'" echo -e " to determine the patch name, then run '${redtxt}magic fix ${bluetxt}patchname${normaltxt}'" echo -e " finally, run '${redtxt}magic${normaltxt}' again to reinstall the patch" echo -e " Some patches cant be automatically fixed, see the website" echo -e " - To make more storage space, run '${redtxt}magic newfs${normaltxt}'" echo -e " - To see LED meanings, run '${redtxt}magic leds${normaltxt}'" echo -e " - To recover vital system files after accidental overwriting with" echo -e " etc-update, run '${redtxt}magic uhoh${normaltxt}'" echo -e " - To force an update of the configuration files, run" echo -e " '${redtxt}magic update${normaltxt}'" echo -e "${normaltxt}" ;; ### # If nothing is entered after "magic" then this default routine is executed # This is the main function of the patch system ### *) $input echo -e "\n\n\n Please answer the following questions (if any) in lowercase:\n" ### # Ask if an emerge --sync is necessary ONLY if the user has already synced # otherwise this is forced ### if [ -f /etc/make.profile/../../make.defaults ]; then echo -en " Do you want to emerge --sync? This is only needed if you have not done\n so in a long time - about a week or two, syncing allows you to install\n the latest stable software. (yes/no): " && read want_sync if [ $want_sync != "yes" ]; then if [ $want_sync != "no" ]; then clear echo "Invalid selection, please try again." exit 1 fi fi else ### # Forced sync here ### export want_sync="yes" fi ### # Want xserver? ### export patchname="$xserver" && queryDatabase if [ $patchinstalled == "false" ]; then ### # This needs to be checked - if Xfree was previously installed, then # automatically upgrade to Xserver. ### export patchname="xfree-patch1" && queryDatabase if [ $patchinstalled == "false" ]; then export patchname="$xserver" && queryDatabase echo -en " Do you want Xserver? (yes/no): " && read want_xserver if [ $want_xserver != "yes" ]; then if [ $want_xserver != "no" ]; then clear echo "Invalid selection, please try again." exit 1 fi fi else want_xserver="yes" fi fi ### # If xserver is already installed, want_xserver is set to no ### export patchname="$xserver" && queryDatabase if [ $patchinstalled == "true" ]; then export want_xserver="no" fi ### # If XFCE is already installed, want_xfce is set to no ### export patchname="$xfce" && queryDatabase if [ $patchinstalled == "false" ]; then export want_xfce="no" fi ### # If xserver is not wanted, xvkbd, kde cannot be installed ### if [ $want_xserver == "no" ]; then export want_xvkbd="no" export want_xfce="no" fi ### # Want xfce? ### export patchname="$xfce" && queryDatabase if [ $patchinstalled == "false" ]; then export patchname="$xserver" && queryDatabase if [ $want_xserver == "yes" ] || [ $patchinstalled == "true" ] ; then echo -en " Do you want XFCE4? (yes/no): " && read want_xfce if [ $want_xfce != "yes" ]; then if [ $want_xfce != "no" ]; then clear echo "Invalid selection, please try again." exit 1 fi fi fi fi ### # Want xvkbd? (If xserver is going to be installed) ### export patchname="$xvkbd" && queryDatabase if [ $patchinstalled == "false" ]; then export patchname="$xserver" && queryDatabase if [ $want_xserver == "yes" ] || [ $patchinstalled == "true" ] ; then echo -en " Do you want XVKBD? (yes/no): " && read want_xvkbd if [ $want_xvkbd != "yes" ]; then if [ $want_xvkbd != "no" ]; then clear echo "Invalid selection, please try again." exit 1 fi fi fi fi $important clear ### # This section echoes back the users choices giving them fair chance to # back out ### if [ $want_sync == "yes" ] && [ -f /etc/make.profile/../../make.defaults ]; then echo -e "\n\n\n sync: ${greentxt}yes${normaltxt}" fi if [ $want_sync == "no" ] && [ -f /etc/make.profile/../../make.defaults ]; then echo -e "\n\n\n sync: ${redtxt}no${normaltxt}" fi if [ $want_sync == "yes" ] && [ ! -f /etc/make.profile/../../make.defaults ]; then echo -e "\n\n\n sync: ${greentxt}FORCED ${redtxt}(You have not synced yet)${normaltxt}" fi export patchname="$xserver" && queryDatabase if [ $patchinstalled == "false" ]; then if [ "$want_xserver" == "yes" ]; then wantColour="${greentxt}" else wantColour="${redtxt}" fi echo -e " xserver: ${wantColour}${want_xserver}${normaltxt}" fi export patchname="$xfce" && queryDatabase if [ $patchinstalled == "false" ]; then if [ "$want_xfce" == "yes" ]; then wantColour="${greentxt}" else wantColour="${redtxt}" fi echo -e " xfce4: ${wantColour}${want_xfce}${normaltxt}" fi export patchname="$xvkbd" && queryDatabase if [ $patchinstalled == "false" ]; then if [ "$want_xvkbd" == "yes" ]; then wantColour="${greentxt}" else wantColour="${redtxt}" fi echo -e " xvkbd: ${wantColour}${want_xvkbd}${normaltxt}" fi echo -e "\n If this is not correct, press Ctrl-C within the next 5 seconds\n" echo -e " After answering all questions this installer should be automated\n so you can leave your xbox and come back to it once its finished!\n" echo -en "${greentxt} " $gggg echo -en "${greentxt}" && echo -n "5 " && sleep 1 && echo -n "4 " && sleep 1 $oooo echo -en "${yellowtxt}3 " && sleep 1 && echo -n "2 " && sleep 1 $rrrr echo -en "${redtxt}1 " && sleep 1 && echo "0" && echo -e "${greentxt} Continuing..." $rxgx sleep 2 echo -en "${normaltxt}" $busy ### # If the user opted to sync, this is where it is done ### if [ $want_sync == "yes" ]; then $busy echo -e "${greentxt} emerge --sync...${normaltxt}\n" emerge --sync failCheck sync $good fi ### # Upgrade portage each time when needed. ### echo -e "${greentxt} Checking for portage update...${normaltxt}" sleep 1 if [ `emerge portage -p | grep ebuild | awk '{ print $2 }' | tail -n 1` = "U" ]; then clear $busy echo "A new version of portage is available, this will be installed now." sleep 5 echo -e "emerge portage...\n" emerge portage failCheck emerge $good fi ### # Fix make.profile... ### if [ `ls -lah /etc/make.profile | awk '{ print $11 }'` != "../usr/portage/profiles/default/linux/x86/2008.0" ]; then echo "Fixing make.profile..." sleep 1 clear echo -n "Old profile detected, updating... " cd /etc/ rm make.profile ln -s ../usr/portage/profiles/default/linux/x86/2008.0 make.profile sleep 1 echo "done." fi ### # This section is where the patches are downloaded and installed - in the # order shown by "magic available" # # IF PATCHES ARE DEPENDENT ON OTHER PATCHES BEING INSTALLED, THE DEPENDENCY # MUST BE CHECKED FIRST OTHERWISE INVALID INFORMATION WILL BE ADDED TO # MAGIC-DATABASE!!!!!! ### # portage patch export patchname="$portage" && queryDatabase export friendlyname="portage" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating Portage overlay" dots export filename="portage.b0x" doPatch addDatabase fi # joymouse patch export patchname="$joymouse" && queryDatabase export friendlyname="joymouse" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating Joymouse" dots export filename="joymouse.b0x" doPatch addDatabase fi # gpm patch export patchname="$gpm" && queryDatabase export friendlyname="gpm" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating GPM" dots export filename="gpm.b0x" doPatch addDatabase fi # raincoat patch export patchname="$raincoat" && queryDatabase export friendlyname="raincoat" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating Raincoat" dots export filename="raincoat.b0x" doPatch addDatabase fi # xserver patch export patchname="$xserver" && queryDatabase export friendlyname="xserver" if [ $patchinstalled == "false" ]; then if [ $want_xserver == "yes" ]; then delDatabaseOld clear echo -n "Updating Xserver" dots export filename="xserver.b0x" doPatch addDatabase xbvsetUpdate export patchname="$displaytools" && delDatabase fi fi # gdm installation export patchname="$xserver" && queryDatabase export friendlyname="gdm" if [ $patchinstalled == "true" ]; then export patchname="$gdm" && queryDatabase if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating GDM" dots export filename="gdm.b0x" doPatch addDatabase xbvsetUpdate fi fi # xvkbd patch export patchname="$xvkbd" && queryDatabase export friendlyname="xvkbd" if [ $patchinstalled == "false" ]; then if [ $want_xvkbd != "no" ]; then delDatabaseOld clear echo -n "Updating XVKBD" dots export filename="xvkbd.b0x" doPatch addDatabase xbvsetUpdate fi fi # blink patch export patchname="$blink" && queryDatabase export friendlyname="blink" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating Blink" dots export filename="blink.b0x" doPatch addDatabase fi # XFCE patch export patchname="$xserver" && queryDatabase export friendlyname="xfce" if [ $patchinstalled == "true" ]; then export patchname="$xfce" && queryDatabase if [ $patchinstalled == "false" ]; then if [ $want_xfce == "yes" ]; then delDatabaseOld clear echo -n "Updating XFCE" dots export filename="xfce.b0x" doPatch addDatabase xbvsetUpdate export patchname="$displaytools" && delDatabase fi fi fi # mkfs.fatx patch export patchname="$mkfsfatx" && queryDatabase export friendlyname="mkfsfatx" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating MKFS.FATX" dots export filename="mkfatx.b0x" doPatch addDatabase fi # sudo patch export patchname="$sudo" && queryDatabase export friendlyname="sudo" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating Sudo" dots export filename="sudo.b0x" doPatch addDatabase fi # monitors patch export patchname="$monitors" && queryDatabase export friendlyname="monitors" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating Monitors" dots export filename="monitors.b0x" doPatch addDatabase fi # eject patch export patchname="$eject" && queryDatabase export friendlyname="eject" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating Eject" dots export filename="eject.b0x" doPatch addDatabase fi # libxbox export patchname="$libxbox" && queryDatabase export friendlyname="libxbox" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating libxbox" dots export filename="libxbox.b0x" doPatch addDatabase fi # Kernel patch export patchname="$kernel" && queryDatabase export friendlyname="kernel" if [ $patchinstalled == "false" ]; then clear delDatabaseOld clear echo -n "Updating Kernel" dots export filename="kernel.b0x" doPatch addDatabase ### # Tell magic a new kernel has been installed ### kernelUpdate export patchname="$displaytools" && delDatabase fi # loader patch export patchname="$loader" && queryDatabase export friendlyname="loader" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating Gentoox Loader" dots export filename="loader.b0x" doPatch addDatabase xbvsetUpdate fi # displaytools patch export patchname="$displaytools" && queryDatabase export friendlyname="displaytools" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating Displaytools" dots export filename="displaytools.b0x" doPatch addDatabase xbvsetUpdate ### # Deprecated patch ### export patchname="xbv-patch1" && delDatabase fi # fstab installation export patchname="$fstab" && queryDatabase export friendlyname="fstab" if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating FSTAB" dots export filename="fstab.b0x" doPatch addDatabase fi # keyboardtoggle installation export patchname="$xserver" && queryDatabase export friendlyname="keyboardtoggle" if [ $patchinstalled == "true" ]; then export patchname="$keyboardtoggle" && queryDatabase if [ $patchinstalled == "false" ]; then delDatabaseOld clear echo -n "Updating Keyboardtoggle" dots export filename="keyboardtoggle.b0x" doPatch addDatabase fi fi export patchname="newportage1" && queryDatabase if [ $patchinstalled == "true" ]; then export patchname="newportage1" && delDatabase $important clear echo -e "\n\n\n Gentoox's Portage overlay has been updated..." echo -e "" echo " You should run 'emerge -Du world' as soon as possible to" echo " update any software in the overlay." echo -e "" ding echo -ne " ${greentxt}Press enter to continue...${normaltxt}" read fi ### # If a new kernel has been installed then this is called to force the user # to reboot - BUT, dont do this if xbvset has been updated. ### export patchname="newkernel1" && queryDatabase if [ $patchinstalled == "true" ]; then export patchname="xbvsetupdate1" && queryDatabase if [ $patchinstalled == "false" ]; then export patchname="newkernel1" && delDatabase $important clear echo -e "\n\n\n You have installed a new kernel..." echo -e "" echo " You MUST reboot to benefit from the changes" echo " If gentoox fails to load after rebooting, delete /e/vmlinuz" echo " and rename /e/oldlinuz to /e/vmlinuz" echo " Finally, when Gentoox boots, run magic fix kernel" echo " Finally, start magic again." echo -e " ${redtxt}ONLY RUN MAGIC FIX KERNEL IF GENTOOX FAILS TO LOAD!${normaltxt}" echo -e "" ding echo -ne " ${greentxt}Press enter to reboot...${normaltxt}" read ### # Clean up first ### export patchname="newkernel1" && delDatabase cleanup reboot exit fi fi ### # If a new kernel has been installed AND xbvset has been updated, this is called ### export patchname="newkernel1" && queryDatabase if [ $patchinstalled == "true" ]; then export patchname="xbvsetupdate1" && queryDatabase if [ $patchinstalled == "true" ]; then ### # First thing to do is delete the database entry that tells magic a new kernel # has been installed so we dont get stuck in a loop each time magic is # executed! Also, the xbvsetupdate entry must be deleted. ### export patchname="newkernel1" && delDatabase export patchname="xbvsetupdate1" && delDatabase $important clear echo -e "\n\n\n You have installed a new kernel..." echo -e " Also xbvset has been updated which must be run before rebooting." echo -e "" echo " You MUST reboot to benefit from the changes" echo " If gentoox fails to load after rebooting, delete /e/vmlinuz" echo " and rename /e/oldlinuz to /e/vmlinuz" echo " Finally, when Gentoox boots, run magic fix kernel" echo " Finally, start magic again." echo -e " ${redtxt}ONLY RUN MAGIC FIX KERNEL IF GENTOOX FAILS TO LOAD!${normaltxt}" echo -e "" ding echo -ne " ${greentxt}Press enter to run xbvset...${normaltxt}" read ### # Clean up first ### clear cleanup /bin/xbvset exit fi fi ### # If xbvset has been updated but NO new kernel has been installed, this is called ### export patchname="newkernel1" && queryDatabase if [ $patchinstalled == "false" ]; then export patchname="xbvsetupdate1" && queryDatabase if [ $patchinstalled == "true" ]; then ### # First thing to do is delete the database entry that tells magic xbvset has been # updated so we dont get stuck in a loop each time magic is executed! ### export patchname="xbvsetupdate1" && delDatabase $important clear echo -e "\n\n\n xbvset has been updated..." echo -e "" echo " You MUST run xbvset now or your system may not boot" echo " correctly next time. After xbvset has been run, your" echo " Xbox may reset." echo -e "" ding echo -ne " ${greentxt}Press enter to run xbvset...${normaltxt}" read ### # Clean up first ### cleanup clear /bin/xbvset exit fi fi ### # Display this if everything finished without needing a reboot. ### clear magicHeader echo -en "${redtxt}" echo -e " ALL DONE " echo -e " GOODBYE! " echo -en "${normaltxt}" echo -e " --------------------------------------------------------------------" echo -e "${bluetxt} NO REBOOT NECESSARY${normaltxt}" magicFooter echo -e "\n\n\n" $good ;; esac