Annotation of /trunk/freespace2/fs2-open-installer.sh
Parent Directory | Revision Log
Revision 96 -
(hide annotations)
(download)
(as text)
Wed Jan 17 00:23:25 2007 UTC (17 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 3634 byte(s)
Wed Jan 17 00:23:25 2007 UTC (17 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 3634 byte(s)
several fixes; first running release
1 | niro | 94 | #!/bin/bash |
2 | niro | 96 | # $Header: /root/magellan-cvs/src/freespace2/fs2-open-installer.sh,v 1.2 2007-01-17 00:23:25 niro Exp $ |
3 | niro | 94 | # Freespace2 retail files installer |
4 | |||
5 | niro | 96 | # some default vars |
6 | DATADIR=/usr/games/freespace2 | ||
7 | CDROM="$1" | ||
8 | |||
9 | COLRED="\033[1;6m\033[31m" | ||
10 | COLGREEN="\033[1;6m\033[32m" | ||
11 | COLDEFAULT="\033[0m" | ||
12 | |||
13 | if [[ ${NOCOLORS} = true ]] | ||
14 | then | ||
15 | COLRED="" | ||
16 | COLGREEN="" | ||
17 | COLDEFAULT="" | ||
18 | fi | ||
19 | |||
20 | is_mounted() { | ||
21 | local dev=$1 | ||
22 | local i | ||
23 | |||
24 | i=$(cat /proc/mounts | grep "${dev} " | cut -d ' ' -f1) | ||
25 | [[ ${i} != ${dev} ]] && return 1 | ||
26 | |||
27 | return 0 | ||
28 | } | ||
29 | |||
30 | niro | 94 | die() |
31 | { | ||
32 | niro | 96 | echo -e ${COLRED}"Error: $@"${COLDEFAULT} |
33 | |||
34 | # clean up | ||
35 | is_mounted ${CDROM} && umount ${CDROM} | ||
36 | sleep 2 | ||
37 | [[ -d ${TMP} ]] && rm -rf ${TMP} | ||
38 | |||
39 | niro | 94 | exit 1 |
40 | } | ||
41 | |||
42 | niro | 96 | cecho() |
43 | { | ||
44 | echo -e ${COLGREEN}"$@"${COLDEFAULT} | ||
45 | } | ||
46 | niro | 94 | |
47 | [[ $(id -u) != 0 ]] && die "You must be root!" | ||
48 | [[ -f ${DATADIR}/.installed ]] && die "Media files already installed." | ||
49 | [[ -z $(which unshield) ]] && die "unshield not found." | ||
50 | [[ -z $(which mktemp) ]] && die "mktemp not found." | ||
51 | [[ -z $(which eject) ]] && die "eject not found." | ||
52 | niro | 96 | [[ -z ${CDROM} ]] && die "No cdrom device given." |
53 | niro | 94 | |
54 | TMP="$(mktemp -d)" | ||
55 | |||
56 | # some needed directories | ||
57 | install -d ${TMP}/cdrom | ||
58 | install -d ${TMP}/data | ||
59 | install -d ${TMP}/retailvp | ||
60 | |||
61 | niro | 96 | cecho "To setup Freespace2 I need to copy several files from the original CDs." |
62 | niro | 94 | echo |
63 | |||
64 | #### disc1 #### | ||
65 | niro | 96 | eject ${CDROM} |
66 | cecho "Please insert disc1 of Freespace2 into your cdrom and press enter" | ||
67 | niro | 94 | read |
68 | niro | 96 | eject -t ${CDROM} |
69 | niro | 94 | |
70 | mount ${CDROM} ${TMP}/cdrom || die "mount disc1" | ||
71 | niro | 96 | [[ ! -f ${TMP}/cdrom/data1.cab ]] && die "disc1 not found" |
72 | niro | 94 | |
73 | niro | 96 | cecho "Now extracting retail files from data1.cab ..." |
74 | pushd ${TMP} | ||
75 | for group in "Basic Install Files" \ | ||
76 | "Intel Anims" \ | ||
77 | "Music Compressed" \ | ||
78 | "High Res Files" | ||
79 | do | ||
80 | unshield -d ./retailvp -g "${group}" -L -j x ${TMP}/cdrom/data1.cab || die "unpacking '${group}'" | ||
81 | done | ||
82 | unshield -d ./ -g "Hud Config Files" -L -j x ${TMP}/cdrom/data1.cab || die "unpacking ${group}" | ||
83 | popd | ||
84 | |||
85 | niro | 94 | umount ${TMP}/cdrom || die "umount disc1 failed" |
86 | eject ${CDROM} | ||
87 | |||
88 | |||
89 | #### disc2 #### | ||
90 | echo | ||
91 | niro | 96 | cecho "Please insert disc2 of Freespace2 into your cdrom and press enter" |
92 | niro | 94 | read |
93 | niro | 96 | eject -t ${CDROM} |
94 | niro | 94 | |
95 | mount ${CDROM} ${TMP}/cdrom || die "mount disc2" | ||
96 | niro | 96 | [[ ! -f ${TMP}/cdrom/data2.cab ]] && die "disc2 not found" |
97 | niro | 94 | |
98 | for i in tango1_fs2.vp COLOSSUS.MVE INTRO.MVE MONO1.MVE | ||
99 | do | ||
100 | niro | 96 | cecho "Copying ${i} to ${TMP}/data" |
101 | niro | 94 | # lower case needed! |
102 | niro | 96 | cp -vg ${TMP}/cdrom/${i} ${TMP}/data/$(echo $i | tr [:upper:] [:lower:]) || die "copying ${i}" |
103 | niro | 94 | done |
104 | umount ${TMP}/cdrom || die "umount disc2 failed" | ||
105 | eject ${CDROM} | ||
106 | |||
107 | |||
108 | #### disc3 #### | ||
109 | echo | ||
110 | niro | 96 | cecho "Please insert disc3 of Freespace2 into your cdrom and press enter" |
111 | niro | 94 | read |
112 | niro | 96 | eject -t ${CDROM} |
113 | niro | 94 | |
114 | mount ${CDROM} ${TMP}/cdrom || die "mount disc3" | ||
115 | niro | 96 | [[ ! -f ${TMP}/cdrom/data3.cab ]] && die "disc3 not found" |
116 | niro | 94 | |
117 | |||
118 | for i in tango2_fs2.vp tango3_fs2.vp BASTION.MVE ENDPART1.MVE \ | ||
119 | ENDPRT2A.MVE ENDPRT2B.MVE MONO2.MVE MONO3.MVE MONO4.MVE | ||
120 | do | ||
121 | niro | 96 | cecho "Copying ${i} to ${TMP}/data" |
122 | niro | 94 | # lower case needed! |
123 | niro | 96 | cp -vg ${TMP}/cdrom/${i} ${TMP}/data/$(echo $i | tr [:upper:] [:lower:]) || die "copying ${i}" |
124 | niro | 94 | done |
125 | umount ${TMP}/cdrom || die "umount disc3 failed" | ||
126 | eject ${CDROM} | ||
127 | |||
128 | |||
129 | niro | 96 | cecho "Installing Retail Freespace2 files to the system ..." |
130 | install -v -m0644 ${TMP}/hud_config_files/* ${DATADIR}/data/players || die "installing HUD" | ||
131 | install -v -m0644 ${TMP}/retailvp/*/* ${DATADIR}/data/players || die "installing retailvps1" | ||
132 | install -v -m0644 ${TMP}/data/*.vp ${DATADIR} || die "installing retailvps2" | ||
133 | install -v -m0644 ${TMP}/data/*.mve ${DATADIR}/data/movies || die "installing movies" | ||
134 | niro | 94 | |
135 | # mark installation as "installed" | ||
136 | touch ${DATADIR}/.installed | ||
137 | |||
138 | niro | 96 | cecho "Cleaning up temp dirs ..." |
139 | niro | 94 | [[ -d ${TMP} ]] && rm -rf ${TMP} |
140 | |||
141 | niro | 96 | cecho "Installation of Freespace2 successfully finished!" |
142 | exit 0 |