-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup_nvoptix.sh
executable file
·108 lines (94 loc) · 2.09 KB
/
setup_nvoptix.sh
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
108
#!/bin/bash
nvoptix_dir="$(dirname "$(readlink -fm "$0")")/lib64/wine"
wine='wine64'
if [ ! -f "$nvoptix_dir/x86_64-unix/nvoptix.dll.so" ]; then
echo "nvoptix.dll.so not found in $nvoptix_dir/x86_64-unix" >&2
exit 1
fi
winever=$($wine --version | grep wine)
if [ -z "$winever" ]; then
echo "$wine: Not a wine executable. Check your $wine." >&2
exit 1
fi
assume=
function ask {
echo "$1"
if [ -z "$assume" ]; then
read -r continue
else
continue=$assume
echo "$continue"
fi
}
POSITIONAL=()
while [[ $# -gt 0 ]]; do
case $1 in
-y)
assume='y'
shift
;;
-n)
assume='n'
shift
;;
*)
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
if [ -z "$WINEPREFIX" ]; then
ask "WINEPREFIX is not set, continue? (y/N)"
if [ "$continue" != "y" ] && [ "$continue" != "Y" ]; then
exit 1
fi
else
if ! [ -f "$WINEPREFIX/system.reg" ]; then
ask "WINEPREFIX does not point to an existing wine installation. Proceeding will create a new one, continue? (y/N)"
if [ "$continue" != "y" ] && [ "$continue" != "Y" ]; then
exit 1
fi
fi
fi
unix_sys_path=$($wine winepath -u 'C:\windows\system32' 2> /dev/null)
if [ -z "$unix_sys_path" ]; then
echo 'Failed to resolve C:\windows\system32.' >&2
exit 1
fi
function remove {
echo " Removing nvoptix... "
local dll="$unix_sys_path/$1.dll"
if [ -h "$dll" ]; then
out=$(rm "$dll" 2>&1)
if [ $? -ne 0 ]; then
echo -e "$out"
exit=2
fi
else
echo -e "'$dll' is not a link or doesn't exist."
exit=2
fi
}
function create {
echo " Installing nvoptix... "
ln -sf "$nvoptix_dir/x86_64-unix/$1.dll.so" "$unix_sys_path/$1.dll"
if [ $? -ne 0 ]; then
echo -e "Failed to create symlink"
exit 1
fi
}
case "$1" in
uninstall)
fun=remove
;;
install)
fun=create
;;
*)
echo "Unrecognized option: $1"
echo "Usage: $0 [install|uninstall]"
exit 1
;;
esac
$fun nvoptix