Compare commits

...

8 Commits
0.1 ... master

Author SHA1 Message Date
Bret ebe3c5313b Update 'bn3t.sh' 2020-11-15 04:19:56 -05:00
Bret 49d1955e1b Update 'bn3t-run.sh' 2020-11-15 04:19:29 -05:00
Bret dc078b32e1 Update 'LICENSE' 2020-11-15 04:18:22 -05:00
Bret 8d98561bb4 Update 'bn3t.sh' 2020-11-15 04:15:30 -05:00
Bret 7e664b699b Update 'bn3t-run.sh' 2020-11-15 04:14:26 -05:00
Bret b67f4f5431 Update 'README.md' 2020-11-15 04:13:23 -05:00
Bret Human 063e205f6c Holiday chroot edition 2019-12-07 05:11:24 -05:00
Bret R. Human 5b28f61aee Added Twitch client support 2019-05-21 08:52:53 -04:00
4 changed files with 375 additions and 172 deletions

23
LICENSE
View File

@ -1,11 +1,11 @@
bn3t bn3t
=== ===
Copyright (c) 2018, Bret R. Human Copyright (c) 2018-2021, Bret R. Human
All rights reserved. All rights reserved.
Further documentation can be found at Further documentation can be found at
https://mage.cynicaloptimist.me/en/bn3t https://mage.cynop.me/en/bn3t
https://psi.cynicaloptimist.me/Caffarius/bn3t/ https://psi.cynop.me/Caffarius/bn3t/
Happy modding! -Bret Happy modding! -Bret
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
@ -19,26 +19,19 @@ modification, are permitted provided that the following conditions are met:
this list of conditions and the following disclaimer in the documentation this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution. and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this 3. The names "Cynical Optimist" and "Bret R. Human" and the software name listed
software must display the following acknowledgment: at the top of this document, or the domain "cynop.me" or any
"Built using software developed by Cynical Optimist - https://cynicaloptimist.me
Ask what we can build for you at info@cynicaloptimist.me"
4. The names "Cynical Optimist" and "Bret R. Human" and the software name listed
at the top of this document, or the domain "cynicaloptimist.me" or any
affiliated service must not be used to endorse or promote products derived affiliated service must not be used to endorse or promote products derived
from this software without prior written permission. For written permission, from this software without prior written permission. For written permission,
contact info@cynicaloptimist.me. contact info@cynop.me.
5. Products derived from this software may not be called the software name 4. Products derived from this software may not be called the software name
listed at the top of this document nor may "Cynical Optimist" or the software listed at the top of this document nor may "Cynical Optimist" or the software
name listed at the top of this document appear in their names without prior name listed at the top of this document appear in their names without prior
written permission of Bret R. Human. written permission of Bret R. Human.
6. Redistributions of any form whatsoever must retain the following 5. Redistributions of any form whatsoever must retain the following
acknowledgment: acknowledgment:
"Built using software developed by Cynical Optimist - https://cynicaloptimist.me
Ask what we can build for you at info@cynicaloptimist.me"
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED

View File

@ -4,4 +4,4 @@ Wrapper for setting up/maintaining a Battle.net install, handy for running it as
## Usage ## Usage
See the wiki article at https://mage.cynicaloptimist.me/en/Bn3t See the wiki article at https://mage.cynop.me/en/Bn3t

View File

