79 Commits
Author SHA1 Message Date
scawp a32922d702 Merge pull request #28 from scawp/ext4-fix
Ext4 fix
2023-11-24 00:05:00 +01:00
scawp d27b178dba Add Reboot to install 2023-11-23 23:49:49 +01:00
scawp c6179033b2 Updated Readme 2023-11-23 17:26:50 +01:00
scawp f674ad76dc Changed tab to spaces 2023-11-23 17:18:20 +01:00
scawp abd7b301ac Added Support for ext4 and changed to override existing rule 2023-11-23 17:16:49 +01:00
scawp de97181d48 Update README.md 2023-11-23 16:39:43 +01:00
scawp 40d9dc1460 Update README.md 2023-11-23 16:36:47 +01:00
scawp c085619ef8 Update README.md 2023-10-12 23:19:16 +02:00
scawp acc2e5d94a Update README.md to plug channel
Maybe if I move this someone will finally subscribe ;)
2023-10-11 22:55:07 +02:00
scawp ae033667f9 Update README.md 2023-10-11 22:11:32 +02:00
scawp 12af3862eb Merge pull request #25 from scawp/update
Update
2023-10-11 22:10:22 +02:00
scawp caa5e85aa7 renamed rule to run before steams to avoid conflict 2023-10-11 21:19:13 +02:00
scawp 2ce8a29318 Updated with support for other file systems 2023-10-11 21:16:56 +02:00
scawp c4f617ca79 remove zMount install 2023-10-07 00:53:16 +02:00
scawp 6bfc08fac9 Merge pull request #24 from scawp/post-3.5
Post 3.5
2023-10-07 00:51:38 +02:00
scawp 57381447c8 Update README.md 2023-10-07 00:50:51 +02:00
scawp 7b107b5233 Update README.md 2023-10-07 00:49:33 +02:00
scawp e0be5491ad add Mount ability for NTFS SD/External/Internal-Partition 2023-10-07 00:35:50 +02:00
scawp 2e4f81e785 Update README.md 2023-10-06 09:25:36 +02:00
scawp 1068b31d2b Fixed bad merge 2022-09-30 08:21:26 +02:00
scawp 5cb035c9d8 Update README.md 2022-09-30 00:03:17 +02:00
scawp c3f735e660 Merge pull request #11 from scawp/Readd-zMount
changed to add any folder called SteamLibrary
2022-09-30 00:01:52 +02:00
scawp ce806669b0 Merge branch 'main' into Readd-zMount 2022-09-30 00:01:44 +02:00
scawp aa8bab290a changed to add any folder called SteamLibrary 2022-09-29 23:59:42 +02:00
scawp 81a4f6794d Should have tested this more.... 2022-09-29 21:53:31 +02:00
scawp fee7e90ef2 Merge pull request #10 from scawp/Readd-zMount
Fix for #6 now also auto adds steam library or creates and adds if not exists
2022-09-29 21:46:03 +02:00
scawp 726aa18d80 README update 2022-09-29 21:35:42 +02:00
scawp e9db8ee745 Merge pull request #9 from scawp/main
merge main
2022-09-29 21:19:14 +02:00
scawp 88ad8caa7c Stole add library code from Valve, thx 2022-09-29 21:17:15 +02:00
scawp ed934766ec Update README.md 2022-09-27 22:44:23 +02:00
scawp 836fae8530 Merge pull request #8 from scawp/Readd-zMount
Re-added manual zMount GUI
2022-09-27 22:42:30 +02:00
scawp 718524076d Prep for merge to main 2022-09-27 22:40:29 +02:00
scawp aa200d97f8 Delete install_automount.sh 2022-09-27 22:35:47 +02:00
scawp 5492959915 Update README.md 2022-09-27 22:32:11 +02:00
scawp fc4dd2b2b3 removed logging 2022-09-27 16:47:29 +02:00
scawp 83036b014c change url for testing 2022-09-27 16:45:54 +02:00
scawp af34293d97 added zmount to install, added auto add to steam library 2022-09-27 09:55:25 +02:00
scawp ee6033b32a readded a slimmed down zMount.sh 2022-09-27 09:31:28 +02:00
scawp 348dc32486 Merge branch 'Merge' into Quick-Auto-Mount-Only 2022-09-27 08:59:05 +02:00
scawp 5b2f51faf2 This is still required. PS Stop coding in main 2022-09-22 13:12:39 +02:00
scawp 39398d549f undoing mess i just made 2022-09-22 12:58:00 +02:00
scawp 4af9f2a912 whoops missed renaming install dir 2022-09-22 12:52:52 +02:00
scawp 8724f1e13f Update README.md 2022-09-22 12:45:10 +02:00
scawp 10c9143cb8 Update README.md 2022-09-22 10:46:26 +02:00
scawp 4d047775ee chaned temp dir and install dir to not conflist woth other projects 2022-09-22 10:40:25 +02:00
scawp 360e6f7afb Update README.md 2022-09-22 10:25:49 +02:00
scawp 907350251d Update README.md 2022-09-19 12:43:15 +02:00
scawp fa0f775e4a updated readme 2022-09-19 11:52:34 +02:00
scawp 7d11b79842 Update README.md 2022-09-19 11:39:10 +02:00
scawp 9d996f5a5b Update README.md 2022-09-19 11:19:29 +02:00
scawp c119967788 Update README.md 2022-09-19 11:13:33 +02:00
scawp b162f43ccb fix install url 2022-09-19 11:12:50 +02:00
scawp f9dc99b486 fix url 2022-09-19 11:12:27 +02:00
scawp 7edacd0e25 Merge pull request #5 from scawp/Quick-Auto-Mount-WIP
Quick auto mount wip
2022-09-19 11:06:36 +02:00
scawp 15f7258234 ready to merge 2022-09-19 11:05:32 +02:00
scawp be88485649 Almost 2022-09-19 11:03:52 +02:00
scawp b6ebec9018 added curl install 2022-09-19 10:53:01 +02:00
scawp 8b353435d0 complete? 2022-09-19 10:22:57 +02:00
scawp c50dbeaacf test 2022-09-19 10:04:41 +02:00
scawp d652b94db5 test 2022-09-19 09:55:20 +02:00
scawp d901cd08e3 testing curl install 2022-09-19 09:51:51 +02:00
scawp 0662441295 Check script is running on the Steam Deck 2022-09-19 09:35:43 +02:00
scawp d2ce0ca697 readme 2022-09-19 00:34:18 +02:00
scawp 1b9aacdac2 Removed logos for zMount, clean up comment 2022-09-19 00:23:09 +02:00
scawp 3b0349fe4c Removed manual mount and whitelist 2022-09-19 00:10:50 +02:00
scawp a7f6dcd13a Update README.md 2022-09-18 01:20:24 +02:00
scawp 695c1a01d5 Update README.md 2022-09-18 00:53:43 +02:00
scawp 617a7b7480 Updated automount 2022-09-18 00:39:55 +02:00
scawp cbbc8f7488 Added label and uuid to GUI 2022-09-16 17:05:45 +02:00
scawp b6478440fb Update README.md 2022-09-12 12:02:29 +02:00
scawp 596a47fdac Update README.md
new video
2022-09-12 12:02:11 +02:00
scawp dc71750b19 added -p option to mkdir to make the user folder in run/media 2022-09-12 11:02:51 +02:00
scawp 5435d0e15f fixes to install script 2022-09-12 10:42:10 +02:00
scawp f309ad2627 Merge pull request #2 from scawp/PR
Updated zMount to find external drives better, Created automount rules and systemd service
2022-09-12 10:12:27 +02:00
scawp 97f831bb61 Merge branch 'main' into PR 2022-09-12 10:12:04 +02:00
scawp f50f608d07 Update README.md 2022-09-12 09:49:22 +02:00
scawp da83261382 gitignore 2022-09-12 09:46:25 +02:00
scawp 031f826afc Tidy up 2022-09-12 09:46:09 +02:00
scawp f95306a3b9 Update README.md 2022-06-14 21:46:22 +02:00
15 changed files with 375 additions and 288 deletions

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
config/
temp/
logs/
+58 -3
View File
@@ -1,5 +1,60 @@
# Steam-Deck.Mount-External-Drive
A Script to (Un)Mount and Setup Auto-Mount for an External USB SSD on the Steam Deck
# Steam-Deck.Mount-External-Drive 3.5
Script to Auto-Mount NTFS, BTRFS & exFat SDCards, External USB Drives (or SSD Docks) & Internal Partitions (If you Dual-Boot) on the Steam Deck
NTFS & BTRFS Partitions containing a SteamLibrary at root level or in a folder named `SteamLibrary` will automatically be added to Steam, exFAT isn't supported as a SteamLibrary but will be Mounted for use with other Launchers or for Media/ROMs etc.
# "This is cool! How can I thank you?"
### Why not drop me a sub over on my youtube channel ;) [Chinballs Gaming](https://www.youtube.com/chinballsTV?sub_confirmation=1)
### Also [Check out all these other things I'm making](https://github.com/scawp/Steam-Deck.Tools-List)
# Steam OS 3.5 Now supports Ext4 external Drives out the box so see **Uninstall** if thats all you need!
# How does this work?
This script is basically a mirror of Valves own Auto-Mount script (which lives on SteamOS at `/usr/lib/hwsupport/steamos-automount.sh` ) adding in support for `ntfs`, `btrfs` & `exFAT` and adding rules for Internal Partitions.
Additional RegEx has been added to the rules to allow he mounting of "Full Disk" Formatted drives (eg ones that don't have a partitions table) so even drives that are eg `sda` or `mmcblk0` as well as `sda1` or `mmcblk0p1` can be mounted.
SteamOS's rule for this lives at `/usr/lib/udev/rules.d/99-steamos-automount.rules` and because SteamOS has a Read-Only File System, files in `/usr/` cannot be changed without removing the Read-Onlyness, however systemd rules can be overwritten due to how systemd prioritieses directories, so by adding a rule with the same name in `/etc/udev/rules.d/` we can override the rule without making changes to SteamOS.
Looking for the old code? see https://github.com/scawp/Steam-Deck.Mount-External-Drive/tree/pre-3.5
a `udev` rule is added to `/etc/udev/rules.d/99-steamos-automount.rules` which takes priority over `/usr/lib/udev/rules.d/99-steamos-automount.rules`
this then calls systemd `/etc/systemd/system/external-drive-mount@[sda|sda1|sda2|sdd1|etc].service`
that then runs `/home/deck/.local/share/scawp/SDMED/automount.sh` to Auto Mount any supported SD/External USB/Internal Partitions.
`/etc/fstab` is not required for mounting in this way, (however if a Device has an `fstab` entry these scripts will still work)
# Video Guide
https://youtu.be/q9tiNzVWjVo
https://www.youtube.com/watch?v=Yglf1EKBv2A
# Operation
The Drive(s) will be Auto-Mounted to `/run/media/deck/[LABEL]` eg `/run/media/deck/External-ssd/` if the Device has no `label` then the Devices `UUID` will be used eg `/run/media/deck/a12332-12bf-a33ab-eef/`
# Installation
## Via Curl (One Line Install)
In Konsole type `curl -sSL https://raw.githubusercontent.com/scawp/Steam-Deck.Mount-External-Drive/main/curl_install.sh | bash`
a `sudo` password is required (run `passwd` if required first)
# Uninstall
`sudo rm /etc/udev/rules.d/99-steamos-automount.rules`
`sudo rm /etc/systemd/system/external-drive-mount@.service`
`sudo rm -r /home/deck/.local/share/scawp/SDMED`
`sudo udevadm control --reload`
`sudo systemctl daemon-reload`
# WORK IN PROGRESS!
This will probably have bugs, so beware! log bugs under [issues](https://github.com/scawp/Steam-Deck.Mount-External-Drive/issues)!
-12
View File
@@ -1,12 +0,0 @@
[Desktop Entry]
Comment=https://github.com/scawp/Steam-Deck.Mount-External-Drive
Exec=
GenericName=
Icon=dialog-scripts
MimeType=
Name=Scawps Mount on Start Up Script
StartupNotify=true
Terminal=false
Type=Application
X-KDE-AutostartScript=true
X-KDE-SubstituteUID=false
Executable → Regular
+208 -18
View File
@@ -1,28 +1,218 @@
#!/bin/bash
#Steam Deck Mount External Drive by scawp
#License: DBAD: https://github.com/scawp/Steam-Deck.Mount-External-Drive/blob/main/LICENSE.md
#Source: https://github.com/scawp/Steam-Deck.Mount-External-Drive
# Use at own Risk!
script_dir="$(dirname $(realpath "$0"))"
config_dir="$script_dir/config"
set -euo pipefail
mkdir -p "$config_dir"
# Originally from https://serverfault.com/a/767079
function mount_drive () {
mkdir "/run/media/deck/$(lsblk -noLABEL $1)"
chown deck:deck "/run/media/deck/$(lsblk -noLABEL $1)"
mount "$1" "/run/media/deck/$(lsblk -noLABEL $1)" -ouid=1000,gid=1000
# 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 [ "$1" = "remove" ]; then
exit 0;
if [[ $# -ne 2 ]]; then
usage
fi
if [ -f "$config_dir/drive_list.conf" ]; then
if [ ! -z "$(grep "^$(lsblk -noUUID /dev/$2)$" "$config_dir/drive_list.conf")" ] || [ ! -z "$(grep "^ALWAYS$" "$config_dir/drive_list.conf")" ]; then
mount_drive "/dev/$2"
ACTION=$1
DEVBASE=$2
DEVICE="/dev/${DEVBASE}"
# Shared between this and the auto-mount script to ensure we're not double-triggering nor automounting while formatting
# or vice-versa.
MOUNT_LOCK="/var/run/jupiter-automount-${DEVBASE//\/_}.lock"
# Obtain lock
exec 9<>"$MOUNT_LOCK"
if ! flock -n 9; then
echo "$MOUNT_LOCK is active: ignoring action $ACTION"
# Do not return a success exit code: it could end up putting the service in 'started' state without doing the mount
# work (further start commands will be ignored after that)
exit 1
fi
# 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
fi
}
exit 0;
# From https://gist.github.com/HazCod/da9ec610c3d50ebff7dd5e7cac76de05
urlencode()
{
[ -z "$1" ] || echo -n "$@" | hexdump -v -e '/1 "%02x"' | sed 's/\(..\)/%\1/g'
}
do_mount()
{
declare -i ret
# NOTE: these values are ABI, since they are sent to the Steam client
readonly FSCK_ERROR=1
readonly MOUNT_ERROR=2
# Get info for this drive: $ID_FS_LABEL, and $ID_FS_TYPE
dev_json=$(lsblk -o PATH,LABEL,FSTYPE --json -- "$DEVICE" | jq '.blockdevices[0]')
ID_FS_LABEL=$(jq -r '.label | select(type == "string")' <<< "$dev_json")
ID_FS_TYPE=$(jq -r '.fstype | select(type == "string")' <<< "$dev_json")
# Global mount options
OPTS="rw,noatime"
# File system type specific mount options
#if [[ ${ID_FS_TYPE} == "vfat" ]]; then
# OPTS+=",users,gid=100,umask=000,shortname=mixed,utf8=1,flush"
#fi
case "${ID_FS_TYPE}" in
"ntfs")
echo "FSType is NTFS"
#Extra Opts don't seem necessary anymore? add if required
#OPTS+=""
;;
"exfat")
echo "FSType is exFat"
#OPTS+=",users,gid=100,umask=000,shortname=mixed,utf8=1,flush"
;;
"btrfs")
echo "FSType is btrfs"
;;
"ext4")
echo "FSType is ext4"
#exit 2
;;
*)
echo "Error mounting ${DEVICE}: unsupported fstype: ${ID_FS_TYPE} - ${dev_json}"
rm "${MOUNT_LOCK}"
exit 2
;;
esac
# 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
# Ask udisks to auto-mount. This needs a version of udisks that supports the 'as-user' option.
ret=0
reply=$(busctl call --allow-interactive-authorization=false --expect-reply=true --json=short \
org.freedesktop.UDisks2 \
/org/freedesktop/UDisks2/block_devices/"${DEVBASE}" \
org.freedesktop.UDisks2.Filesystem \
Mount 'a{sv}' 3 \
as-user s deck \
auth.no_user_interaction b true \
options s "$OPTS") || ret=$?
if (( ret != 0 )); then
send_steam_url "system/devicemountresult" "${DEVBASE}/${MOUNT_ERROR}"
echo "Error mounting ${DEVICE} (status = $ret)"
exit 1
fi
# Expected reply is of the format
# {"type":"s","data":["/run/media/deck/home"]}
mount_point=$(jq -r '.data[0] | select(type == "string")' <<< "$reply" || true)
if [[ -z $mount_point ]]; then
echo "Error when mounting ${DEVICE}: udisks returned success but could not parse reply:"
echo "---"$'\n'"$reply"$'\n'"---"
exit 1
fi
if [[ ${ID_FS_TYPE} == "exfat" ]]; then
echo "exFat does not support symlinks, do not add library to Steam"
exit 0
fi
# Create a symlink from /run/media to keep compatibility with apps
# that use the older mount point (for SD cards only).
case "${DEVBASE}" in
mmcblk0p*)
if [[ -z "${ID_FS_LABEL}" ]]; then
old_mount_point="/run/media/${DEVBASE}"
else
old_mount_point="/run/media/${mount_point##*/}"
fi
if [[ ! -d "${old_mount_point}" ]]; then
rm -f -- "${old_mount_point}"
ln -s -- "${mount_point}" "${old_mount_point}"
fi
;;
esac
echo "**** Mounted ${DEVICE} at ${mount_point} ****"
if [ -f "${mount_point}/libraryfolder.vdf" ]; then
send_steam_url "addlibraryfolder" "${mount_point}"
else
#TODO check permissions are 1000 when creating new SteamLibrary
mkdir -p "${mount_point}/SteamLibrary"
chown deck:deck "${mount_point}/SteamLibrary"
send_steam_url "addlibraryfolder" "${mount_point}/SteamLibrary"
fi
}
do_unmount()
{
local mount_point=$(findmnt -fno TARGET "${DEVICE}" || true)
if [[ -n $mount_point ]]; then
# Remove symlink to the mount point that we're unmounting
find /run/media -maxdepth 1 -xdev -type l -lname "${mount_point}" -exec rm -- {} \;
else
# If we don't know the mount point then remove all broken symlinks
find /run/media -maxdepth 1 -xdev -xtype l -exec rm -- {} \;
fi
}
do_retrigger()
{
local mount_point=$(findmnt -fno TARGET "${DEVICE}" || true)
[[ -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
+96
View File
@@ -0,0 +1,96 @@
#!/bin/bash
#Steam Deck Mount External Drive by scawp
#License: DBAD: https://github.com/scawp/Steam-Deck.Mount-External-Drive/blob/main/LICENSE.md
#Source: https://github.com/scawp/Steam-Deck.Mount-External-Drive
# Use at own Risk!
#curl -sSL https://raw.githubusercontent.com/scawp/Steam-Deck.Mount-External-Drive/main/curl_install.sh | bash
#stop running script if anything returns an error (non-zero exit )
set -e
repo_url="https://raw.githubusercontent.com/scawp/Steam-Deck.Mount-External-Drive/main"
repo_lib_dir="$repo_url/lib"
tmp_dir="/tmp/scawp.SDMED.install"
rules_install_dir="/etc/udev/rules.d"
service_install_dir="/etc/systemd/system"
script_install_dir="/home/deck/.local/share/scawp/SDMED"
device_name="$(uname --nodename)"
user="$(id -u deck)"
if [ "$device_name" != "steamdeck" ] || [ "$user" != "1000" ]; then
zenity --question --width=400 \
--text="This code has been written specifically for the Steam Deck with user Deck \
\nIt appears you are running on a different system/non-standard configuration. \
\nAre you sure you want to continue?"
if [ "$?" != 0 ]; then
#NOTE: This code will never be reached due to "set -e", the system will already exit for us but just incase keep this
echo "bye then! xxx"
exit 1;
fi
fi
function install_automount () {
zenity --question --width=400 \
--text="Read $repo_url/README.md before proceeding. \
\nDo you want to install the Auto-Mount Service?"
if [ "$?" != 0 ]; then
#NOTE: This code will never be reached due to "set -e", the system will already exit for us but just incase keep this
echo "bye then! xxx"
exit 0;
fi
echo "Making tmp folder $tmp_dir"
mkdir -p "$tmp_dir"
echo "Downloading Required Files"
curl -o "$tmp_dir/automount.sh" "$repo_url/automount.sh"
curl -o "$tmp_dir/external-drive-mount@.service" "$repo_lib_dir/external-drive-mount@.service"
curl -o "$tmp_dir/99-steamos-automount.rules" "$repo_lib_dir/99-steamos-automount.rules"
echo "Making script folder $script_install_dir"
mkdir -p "$script_install_dir"
echo "Copying $tmp_dir/automount.sh to $script_install_dir/automount.sh"
sudo cp "$tmp_dir/automount.sh" "$script_install_dir/automount.sh"
echo "Adding Execute and Removing Write Permissions"
sudo chmod 555 $script_install_dir/automount.sh
echo "Copying $tmp_dir/99-steamos-automount.rules to $rules_install_dir/99-steamos-automount.rules"
sudo cp "$tmp_dir/99-steamos-automount.rules" "$rules_install_dir/99-steamos-automount.rules"
#remove old rules if installed
if [ -f "$rules_install_dir/99-external-drive-mount.rules" ]; then
sudo rm "$rules_install_dir/99-external-drive-mount.rules"
fi
if [ -f "$rules_install_dir/98-external-drive-mount.rules" ]; then
sudo rm "$rules_install_dir/98-external-drive-mount.rules"
fi
echo "Copying $tmp_dir/external-drive-mount@.service to $service_install_dir/external-drive-mount@.service"
sudo cp "$tmp_dir/external-drive-mount@.service" "$service_install_dir/external-drive-mount@.service"
echo "Reloading Services"
sudo udevadm control --reload
sudo systemctl daemon-reload
}
install_automount
zenity --question --width=400 \
--text="Restart Required to take effect, \
\nDo you want to Restart Now?"
if [ "$?" != 0 ]; then
#NOTE: This code will never be reached due to "set -e", the system will already exit for us but just incase keep this
echo "bye then! xxx"
exit 0;
fi
reboot
echo "Done."
-46
View File
@@ -1,46 +0,0 @@
#!/bin/bash
#Steam Deck Mount External Drive by scawp
#License: DBAD: https://github.com/scawp/Steam-Deck.Mount-External-Drive/blob/main/LICENSE.md
#Source: https://github.com/scawp/Steam-Deck.Mount-External-Drive
# Use at own Risk!
script_dir="$(dirname $(realpath "$0"))"
lib_dir="$script_dir/lib"
conf_dir="$script_dir/conf"
rules_install_dir="/etc/udev/rules.d"
service_install_dir="/etc/systemd/system"
echo -en "Read https://github.com/scawp/Steam-Deck.Mount-External-Drive before proceeding. \
\nDo you want to install the Auto-Mount Service? (y/n) :"
read confirm
if [ "$confirm" != "y" ]; then
echo "bye then! xxx"
exit 0;
fi
echo -en "Would you like to Auto-Mount Any and All External Drives? \
\n\"y\": Any Drive will be Auto-Mounted on insert. \
\n\"n\": Drives that are Whitelisted using \"zMount.sh\" will be Auto-Mounted on insert. \
\n(y/n) :"
read confirm
if [ "$confirm" != "y" ]; then
echo "ALWAYS" > $conf_dir/drive_list.conf
fi
echo "Copying $lib_dir/99-external-drive-mount.rules to $rules_install_dir/99-external-drive-mount.rules"
sudo cp "$lib_dir/99-external-drive-mount.rules" "$rules_install_dir/99-external-drive-mount.rules"
sed -e "s&\[AUTOMOUNTSCRIPT\]&$script_dir&g" "$lib_dir/template.service" > "$lib_dir/external-drive-mount@.service"
echo "Copying $lib_dir/external-drive-mount@.service to $service_install_dir/external-drive-mount@.service"
sudo cp "$lib_dir/external-drive-mount@.service" "$service_install_dir/external-drive-mount@.service"
echo "Adding Execute permissions"
chmod +x $script_dir/zMount.sh
chmod +x $script_dir/automount.sh
echo "Reloading Services"
sudo udevadm control --reload
sudo systemctl daemon-reload
echo "Done."
-4
View File
@@ -1,4 +0,0 @@
# /etc/udev/rules.d/
# sudo udevadm control --reload
KERNEL=="sd[a-z][0-9]", ACTION=="add", RUN+="/bin/systemctl start external-drive-mount@%k.service"
KERNEL=="sd[a-z][0-9]", ACTION=="remove", RUN+="/bin/systemctl stop external-drive-mount@%k.service"
+8
View File
@@ -0,0 +1,8 @@
# /etc/udev/rules.d/
# sudo udevadm control --reload
KERNEL=="sd[a-z]|sd[a-z][0-9]", ACTION=="add", RUN+="/bin/systemctl start --no-block external-drive-mount@%k.service"
KERNEL=="sd[a-z]|sd[a-z][0-9]", ACTION=="remove", RUN+="/bin/systemctl stop --no-block external-drive-mount@%k.service"
KERNEL=="mmcblk0|mmcblk0p[0-9]", ACTION=="add", RUN+="/bin/systemctl start --no-block external-drive-mount@%k.service"
KERNEL=="mmcblk0|mmcblk0p[0-9]", ACTION=="remove", RUN+="/bin/systemctl stop --no-block external-drive-mount@%k.service"
KERNEL=="nvme0n1p9|nvme0n1p1[0-9]", ACTION=="add", RUN+="/bin/systemctl start --no-block external-drive-mount@%k.service"
KERNEL=="nvme0n1p9|nvme0n1p1[0-9]", ACTION=="remove", RUN+="/bin/systemctl stop --no-block external-drive-mount@%k.service"
+2 -2
View File
@@ -8,5 +8,5 @@ Description=Mount External Drive on %i
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=[AUTOMOUNTSCRIPT]/automount.sh add %i
ExecStop=[AUTOMOUNTSCRIPT]/automount.sh remove %i
ExecStart=/home/deck/.local/share/scawp/SDMED/automount.sh add %i
ExecStop=/home/deck/.local/share/scawp/SDMED/automount.sh remove %i
-12
View File
@@ -1,12 +0,0 @@
# /etc/systemd/system
# maybe move to user? ~/.local/share/systemd/user
# sudo systemctl daemon-reload
[Unit]
Description=Mount External Drive on %i
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=[AUTOMOUNTSCRIPT]/automount.sh add %i
ExecStop=[AUTOMOUNTSCRIPT]/automount.sh remove %i
-39
View File
@@ -1,39 +0,0 @@
#!/bin/bash
#Steam Deck Mount External Drive by scawp
#License: DBAD: https://github.com/scawp/Steam-Deck.Mount-External-Drive/blob/main/LICENSE.md
#Source: https://github.com/scawp/Steam-Deck.Mount-External-Drive
# Use at own Risk!
script_dir="$(dirname $(realpath "$0"))"
tmp_dir="$script_dir/temp"
log_dir="$script_dir/logs"
config_dir="$script_dir/config"
mkdir -p "$tmp_dir"
mkdir -p "$log_dir"
mkdir -p "$config_dir"
function log_error () {
echo "$1" | sed "s&^&[$(date "+%F %T")] ("$0") &" | tee -a "$log_dir/error.log"
}
function log_msg () {
echo "$1" | sed "s&^&[$(date "+%F %T")] ("$0") &" | tee -a "$log_dir/info.log"
}
function mount_drive () {
udisksctl mount --no-user-interaction -b "$1" 2> $tmp_dir/last_error.log 1> $tmp_dir/last_msg.log
if [ "$?" != 0 ]; then
log_error "$(sed -n '1p' $tmp_dir/last_error.log)"
else
log_msg "$(sed -n '1p' $tmp_dir/last_msg.log)"
fi
}
if [ -f "$config_dir/drive_list.conf" ]; then
while read -r drive_uuid; do
mount_drive "/dev/disk/by-uuid/$drive_uuid"
done < "$config_dir/drive_list.conf"
else
log_error "No Config file, Run \"./zMount.sh\" and add a drive to \"Boot on Start up\"!"
fi
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

-152
View File
@@ -1,152 +0,0 @@
#!/bin/bash
#Steam Deck Mount External Drive by scawp
#License: DBAD: https://github.com/scawp/Steam-Deck.Mount-External-Drive/blob/main/LICENSE.md
#Source: https://github.com/scawp/Steam-Deck.Mount-External-Drive
# Use at own Risk!
script_dir="$(dirname $(realpath "$0"))"
tmp_dir="$script_dir/temp"
log_dir="$script_dir/logs"
config_dir="$script_dir/config"
mkdir -p "$tmp_dir"
mkdir -p "$log_dir"
mkdir -p "$config_dir"
external_drive_list="$tmp_dir/external_drive_list.txt"
#TODO this is to fore kdesu dialog to use sudo, maybe theres a better way?
if [ ! -f ~/.config/kdesurc ];then
touch ~/.config/kdesurc
echo "[super-user-command]" > ~/.config/kdesurc
echo "super-user-command=sudo" >> ~/.config/kdesurc
fi
function log_error () {
echo "$1" | sed "s&^&[$(date "+%F %T")] ("$0") &" | tee -a "$log_dir/error.log"
}
function log_msg () {
echo "$1" | sed "s&^&[$(date "+%F %T")] ("$0") &" | tee -a "$log_dir/info.log"
}
function list_gui () {
#IFS=$';';
# --extra-button "Auto Mount"
selected_device=$(zenity --list --title="Select Drive to (un)Mount" \
--width=1000 --height=360 --print-column=ALL --separator="\t" \
--ok-label "(Un)Mount" --extra-button "Refresh" \
--column="Path" --column="Size" --column="UUID" \
--column="Mount Point" \
$(cat "$external_drive_list" | sed -e 's/$/\t/'))
ret_value="$?"
#unset IFS;
}
function confirm_gui () {
zenity --question --width=400 \
--text="Do you want to $1 device $2 with uuid of $3?"
if [ "$?" = 1 ]; then
exit 1;
fi
}
function get_drive_list () {
lsblk -nlo HOTPLUG,PATH,SIZE,UUID,MOUNTPOINT | grep -i '^\s*1' | awk '$4!=""' | awk '{ if ( $5!="") print $2"\t"$3"\t"$4"\t"$5;else print $2"\t"$3"\t"$4"\tUnmounted"}' > "$external_drive_list"
}
function sudo_mount_drive () {
if [ "$1" = "mount" ]; then
kdesu -c "udisksctl mount -b \"/dev/disk/by-uuid/$2\" 2> $tmp_dir/last_error.log 1> $tmp_dir/last_msg.log"
else
kdesu -c "udisksctl unmount -b \"/dev/disk/by-uuid/$2\" 2> $tmp_dir/last_error.log 1> $tmp_dir/last_msg.log"
fi
if [ "$?" != 0 ]; then
log_error "$(sed -n '1p' $tmp_dir/last_error.log)"
ret_value="$(sed -n '1p' $tmp_dir/last_error.log)"
ret_success=0
else
log_msg "$(sed -n '1p' $tmp_dir/last_msg.log)"
ret_value="$(sed -n '1p' $tmp_dir/last_msg.log)"
ret_success=1
fi
}
function mount_drive () {
if [ "$1" = "mount" ]; then
udisksctl mount --no-user-interaction -b "/dev/disk/by-uuid/$2" 2> $tmp_dir/last_error.log 1> $tmp_dir/last_msg.log
else
udisksctl unmount --no-user-interaction -b "/dev/disk/by-uuid/$2" 2> $tmp_dir/last_error.log 1> $tmp_dir/last_msg.log
fi
if [ "$?" != 0 ]; then
log_error "$(sed -n '1p' $tmp_dir/last_error.log)"
ret_value="$(sed -n '1p' $tmp_dir/last_error.log)"
sudo_mount_drive $1 $2
else
log_msg "$(sed -n '1p' $tmp_dir/last_msg.log)"
ret_value="$(sed -n '1p' $tmp_dir/last_msg.log)"
ret_success=1
fi
}
function main () {
get_drive_list
list_gui
echo "$ret_value"
mount_point="$(echo "$selected_device" | awk '{ print $4 }')"
path="$(echo "$selected_device" | awk '{ print $1 }')"
uuid="$(echo "$selected_device" | awk '{ print $3 }')"
echo "the path: $path"
if [ "$ret_value" = 1 ]; then
if [ "$selected_device" = "Refresh" ]; then
main
else
if [ "$selected_device" = "Auto Mount" ]; then
continue
else
exit 1;
fi
fi
fi
if [ "$selected_device" = "" ]; then
zenity --error --width=400 \
--text="No Device Selected, Quitting!"
exit 1;
fi
if [ "$mount_point" = "Unmounted" ]; then
confirm_gui "mount" "$path" "$uuid"
mount_drive "mount" "$uuid"
if [ "$ret_success" = "1" ]; then
if [ -f "$config_dir/drive_list.conf" ]; then
if [ ! "$(grep ^"$uuid"$ "$config_dir/drive_list.conf")" ]; then
#TODO: Function
zenity --question --width=400 \
--text="Do you want to mount "$(lsblk -noMOUNTPOINT $path)" on Boot?"
if [ "$?" = 0 ]; then
echo "$uuid" >> "$config_dir/drive_list.conf"
zenity --info --width=400 \
--text="$path will be mounted on Boot"
exit 0;
fi
fi
fi
fi
else
confirm_gui "unmount" "$path" "$uuid"
mount_drive "unmount" "$uuid"
fi
zenity --info --width=400 \
--text="$ret_value"
exit 0;
}
main