mirror of
https://github.com/ublue-os/bazzite.git
synced 2025-02-21 18:40:00 +00:00
chore: Remove now unneeded files
This commit is contained in:
parent
14c6732085
commit
0944aa3f46
@ -1,83 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
exec &> >(tee | logger -t steamos-format-device)
|
||||
|
||||
RUN_VALIDATION=1
|
||||
EXTENDED_OPTIONS="nodiscard"
|
||||
# default owner for the new filesystem
|
||||
OWNER="1000:1000"
|
||||
|
||||
OPTS=$(getopt -l force,skip-validation,full,quick,owner:,device: -n format-device.sh -- "" "$@")
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
--force) RUN_VALIDATION=0; shift ;;
|
||||
--skip-validation) RUN_VALIDATION=0; shift ;;
|
||||
--full) EXTENDED_OPTIONS="discard"; shift ;;
|
||||
--quick) EXTENDED_OPTIONS="nodiscard"; shift ;;
|
||||
--owner) OWNER="$2"; shift 2;;
|
||||
--device) STORAGE_DEVICE="$2"; shift 2 ;;
|
||||
--) shift; break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "$#" -gt 0 ]]; then
|
||||
echo "Unknown option $1"; exit 22
|
||||
fi
|
||||
|
||||
EXTENDED_OPTIONS="$EXTENDED_OPTIONS,root_owner=$OWNER"
|
||||
|
||||
STORAGE_PARTITION="${STORAGE_DEVICE}p1"
|
||||
|
||||
if [[ ! -e "$STORAGE_DEVICE" ]]; then
|
||||
exit 19 #ENODEV
|
||||
fi
|
||||
|
||||
STORAGE_PARTBASE="${STORAGE_PARTITION#/dev/}"
|
||||
|
||||
systemctl stop steamos-automount@"$STORAGE_PARTBASE".service
|
||||
|
||||
# If any partitions on the device are mounted, unmount them before continuing
|
||||
# to prevent problems later
|
||||
for m in $(lsblk -n "$STORAGE_DEVICE" -o MOUNTPOINTS| awk NF | sort -u); do
|
||||
if ! umount "$m"; then
|
||||
echo "Failed to unmount filesystem: $m"
|
||||
exit 32 # EPIPE
|
||||
fi
|
||||
done
|
||||
|
||||
# Test the sdcard
|
||||
# Some fake cards advertise a larger size than their actual capacity,
|
||||
# which can result in data loss or other unexpected behaviour. It is
|
||||
# best to try to detect these issues as early as possible.
|
||||
if [[ "$RUN_VALIDATION" != "0" ]]; then
|
||||
echo "stage=testing"
|
||||
fi
|
||||
|
||||
# Format as EXT4 with casefolding for proton compatibility
|
||||
echo "stage=formatting"
|
||||
sync
|
||||
parted --script "$STORAGE_DEVICE" mklabel gpt mkpart primary 0% 100%
|
||||
sync
|
||||
mkfs.btrfs -f -K "$STORAGE_PARTITION"
|
||||
MOUNT_DIR="/var/run/sdcard-mount"
|
||||
mkdir -p "$MOUNT_DIR"
|
||||
mount -o "rw,noatime,lazytime,compress-force=zstd,space_cache=v2,autodefrag,ssd_spread" "$STORAGE_PARTITION" "$MOUNT_DIR"
|
||||
btrfs subvolume create "$MOUNT_DIR/@"
|
||||
btrfs subvolume set-default "$MOUNT_DIR/@"
|
||||
umount -l "$MOUNT_DIR"
|
||||
rmdir "$MOUNT_DIR"
|
||||
sync
|
||||
udevadm settle
|
||||
|
||||
# trigger the mount service
|
||||
if ! systemctl start steamos-automount@"$STORAGE_PARTBASE".service; then
|
||||
echo "Failed to start mount service"
|
||||
journalctl --no-pager --boot=0 -u steamos-automount@"$STORAGE_PARTBASE".service
|
||||
exit 5
|
||||
fi
|
||||
|
||||
exit 0
|
@ -1,143 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Originally from https://serverfault.com/a/767079
|
||||
|
||||
# This script is called from our systemd unit file to mount or unmount
|
||||
# a USB drive.
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "Usage: $0 {add|remove} device_name (e.g. sdb1)"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [[ $# -ne 2 ]]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
ACTION=$1
|
||||
DEVBASE=$2
|
||||
DEVICE="/dev/${DEVBASE}"
|
||||
|
||||
# Wait N seconds for steam
|
||||
wait_steam()
|
||||
{
|
||||
local i=0
|
||||
local wait=$1
|
||||
echo "Waiting up to $wait seconds for steam to load"
|
||||
while ! pgrep -x steamwebhelper &>/dev/null && (( i++ < wait )); do
|
||||
sleep 1
|
||||
done
|
||||
}
|
||||
|
||||
send_steam_url()
|
||||
{
|
||||
local command="$1"
|
||||
local arg="$2"
|
||||
local encoded=$(urlencode "$arg")
|
||||
if pgrep -x "steam" > /dev/null; then
|
||||
# TODO use -ifrunning and check return value - if there was a steam process and it returns -1, the message wasn't sent
|
||||
# need to retry until either steam process is gone or -ifrunning returns 0, or timeout i guess
|
||||
systemd-run -M 1000@ --user --collect --wait sh -c "./.steam/root/ubuntu12_32/steam steam://${command}/${encoded@Q}"
|
||||
echo "Sent URL to steam: steam://${command}/${arg} (steam://${command}/${encoded})"
|
||||
else
|
||||
echo "Could not send steam URL steam://${command}/${arg} (steam://${command}/${encoded}) -- steam not running"
|
||||
fi
|
||||
}
|
||||
|
||||
# From https://gist.github.com/HazCod/da9ec610c3d50ebff7dd5e7cac76de05
|
||||
urlencode()
|
||||
{
|
||||
[ -z "$1" ] || echo -n "$@" | hexdump -v -e '/1 "%02x"' | sed 's/\(..\)/%\1/g'
|
||||
}
|
||||
|
||||
do_mount()
|
||||
{
|
||||
# Prior to talking to udisks, we need all udev hooks (we were started by one) to finish, so we know it has knowledge
|
||||
# of the drive. Our own rule starts us as a service with --no-block, so we can wait for rules to settle here
|
||||
# safely.
|
||||
if ! udevadm settle; then
|
||||
echo "Failed to wait for \`udevadm settle\`"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mount_point=/mnt/sdcard
|
||||
if [[ ! -d "${mount_point}" ]]; then
|
||||
mkdir -p "${mount_point}"
|
||||
/bin/mount "${DEVICE}" "${mount_point}"
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "Error mounting ${DEVICE}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Workaround for for Steam compression bug
|
||||
for d in "${mount_point}"/steamapps/{downloading,temp} ; do
|
||||
if ! btrfs subvolume show "$d" &>/dev/null; then
|
||||
mkdir -p "$d"
|
||||
rm -rf "$d"
|
||||
btrfs subvolume create "$d"
|
||||
chattr +C "$d"
|
||||
chown 1000:1000 "${d%/*}" "$d"
|
||||
fi
|
||||
done
|
||||
|
||||
# backwards compatibility
|
||||
if [[ "${DEVBASE}" == 'mmcblk0p1' ]]; then
|
||||
mkdir -p /run/media
|
||||
ln -sfT "${mount_point}" /run/media/mmcblk0p1
|
||||
fi
|
||||
|
||||
chown 1000:1000 -- "${mount_point}"
|
||||
|
||||
echo "**** Mounted ${DEVICE} at ${mount_point} ****"
|
||||
|
||||
# If Steam is running, notify it
|
||||
send_steam_url "addlibraryfolder" "${mount_point}"
|
||||
}
|
||||
|
||||
do_unmount()
|
||||
{
|
||||
# If Steam is running, notify it
|
||||
local mount_point=/mnt/sdcard
|
||||
send_steam_url "removelibraryfolder" "${mount_point}"
|
||||
# Remove symlink to the mount point that we're unmounting
|
||||
find /run/media -maxdepth 1 -xdev -type l -lname "${mount_point}" -exec rm -- {} \;
|
||||
if [[ -L /run/media/mmcblk0p1 && "$(realpath /run/media/mmcblk0p1)" == "$(realpath "${mount_point}")" ]]; then
|
||||
rm -f /run/media/mmcblk0p1
|
||||
fi
|
||||
if mountpoint -q "${mount_point}"/steamapps/compatdata; then
|
||||
/bin/umount -l -R "${mount_point}"/steamapps/compatdata
|
||||
fi
|
||||
/bin/umount "${mount_point}"
|
||||
}
|
||||
|
||||
do_retrigger()
|
||||
{
|
||||
local mount_point=/mnt/sdcard
|
||||
[[ -n $mount_point ]] || return 0
|
||||
|
||||
# In retrigger mode, we want to wait a bit for steam as the common pattern is starting in parallel with a retrigger
|
||||
wait_steam 10
|
||||
# This is a truly gnarly way to ensure steam is ready for commands.
|
||||
# TODO literally anything else
|
||||
sleep 6
|
||||
send_steam_url "addlibraryfolder" "${mount_point}"
|
||||
}
|
||||
|
||||
case "${ACTION}" in
|
||||
add)
|
||||
do_mount
|
||||
;;
|
||||
remove)
|
||||
do_unmount
|
||||
;;
|
||||
retrigger)
|
||||
do_retrigger
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
@ -1,6 +0,0 @@
|
||||
# Originally from https://serverfault.com/a/767079
|
||||
# Run a mount script through systemd on any mmcblk0p* and sd[a-z]* activity
|
||||
|
||||
# The service expects to be asynchronous and shouldn't block udev rules
|
||||
KERNEL=="mmcblk0p[0-9]", ACTION=="add", RUN+="/bin/systemctl start --no-block steamos-automount@%k.service"
|
||||
KERNEL=="mmcblk0p[0-9]", ACTION=="remove", RUN+="/bin/systemctl stop --no-block steamos-automount@%k.service"
|
Loading…
x
Reference in New Issue
Block a user