Skip to content

Commit 3ae7cda

Browse files
committed
install_from_cd.sh: Add CD audio ripping functionality
1 parent 4f8c9ff commit 3ae7cda

File tree

1 file changed

+54
-13
lines changed

1 file changed

+54
-13
lines changed

install_from_cd.sh

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ mk_pk3()
1414
# grabs a patch .zip from archive.org and saves it as a pk3
1515
grab_patch()
1616
{
17-
wget -nc -O ./pak$2.pk3 http://archive.org/download/hl_shareware_data/valve/$1.zip
17+
wget -nc -O ./pak$2.pk4 http://archive.org/download/hl_shareware_data/valve/$1.zip
1818
}
1919

2020
SCRPATH="$( cd "$( dirname $(readlink -nf $0) )" && pwd )"
@@ -42,18 +42,22 @@ if ! [ -f "$CDROM_PATH"/data1.cab ]; then
4242
exit 1
4343
fi
4444

45-
# Grab the cabinet data off the CD
46-
mkdir -p ./tmp
47-
unshield -d ./tmp x "$CDROM_PATH"/data1.cab
48-
49-
# Let's shove them all into a convenient .pk3dir
50-
mkdir -p ./$OUTPK3DIR
51-
mv -v ./tmp/Half-Life_PAK_File/valve/pak0.pak ./pak00_cd.pak
52-
rsync -av ./tmp/Half-Life_Program_Files/valve/ ./$OUTPK3DIR/
53-
mv -v ./tmp/Half-Life_Program_Files/media ./$OUTPK3DIR/media
54-
mv -v ./tmp/Half-Life_Program_Files/logos ./$OUTPK3DIR/logos
55-
cd ./$OUTPK3DIR
56-
mk_pk3 pak01_cd
45+
# Check if we need to do anything
46+
if ! [ -f "$SCRPATH/pak00_cd.pak" ] || ! [ -f "$SCRPATH/pak01_cd.pk3" ]; then
47+
# Grab the cabinet data off the CD
48+
mkdir -p ./tmp
49+
unshield -d ./tmp x "$CDROM_PATH"/data1.cab
50+
51+
# Let's shove them all into a convenient .pk3dir
52+
mkdir -p ./$OUTPK3DIR
53+
mv -v ./tmp/Half-Life_PAK_File/valve/pak0.pak ./pak00_cd.pak
54+
rsync -av ./tmp/Half-Life_Program_Files/valve/ ./$OUTPK3DIR/
55+
mv -v ./tmp/Half-Life_Program_Files/media ./$OUTPK3DIR/media
56+
mv -v ./tmp/Half-Life_Program_Files/logos ./$OUTPK3DIR/logos
57+
cd ./$OUTPK3DIR
58+
mk_pk3 pak01_cd
59+
fi
60+
5761
cd "$SCRPATH"
5862

5963
# Get the latest patch, because that'll fix the menu assets and add more fun, free content
@@ -72,5 +76,42 @@ grab_patch 11071108 14_1108
7276
grab_patch 11081109 15_1109
7377
grab_patch 11091110 16_1110
7478

79+
# Make sure we're back in here
80+
cd "$SCRPATH"
81+
82+
printf "All done. Would you like to rip the the Compact Disc Digital Audio for music?\ny/n: "
83+
read CHOICE
84+
85+
if [[ "$CHOICE" == [Yy]* ]]; then
86+
# check if we require rippin tunes
87+
if ! [ -f "$SCRPATH/music/track02.wav" ] && ! [ -f "$SCRPATH/music/track02.ogg" ]; then
88+
if [ -x "$(command -v cdparanoia)" ]; then
89+
mkdir -p "./music"
90+
cd "./music"
91+
cdparanoia -B
92+
rename ".cdda." "." *.wav
93+
94+
# Maybe the user does not have the physical disc and cdp fails.
95+
if [ -f "$SCRPATH/music/track02.wav" ]; then
96+
# I'd offer FLAC, but that also requires the ffmpeg plugin
97+
if [ -x "$(command -v oggenc)" ]; then
98+
printf "All done. Would you like to convert them to OGG for playback compatibility\nas well as space preservation (frees up ~330 MB)?\ny/n: "
99+
read CHOICE
100+
if [[ "$CHOICE" == [Yy]* ]]; then
101+
oggenc *.wav
102+
rm *.wav
103+
fi
104+
fi
105+
fi
106+
else
107+
printf "cdparanoia is missing. Cannot rip music.\nPlease run the installer again once you've got it installed.\n"
108+
fi
109+
else
110+
printf "Music is already present.\n"
111+
fi
112+
fi
113+
114+
cd "$SCRPATH"
115+
75116
rm -rfv ./$OUTPK3DIR
76117
rm -rfv ./tmp

0 commit comments

Comments
 (0)