Browse Source

initial commit

tags/0.1
Bret R. Human 4 weeks ago
commit
a97e58f4e2
4 changed files with 727 additions and 0 deletions
  1. 52
    0
      LICENSE
  2. 7
    0
      README.md
  3. 351
    0
      bn3t-run.sh
  4. 317
    0
      bn3t.sh

+ 52
- 0
LICENSE View File

@@ -0,0 +1,52 @@
1
+bn3t
2
+===
3
+Copyright (c) 2018, Bret R. Human
4
+All rights reserved.
5
+
6
+Further documentation can be found at
7
+   https://mage.cynicaloptimist.me/en/bn3t
8
+   https://psi.cynicaloptimist.me/Caffarius/bn3t/
9
+Happy modding! -Bret
10
+
11
+Redistribution and use in source and binary forms, with or without
12
+modification, are permitted provided that the following conditions are met:
13
+
14
+1. Redistributions of source code must retain the above copyright notice,
15
+   the documentation link and note, this list of conditions, and the following
16
+   disclaimer.
17
+
18
+2. Redistributions in binary form must reproduce the above copyright notice,
19
+   this list of conditions and the following disclaimer in the documentation
20
+   and/or other materials provided with the distribution.
21
+
22
+3. All advertising materials mentioning features or use of this
23
+   software must display the following acknowledgment:
24
+"Built using software developed by Cynical Optimist - https://cynicaloptimist.me
25
+ Ask what we can build for you at info@cynicaloptimist.me"
26
+
27
+4. The names "Cynical Optimist" and "Bret R. Human" and the software name listed
28
+   at the top of this document, or the domain "cynicaloptimist.me" or any
29
+   affiliated service must not be used to endorse or promote products derived
30
+   from this software without prior written permission. For written permission,
31
+   contact info@cynicaloptimist.me.
32
+
33
+5. Products derived from this software may not be called the software name
34
+   listed at the top of this document nor may "Cynical Optimist" or the software
35
+   name listed at the top of this document appear in their names without prior
36
+   written permission of Bret R. Human.
37
+
38
+6. Redistributions of any form whatsoever must retain the following
39
+   acknowledgment:
40
+"Built using software developed by Cynical Optimist - https://cynicaloptimist.me
41
+ Ask what we can build for you at info@cynicaloptimist.me"
42
+
43
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
44
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
45
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
46
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
47
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
48
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
49
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
52
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

+ 7
- 0
README.md View File

@@ -0,0 +1,7 @@
1
+# bn3t
2
+
3
+Wrapper for setting up/maintaining a Battle.net install, handy for running it as a secondary user.
4
+
5
+
6
+## Usage
7
+See the wiki article at https://mage.cynicaloptimist.me/en/Bn3t

+ 351
- 0
bn3t-run.sh View File

