summaryrefslogtreecommitdiff
blob: c324b61bf89edec70699dd2ed8bd1083d9e5c07e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# Initial version by Bioware
# Modified to match the gentoo setup
# 03/27/2003 phoen][x <phoenix@gentoo.org>

cd GENTOO_DIR/nwn || exit 1

aRequiredDirs=(ambient data music override miles nwm)
aRequiredFiles=(chitin.key dialog.tlk nwmain)
aLCDirs=(ambient data dmvault hak localvault music override portraits)
aProblemFiles=()
aWritables=(nwn.ini nwnplayer.ini nwncdkey.ini saves localvault tempclient currentgame dmvault)

printf "Checking for required files\n\n"

for d in ${aRequiredDirs[@]} ; do
	if [[ -d $d ]] ; then
		printf "PASSED: $d directory exists\n"
	else
		printf "FAILED: $d directory missing\n"
		exit 1
	fi
done

for f in ${aRequiredFiles[@]} ; do
	if [[ -f $f ]] ; then
		printf "PASSED: $f exists\n"
	else
		printf "FAILED: $f missing\n"
		exit 1
	fi
done

printf "\nFixing case\n\n"

if [[ -f dialog.TLK ]] ; then
	mv dialog.TLK dialog.tlk
fi

if [[ -f dialogF.TLK ]] ; then
	mv dialogF.TLK dialogf.tlk
fi

for d in ${aLCDirs[@]} ; do
	if [[ -d $d ]] ; then
		printf "$d\n"
		cd $d

		for f in $(find . -name '*.*') ; do
			lcf=$(echo $f | tr [:upper:] [:lower:])
			if [[ $f != $lcf ]] && [[ -f $f ]] ; then
				mv $f $(echo $f | tr [:upper:] [:lower:]) 
			fi
			printf .
		done

		cd ..
		printf "\n"
	fi
done

defIFS=$IFS
IFS='|'

if [[ -d saves ]] ; then
	cd saves
	for d in $(find . -name '* - *' -type d -printf "%f|") ; do
		printf "saves/$d\n"
		cd "$d"

		[[ -f Portrait.tga ]] && mv Portrait.tga portrait.tga
		[[ -f Screen.tga ]] && mv Screen.tga screen.tga

		cd ..
	done
	cd ..
fi

IFS=$defIFS

printf "\nChecking for problem files\n\n"

for f in ${aProblemFiles[@]} ; do
	if [[ -e $f ]] ; then
		printf "WARNING: $f exists, deleting this file is recommended\n"
	fi
done

printf "\nFixing permissions\n\n"

chown GENTOO_USER:GENTOO_GROUP GENTOO_DIR/nwn/ -R
chmod g+rwX GENTOO_DIR/nwn/ -R

# 1.65-specific fixes to permissions
[ -e GENTOO_DIR/nwn/data/patch.bif ] && \
	chmod a-x GENTOO_DIR/nwn/data/patch.bif 2>&1 > /dev/null
chmod a-x GENTOO_DIR/nwn/nwm/Chapter1.nwm 2>&1 > /dev/null
chmod a-x GENTOO_DIR/nwn/nwm/Chapter1E.nwm 2>&1 > /dev/null
chmod a-x GENTOO_DIR/nwn/nwm/Chapter2.nwm 2>&1 > /dev/null
chmod a-x GENTOO_DIR/nwn/nwm/Chapter2E.nwm 2>&1 > /dev/null
chmod a-x GENTOO_DIR/nwn/nwm/Chapter3.nwm 2>&1 > /dev/null
chmod a-x GENTOO_DIR/nwn/nwm/Chapter4.nwm 2>&1 > /dev/null
chmod a-x GENTOO_DIR/nwn/nwm/Prelude.nwm 2>&1 > /dev/null
[ -e GENTOO_DIR/nwn/patch.key ] && \
	chmod a-x GENTOO_DIR/nwn/patch.key 2>&1 > /dev/null

printf "\nYou are ready to run Neverwinter Nights.\n\n"