##!/bin/bash --debug #!/bin/bash #FUNCTIONS. ################################################################ #### #### # For testing purposes. #### #### function BUGPAUSE { echo " " echo "-----------------------------------------------------------" echo " MANUAL BUG CHECK!" echo " Is the program doing what you expect? Please " echo " review preceeding output for correctness. Thank you." echo "-----------------------------------------------------------" echo " " ask "Continue? [Y/n]" if [ $? -ne 0 ]; then { exit 100 } fi } #### #### # Error Handler. #### #### function ERROR { clear echo "----------------" echo "| ABEND: Code $1 |" echo "-------------------------------------------------------------------------" echo " Bummer! An error occurred!" echo " Don't you just hate it when..." echo "${2}?" echo "==========================" echo " Maybe this will help...." echo "==========================" SYNTAX ask "Would you like to exit at this point? [y/N]" if [ $? -eq 0 ]; then exit $1 fi } #### #### # Displays syntax, usage information, other comments. #### #### function SYNTAX { echo " " echo "-------------------------------------------------------------------------" echo "This installer needs to be run from /root/bin/." echo "" echo "NOTE:" echo "There is a part of this program for Debian and Debian-like distros " echo "and another for those using RPM-based distributions. Please use ONLY" echo "the approrpiate code." echo " " echo "Much of the code is hard-wired to expect the source files to be in" echo "/root/bin/ since this is likely to be inaccessible to Joe User, and" echo "therefore relatively inviolate. This is a safety feature, since many" echo "of the utilities and programs that make up the KludgeKollection can be" echo "potentially lethal." echo "-------------------------------------------------------------------------" } #### #### # APT_GETTER # Checks to see if the package is already installed. If they are not, # APT_GETTER calls APT_INSTALLER to install the requested package. #### #### function APT_GETTER { clear if ! [ -z /etc/debian_version ]; then #VALIDATE APT SOURCES LIST { ask "Shall I validate your apt sources list first? [Y/n]" if [ $? -eq 0 ]; then { echo "Validating /etc/apt/sources.list." apt-get update } fi clear # MAKE SURE THAT debian_package_list IS IN THE CURRENT DIRECTORY. if ! [ -f ./debian_package_list ]; then ERROR 4 "debian_package_list is not in the current directory" fi # for PACKAGE in `cat ./debian_package_list | cut -d/ -f1`; do # FOR EACH PACKAGE IN debian_package_list DO THIS PROCESS. for PACKAGE in `cat ./debian_package_list`; do { PACK=`echo $PACKAGE | cut -d/ -f1` dpkg -L $PACK > nul if [ $? -eq 0 ]; then { echo "Package $PACKAGE is already installed." } else { echo "Preparing to install package $PACKAGE" ask "Would you like to install $PACKAGE? [Y/n]" if [ $? -eq 0 ]; then { apt-get install $PACKAGE if [ -$? -ne 0 ]; then { ERROR $? "packages like $PACKAGE fail to install" } else { echo "Skipped package $PACKAGE." } fi } fi } fi } done } fi } #### #### # LOCAL_RPM uses INSTALL_PACKAGE to install some locally provided RPMS for # those who wish to use them (and are using RPM-based distros.) #### #### function LOCAL_RPM { echo "We will now install some packages from local storage." if ! [ -f ./rpm_package_list ]; then ERROR 5 "The rpm_package_list file is not in the current directory" fi for i in `cat rpm_package_list`; do { clear echo "Would you like to install the following package?" ask "$i [Y/n]" if [ $? -eq 0 ]; then { rpm -ivh $i } else echo "Package $i was skipped." fi } done } #### #### # VERSION just gives the version number. D'oh! #### #### function VERSION { echo " KludgeKollection Installer/Patcher, Version 10302k3-a" } #### #### # # KLUDGEINSTALL--Installs the KludgeKollection Scripts. # #### #### function KLUDGEINSTALL () { echo "Doing main install of the KludgeKollection." for i in `cat /root/bin/kludgelist`; do { echo "Installing $i in /usr/bin..." chmod 755 $i scp $i /usr/bin } done echo "===========================================================" echo "Installing patched MOSRUN scripts...." echo "===========================================================" echo "New versions of openMosix user utility kits expect to " echo "find mosrun (and mosctl) in /bin, rather than /usr/bin." echo "However, the tools provided in the kits do not always" echo "reflect this change, and erroniously look for " echo "/usr/bin/mosrun and /usr/bin/mosctl." echo " " echo "The KludgeKollection provides a replacement set of scripts," echo "which have been modified to correctly locate the required " echo "programs in /bin." echo " " echo "In addition, a replacement runon is (somewhat pointlessly)" echo "provided for your convenience." echo "============================================================" ask "Do you want to replace the existing copies of these utilities?" n if [ $? -eq 0 ]; then { for i in cpujob iojob runon nomig runhome nodecay slowdecay fastdecay; do { echo "Installing replacement $i..." cp /root/bin/$i /usr/bin cp /root/bin/$i /bin } done } else { for i in cpujob iojob runon nomig runhome nodecay slowdecay fastdecay; do rm /usr/bin/$i done echo "No replacements were made. The original versions remain in /bin." } fi } ########################## End Functions ###################### ############################################################### ########################## MAIN ############################### ############################################################### echo "========================================================" VERSION echo " KLUDGEKOLLECTION openMosix Utilities Installer Script " echo " For RedHat 7.x +, Mandrake 9.1, and ClusterKNOPPIX 3.3" echo " September 24, 2003 release. Should also work with " echo " standard Debian installs (though I've not yet tried it)" echo "=======================================================" if ! [ -d /root/bin ]; then mkdir -p /root/bin/ fi if [ ! -z $1 ]; then { VERSION exit 0 } fi for i in newscript newscript_template; do echo "Locking down $i...." chmod 555 /usr/bin/$i done echo "Locking down the SNAPBACK Backup utility." chmod 744 /usr/bin/snapback chmod 644 /usr/bin/backup_exclude chmod 644 /usr/bin/snapback_hostkey # BASIC UTILITIES--the core KludgeKollection. KLUDGEINSTALL ln -s /usr/bin/vncviewer /usr/bin/vnc echo " " echo "Installing some Samba stuff" scp /root/bin/smbadduser /usr/bin/smbadduser echo " " echo "Installing setistart.sh" scp /root/bin/setistart.sh /usr/bin/setistart echo "Configuring SSSH (from Linux Server Hacks (Rob Flickenger/O'Reilly))" ask "Is /usr/bin/do_ssh_hosts updated to reflect the hosts on *YOUR* network?" if [ $? -eq 0 ]; then for i in `cat do_ssh_hosts`; do ln -s /usr/bin/sssh /usr/bin/$i if [ $? -ne 0 ]; then ERROR 102 "we fail to create a symlink for $i" else echo "$i link created." fi done else echo "Edit do_ssh_hosts to list the hosts on your network" echo "Then, execute a command similar to the following" echo 'for i in `cat do_ssh_hosts`; do ln -s /usr/bin/sssh /usr/bin/$i; done' fi # KERNEL SOURCE PACKAGE echo "=============================================================" echo "Shall we install the openMosix kernel sources" echo "so you can roll your own kernel?" echo "NOTE: The Kernel source is quite large, so it is not included " echo "with the KludgeKollection or the KludgeKlump tarball." echo "You should download the current version from " echo "Wim Vandermissen's site, www.bofh.be/clusterknoppix. and " echo "place it in /root/bin along with this install program." echo "You will then need to edit the following dpkg command to " echo "reflect the proper filename." echo " " ask "--->Is the Kernel source file locally placed and ready to install?" if [ $? -ne 0 ]; then echo "Aborting Kernel Source install at your request." else dpkg -i kernel-source-2.4.22-openmosix-1_10.00.Custom_all.deb echo " " echo "Remember: These 'install' a .tar.bz2 file in /usr/src." echo "We recommend moving this tar-ball to your home directory and" echo "unpacking/decompressing it there, and then doing all your " echo "kernel voodoo there, rather than in /usr/src, where there are" echo "'usually incomplete' header libraries that might result in the" echo "compilation of a corrupt kernel." fi # USER PACKAGES for DEBIAN or RPM ask "Is this a DEBIAN-based distro?" if [ $? -eq 0 ]; then { echo "Running package installations for DEBIAN." APT_GETTER } else { ask "Is this an RPM-based distro such as RedHat, SuSE or Mandrake?" if [ $? -eq 0 ]; then { echo "Running package installations for RPM-based distros." LOCAL_RPM } else { echo "Sorry. This installer doesn't support Windows!" echo "Just kidding. Didn't mean to insult you, buddy." echo "Seriously, though, this installer only works with" echo "DEBIAN-based distros and RPM-based distros." echo " " echo "So no packages were installed." } fi } fi #PATCHING/FIXING (Mostly for hd-install of ClusterKNOPPIX and Debian.) echo "--------------------------------" echo "Removing some spurious symlinks." echo "--------------------------------" rm /usr/share/man/man1/ctags1.gz rm /usr/share/man/man1/emacs.1.gz rm /usr/share/man/man1/etags.1.gz echo "------------------------------------------------" echo " Adding /mfs directory so we can use oMFS/DFSA." echo "------------------------------------------------" if ! [ -d /mnt/o/mfs ]; then mkdir -p /mnt/o/mfs if [ $? -eq 0 ]; then ln -s /mnt/o/mfs /mfs echo 'Made /mfs directory for oMFS/DFSA.' echo 'Also made /mfs symlink for /mnt/o/mfs so it appears that' else ERROR 103 "when we can't make /mnt/o/mfs" fi else echo '/mfs directory exists already.' fi cat /etc/fstab >hosts.unties clear echo " " echo "============================================================" echo "Installing slightly patched openmosix script in /etc/init.d." echo "============================================================" echo "The stock version of /etc/init.d/openmosix does _NOT_ check " echo "for root privileges before attempting to start. Indeed, it " echo "will appear to run correctly when run by someone other than " echo "root, but, in actuality, openMosix does NOT get started. " echo "Obviously, this can lead to problems, so I've added a small " echo "patch to the stock script (as supplied with ClusterKNOPPIX " echo "version 3.3, Sept 24, 2003 release), and presumably as " echo "supplied generally with the current version of openMosix." echo "The patch is a simple test that uses the \"id\" command to " echo "check that the user running /etc/init.d/openmosix is really" echo "root. If the user is NOT, openMosix will abort with an" echo "appropriate error message. Otherwise, it starts normally." echo " " ask "Would you like to install this patched version of openMosix?" if [ $? -eq 0 ]; then { scp /root/bin/openmosix /etc/init.d/openmosix echo "Patched version of openmosix script has been installed." } else { echo "Installation aborted at your request." } fi echo "=============================" echo "END KludgeKollection Install." echo "============================="