Holiday chroot edition
This commit is contained in:
parent
5b28f61aee
commit
063e205f6c
169
bn3t-run.sh
169
bn3t-run.sh
|
@ -10,7 +10,7 @@
|
|||
## info@cynicaloptimist.me
|
||||
#####################################################################
|
||||
# bn3t-run
|
||||
script_ver="0.2"
|
||||
script_ver="0.3"
|
||||
page="https://mage.cynicaloptimist.me/en/bn3t"
|
||||
# author: Bret Human
|
||||
# date: Dec 6, 2018
|
||||
|
@ -44,20 +44,21 @@ app_loc="/Battle.net/Battle.net.exe"
|
|||
console="bash"
|
||||
usage="bn3t-run, version ${script_ver}
|
||||
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)
|
||||
-d | Debug messages on (turns verbose on)
|
||||
-v | Verbose messages on
|
||||
-s | Runs ${app_name} setup
|
||||
-b | Runs wineboot
|
||||
-w | Runs winetricks
|
||||
-m | Runs Twitch client
|
||||
-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)
|
||||
-d | Debug messages on (turns verbose on)
|
||||
-g | Launches the game of your choice
|
||||
-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
|
||||
-z | Set the DISPLAY variable
|
||||
See more documentation at: ${page}"
|
||||
|
||||
# Catch CTRL+C and cleanup
|
||||
|
@ -65,12 +66,14 @@ trap "echo '' && inform '---------------------------------' && inform 'Caught CT
|
|||
|
||||
## Set default environment
|
||||
cd /home/"${runas_user}"
|
||||
export RADV_PERFTEST=aco
|
||||
export WINEPREFIX="/home/${runas_user}/.bnet"
|
||||
export HOME="/home/${runas_user}"
|
||||
export USER="${runas_user}"
|
||||
export USERNAME="${runas_user}"
|
||||
export LOGNAME="${runas_user}"
|
||||
export WINEDEBUG=-all
|
||||
#export WINEDLLOVERRIDES="winemenubuilder.exe=d"
|
||||
export XAUTHORITY="/home/${runas_user}/.Xauthority"
|
||||
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/sbin"
|
||||
unset OLDPWD
|
||||
|
@ -79,6 +82,8 @@ unset SUDO_COMMAND
|
|||
unset SUDO_USER
|
||||
unset SUDO_UID
|
||||
|
||||
|
||||
|
||||
## Define our functions
|
||||
function debug () {
|
||||
if [ ! "${WINEDEBUG}" ]; then
|
||||
|
@ -92,6 +97,13 @@ function inform () {
|
|||
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 {
|
||||
debug "clean"
|
||||
|
||||
|
@ -111,6 +123,7 @@ function clean {
|
|||
unset game_name
|
||||
unset game_start
|
||||
unset to_tray
|
||||
unset DISPLAY
|
||||
|
||||
# Func
|
||||
unset debug
|
||||
|
@ -225,9 +238,29 @@ function run_wine () {
|
|||
|
||||
|
||||
## Pick up any arguments provided
|
||||
while getopts ":g:G:p:P:a:A:dDvVsSbBwWtTnNcChHxXmM" option; do
|
||||
while getopts ":a:A:g:G:p:P:bBcCdDhHmMnNsStTvVwWxXzZ" option; do
|
||||
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")
|
||||
if [ "${WINEDEBUG}" ]; then
|
||||
unset WINEDEBUG
|
||||
|
@ -236,13 +269,10 @@ while getopts ":g:G:p:P:a:A:dDvVsSbBwWtTnNcChHxXmM" option; do
|
|||
app_verbose="y"
|
||||
fi
|
||||
;;
|
||||
"p"|"P") export WINEPREFIX="${OPTARG}";;
|
||||
"a"|"A")
|
||||
case "${OPTARG}" in
|
||||
32) export WINEARCH=win32;;
|
||||
64) export WINEARCH=win64;;
|
||||
*) inform "Weird architecture: ${OPTARG}, ignoring";;
|
||||
esac
|
||||
"g"|"G") game_launch="${OPTARG}";;
|
||||
"h"|"H")
|
||||
echo "${usage}"
|
||||
warp 0
|
||||
;;
|
||||
"m"|"M")
|
||||
echo "Running Twitch Client..."
|
||||
|
@ -252,12 +282,47 @@ while getopts ":g:G:p:P:a:A:dDvVsSbBwWtTnNcChHxXmM" option; do
|
|||
wine C:\\users\\${runas_user}\\Application\ Data\\Twitch\\Bin\\Twitch.exe
|
||||
else
|
||||
inform "...but it helps to install it first..."
|
||||
if [ ! -f "/tmp/TwitchSetup.exe" ]; then
|
||||
inform "/tmp/TwitchSetup.exe was not found. Retreiving."
|
||||
wget -O "/tmp/TwitchSetup.exe" "${tc_addr}" ||
|
||||
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 "/tmp/TwitchSetup.exe"
|
||||
wine "${WINEPREFIX}/drive_c/TwitchSetup.exe"
|
||||
fi
|
||||
;;
|
||||
"n"|"N")
|
||||
inform "...with No BS..."
|
||||
nobs_mode="y"
|
||||
;;
|
||||
"p"|"P") export WINEPREFIX="${OPTARG}";;
|
||||
"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 "${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")
|
||||
|
@ -269,23 +334,6 @@ while getopts ":g:G:p:P:a:A:dDvVsSbBwWtTnNcChHxXmM" option; do
|
|||
winetricks
|
||||
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")
|
||||
echo "Upgrading dxvk..."
|
||||
nobs_mode="y"
|
||||
|
@ -295,44 +343,9 @@ while getopts ":g:G:p:P:a:A:dDvVsSbBwWtTnNcChHxXmM" option; do
|
|||
winetricks --force dxvk
|
||||
fi
|
||||
;;
|
||||
"b"|"B")
|
||||
echo "Running wineboot..."
|
||||
nobs_mode="y"
|
||||
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
|
||||
"z"|"Z")
|
||||
inform "DISPLAY set to ${OPTARG}"
|
||||
DISPLAY=${OPTARG}
|
||||
;;
|
||||
*) echo "Unknown option: -${OPTARG}"
|
||||
echo "${usage}"
|
||||
|
|
326
bn3t.sh
326
bn3t.sh
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
## Copyright © 2018 Bret Human
|
||||
## Copyright © 2018-2020 Bret Human
|
||||
## https://cynicaloptimist.me/
|
||||
##
|
||||
## Documentation at:
|
||||
|
@ -10,7 +10,7 @@
|
|||
## info@cynicaloptimist.me
|
||||
#####################################################################
|
||||
# bn3t
|
||||
script_ver="0.2"
|
||||
script_ver="0.3"
|
||||
page="https://mage.cynicaloptimist.me/en/bn3t"
|
||||
# author: Bret Human
|
||||
# date: Dec 6, 2018
|
||||
|
@ -46,26 +46,29 @@ dl_addr="https://psi.cynicaloptimist.me/Caffarius/bn3t/raw/branch/master/bn3t-ru
|
|||
runas_user="`whoami`"
|
||||
app_name="Battle.net"
|
||||
run_cmd="bn3t-run.sh"
|
||||
jail_dir="/var/jail"
|
||||
check_wait="3"
|
||||
usage="bn3t, version ${script_ver}
|
||||
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)
|
||||
-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
|
||||
-w | Runs winetricks
|
||||
-m | Runs Twitch Client (for /M/ods - I'm running out of letters)
|
||||
-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)
|
||||
-d | Debug messages on (turns verbose on)
|
||||
-g | Launches the game of your choice
|
||||
-h | Help (this message)
|
||||
-x | Force upgrade DXVK
|
||||
-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}"
|
||||
|
||||
# Catch CTRL+C and cleanup
|
||||
|
@ -79,13 +82,22 @@ function refresh {
|
|||
|
||||
function debug () {
|
||||
if [ "${app_debug}" ]; then
|
||||
echo "-D- ${1}"
|
||||
echo -e "-D- ${1}"
|
||||
fi
|
||||
}
|
||||
|
||||
function inform () {
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -124,14 +136,40 @@ function die () {
|
|||
else
|
||||
if [ "${runas_user}" == "root" ]; then
|
||||
debug "Root? Madness. Just removing xhost then..."
|
||||
inform "`xhost -SI:localuser:"${runas_user}"`"
|
||||
inform "`xhost -SI:localuser:root`"
|
||||
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"
|
||||
inform "`xhost -SI:localuser:"${runas_user}"`"
|
||||
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
|
||||
unset clean
|
||||
unset fizzle
|
||||
|
@ -183,12 +221,18 @@ function check {
|
|||
## Pick up any arguments provided
|
||||
# None are required, we'll use default values.
|
||||
launch_opt=""
|
||||
while getopts ":g:G:u:U:p:P:a:A:dDvVkKsSbBwWtTnNcChHxXiImM" option; do
|
||||
while getopts ":a:A:g:G:p:P:u:U:z:Z:bBcCdDhHiIjJkKmMnNsStTvVwWxX" option; do
|
||||
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}";;
|
||||
"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")
|
||||
if [ ! "${app_debug}" ]; then # Let's not do this too much...
|
||||
app_debug="y"
|
||||
|
@ -206,54 +250,10 @@ while getopts ":g:G:u:U:p:P:a:A:dDvVkKsSbBwWtTnNcChHxXiImM" option; do
|
|||
debug ""
|
||||
fi
|
||||
;;
|
||||
"w"|"W")
|
||||
inform "Winetricks mode"
|
||||
launch_opt="${launch_opt} -w"
|
||||
;;
|
||||
"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"
|
||||
;;
|
||||
"m"|"M")
|
||||
inform "Twitch mode"
|
||||
launch_opt="${launch_opt} -m"
|
||||
;;
|
||||
"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}"
|
||||
"g"|"G") launch_opt="${launch_opt} -g ${OPTARG}";;
|
||||
"h"|"H")
|
||||
echo "${usage}"
|
||||
fizzle 0
|
||||
;;
|
||||
"i"|"I")
|
||||
debug "User-side install requested"
|
||||
|
@ -281,12 +281,58 @@ while getopts ":g:G:u:U:p:P:a:A:dDvVkKsSbBwWtTnNcChHxXiImM" option; do
|
|||
(echo "Failed to change permissions on ${app_dir}${run_cmd}" && fizzle 1)
|
||||
fi
|
||||
|
||||
echo "Installed successfully."
|
||||
echo "Install process completed."
|
||||
fizzle 0
|
||||
;;
|
||||
"h"|"H")
|
||||
echo "${usage}"
|
||||
fizzle 0
|
||||
"j"|"J")
|
||||
debug "Running ${appname} in a chroot jail under ${jail_dir}/${runas_user}/"
|
||||
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 "${usage}"
|
||||
|
@ -305,11 +351,139 @@ if [ "`whoami`" == "${runas_user}" ]; then
|
|||
debug "Launching as original user, going native"
|
||||
${app_dir}${run_cmd}${launch_opt}
|
||||
else
|
||||
debug "Launching as ${runas_user}, checking xhost"
|
||||
debug "Checking xhost"
|
||||
if [ ! "`xhost | grep ${runas_user}`" ]; then
|
||||
inform "`xhost +SI:localuser:"${runas_user}"`"
|
||||
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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue