1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $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 $ |
3 |
# Freespace2 retail files installer |
# Freespace2 retail files installer |
4 |
|
|
5 |
|
# 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 |
die() |
die() |
31 |
{ |
{ |
32 |
echo "Error: $@" |
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 |
exit 1 |
exit 1 |
40 |
} |
} |
41 |
|
|
42 |
DATADIR=/usr/games/freespace2 |
cecho() |
43 |
CDROM="$1" |
{ |
44 |
|
echo -e ${COLGREEN}"$@"${COLDEFAULT} |
45 |
|
} |
46 |
|
|
47 |
[[ $(id -u) != 0 ]] && die "You must be root!" |
[[ $(id -u) != 0 ]] && die "You must be root!" |
48 |
[[ -f ${DATADIR}/.installed ]] && die "Media files already installed." |
[[ -f ${DATADIR}/.installed ]] && die "Media files already installed." |
49 |
[[ -z $(which unshield) ]] && die "unshield not found." |
[[ -z $(which unshield) ]] && die "unshield not found." |
50 |
[[ -z $(which mktemp) ]] && die "mktemp not found." |
[[ -z $(which mktemp) ]] && die "mktemp not found." |
51 |
[[ -z $(which eject) ]] && die "eject not found." |
[[ -z $(which eject) ]] && die "eject not found." |
52 |
#[[ -z $(which dialog) ]] && die "dialog not found." |
[[ -z ${CDROM} ]] && die "No cdrom device given." |
|
[[ -z ${CDROM} ]] && "No cdrom device given." |
|
53 |
|
|
54 |
TMP="$(mktemp -d)" |
TMP="$(mktemp -d)" |
55 |
|
|
58 |
install -d ${TMP}/data |
install -d ${TMP}/data |
59 |
install -d ${TMP}/retailvp |
install -d ${TMP}/retailvp |
60 |
|
|
61 |
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." |
62 |
echo |
echo |
63 |
|
|
64 |
#### disc1 #### |
#### disc1 #### |
65 |
echo "Please insert Disc1 of Freespace2 into your cdrom and press enter" |
eject ${CDROM} |
66 |
|
cecho "Please insert disc1 of Freespace2 into your cdrom and press enter" |
67 |
read |
read |
68 |
|
eject -t ${CDROM} |
69 |
|
|
70 |
mount ${CDROM} ${TMP}/cdrom || die "mount disc1" |
mount ${CDROM} ${TMP}/cdrom || die "mount disc1" |
71 |
[[ ! -f ${TMP}/cdrom/data1.cab ]] && "Disc1 not found" |
[[ ! -f ${TMP}/cdrom/data1.cab ]] && die "disc1 not found" |
72 |
|
|
73 |
|
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 |
|
|
|
echo "Copying data1.cab and data1.hdr to ${TMP}/data" |
|
|
cp ${TMP}/cdrom/data1.{cab,hdr} ${TMP}/data || die "copying data1.cab/hdr" |
|
85 |
umount ${TMP}/cdrom || die "umount disc1 failed" |
umount ${TMP}/cdrom || die "umount disc1 failed" |
86 |
eject ${CDROM} |
eject ${CDROM} |
87 |
|
|
88 |
|
|
89 |
#### disc2 #### |
#### disc2 #### |
90 |
echo |
echo |
91 |
echo "Please insert Disc2 of Freespace2 into your cdrom and press enter" |
cecho "Please insert disc2 of Freespace2 into your cdrom and press enter" |
92 |
read |
read |
93 |
|
eject -t ${CDROM} |
94 |
|
|
95 |
mount ${CDROM} ${TMP}/cdrom || die "mount disc2" |
mount ${CDROM} ${TMP}/cdrom || die "mount disc2" |
96 |
[[ ! -f ${TMP}/cdrom/data2.cab ]] && "Disc2 not found" |
[[ ! -f ${TMP}/cdrom/data2.cab ]] && die "disc2 not found" |
97 |
|
|
98 |
for i in tango1_fs2.vp COLOSSUS.MVE INTRO.MVE MONO1.MVE |
for i in tango1_fs2.vp COLOSSUS.MVE INTRO.MVE MONO1.MVE |
99 |
do |
do |
100 |
echo "Copying ${i} to ${TMP}/data" |
cecho "Copying ${i} to ${TMP}/data" |
101 |
# lower case needed! |
# lower case needed! |
102 |
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}" |
103 |
done |
done |
104 |
umount ${TMP}/cdrom || die "umount disc2 failed" |
umount ${TMP}/cdrom || die "umount disc2 failed" |
105 |
eject ${CDROM} |
eject ${CDROM} |
107 |
|
|
108 |
#### disc3 #### |
#### disc3 #### |
109 |
echo |
echo |
110 |
echo "Please insert Disc3 of Freespace2 into your cdrom and press enter" |
cecho "Please insert disc3 of Freespace2 into your cdrom and press enter" |
111 |
read |
read |
112 |
|
eject -t ${CDROM} |
113 |
|
|
114 |
mount ${CDROM} ${TMP}/cdrom || die "mount disc3" |
mount ${CDROM} ${TMP}/cdrom || die "mount disc3" |
115 |
[[ ! -f ${TMP}/cdrom/data3.cab ]] && "Disc3 not found" |
[[ ! -f ${TMP}/cdrom/data3.cab ]] && die "disc3 not found" |
116 |
|
|
117 |
|
|
118 |
for i in tango2_fs2.vp tango3_fs2.vp BASTION.MVE ENDPART1.MVE \ |
for i in tango2_fs2.vp tango3_fs2.vp BASTION.MVE ENDPART1.MVE \ |
119 |
ENDPRT2A.MVE ENDPRT2B.MVE MONO2.MVE MONO3.MVE MONO4.MVE |
ENDPRT2A.MVE ENDPRT2B.MVE MONO2.MVE MONO3.MVE MONO4.MVE |
120 |
do |
do |
121 |
echo "Copying ${i} to ${TMP}/data" |
cecho "Copying ${i} to ${TMP}/data" |
122 |
# lower case needed! |
# lower case needed! |
123 |
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}" |
124 |
done |
done |
125 |
umount ${TMP}/cdrom || die "umount disc3 failed" |
umount ${TMP}/cdrom || die "umount disc3 failed" |
126 |
eject ${CDROM} |
eject ${CDROM} |
127 |
|
|
128 |
|
|
129 |
echo |
cecho "Installing Retail Freespace2 files to the system ..." |
130 |
echo "Now extracting files from retail version ..." |
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 |
for group in "Basic Install Files" \ |
install -v -m0644 ${TMP}/data/*.vp ${DATADIR} || die "installing retailvps2" |
133 |
"Intel Anims" \ |
install -v -m0644 ${TMP}/data/*.mve ${DATADIR}/data/movies || die "installing movies" |
|
"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" |
|
134 |
|
|
135 |
# mark installation as "installed" |
# mark installation as "installed" |
136 |
touch ${DATADIR}/.installed |
touch ${DATADIR}/.installed |
137 |
|
|
138 |
echo "Cleaning up temp dirs ..." |
cecho "Cleaning up temp dirs ..." |
139 |
[[ -d ${TMP} ]] && rm -rf ${TMP} |
[[ -d ${TMP} ]] && rm -rf ${TMP} |
140 |
|
|
141 |
echo "Installation of Freespace2 successfully finished!" |
cecho "Installation of Freespace2 successfully finished!" |
142 |
|
exit 0 |