@@ -0,0 +1,351 @@
1
+#!/bin/bash
2
+## Copyright © 2018 Bret Human
3
+## https://cynicaloptimist.me/
4
+##
5
+##    Documentation at:
6
+## https://mage.cynicaloptimist.me/en/bn3t
7
+## https://psi.cynicaloptimist.me/Caffarius/bn3t/
8
+##
9
+## For questions or comments write:
10
+##    info@cynicaloptimist.me
11
+#####################################################################
12
+#                               bn3t-run
13
+script_ver="0.1"
14
+page="https://mage.cynicaloptimist.me/en/bn3t"
15
+# author: Bret Human
16
+# date: Dec 6, 2018
17
+#
18
+#####################################################################
19
+#
20
+# A wrapper for wrappers, used to install/manage/own a Battle.net
21
+# installation within Wine in a Linux environment.
22
+#
23
+# This script is intended to be run by bn3t, Hence the name.
24
+#
25
+# This is the second script in the line, fired off by bn3t. This
26
+# script handles conditionals for safely running Battle.net or
27
+# most of its apps. The syntax makes it easily modular.
28
+#
29
+# If you want to add a game, search for "function game_on".
30
+#
31
+#####################################################################
32
+#
33
+# This is free software; you are free to change and redistribute it.
34
+# There is NO WARRANTY of any kind.
35
+#
36
+#####################################################################
37
+
38
+runas_user="`whoami`"
39
+app_name="Battle.net"
40
+dl_addr="https://www.battle.net/download/getInstallerForGame?os=win&locale=enUS&version=LIVE&gameProgram=BATTLENET_APP"
41
+install_dir="/drive_c/Program Files (x86)"
42
+app_loc="/Battle.net/Battle.net.exe"
43
+console="bash"
44
+usage="bn3t-run, version ${script_ver}
45
+Usage: ./`basename ${0}` -g (game) -p (prefix) -a (arch) -dvsbwtnchx
46
+     -g   | Launches the game of your choice
47
+     -p   | Selects the location of the Wine prefix
48
+     -a   | Selects the architecture to run as (32 | 64)
49
+     -d   | Debug messages on (turns verbose on)
50
+     -v   | Verbose messages on
51
+     -s   | Runs ${app_name} setup
52
+     -b   | Runs wineboot
53
+     -w   | Runs winetricks
54
+     -t   | Attempts to launch to the system tray
55
+     -n   | No BS mode - doesn't launch an app (for boot/tricks/console safety)
56
+     -c   | Launch a console session as specified user (can launch Xapps)
57
+     -h   | Help (this message)
58
+     -x   | Force upgrade DXVK
59
+See more documentation at: ${page}"
60
+
61
+# Catch CTRL+C and cleanup
62
+trap "echo '' && inform '---------------------------------' && inform 'Caught CTRL+C' && warp 2" 2
63
+
64
+## Set default environment
65
+cd /home/"${runas_user}"
66
+export WINEPREFIX="/home/${runas_user}/.bnet"
67
+export HOME="/home/${runas_user}"
68
+export USER="${runas_user}"
69
+export USERNAME="${runas_user}"
70
+export LOGNAME="${runas_user}"
71
+export WINEDEBUG=-all
72
+export XAUTHORITY="/home/${runas_user}/.Xauthority"
73
+export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin"
74
+unset OLDPWD
75
+unset SUDO_GID
76
+unset SUDO_COMMAND
77
+unset SUDO_USER
78
+unset SUDO_UID
79
+
80
+## Define our functions
81
+function debug () {
82
+    if [ ! "${WINEDEBUG}" ]; then
83
+        echo "-d- ${1}"
84
+    fi
85
+}
86
+
87
+function inform () {
88
+    if [ "${app_verbose}" ]; then
89
+        echo "--- ${1}"
90
+    fi
91
+}
92
+
93
+function clean {
94
+    debug "clean"
95
+
96
+	# Var
97
+    unset script_ver
98
+    unset runas_user
99
+    unset app_name
100
+    unset dl_addr
101
+    unset install_dir
102
+    unset app_loc
103
+    unset console
104
+    unset usage
105
+    unset WINEPREFIX
106
+    unset WINEDEBUG
107
+    unset WINEARCH
108
+    unset game_launch
109
+    unset game_name
110
+    unset game_start
111
+    unset to_tray
112
+
113
+    # Func
114
+    unset debug
115
+    unset inform
116
+    unset game_on
117
+    unset run_wine
118
+}
119
+
120
+function warp () {
121
+    debug "warp"   # exit the dungeon
122
+    inform "Cleaning up ${runas_user}-side..."
123
+    clean
124
+    unset clean
125
+
126
+    if [ "$1" ]; then
127
+        unset warp && exit $1
128
+    else
129
+        echo "...what...?"
130
+        unset warp && exit 5
131
+    fi
132
+}
133
+
134
+function game_on {
135
+    debug "game_on"
136
+    case "${game_launch}" in
137
+        test)
138
+            echo "glxgears!"
139
+            if [ "`which glxgears`" ]; then
140
+                glxgears
141
+            else
142
+                echo "glxgears is not installed, or I can't find it in PATH"
143
+                warp 1
144
+            fi
145
+            ;;
146
+        wtcg|Wtcg|WTCG|hearth|hearthstone|HEARTH|HEARTHSTONE|hs|HS)
147
+            game_name="Hearthstone"
148
+            game_start="/Hearthstone/Hearthstone Beta Launcher.exe"
149
+            ;;
150
+        d3|D3|diablo3|Diablo3|DIABLO3)
151
+            game_name="Diablo 3"
152
+            game_start="/Diablo III/Diablo III Launcher.exe"
153
+            ;;
154
+        sc2|SC2|starcraft2|Starcraft2|StarCraft2|STARCRAFT2)
155
+            game_name="StarCraft II"
156
+            game_start="/StarCraft II/StarCraft II.exe"
157
+            ;;
158
+        sc|SC|starcraft|Starcraft|StarCraft|STARCRAFT)
159
+            game_name="StarCraft"
160
+            game_start="/StarCraft/StarCraft Launcher.exe"
161
+            ;;
162
+        wow|Wow|woW|WoW|WOW|worldofwarcraft|WorldofWarcraft|WorldOfWarcraft|WorldofWarCraft|WorldOfWarCraft|WORLDOFWARCRAFT)
163
+            game_name="World of WarCraft"
164
+            game_start="/World of Warcraft/World of Warcraft Launcher.exe"
165
+            ;;
166
+        hero|Hero|HERO|heros|Heros|HEROS|hots|HotS|HOTS)
167
+            game_name="Heroes of the Storm"
168
+            game_start="/Heroes of the Storm/Heroes of the Storm.exe"
169
+            ;;
170
+        pro|Pro|PRO|ow|OW|overwatch|Overwatch|OverWatch|OVERWATCH)
171
+            game_name="Overwatch"
172
+            game_start="/Overwatch/Overwatch Launcher.exe"
173
+            ;;
174
+        dst2|Dst2|DST2|destiny2|Destiny2|DESTINY2)
175
+            echo "Destiny 2 cannot currently run on Linux without being banned."
176
+            warp 1
177
+            ;;
178
+        *)  echo "Unrecognized game: ${game_launch} - Can't launch!"
179
+            echo "${usage}"
180
+            warp 1
181
+            ;;
182
+    esac
183
+
184
+    if [ "${game_launch}" != "test" ]; then
185
+        echo "Attempting to run ${game_name}..."
186
+        if [ -f "${WINEPREFIX}${install_dir}${game_start}" ]; then
187
+            run_wine "${WINEPREFIX}${install_dir}${game_start}"
188
+        else
189
+            echo "${game_name} is not currently installed."
190
+            warp 1
191
+        fi
192
+    fi
193
+}
194
+
195
+function run_wine () {
196
+    debug "run_wine ${1}"
197
+    if [ "${WINEARCH}" == "win64" ]; then
198
+        debug "arch: win64"
199
+        if [ "${WINEDEBUG}" ]; then
200
+            wine64 "${1}" "${to_tray}" > /dev/null 2>&1
201
+        else
202
+            wine64 "${1}" "${to_tray}"
203
+        fi
204
+        wine64 "${1}" "${to_tray}"
205
+    elif [ "${WINEARCH}" == "win32" ]; then
206
+        debug "arch: win32"
207
+        if [ "${WINEDEBUG}" ]; then
208
+            wine "${1}" "${to_tray}" > /dev/null 2>&1
209
+        else
210
+            wine "${1}" "${to_tray}"
211
+        fi
212
+    else    # Default to AMD64
213
+        debug "arch: default (AMD64)"
214
+        export WINEARCH=win64
215
+        if [ "${WINEDEBUG}" ]; then
216
+            wine64 "${1}" "${to_tray}" > /dev/null 2>&1
217
+        else
218
+            wine64 "${1}" "${to_tray}"
219
+        fi
220
+    fi
221
+}
222
+
223
+
224
+
225
+## Pick up any arguments provided
226
+while getopts ":g:G:p:P:a:A:dDvVsSbBwWtTnNcChHxX" option; do
227
+    case "${option}" in
228
+        "g"|"G") game_launch="${OPTARG}";;
229
+        "d"|"D")
230
+            if [ "${WINEDEBUG}" ]; then
231
+                unset WINEDEBUG
232
+                debug "Run debug enabled"
233
+                debug "`realpath "${0}"` version ${script_ver} running as ${runas_user}"
234
+                app_verbose="y"
235
+            fi
236
+            ;;
237
+        "p"|"P") export WINEPREFIX="${OPTARG}";;
238
+        "a"|"A")
239
+            case "${OPTARG}" in
240
+                32) export WINEARCH=win32;;
241
+                64) export WINEARCH=win64;;
242
+                *) inform "Weird architecture: ${OPTARG}, ignoring";;
243
+            esac
244
+            ;;
245
+        "w"|"W")
246
+            echo "Running winetricks..."
247
+            nobs_mode="y"
248
+            if [ ! "${app_verbose}" ]; then
249
+                winetricks > /dev/null 2>&1
250
+            else
251
+                winetricks
252
+            fi
253
+            ;;
254
+        "s"|"S")
255
+            nobs_mode="y"
256
+            if [ -f "${WINEPREFIX}${install_dir}${app_loc}" ]; then
257
+                echo "${app_name} looks like it's already installed. Aborting setup."
258
+                warp 1
259
+            else
260
+                echo "Running setup..."
261
+                if [ ! -f "/tmp/${app_name}-Setup.exe" ]; then
262
+                    inform "/tmp/${app_name}-Setup.exe was not found. Retreiving."
263
+                    wget -O "/tmp/${app_name}-Setup.exe" "${dl_addr}" ||
264
+                    (echo "Failed to download installer from ${dl_addr}" && warp 1)
265
+                else
266
+                    inform "Looks like the installer is in place. Executing."
267
+                fi
268
+                run_wine "/tmp/${app_name}-Setup.exe"
269
+            fi
270
+            ;;
271
+        "x"|"X")
272
+            echo "Upgrading dxvk..."
273
+            nobs_mode="y"
274
+            if [ ! "${app_verbose}" ]; then
275
+                winetricks --force dxvk > /dev/null 2>&1
276
+            else
277
+                winetricks --force dxvk
278
+            fi
279
+            ;;
280
+        "b"|"B")
281
+            echo "Running wineboot..."
282
+            nobs_mode="y"
283
+            if [ -d "${WINEPREFIX}" ]; then
284
+                echo "${WINEPREFIX} already exists! Refusing to wineboot."
285
+            else
286
+                if [ "${WINEDEBUG}" ]; then
287
+                    wineboot > /dev/null 2>&1
288
+                else
289
+                    wineboot
290
+                fi
291
+            fi
292
+            ;;
293
+        "n"|"N")
294
+            inform "...with No BS..."
295
+            nobs_mode="y"
296
+            ;;
297
+        "c"|"C")
298
+            echo "Running console..."
299
+            nobs_mode="y"
300
+            ${console}
301
+            ;;
302
+        "v"|"V")
303
+            if [ "${WINEDEBUG}" ]; then
304
+                if [ ! "${app_verbose}" ]; then
305
+                    app_verbose="y"
306
+                    #inform "Run verbose enabled"
307
+                    inform "`realpath "${0}"` version ${script_ver} running as ${runas_user}"
308
+                fi
309
+            fi
310
+            ;;
311
+        "t"|"T")
312
+            to_tray="--autostarted"
313
+            inform "Attempting hide to system tray"
314
+            ;;
315
+        "h"|"H")
316
+            echo "${usage}"
317
+            warp 0
318
+            ;;
319
+        *)  echo "Unknown option: -${OPTARG}"
320
+            echo "${usage}"
321
+            warp 1
322
+            ;;
323
+    esac
324
+done
325
+
326
+
327
+
328
+## If a game was set for launch, give it a shot. Otherwise launcher.
329
+if [ "${nobs_mode}" ]; then
330
+    debug "Skipping app launches"
331
+else
332
+    debug "launch_select"
333
+    if [[ -d "${WINEPREFIX}" || "${game_launch}" == "test" ]]; then
334
+        if [ "${game_launch}" ]; then
335
+            inform "game_launch argument: ${game_launch}"
336
+            game_on
337
+        else
338
+            echo "Running ${app_name}"
339
+            run_wine "${WINEPREFIX}${install_dir}${app_loc}"
340
+        fi
341
+    else
342
+        echo "Prefix ${WINEPREFIX} does not exist! Prep with -bs first"
343
+        warp 1
344
+    fi
345
+fi
346
+
347
+
348
+
349
+## If we still exist, clean up.
350
+debug "final notice"
351
+warp 0

