diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-06-15 15:44:50 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-06-15 15:44:50 +0900 |
| commit | c51805360d13539ae1f54370307b4c6c46ed4f80 (patch) | |
| tree | d4c3404b19bd6a4be99bb8908eacc10566cd6e3f /ar/.local/bin/mounter | |
| parent | 46f1cd6f835447c5578af4fa9f6a22241fb58791 (diff) | |
modified bin/mounter
Diffstat (limited to 'ar/.local/bin/mounter')
| -rwxr-xr-x | ar/.local/bin/mounter | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ar/.local/bin/mounter b/ar/.local/bin/mounter index 1f71df5..eb5f94a 100755 --- a/ar/.local/bin/mounter +++ b/ar/.local/bin/mounter @@ -36,6 +36,18 @@ mountbase() { getmount() { [ -z "$1" ] && mp="$(find "/media/$USER" /mnt -mindepth 1 -maxdepth 1 -type d 2>/dev/null | dmenu -i -p "Mount this drive where?")" || mp="$1" test -n "$mp" + # Ensure the /media/$USER base exists and is owned by the user before any + # mountpoint is created under it. Otherwise `sudo mkdir -p` would create the + # base as root and only the leaf would get chowned below. + case "$mp" in + "/media/$USER"/*) + if [ ! -d "/media/$USER" ]; then + sudo -A mkdir -p "/media/$USER" && sudo -A chown "$USER":"$(id -gn)" "/media/$USER" + elif [ "$(stat -c '%U' "/media/$USER")" != "$USER" ]; then + sudo -A chown "$USER":"$(id -gn)" "/media/$USER" + fi + ;; + esac if [ ! -d "$mp" ]; then mkdiryn=$(printf "Yes\nNo" | dmenu -i -p "$mp does not exist. Create it?") [ "$mkdiryn" = "Yes" ] && (mkdir -p "$mp" 2>/dev/null || { sudo -A mkdir -p "$mp" && sudo -A chown "$USER":"$(id -gn)" "$mp"; }) |