@ -1,17 +1,17 @@
#!/bin/bash #!/bin/bash
## Copyright © 2018 Bret Human ## Copyright © 2018-2021 Bret Human
## https://cynicaloptimist.me/ ## https://cynop.me/
## ##
## Documentation at: ## Documentation at:
## https://mage.cynicaloptimist.me/en/bn3t ## https://mage.cynop.me/en/bn3t
## https://psi.cynicaloptimist.me/Caffarius/bn3t/ ## https://psi.cynop.me/Caffarius/bn3t/
## ##
## For questions or comments write: ## For questions or comments write:
## info@cynicaloptimist.me ## info@cynop.me
##################################################################### #####################################################################
# bn3t-run # bn3t-run
script_ver="0.1" script_ver="0.3.1"
page="https://mage.cynicaloptimist.me/en/bn3t" page="https://mage.cynop.me/en/bn3t"
# author: Bret Human # author: Bret Human
# date: Dec 6, 2018 # date: Dec 6, 2018
# #
@ -38,24 +38,27 @@ page="https://mage.cynicaloptimist.me/en/bn3t"
runas_user="`whoami`" runas_user="`whoami`"
app_name="Battle.net" app_name="Battle.net"
dl_addr="https://www.battle.net/download/getInstallerForGame?os=win&locale=enUS&version=LIVE&gameProgram=BATTLENET_APP" dl_addr="https://www.battle.net/download/getInstallerForGame?os=win&locale=enUS&version=LIVE&gameProgram=BATTLENET_APP"
tc_addr="https://desktop.twitchsvc.net/installer/windows/TwitchSetup.exe"
install_dir="/drive_c/Program Files (x86)" install_dir="/drive_c/Program Files (x86)"
app_loc="/Battle.net/Battle.net.exe" app_loc="/Battle.net/Battle.net.exe"
console="bash" console="bash"
usage="bn3t-run, version ${script_ver} usage="bn3t-run, version ${script_ver}
Usage: ./`basename ${0}` -g (game) -p (prefix) -a (arch) -dvsbwtnchx Usage: ./`basename ${0}` -g (game) -p (prefix) -a (arch) -dvsbwtnchx
-g | Launches the game of your choice
-p | Selects the location of the Wine prefix
-a | Selects the architecture to run as (32 | 64) -a | Selects the architecture to run as (32 | 64)
-d | Debug messages on (turns verbose on)
-v | Verbose messages on
-s | Runs ${app_name} setup
-b | Runs wineboot -b | Runs wineboot
-w | Runs winetricks
-t | Attempts to launch to the system tray
-n | No BS mode - doesn't launch an app (for boot/tricks/console safety)
-c | Launch a console session as specified user (can launch Xapps) -c | Launch a console session as specified user (can launch Xapps)
-d | Debug messages on (turns verbose on)
-g | Launches the game of your choice
-h | Help (this message) -h | Help (this message)
-m | Runs Twitch client
-n | No BS mode - doesn't launch an app (for boot/tricks/console safety)
-p | Selects the location of the Wine prefix
-s | Runs ${app_name} setup
-t | Attempts to launch to the system tray
-v | Verbose messages on
-w | Runs winetricks
-x | Force upgrade DXVK -x | Force upgrade DXVK
-z | Set the DISPLAY variable
See more documentation at: ${page}" See more documentation at: ${page}"
# Catch CTRL+C and cleanup # Catch CTRL+C and cleanup
@ -63,12 +66,14 @@ trap "echo '' && inform '---------------------------------' && inform 'Caught CT
## Set default environment ## Set default environment
cd /home/"${runas_user}" cd /home/"${runas_user}"
export RADV_PERFTEST=aco
export WINEPREFIX="/home/${runas_user}/.bnet" export WINEPREFIX="/home/${runas_user}/.bnet"
export HOME="/home/${runas_user}" export HOME="/home/${runas_user}"
export USER="${runas_user}" export USER="${runas_user}"
export USERNAME="${runas_user}" export USERNAME="${runas_user}"
export LOGNAME="${runas_user}" export LOGNAME="${runas_user}"
export WINEDEBUG=-all export WINEDEBUG=-all
#export WINEDLLOVERRIDES="winemenubuilder.exe=d"
export XAUTHORITY="/home/${runas_user}/.Xauthority" export XAUTHORITY="/home/${runas_user}/.Xauthority"
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin" export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin"
unset OLDPWD unset OLDPWD
@ -77,6 +82,8 @@ unset SUDO_COMMAND
unset SUDO_USER unset SUDO_USER
unset SUDO_UID unset SUDO_UID
## Define our functions ## Define our functions
function debug () { function debug () {
if [ ! "${WINEDEBUG}" ]; then if [ ! "${WINEDEBUG}" ]; then
@ -90,6 +97,13 @@ function inform () {
fi fi
} }
if [ -z "${DISPLAY}" ]; then
inform "DISPLAY not set - using default (0.0)";
export DISPLAY=:0.0
else
debug "Using DISPLAY variable: ${DISPLAY}";
fi
function clean { function clean {
debug "clean" debug "clean"
@ -109,6 +123,7 @@ function clean {
unset game_name unset game_name
unset game_start unset game_start
unset to_tray unset to_tray
unset DISPLAY
# Func # Func
unset debug unset debug
@ -223,9 +238,29 @@ function run_wine () {
## Pick up any arguments provided ## Pick up any arguments provided
while getopts ":g:G:p:P:a:A:dDvVsSbBwWtTnNcChHxX" option; do while getopts ":a:A:g:G:p:P:bBcCdDhHmMnNsStTvVwWxXzZ" option; do
case "${option}" in case "${option}" in
"g"|"G") game_launch="${OPTARG}";; "a"|"A")
case "${OPTARG}" in
32) export WINEARCH=win32;;
64) export WINEARCH=win64;;
*) inform "Weird architecture: ${OPTARG}, ignoring";;
esac
;;
"b"|"B")
echo "Running wineboot..."
nobs_mode="y"
if [ "${WINEDEBUG}" ]; then
wineboot > /dev/null 2>&1
else
wineboot
fi
;;
"c"|"C")
echo "Running console..."
nobs_mode="y"
${console}
;;
"d"|"D") "d"|"D")
if [ "${WINEDEBUG}" ]; then if [ "${WINEDEBUG}" ]; then
unset WINEDEBUG unset WINEDEBUG
@ -234,13 +269,61 @@ while getopts ":g:G:p:P:a:A:dDvVsSbBwWtTnNcChHxX" option; do
app_verbose="y" app_verbose="y"
fi fi
;; ;;
"g"|"G") game_launch="${OPTARG}";;
"h"|"H")
echo "${usage}"
warp 0
;;
"m"|"M")
echo "Running Twitch Client..."
nobs_mode="y"
if [ -d ${WINEPREFIX}/drive_c/users/${runas_user}/Application\ Data/Twitch ]; then
wine C:\\users\\${runas_user}\\Application\ Data\\Twitch\\Bin\\Twitch.exe
else
inform "...but it helps to install it first..."
if [ ! -f "${WINEPREFIX}/drive_c/TwitchSetup.exe" ]; then
inform "${WINEPREFIX}/drive_c/TwitchSetup.exe was not found. Retreiving."
wget -O "${WINEPREFIX}/drive_c/TwitchSetup.exe" "${tc_addr}" ||
(echo "Failed to download installer from ${tc_addr}"; warp 1)
fi
wine "${WINEPREFIX}/drive_c/TwitchSetup.exe"
fi
;;
"n"|"N")
inform "...with No BS..."
nobs_mode="y"
;;
"p"|"P") export WINEPREFIX="${OPTARG}";; "p"|"P") export WINEPREFIX="${OPTARG}";;
"a"|"A") "s"|"S")
case "${OPTARG}" in nobs_mode="y"
32) export WINEARCH=win32;; if [ -f "${WINEPREFIX}${install_dir}${app_loc}" ]; then
64) export WINEARCH=win64;; echo "${app_name} looks like it's already installed. Aborting setup."
*) inform "Weird architecture: ${OPTARG}, ignoring";; warp 1
esac else
echo "Running setup..."
if [ ! -f "${WINEPREFIX}/drive_c/${app_name}-Setup.exe" ]; then
inform "${WINEPREFIX}/drive_c/${app_name}-Setup.exe was not found. Retreiving."
wget -O "${WINEPREFIX}/drive_c/${app_name}-Setup.exe" "${dl_addr}" ||
(echo "Failed to download installer from ${dl_addr}" && warp 1)
else
inform "Looks like the installer is in place. Executing."
fi
run_wine "${WINEPREFIX}/drive_c/${app_name}-Setup.exe"
fi
;;
"t"|"T")
to_tray="--autostarted"
inform "Attempting hide to system tray"
;;
"v"|"V")
if [ "${WINEDEBUG}" ]; then
if [ ! "${app_verbose}" ]; then
app_verbose="y"
#inform "Run verbose enabled"
inform "`realpath "${0}"` version ${script_ver} running as ${runas_user}"
fi
fi
;; ;;
"w"|"W") "w"|"W")
echo "Running winetricks..." echo "Running winetricks..."
@ -251,23 +334,6 @@ while getopts ":g:G:p:P:a:A:dDvVsSbBwWtTnNcChHxX" option; do
winetricks winetricks
fi fi
;; ;;
"s"|"S")
nobs_mode="y"
if [ -f "${WINEPREFIX}${install_dir}${app_loc}" ]; then
echo "${app_name} looks like it's already installed. Aborting setup."
warp 1
else
echo "Running setup..."
if [ ! -f "/tmp/${app_name}-Setup.exe" ]; then
inform "/tmp/${app_name}-Setup.exe was not found. Retreiving."
wget -O "/tmp/${app_name}-Setup.exe" "${dl_addr}" ||
(echo "Failed to download installer from ${dl_addr}" && warp 1)
else
inform "Looks like the installer is in place. Executing."
fi
run_wine "/tmp/${app_name}-Setup.exe"
fi
;;
"x"|"X") "x"|"X")
echo "Upgrading dxvk..." echo "Upgrading dxvk..."
nobs_mode="y" nobs_mode="y"
@ -277,44 +343,9 @@ while getopts ":g:G:p:P:a:A:dDvVsSbBwWtTnNcChHxX" option; do
winetricks --force dxvk winetricks --force dxvk
fi fi
;; ;;
"b"|"B") "z"|"Z")
echo "Running wineboot..." inform "DISPLAY set to ${OPTARG}"
nobs_mode="y" DISPLAY=${OPTARG}
if [ -d "${WINEPREFIX}" ]; then
echo "${WINEPREFIX} already exists! Refusing to wineboot."
else
if [ "${WINEDEBUG}" ]; then
wineboot > /dev/null 2>&1
else
wineboot
fi
fi
;;
"n"|"N")
inform "...with No BS..."
nobs_mode="y"
;;
"c"|"C")
echo "Running console..."
nobs_mode="y"
${console}
;;
"v"|"V")
if [ "${WINEDEBUG}" ]; then
if [ ! "${app_verbose}" ]; then
app_verbose="y"
#inform "Run verbose enabled"
inform "`realpath "${0}"` version ${script_ver} running as ${runas_user}"
fi
fi
;;
"t"|"T")
to_tray="--autostarted"
inform "Attempting hide to system tray"
;;
"h"|"H")
echo "${usage}"
warp 0
;; ;;
*) echo "Unknown option: -${OPTARG}" *) echo "Unknown option: -${OPTARG}"
echo "${usage}" echo "${usage}"

