Skip to content

Commit

Permalink
Merge pull request #201 from t0b10-r3tr0/bind_function_enhancements
Browse files Browse the repository at this point in the history
Implement bind_files function, add directory check to bind_directories
  • Loading branch information
kloptops authored Dec 12, 2024
2 parents 67b29a3 + 40213dd commit 1d867a0
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions PortMaster/funcs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,49 @@ fi

bind_directories() {
# Usage: bind_directories ~/.config/StardewValley $GAMEDIR/savedata
#
#
# Reason: some platforms (batocera) use exfat for the home directory, so we can't use symbolic links
# We then instead use bind mount, however retrodeck cannot bind mount because it does not run in root.
#
if [ "$PM_CAN_MOUNT" = "Y" ]; then
[[ -L "$1" ]] && rm -f "$1"
mkdir -p "$1"
$ESUDO umount "$1"
$ESUDO mount --bind "$2" "$1"
[[ -L "$1" ]] && rm -f "$1" && echo "removed previous symlink $1"
# Ensure the directory exists before attempting the bind mount
if [ -d "$2" ]; then
mkdir -p "$1"
$ESUDO umount "$1"
$ESUDO mount --bind "$2" "$1" && echo "successful bind mount from $2 to $1"
else
echo "no directory found at $2"
fi
else
# RetroDECK cant use bind mount without root.
rm -f "$1"
ln -sfv "$2" "$1"
fi
}

bind_files() {
# Usage: bind_files ~/.config_file $GAMEDIR/conf/.config_file
#
# Reason: some platforms (batocera) use exfat for the home directory, so we can't use symbolic links
# We then instead use bind mount, however retrodeck cannot bind mount because it does not run in root.
#
if [ "$PM_CAN_MOUNT" = "Y" ]; then
[[ -L "$1" ]] && rm -f "$1" && echo "removed previous symlink $1"
# Ensure the file exists before attempting the bind mount
if [ -f "$2" ]; then
touch "$1"
$ESUDO umount "$1"
$ESUDO mount --bind "$2" "$1" && echo "successful bind mount from $2 to $1"
else
echo "no file found at $2"
fi
else
# RetroDECK cant use bind mount without root.
rm -f "$1"
ln -sfv "$2" "$1"
fi
}

pm_begin_splash() {
# Usage: pm_begin_splash
Expand Down

0 comments on commit 1d867a0

Please sign in to comment.