window-manager/scripts/rootedinit.sh

42 lines
No EOL
1.5 KiB
Bash
Executable file

#!/bin/sh
# from volume-root.sh
if [ -z "$1" ]; then
DIR="$HOME/.config/hypr/scripts"
SELF="$(realpath "$DIR/$(basename "$0")")"
if [ "$SELF" != "$(realpath "$0")" ]; then
echo "This script must exist inside of $DIR";
exit 1;
fi
else
if [ "root" != "$USER" ]; then
echo "Only root are allowed to arbitrarily specify the directory.";
exit 1;
fi
DIR=$1
SELF="Something went horribly wrong! You were assumed to be root in one check, but non-root by the next one.";
fi
if [ "root" != "$USER" ]; then
if [ "$SELF" != "$(realpath "$0")" ]; then
echo "This script must exist inside of $DIR";
exit 1;
fi
exec sudo "$SELF" "$DIR";
echo "NOTE: You should never see this message!"
exit 1;
fi
# custom logic for rootedinit.sh
USRDIR="$DIR/../../.."
iptables -P FORWARD ACCEPT #Or Waydroid won't have internet access; iptables-save didn't work for some reason
mount -Bv "$USRDIR/Obrazy" "$USRDIR/.local/share/waydroid/data/media/0/Pictures"
mount -Bv "$USRDIR/Obrazy" "$USRDIR/.local/share/waydroid/data/media/0/DCIM"
mount -Bv "$USRDIR/Dokumenty" "$USRDIR/.local/share/waydroid/data/media/0/Documents"
mount -Bv "$USRDIR/Pobrane" "$USRDIR/.local/share/waydroid/data/media/0/Download"
mount -Bv "$USRDIR/.config" "$USRDIR/.local/share/waydroid/data/media/0/Source OS/conf"
mount -Bv "$USRDIR/.var/app" "$USRDIR/.local/share/waydroid/data/media/0/Source OS/flatpak"
swapon /dev/nvme0n1p3 #Unrelated to Waydroid, but this is probably the least awkward place to lazily put it