335
bn3t.sh
View File

@ -1,17 +1,17 @@
#!/bin/bash #!/bin/bash
## Copyright © 2018 Bret Human ## Copyright © 2018-2021 Bret Human
## https://cynicaloptimist.me/ ## https://cynop.me/
## ##
## Documentation at: ## Documentation at:
## https://mage.cynicaloptimist.me/en/bn3t ## https://mage.cynop.me/en/bn3t
## https://psi.cynicaloptimist.me/Caffarius/bn3t/ ## https://psi.cynop.me/Caffarius/bn3t/
## ##
## For questions or comments write: ## For questions or comments write:
## info@cynicaloptimist.me ## info@cynop.me
##################################################################### #####################################################################
# bn3t # bn3t
script_ver="0.1" script_ver="0.3.1"
page="https://mage.cynicaloptimist.me/en/bn3t" page="https://mage.cynop.me/en/bn3t"
# author: Bret Human # author: Bret Human
# date: Dec 6, 2018 # date: Dec 6, 2018
# #
@ -35,7 +35,7 @@ page="https://mage.cynicaloptimist.me/en/bn3t"
# ./bn3t.sh -u username -bxs # ./bn3t.sh -u username -bxs
# #
# Or I guess you could manually download the script from: # Or I guess you could manually download the script from:
dl_addr="https://psi.cynicaloptimist.me/Caffarius/bn3t/raw/branch/master/bn3t-run.sh" dl_addr="https://psi.cynop.me/Caffarius/bn3t/raw/branch/master/bn3t-run.sh"
##################################################################### #####################################################################
# #
# This is free software; you are free to change and redistribute it. # This is free software; you are free to change and redistribute it.
@ -46,25 +46,29 @@ dl_addr="https://psi.cynicaloptimist.me/Caffarius/bn3t/raw/branch/master/bn3t-ru
runas_user="`whoami`" runas_user="`whoami`"
app_name="Battle.net" app_name="Battle.net"
run_cmd="bn3t-run.sh" run_cmd="bn3t-run.sh"
jail_dir="/var/jail"
check_wait="3" check_wait="3"
usage="bn3t, version ${script_ver} usage="bn3t, version ${script_ver}
Usage: ./`basename ${0}` -g (game) -u (user) -p (prefix) -a (arch) -dvksbwtnchxi Usage: ./`basename ${0}` -g (game) -u (user) -p (prefix) -a (arch) -dvksbwtnchxi
-g | Launches the game of your choice
-u | Runs ${app_name} as the user specified
-p | Selects the location of the Wine prefix
-a | Selects the architecture to run as (32 | 64) -a | Selects the architecture to run as (32 | 64)
-d | Debug messages on (turns verbose on)
-v | Verbose messages on
-k | Kill all processes for a user (not current user or root)
-s | Runs ${app_name} setup
-b | Runs wineboot -b | Runs wineboot
-w | Runs winetricks
-t | Attempts to launch to the system tray
-n | No BS mode - doesn't launch an app (for boot/tricks/console safety)
-c | Launch a console session as specified user (can launch Xapps) -c | Launch a console session as specified user (can launch Xapps)
-d | Debug messages on (turns verbose on)
-g | Launches the game of your choice
-h | Help (this message) -h | Help (this message)
-x | Force upgrade DXVK
-i | Install the bn3t-run script for the specified user - mandantory -i | Install the bn3t-run script for the specified user - mandantory
-j | Run ${run_cmd} inside a chroot jail at ${jail_dir}
-k | Kill all processes for a user (not current user or root)
-m | Runs Twitch Client (for /M/ods - I'm running out of letters)
-n | No BS mode - doesn't launch an app (for boot/tricks/console safety)
-p | Selects the location of the Wine prefix
-s | Runs ${app_name} setup
-t | Attempts to launch to the system tray
-u | Runs ${app_name} as the user specified
-v | Verbose messages on
-w | Runs winetricks
-x | Force upgrade DXVK
-z | Set the DISPLAY variable used in ${run_cmd}
See more documentation at: ${page}" See more documentation at: ${page}"
# Catch CTRL+C and cleanup # Catch CTRL+C and cleanup
@ -78,13 +82,22 @@ function refresh {
function debug () { function debug () {
if [ "${app_debug}" ]; then if [ "${app_debug}" ]; then
echo "-D- ${1}" echo -e "-D- ${1}"
fi fi
} }
function inform () { function inform () {
if [ "${app_verbose}" ]; then if [ "${app_verbose}" ]; then
echo "--- ${1}" echo -e "--- ${1}"
fi
}
function buff_cmd_output () {
read cmd_input
cmd_output=$(eval "${cmd_input}")
if [ ! -z "${cmd_output}" ]; then
debug "${cmd_output}"
fi fi
} }
@ -123,14 +136,40 @@ function die () {
else else
if [ "${runas_user}" == "root" ]; then if [ "${runas_user}" == "root" ]; then
debug "Root? Madness. Just removing xhost then..." debug "Root? Madness. Just removing xhost then..."
inform "`xhost -SI:localuser:"${runas_user}"`" inform "`xhost -SI:localuser:root`"
else else
debug "Launched as ${runas_user}, killing processes" debug "Launched as ${runas_user}, killing processes and removing xhost..."
sudo -u "${runas_user}" -- bash -c "kill -9 -1" sudo -u "${runas_user}" -- bash -c "kill -9 -1"
inform "`xhost -SI:localuser:"${runas_user}"`" inform "`xhost -SI:localuser:"${runas_user}"`"
fi fi
fi fi
if [ "${jailbird}" == "1" ]; then
debug "Removing root from xhost..."
inform "`xhost -SI:localuser:root`"
debug "Delaying jail demolition..."
sleep 1
debug "Demolishing jail..."
echo "sudo rm ${jail_dir}/${runas_user}/bin 2>&1" | buff_cmd_output
echo "sudo rm ${jail_dir}/${runas_user}/sbin 2>&1" | buff_cmd_output
echo "sudo rm ${jail_dir}/${runas_user}/lib 2>&1" | buff_cmd_output
echo "sudo rm ${jail_dir}/${runas_user}/lib64 2>&1" | buff_cmd_output
echo "sudo umount -l ${jail_dir}/${runas_user}/usr 2>&1" | buff_cmd_output
echo "sudo umount -l ${jail_dir}/${runas_user}/etc 2>&1" | buff_cmd_output
echo "sudo umount -l ${jail_dir}/${runas_user}/tmp/pulse-socket 2>&1" | buff_cmd_output
echo "sudo umount -l ${jail_dir}/${runas_user}/dev 2>&1" | buff_cmd_output
echo "sudo umount -l ${jail_dir}/${runas_user}/proc 2>&1" | buff_cmd_output
echo "sudo umount -l ${jail_dir}/${runas_user}/sys 2>&1" | buff_cmd_output
echo "sudo umount -l ${jail_dir}/${runas_user}/run 2>&1" | buff_cmd_output
echo "sudo umount -l ${jail_dir}/${runas_user}/tmp 2>&1" | buff_cmd_output
echo "sudo umount -l ${jail_dir}/${runas_user}/var 2>&1" | buff_cmd_output
echo "sudo umount -l ${jail_dir}/${runas_user}/home/${runas_user} 2>&1" | buff_cmd_output
debug "Jail demolished."
fi
clean clean
unset clean unset clean
unset fizzle unset fizzle
@ -182,12 +221,18 @@ function check {
## Pick up any arguments provided ## Pick up any arguments provided
# None are required, we'll use default values. # None are required, we'll use default values.
launch_opt="" launch_opt=""
while getopts ":g:G:u:U:p:P:a:A:dDvVkKsSbBwWtTnNcChHxXiI" option; do while getopts ":a:A:g:G:p:P:u:U:z:Z:bBcCdDhHiIjJkKmMnNsStTvVwWxX" option; do
case "${option}" in case "${option}" in
"k"|"K") die 0;;
"g"|"G") launch_opt="${launch_opt} -g ${OPTARG}";;
"p"|"P") launch_opt="${launch_opt} -p ${OPTARG}";;
"a"|"A") launch_opt="${launch_opt} -a ${OPTARG}";; "a"|"A") launch_opt="${launch_opt} -a ${OPTARG}";;
"b"|"B")
inform "Wineboot mode"
launch_opt="${launch_opt} -b"
;;
"c"|"C")
inform "Console requested"
nobs_mode="y"
launch_opt="${launch_opt} -c"
;;
"d"|"D") "d"|"D")
if [ ! "${app_debug}" ]; then # Let's not do this too much... if [ ! "${app_debug}" ]; then # Let's not do this too much...
app_debug="y" app_debug="y"
@ -205,50 +250,10 @@ while getopts ":g:G:u:U:p:P:a:A:dDvVkKsSbBwWtTnNcChHxXiI" option; do
debug "" debug ""
fi fi
;; ;;
"w"|"W") "g"|"G") launch_opt="${launch_opt} -g ${OPTARG}";;
inform "Winetricks mode" "h"|"H")
launch_opt="${launch_opt} -w" echo "${usage}"
;; fizzle 0
"s"|"S")
inform "Setup mode"
nobs_mode="y"
launch_opt="${launch_opt} -s"
;;
"x"|"X")
inform "Force upgrading dxvk"
launch_opt="${launch_opt} -x"
;;
"b"|"B")
inform "Wineboot mode"
launch_opt="${launch_opt} -b"
;;
"n"|"N")
inform "No BS mode"
nobs_mode="y"
launch_opt="${launch_opt} -n"
;;
"c"|"C")
inform "Console requested"
nobs_mode="y"
launch_opt="${launch_opt} -c"
;;
"v"|"V")
if [ ! "${app_debug}" ]; then
if [ ! "${app_verbose}" ]; then
app_verbose="y"
inform "Verbose enabled"
inform "`realpath "${0}"` version ${script_ver} running as `whoami`"
launch_opt=" -v${launch_opt}"
fi
fi
;;
"t"|"T")
debug "Hiding to system tray"
launch_opt="${launch_opt} -t"
;;
"u"|"U")
debug "Setting user to ${OPTARG}"
runas_user="${OPTARG}"
;; ;;
"i"|"I") "i"|"I")
debug "User-side install requested" debug "User-side install requested"
@ -276,12 +281,58 @@ while getopts ":g:G:u:U:p:P:a:A:dDvVkKsSbBwWtTnNcChHxXiI" option; do
(echo "Failed to change permissions on ${app_dir}${run_cmd}" && fizzle 1) (echo "Failed to change permissions on ${app_dir}${run_cmd}" && fizzle 1)
fi fi
echo "Installed successfully." echo "Install process completed."
fizzle 0 fizzle 0
;; ;;
"h"|"H") "j"|"J")
echo "${usage}" debug "Running ${appname} in a chroot jail under ${jail_dir}/${runas_user}/"
fizzle 0 jailbird=1
;;
"k"|"K") die 0;;
"m"|"M")
inform "Twitch mode"
launch_opt="${launch_opt} -m"
;;
"n"|"N")
inform "No BS mode"
nobs_mode="y"
launch_opt="${launch_opt} -n"
;;
"p"|"P") launch_opt="${launch_opt} -p ${OPTARG}";;
"s"|"S")
inform "Setup mode"
nobs_mode="y"
launch_opt="${launch_opt} -s"
;;
"t"|"T")
debug "Hiding to system tray"
launch_opt="${launch_opt} -t"
;;
"u"|"U")
debug "Setting user to ${OPTARG}"
runas_user="${OPTARG}"
;;
"v"|"V")
if [ ! "${app_debug}" ]; then
if [ ! "${app_verbose}" ]; then
app_verbose="y"
inform "Verbose enabled"
inform "`realpath "${0}"` version ${script_ver} running as `whoami`"
launch_opt=" -v${launch_opt}"
fi
fi
;;
"w"|"W")
inform "Winetricks mode"
launch_opt="${launch_opt} -w"
;;
"x"|"X")
inform "Force upgrading dxvk"
launch_opt="${launch_opt} -x"
;;
"z"|"Z")
inform "Setting DISPLAY to ${OPTARG}"
launch_opt="${launch_opt} -z ${OPTARG}"
;; ;;
* ) echo "Unknown option: -${OPTARG}" * ) echo "Unknown option: -${OPTARG}"
echo "${usage}" echo "${usage}"
@ -300,11 +351,139 @@ if [ "`whoami`" == "${runas_user}" ]; then
debug "Launching as original user, going native" debug "Launching as original user, going native"
${app_dir}${run_cmd}${launch_opt} ${app_dir}${run_cmd}${launch_opt}
else else
debug "Launching as ${runas_user}, checking xhost" debug "Checking xhost"
if [ ! "`xhost | grep ${runas_user}`" ]; then if [ ! "`xhost | grep ${runas_user}`" ]; then
inform "`xhost +SI:localuser:"${runas_user}"`" inform "`xhost +SI:localuser:"${runas_user}"`"
fi fi
sudo -u "${runas_user}" -- dbus-launch ${app_dir}${run_cmd}${launch_opt}
if [ ! "${jailbird}" == "1" ]; then
# Just launch it as a regular secondary user app
debug "Launching as ${runas_user}..."
sudo -u "${runas_user}" -- dbus-launch ${app_dir}${run_cmd}${launch_opt}
else
# Hooooooowiiiiiiee. We're gonna build a jail!
if [ ! "`xhost | grep root`" ]; then
inform "`xhost +SI:localuser:root`"
fi
debug "Preparing ${runas_user}'s chroot environment..."
sudo mkdir -p ${jail_dir}/${runas_user}/tmp
sudo mkdir -p ${jail_dir}/${runas_user}/usr
sudo mkdir -p ${jail_dir}/${runas_user}/var
sudo mkdir -p ${jail_dir}/${runas_user}/proc
sudo mkdir -p ${jail_dir}/${runas_user}/sys
sudo mkdir -p ${jail_dir}/${runas_user}/dev
sudo mkdir -p ${jail_dir}/${runas_user}/run
sudo mkdir -p ${jail_dir}/${runas_user}/etc
sudo mkdir -p ${jail_dir}/${runas_user}/home/${runas_user}
if mountpoint ${jail_dir}/${runas_user}/tmp > /dev/null; then
debug "/tmp is already mounted?"
else
debug "Mounting /tmp..."
sudo mount -t tmpfs -o size=2G tmpfs ${jail_dir}/${runas_user}/tmp
fi
if mountpoint ${jail_dir}/${runas_user}/proc > /dev/null; then
debug "/proc is already mounted?"
else
debug "Mounting /proc..."
sudo mount --bind /proc ${jail_dir}/${runas_user}/proc
fi
if mountpoint ${jail_dir}/${runas_user}/sys > /dev/null; then
debug "/sys is already mounted?"
else
debug "Mounting /sys..."
sudo mount --bind /sys ${jail_dir}/${runas_user}/sys
fi
if mountpoint ${jail_dir}/${runas_user}/dev > /dev/null; then
debug "/dev is already mounted?"
else
debug "Mounting /dev..."
sudo mount --bind /dev ${jail_dir}/${runas_user}/dev
fi
if mountpoint ${jail_dir}/${runas_user}/run > /dev/null; then
debug "/run is already mounted?"
else
debug "Mounting /run..."
sudo mount --bind /run ${jail_dir}/${runas_user}/run
fi
if mountpoint ${jail_dir}/${runas_user}/var > /dev/null; then
debug "/var is already mounted?"
else
debug "Mounting /var..."
sudo mount --bind /var ${jail_dir}/${runas_user}/var
fi
if mountpoint ${jail_dir}/${runas_user}/etc > /dev/null; then
debug "/etc is already mounted?"
else
debug "Mounting /etc..."
sudo mount --bind /etc ${jail_dir}/${runas_user}/etc
fi
if mountpoint ${jail_dir}/${runas_user}/usr > /dev/null; then
debug "/usr is already mounted?"
else
debug "Mounting /usr..."
sudo mount --bind /usr ${jail_dir}/${runas_user}/usr
fi
if mountpoint ${jail_dir}/${runas_user}/home/${runas_user} > /dev/null; then
debug "/home/${runas_user} is already mounted?"
else
debug "Mounting /home/${runas_user}..."
sudo mount --bind /mnt/ace/home/${runas_user} ${jail_dir}/${runas_user}/home/${runas_user}
fi
if [ ! -d ${jail_dir}/${runas_user}/bin ]; then
debug "Linking /bin to usr/bin..."
sudo bash -c "cd ${jail_dir}/${runas_user}; ln -s usr/bin bin"
fi
if [ ! -d ${jail_dir}/${runas_user}/sbin ]; then
debug "Linking /sbin to usr/bin (that's not a typo!)..."
sudo bash -c "cd ${jail_dir}/${runas_user}; ln -s usr/bin sbin"
fi
if [ ! -d ${jail_dir}/${runas_user}/lib ]; then
debug "Linking /lib to usr/lib..."
sudo bash -c "cd ${jail_dir}/${runas_user}; ln -s usr/lib lib"
fi
if [ ! -d ${jail_dir}/${runas_user}/lib64 ]; then
debug "Linking /lib64 to usr/lib (that's not a typo!)..."
sudo bash -c "cd ${jail_dir}/${runas_user}; ln -s usr/lib lib64"
fi
if [ ! -S ${jail_dir}/${runas_user}/tmp/pulse-socket ]; then
if [ ! -f ${jail_dir}/${runas_user}/tmp/pulse-socket ]; then
debug "Creating /tmp/pulse-socket to link sound..."
sudo -u ${runas_user} touch ${jail_dir}/${runas_user}/tmp/pulse-socket
fi
if mountpoint ${jail_dir}/${runas_user}/tmp/pulse-socket > /dev/null; then
debug "/tmp/pulse-socket is already mounted?"
else
debug "Mounting /tmp/pulse-socket..."
sudo mount --bind /tmp/pulse-socket ${jail_dir}/${runas_user}/tmp/pulse-socket
fi
else
debug "/tmp/pulse-socket is already a socket?"
fi
debug "...chroot prepared."
debug "Launching as ${runas_user} jailed inside ${jail_dir}/${runas_user}/..."
sudo -u root -- chroot ${jail_dir}/${runas_user}/ sudo -u ${runas_user} dbus-launch ${app_dir}${run_cmd}${launch_opt}
fi
debug "...returned to wrapper."
fi fi
@ -314,4 +493,4 @@ debug "Final Notice"
if [ "${app_check}" ]; then if [ "${app_check}" ]; then
check check
fizzle 0 fizzle 0
fi fi