+ 317
- 0
bn3t.sh View File

@@ -0,0 +1,317 @@
1
+#!/bin/bash
2
+## Copyright © 2018 Bret Human
3
+## https://cynicaloptimist.me/
4
+##
5
+##    Documentation at:
6
+## https://mage.cynicaloptimist.me/en/bn3t
7
+## https://psi.cynicaloptimist.me/Caffarius/bn3t/
8
+##
9
+## For questions or comments write:
10
+##    info@cynicaloptimist.me
11
+#####################################################################
12
+#                                bn3t
13
+script_ver="0.1"
14
+page="https://mage.cynicaloptimist.me/en/bn3t"
15
+# author: Bret Human
16
+# date: Dec 6, 2018
17
+#
18
+#####################################################################
19
+#
20
+# A wrapper for wrappers, used to install/manage/own a Battle.net
21
+# installation within Wine in a Linux environment.
22
+#
23
+# Extra handy for running Battle.net under a secondary account for
24
+# added security. Can be used for lots of zany wine needs, like
25
+# spawning a multitude of Wine prefixes and installing Battle.net in
26
+# all of them.
27
+#
28
+# This is the first of two scripts. It is meant to be the sanitizer
29
+# crew and the firing squad for bn3t-run. bn3t-run must be installed.
30
+#
31
+# Install bn3t-run for your desired user with:
32
+#      ./bn3t.sh -u username -i
33
+#
34
+# Then you can prep the environment and install Battle.net via:
35
+#      ./bn3t.sh -u username -bxs
36
+#
37
+# Or I guess you could manually download the script from:
38
+dl_addr="https://psi.cynicaloptimist.me/Caffarius/bn3t/raw/branch/master/bn3t-run.sh"
39
+#####################################################################
40
+#
41
+# This is free software; you are free to change and redistribute it.
42
+# There is NO WARRANTY of any kind.
43
+#
44
+#####################################################################
45
+
46
+runas_user="`whoami`"
47
+app_name="Battle.net"
48
+run_cmd="bn3t-run.sh"
49
+check_wait="3"
50
+usage="bn3t, version ${script_ver}
51
+Usage: ./`basename ${0}` -g (game) -u (user) -p (prefix) -a (arch) -dvksbwtnchxi
52
+     -g   | Launches the game of your choice
53
+     -u   | Runs ${app_name} as the user specified
54
+     -p   | Selects the location of the Wine prefix
55
+     -a   | Selects the architecture to run as (32 | 64)
56
+     -d   | Debug messages on (turns verbose on)
57
+     -v   | Verbose messages on
58
+     -k   | Kill all processes for a user (not current user or root)
59
+     -s   | Runs ${app_name} setup
60
+     -b   | Runs wineboot
61
+     -w   | Runs winetricks
62
+     -t   | Attempts to launch to the system tray
63
+     -n   | No BS mode - doesn't launch an app (for boot/tricks/console safety)
64
+     -c   | Launch a console session as specified user (can launch Xapps)
65
+     -h   | Help (this message)
66
+     -x   | Force upgrade DXVK
67
+     -i   | Install the bn3t-run script for the specified user - mandantory
68
+See more documentation at: ${page}"
69
+
70
+# Catch CTRL+C and cleanup
71
+trap "echo '' && inform '---------------------------------' && inform 'Caught CTRL+C' && check" 2
72
+
73
+## Define our functions
74
+function refresh {
75
+    app_dir="/home/${runas_user}/.script/"
76
+    app_check="ps -ef | grep ${runas_user} | grep Battle.net.exe | grep -v grep"
77
+}
78
+
79
+function debug () {
80
+    if [ "${app_debug}" ]; then
81
+        echo "-D- ${1}"
82
+    fi
83
+}
84
+
85
+function inform () {
86
+    if [ "${app_verbose}" ]; then
87
+        echo "--- ${1}"
88
+    fi
89
+}
90
+
91
+function clean {
92
+    debug "Clean"
93
+
94
+    # Var
95
+    unset script_ver
96
+    unset page
97
+    unset runas_user
98
+    unset app_name
99
+    unset run_cmd
100
+    unset check_wait
101
+    unset usage
102
+    unset app_dir
103
+    unset app_check
104
+    unset app_debug
105
+    unset app_verbose
106
+    unset launch_opt
107
+    unset nobs_mode
108
+    unset dl_addr
109
+
110
+    # Func
111
+    unset refresh
112
+    unset debug
113
+    unset inform
114
+    unset check
115
+}
116
+
117
+function die () {
118
+    debug "die"
119
+    echo "Cleaning up..."
120
+    
121
+    if [ "`whoami`" == "${runas_user}" ]; then
122
+        debug "Launched as original user, not killing processes"
123
+    else
124
+        if [ "${runas_user}" == "root" ]; then
125
+            debug "Root? Madness. Just removing xhost then..."
126
+            inform "`xhost -SI:localuser:"${runas_user}"`"
127
+        else
128
+            debug "Launched as ${runas_user}, killing processes"
129
+            sudo -u "${runas_user}" -- bash -c "kill -9 -1"
130
+            inform "`xhost -SI:localuser:"${runas_user}"`"
131
+        fi
132
+    fi
133
+
134
+    clean
135
+    unset clean
136
+    unset fizzle
137
+
138
+    if [ "$1" ]; then
139
+        unset die && exit $1
140
+    else
141
+        echo "...what?"
142
+        unset die && exit 5
143
+    fi
144
+	exit 5
145
+}
146
+
147
+function fizzle () {
148
+    debug "fizzle" # https://mtg.gamepedia.com/Fizzle
149
+    echo "Exiting..."
150
+    clean
151
+    unset clean
152
+    unset die
153
+    
154
+    if [ "$1" ]; then
155
+        unset fizzle && exit $1
156
+    else
157
+        echo "...what?"
158
+        unset fizzle && exit 5
159
+    fi
160
+	exit 5
161
+}
162
+
163
+function check {
164
+    debug "check"
165
+    i="0"
166
+    while [ "${i}" -lt "${check_wait}" ]; do
167
+        if [ "$(eval ${app_check})" ]; then
168
+            inform "${app_name} is still running. Waiting to see if we need to murder... $[ ${check_wait} - ${i} ]"
169
+            sleep 1
170
+        else
171
+            unset i
172
+            die 0
173
+        fi
174
+
175
+        i=$[ $i + 1 ]
176
+    done
177
+    unset i
178
+}
179
+
180
+
181
+
182
+## Pick up any arguments provided
183
+# None are required, we'll use default values.
184
+launch_opt=""
185
+while getopts ":g:G:u:U:p:P:a:A:dDvVkKsSbBwWtTnNcChHxXiI" option; do
186
+    case "${option}" in
187
+        "k"|"K") die 0;;
188
+        "g"|"G") launch_opt="${launch_opt} -g ${OPTARG}";;
189
+        "p"|"P") launch_opt="${launch_opt} -p ${OPTARG}";;
190
+        "a"|"A") launch_opt="${launch_opt} -a ${OPTARG}";;
191
+        "d"|"D")
192
+            if [ ! "${app_debug}" ]; then # Let's not do this too much...
193
+                app_debug="y"
194
+                launch_opt=" -d${launch_opt}"
195
+                debug "Debug enabled"
196
+                if [ ! "${app_verbose}" ]; then
197
+                    debug "`realpath "${0}"` version ${script_ver} running as `whoami`"
198
+                fi
199
+                app_verbose="y"
200
+                debug ""
201
+                debug "This is free software; you are free to change and redistribute it."
202
+                debug "There is NO WARRANTY of any kind."
203
+                debug ""
204
+                debug "Documentation at:    ${page}"
205
+                debug ""
206
+            fi
207
+            ;;
208
+        "w"|"W")
209
+            inform "Winetricks mode"
210
+            launch_opt="${launch_opt} -w"
211
+            ;;
212
+        "s"|"S")
213
+            inform "Setup mode"
214
+            nobs_mode="y"
215
+            launch_opt="${launch_opt} -s"
216
+            ;;
217
+        "x"|"X")
218
+            inform "Force upgrading dxvk"
219
+            launch_opt="${launch_opt} -x"
220
+            ;;
221
+        "b"|"B")
222
+            inform "Wineboot mode"
223
+            launch_opt="${launch_opt} -b"
224
+            ;;
225
+        "n"|"N")
226
+            inform "No BS mode"
227
+            nobs_mode="y"
228
+            launch_opt="${launch_opt} -n"
229
+            ;;
230
+        "c"|"C")
231
+            inform "Console requested"
232
+            nobs_mode="y"
233
+            launch_opt="${launch_opt} -c"
234
+            ;;
235
+        "v"|"V")
236
+            if [ ! "${app_debug}" ]; then
237
+                if [ ! "${app_verbose}" ]; then
238
+                    app_verbose="y"
239
+                    inform "Verbose enabled"
240
+                    inform "`realpath "${0}"` version ${script_ver} running as `whoami`"
241
+                    launch_opt=" -v${launch_opt}"
242
+                fi
243
+            fi
244
+            ;;
245
+        "t"|"T")
246
+            debug "Hiding to system tray"
247
+            launch_opt="${launch_opt} -t"
248
+            ;;
249
+        "u"|"U")
250
+            debug "Setting user to ${OPTARG}"
251
+            runas_user="${OPTARG}"
252
+            ;;
253
+        "i"|"I")
254
+            debug "User-side install requested"
255
+            refresh
256
+            
257
+            if [ "`whoami`" == "${runas_user}" ]; then
258
+                debug "Running as original user, just downloading it"
259
+                mkdir -p "${app_dir}" ||
260
+                (echo "Failed to make directory ${app_dir}" && fizzle 1)
261
+                
262
+                wget "${dl_addr}" -O "${app_dir}${run_cmd}" ||
263
+                (echo "Failed to download script from ${dl_addr}" && fizzle 1)
264
+                
265
+                chmod 700 "${app_dir}${run_cmd}" ||
266
+                (echo "Failed to change permissions on ${app_dir}${run_cmd}" && fizzle 1)
267
+            else
268
+                debug "Running as ${runas_user}, switching and downloading"
269
+                sudo -u "${runas_user}" -- mkdir -p "${app_dir}" ||
270
+                (echo "Failed to make directory ${app_dir}" && fizzle 1)
271
+                
272
+                sudo -u "${runas_user}" -- wget "${dl_addr}" -O "${app_dir}${run_cmd}" ||
273
+                (echo "Failed to download script from ${dl_addr}" && fizzle 1)
274
+                
275
+                sudo -u "${runas_user}" -- chmod 700 "${app_dir}${run_cmd}" ||
276
+                (echo "Failed to change permissions on ${app_dir}${run_cmd}" && fizzle 1)
277
+            fi
278
+
279
+            echo "Installed successfully."
280
+            fizzle 0
281
+            ;;
282
+        "h"|"H")
283
+            echo "${usage}"
284
+            fizzle 0
285
+            ;;
286
+        * ) echo "Unknown option: -${OPTARG}"
287
+            echo "${usage}"
288
+            fizzle 1
289
+            ;;
290
+    esac
291
+done
292
+debug "launch_opt:${launch_opt}"
293
+
294
+
295
+
296
+## Pass our knowledge on.
297
+refresh
298
+debug "run_app"
299
+if [ "`whoami`" == "${runas_user}" ]; then
300
+    debug "Launching as original user, going native"
301
+    ${app_dir}${run_cmd}${launch_opt}
302
+else
303
+    debug "Launching as ${runas_user}, checking xhost"
304
+    if [ ! "`xhost | grep ${runas_user}`" ]; then
305
+        inform "`xhost +SI:localuser:"${runas_user}"`"
306
+    fi
307
+    sudo -u "${runas_user}" -- dbus-launch ${app_dir}${run_cmd}${launch_opt}
308
+fi
309
+
310
+
311
+
312
+## If we still exist, clean up.
313
+debug "Final Notice"
314
+if [ "${app_check}" ]; then
315
+    check
316
+    fizzle 0
317
+fi

Loading…
Cancel
Save