home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
-
- # Autorun script. Will be launched by most Linux systems
- # when CD is inserted. System can launch it immediately
- # or ask whether to launch it, depending on configuration
-
- # Runs main install script in a new Xterm window if this
- # Sybex course was not installed before
-
-
- # CompareCourses function - compares two courses lines.
- # Returns 0 if all the courses names in the second line
- # are present in the first line
- # Arguments:
- # $1 - courses line to be compared to
- # (must be quoted to be passed as one argument)
- # $2 - thrown away using shift - usually key part of .ini file string
- # All remaining arguments (usually value part of .ini file string)
- # treated as course names and must be separated by spaces or tabs
- CompareCourses()
- {
- # Keep first string
- COMPARE_TO="$1";
-
- # Throw away not-course arguments
- shift;
- shift;
-
- for i in "$@"
- do
- case "$COMPARE_TO" in
- *"$i"*)
- # already installed course name found in the first string
- ;;
- *)
- # new course name - not found in the first string
- # must be installed
- return 1;
- ;;
- esac
- done
-
- # no new courses
- return 0;
- }
-
- #
- # Main script start
- #
-
- # Change current directory to CD
- SRCPATH=`dirname "$0"`;
-
- cd "$SRCPATH";
-
- case `uname -s` in
- Linux)
- # Linux autorun script
- ;;
- *)
- # No known autorun on Solaris
- # Anyway, will not work on Solaris -
- # variables will not be kept outside .ini file reading cycles
- echo "Sorry, only Linux autorun supported.";
- exit 1;
- ;;
- esac
-
- if [ -s "$HOME/Sybex/sybex.jar" ] ; then
- if [ -s "$HOME/Sybex/edugen.ini" ] ; then
- # Proper previous installation found
- # Check whether this course is installed
-
- CD_COURSES="NONE";
- while read LINE
- do
- case $LINE in
- "name="*)
- # Courses on this CD - from disk.ini
- CD_COURSES="$LINE";
- break;
- ;;
- esac
- done < "$SRCPATH/disk.ini"
-
- if [ "$CD_COURSES" = "NONE" ] ; then
- # corrupted disk.ini - nothing to install
- exit 1;
- fi
-
- INSTALLED="NONE";
- while read LINE
- do
- case $LINE in
- "installed="*)
- # installed courses from edugen.ini
- INSTALLED="$LINE";
- break;
- ;;
- esac
- done < "$HOME/Sybex/edugen.ini"
-
- if [ "$INSTALLED" = "NONE" ] ; then
- # corrupted installation - reinstall
- xterm -e "./install.sh";
- exit 0;
- fi
-
-
- # make each course a separate argument by replacing
- # .ini file symbols (=,) and DOS/WINDOWS carriage returns
- # by spaces
- CD_COURSES=`echo "$CD_COURSES" | tr ",=\015" ' '`;
-
- if CompareCourses "$INSTALLED" $CD_COURSES; then
- # all courses on this CD are already installed
- exit 1;
- fi
- fi
- fi
-
- # THis Sybex course was not properly installed before - run installation
- xterm -e "./install.sh";
-
- exit 0;