--- trunk/freespace2/fs2-open-installer.sh 2007/01/15 22:29:02 94 +++ trunk/freespace2/fs2-open-installer.sh 2007/01/17 00:23:25 96 @@ -1,23 +1,55 @@ #!/bin/bash -# $Header: /root/magellan-cvs/src/freespace2/fs2-open-installer.sh,v 1.1 2007-01-15 22:29:01 niro Exp $ +# $Header: /root/magellan-cvs/src/freespace2/fs2-open-installer.sh,v 1.2 2007-01-17 00:23:25 niro Exp $ # Freespace2 retail files installer +# some default vars +DATADIR=/usr/games/freespace2 +CDROM="$1" + +COLRED="\033[1;6m\033[31m" +COLGREEN="\033[1;6m\033[32m" +COLDEFAULT="\033[0m" + +if [[ ${NOCOLORS} = true ]] +then + COLRED="" + COLGREEN="" + COLDEFAULT="" +fi + +is_mounted() { + local dev=$1 + local i + + i=$(cat /proc/mounts | grep "${dev} " | cut -d ' ' -f1) + [[ ${i} != ${dev} ]] && return 1 + + return 0 +} + die() { - echo "Error: $@" + echo -e ${COLRED}"Error: $@"${COLDEFAULT} + + # clean up + is_mounted ${CDROM} && umount ${CDROM} + sleep 2 + [[ -d ${TMP} ]] && rm -rf ${TMP} + exit 1 } -DATADIR=/usr/games/freespace2 -CDROM="$1" +cecho() +{ + echo -e ${COLGREEN}"$@"${COLDEFAULT} +} [[ $(id -u) != 0 ]] && die "You must be root!" [[ -f ${DATADIR}/.installed ]] && die "Media files already installed." [[ -z $(which unshield) ]] && die "unshield not found." [[ -z $(which mktemp) ]] && die "mktemp not found." [[ -z $(which eject) ]] && die "eject not found." -#[[ -z $(which dialog) ]] && die "dialog not found." -[[ -z ${CDROM} ]] && "No cdrom device given." +[[ -z ${CDROM} ]] && die "No cdrom device given." TMP="$(mktemp -d)" @@ -26,35 +58,48 @@ install -d ${TMP}/data install -d ${TMP}/retailvp -echo "To setup Freespace2 I need to copy several files from the original CDs." +cecho "To setup Freespace2 I need to copy several files from the original CDs." echo #### disc1 #### -echo "Please insert Disc1 of Freespace2 into your cdrom and press enter" +eject ${CDROM} +cecho "Please insert disc1 of Freespace2 into your cdrom and press enter" read +eject -t ${CDROM} mount ${CDROM} ${TMP}/cdrom || die "mount disc1" -[[ ! -f ${TMP}/cdrom/data1.cab ]] && "Disc1 not found" +[[ ! -f ${TMP}/cdrom/data1.cab ]] && die "disc1 not found" + +cecho "Now extracting retail files from data1.cab ..." +pushd ${TMP} +for group in "Basic Install Files" \ + "Intel Anims" \ + "Music Compressed" \ + "High Res Files" +do + unshield -d ./retailvp -g "${group}" -L -j x ${TMP}/cdrom/data1.cab || die "unpacking '${group}'" +done +unshield -d ./ -g "Hud Config Files" -L -j x ${TMP}/cdrom/data1.cab || die "unpacking ${group}" +popd -echo "Copying data1.cab and data1.hdr to ${TMP}/data" -cp ${TMP}/cdrom/data1.{cab,hdr} ${TMP}/data || die "copying data1.cab/hdr" umount ${TMP}/cdrom || die "umount disc1 failed" eject ${CDROM} #### disc2 #### echo -echo "Please insert Disc2 of Freespace2 into your cdrom and press enter" +cecho "Please insert disc2 of Freespace2 into your cdrom and press enter" read +eject -t ${CDROM} mount ${CDROM} ${TMP}/cdrom || die "mount disc2" -[[ ! -f ${TMP}/cdrom/data2.cab ]] && "Disc2 not found" +[[ ! -f ${TMP}/cdrom/data2.cab ]] && die "disc2 not found" for i in tango1_fs2.vp COLOSSUS.MVE INTRO.MVE MONO1.MVE do - echo "Copying ${i} to ${TMP}/data" + cecho "Copying ${i} to ${TMP}/data" # lower case needed! - cp ${i} ${TMP}/data/$(echo $i | tr [:upper:] [:lower:]) || die "copying ${i}" + cp -vg ${TMP}/cdrom/${i} ${TMP}/data/$(echo $i | tr [:upper:] [:lower:]) || die "copying ${i}" done umount ${TMP}/cdrom || die "umount disc2 failed" eject ${CDROM} @@ -62,47 +107,36 @@ #### disc3 #### echo -echo "Please insert Disc3 of Freespace2 into your cdrom and press enter" +cecho "Please insert disc3 of Freespace2 into your cdrom and press enter" read +eject -t ${CDROM} mount ${CDROM} ${TMP}/cdrom || die "mount disc3" -[[ ! -f ${TMP}/cdrom/data3.cab ]] && "Disc3 not found" +[[ ! -f ${TMP}/cdrom/data3.cab ]] && die "disc3 not found" for i in tango2_fs2.vp tango3_fs2.vp BASTION.MVE ENDPART1.MVE \ ENDPRT2A.MVE ENDPRT2B.MVE MONO2.MVE MONO3.MVE MONO4.MVE do - echo "Copying ${i} to ${TMP}/data" + cecho "Copying ${i} to ${TMP}/data" # lower case needed! - cp ${i} ${TMP}/data/$(echo $i | tr [:upper:] [:lower:]) || die "copying ${i}" + cp -vg ${TMP}/cdrom/${i} ${TMP}/data/$(echo $i | tr [:upper:] [:lower:]) || die "copying ${i}" done umount ${TMP}/cdrom || die "umount disc3 failed" eject ${CDROM} -echo -echo "Now extracting files from retail version ..." - -for group in "Basic Install Files" \ - "Intel Anims" \ - "Music Compressed" \ - "High Res Files" -do - unshield -d ${TMP}/retailvp -g "$group" -L -j x data1.cab || die "unpacking ${group}" -done -unshield -d ${TMP} -g "Hud Config Files" -L -j x data1.cab || die "unpacking ${group}" - - -echo "Installing Retail Freespace2 files to the system ..." -install -m0644 ${TMP}/hud_config_files/* ${DATADIR}/data/players || die "installing HUD" -install -m0644 ${TMP}/retailvp/*/* ${DATADIR}/data/players || die "installing retailvps1" -install -m0644 ${TMP}/data/*.vp ${DATADIR} || die "installing retailvps2" -install -m0644 ${TMP}/data/*.mve ${DATADIR}/data/movies || die "installing movies" +cecho "Installing Retail Freespace2 files to the system ..." +install -v -m0644 ${TMP}/hud_config_files/* ${DATADIR}/data/players || die "installing HUD" +install -v -m0644 ${TMP}/retailvp/*/* ${DATADIR}/data/players || die "installing retailvps1" +install -v -m0644 ${TMP}/data/*.vp ${DATADIR} || die "installing retailvps2" +install -v -m0644 ${TMP}/data/*.mve ${DATADIR}/data/movies || die "installing movies" # mark installation as "installed" touch ${DATADIR}/.installed -echo "Cleaning up temp dirs ..." +cecho "Cleaning up temp dirs ..." [[ -d ${TMP} ]] && rm -rf ${TMP} -echo "Installation of Freespace2 successfully finished!" +cecho "Installation of Freespace2 successfully finished!" +exit 0