Skip to content

Commit cb24243

Browse files
author
twojstaryzdomu
committed
Refactor runcommand.sh's output directory into a global variable and use /tmp as fallback
This is to allow another directory for runcommand.sh outputs for cases when output are worth preserving (i.e. crash). Also, /dev/shm may not be accessible on all environments, for user discretionary reasons. When /dev/shm doesn't exist or isn't writable, Fall back to /tmp.
1 parent 9cb9e56 commit cb24243

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

scriptmodules/supplementary/runcommand/runcommand.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@
7979

8080
ROOTDIR="/opt/retropie"
8181
CONFIGDIR="$ROOTDIR/configs"
82-
LOG="/dev/shm/runcommand.log"
82+
OUTPUTDIR="/dev/shm"
83+
[ -d "${OUTPUTDIR}" ] \
84+
&& [ -w "${OUTPUTDIR}" ] \
85+
|| OUTPUTDIR=/tmp
86+
LOG="${OUTPUTDIR}/runcommand.log"
8387

8488
RUNCOMMAND_CONF="$CONFIGDIR/all/runcommand.cfg"
8589
VIDEO_CONF="$CONFIGDIR/all/videomodes.cfg"
@@ -929,7 +933,7 @@ function switch_fb_res() {
929933

930934
function build_xinitrc() {
931935
local mode="$1"
932-
local xinitrc="/dev/shm/retropie_xinitrc"
936+
local xinitrc="${OUTPUTDIR}/retropie_xinitrc"
933937

934938
case "$mode" in
935939
clear)
@@ -1068,7 +1072,7 @@ function config_backend() {
10681072
}
10691073
10701074
function retroarch_append_config() {
1071-
local conf="/dev/shm/retroarch.cfg"
1075+
local conf="${OUTPUTDIR}/retroarch.cfg"
10721076
local dim
10731077
10741078
# only for retroarch emulators
@@ -1317,7 +1321,7 @@ function launch_command() {
13171321
}
13181322
13191323
function log_info() {
1320-
echo -e "$SYSTEM\n$EMULATOR\n$ROM\n$COMMAND" >/dev/shm/runcommand.info
1324+
echo -e "$SYSTEM\n$EMULATOR\n$ROM\n$COMMAND" >${OUTPUTDIR}/runcommand.info
13211325
}
13221326
13231327
function runcommand() {

0 commit comments

Comments
 (0)