some mount and unmount scripts

This commit is contained in:
2025-07-27 13:46:15 +02:00
parent b2a0364fcb
commit 299e5aa5de
9 changed files with 99 additions and 18 deletions

17
.scripts/issu.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
if [ "$(id -u)" -eq 0 ]; then
exit 1
fi
if [ -n "$SUDO_USER" ]; then
exit 1
fi
if [ "$LOGNAME" != "$USER" ]; then
exit 1
fi
if [ "$(ps -o comm= -p $(ps -o ppid= -p $$) 2>/dev/null)" = "su" ]; then
exit 1
fi

View File

@@ -1,19 +1,24 @@
#!/bin/sh
[ -z $SMB_CREDENTIALS ] && SMB_CREDENTIALS="$HOME/.smbcredentials"
[ ! -f $SMB_CREDENTIALS ] && exit 1
path="$(dirname "$(realpath "$0")")"
[ -z $SMB_HOST ] && SMB_HOST="10.8.0.1"
[ -z $SMB_DIR ] && SMB_DIR="share"
[ -z $SMB_MOUNT_POINT ] && SMB_MOUNT_POINT="/mnt/smb"
[ -z $SMB_UID ] && SMB_UID=$(id -u)
[ -z $SMB_GID ] && SMB_GID=$(id -g)
"$path/issu.sh" || {
echo "Do not run this script in sudo mode."
exit 1
}
[ -z "$SMB_CREDENTIALS" ] && SMB_CREDENTIALS="$HOME/.smbcredentials"
[ ! -f "$SMB_CREDENTIALS" ] && exit 1
[ -z "$SMB_HOST" ] && SMB_HOST="10.8.0.1"
[ -z "$SMB_DIR" ] && SMB_DIR="share"
[ -z "$SMB_MOUNT_POINT" ] && SMB_MOUNT_POINT="/mnt/smb"
[ -z "$SMB_UID" ] && SMB_UID=$(id -u)
[ -z "$SMB_GID" ] && SMB_GID=$(id -g)
[ ! -d "$SMB_MOUNT_POINT" ] && sudo mkdir -p "$SMB_MOUNT_POINT"
sudo mount -t cifs //$SMB_HOST/$SMB_DIR "$SMB_MOUNT_POINT" -o credentials=$SMB_CREDENTIALS,uid=$SMB_UID,gid=$SMB_GID
if [ $? -eq 0 ]; then
if sudo mount -t cifs //"$SMB_HOST"/"$SMB_DIR" "$SMB_MOUNT_POINT" -o credentials="$SMB_CREDENTIALS",uid="$SMB_UID",gid="$SMB_GID"; then
echo "Mounted $SMB_HOST/$SMB_DIR at $SMB_MOUNT_POINT"
else
echo "Failed to mount $SMB_HOST/$SMB_DIR at $SMB_MOUNT_POINT"

9
.scripts/smb-unmount.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
[ -z "$SMB_MOUNT_POINT" ] && SMB_MOUNT_POINT="/mnt/smb"
if sudo umount "$SMB_MOUNT_POINT" && sudo rmdir "$SMB_MOUNT_POINT"; then
echo "Unmounted and removed mount point $SMB_MOUNT_POINT"
else
exit 1
fi

29
.scripts/wsl-mount.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/sh
path="$(dirname "$(realpath "$0")")"
"$path/issu.sh" || {
echo "Do not run this script in sudo mode."
exit 1
}
[ -z "$1" ] && echo "Usage: $0 <VHDX_PATH>" && exit 1
vhdx_path="$1"
[ -z "$2" ] && mount_point="/mnt/wsl" || mount_point="$2"
[ -d "$mount_point" ] || sudo mkdir -p "$mount_point"
username=$(whoami)
sudo chown "$username:$username" "$mount_point"
export LIBGUESTFS_BACKEND=direct
guestmount --add "$vhdx_path" --inspector --ro "$mount_point" || {
echo "Failed to mount VHDX file."
exit 1
}
echo "Successfully mounted $vhdx_path to $mount_point"

15
.scripts/wsl-unmount.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
[ -z "$1" ] && mount_point="/mnt/wsl" || mount_point="$1"
sudo umount "$mount_point" || {
echo "Failed to unmount $mount_point. It may not be mounted or you may not have the necessary permissions."
exit 1
}
sudo rmdir "$mount_point" || {
echo "Failed to remove the mount point directory $mount_point. It may not be empty or you may not have the necessary permissions."
exit 1
}
echo "Successfully unmounted and removed $mount_point."

8
.scripts/xdph-nuclear.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env bash
sleep 1
killall -e xdg-desktop-portal-hyprland
killall -e xdg-desktop-portal-wlr
killall xdg-desktop-portal
/usr/lib/xdg-desktop-portal-hyprland &
sleep 2
/usr/lib/xdg-desktop-portal &