Last active
August 30, 2018 18:18
-
-
Save air/20a0c985b23684f5f6df to your computer and use it in GitHub Desktop.
Setup script to run Steam on Chromebook using a library on an external SD card.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o nounset | |
# 2016-01-02 updated to use whichever device the card is mounted on. | |
# 2016-07-28 update to use ext4 or fuseblk | |
# Params | |
#-------------------------------------------------------------------- | |
# 1. where ChromeOS mounts your SD card | |
sd_mount="/var/host/media/removable/SD Card" | |
# 2. where you want to mount your card with custom flags | |
custom_sd_mount="/home/air/sdcard" | |
# 3. replace ext4 as appropriate with one of: vfat,fuseblk | |
sd_format="ext4" | |
# Derived params | |
#-------------------------------------------------------------------- | |
default_mount="${sd_mount}/steamapps" | |
home_mount="${custom_sd_mount}/steamapps" | |
# Clean up orphaned mounts | |
#-------------------------------------------------------------------- | |
mount | grep "${custom_sd_mount}" >/dev/null | |
if [[ $? -eq 0 ]]; then | |
# Our custom mount is in the mount table. Check if we can 'ls' in it | |
ls ${custom_sd_mount} >/dev/null 2>&1 | |
if [[ ! $? -eq 0 ]]; then | |
echo "Orphaned mount detected: ${custom_sd_mount}" | |
umount ${custom_sd_mount} | |
if [[ $? -eq 0 ]]; then | |
echo "Unmount succeeded for ${custom_sd_mount}" | |
else | |
echo "Unmount failed, run with sudo" | |
exit 5 | |
fi | |
fi | |
fi | |
# Set up the normal mount if needed, since Chrome 38 removed automounting of ext4. | |
# https://code.google.com/p/chromium/issues/detail?id=315401 | |
# After Chrome 38 this is unused, the "SD Card" mount will be present. | |
#-------------------------------------------------------------------- | |
# mount | grep "${sd_mount}" >/dev/null | |
# if [[ ! $? -eq 0 ]]; then | |
# echo "Could not find default SD mount ${sd_mount}, mounting" | |
# mount ${sd_device} "${sd_mount}" | |
# if [[ ! $? -eq 0 ]]; then | |
# echo "Abort, failed to mount card." | |
# exit 1 | |
# fi | |
# mount_proof=$(mount | grep ${sd_device}) | |
# echo "Mounted SD as ${mount_proof}" | |
# fi | |
# If SD card is plugged in, get the device name | |
#-------------------------------------------------------------------- | |
card_mount=`mount | grep "${sd_mount}"` | |
if [[ -z "${card_mount}" ]]; then | |
echo "Abort: Could not find SD device ${sd_mount}, card not plugged in" | |
exit 6 | |
fi | |
sd_device=`echo ${card_mount} | cut -f1 -d' '` | |
echo "SD device is ${sd_device}" | |
# check Steam and make our custom mount if needed | |
#-------------------------------------------------------------------- | |
if [[ ! -d "${default_mount}" ]]; then | |
echo "Abort: Could not find Steam in default location ${default_mount}" | |
exit 3 | |
fi | |
if [[ ! -d "${home_mount}" ]]; then | |
# mount SD card in home dir with exec permissions | |
mount -t ${sd_format} -o defaults,nosuid,nodev ${sd_device} ${custom_sd_mount} | |
if [[ ! -d "${home_mount}" ]]; then | |
echo "Abort: Executed mount with type ${sd_format} but can't find home mount ${home_mount}" | |
exit 4 | |
else | |
echo "SteamApps is now mounted to ${home_mount}" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment