summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit <justsaumit@protonmail.com>2024-09-21 16:15:45 +0530
committerSaumit <justsaumit@protonmail.com>2024-09-21 16:15:45 +0530
commit9997f059b41ffb09bfdf81b3cf2c9612aa622643 (patch)
tree71f63df209d4b1232221b0ab5a950bced5ce449d
parent1fdfb860b451de8e563c886e365ae24b9a353ca7 (diff)
.scripts: Adding efi-grub-entry, vpn, and work script
-rwxr-xr-x.scripts/add_efi_grub_entry.sh47
-rwxr-xr-x.scripts/spunup-vpn13
-rwxr-xr-x.scripts/work6
3 files changed, 66 insertions, 0 deletions
diff --git a/.scripts/add_efi_grub_entry.sh b/.scripts/add_efi_grub_entry.sh
new file mode 100755
index 0000000..638907c
--- /dev/null
+++ b/.scripts/add_efi_grub_entry.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+# Check if the script is run as root
+if [ "$EUID" -ne 0 ]; then
+ echo "Please run as root (use sudo)"
+ exit 1
+fi
+
+# Get the EFI partition
+echo "Identifying EFI partitions..."
+efiparts=$(sudo fdisk -l | grep "EFI System" | awk '{print $1}')
+echo "Detected EFI partition: $efiparts"
+
+# Prompt user to select an EFI partition
+[ $(command -v fzf) ] && efipart=$(echo "$efiparts" | fzf --prompt="Select an EFI partition: ") || \
+ echo "Please enter the full path of the EFI partition you want to use (e.g., /dev/nvme0n1p1):" && read efipart
+
+# Get the UUID of the EFI partition
+uuid=$(sudo blkid "$efipart" | awk -F '"' '{print $2}')
+echo "Detected UUID: $uuid"
+
+# Grant write permission to the 40_custom file
+echo "Granting write permissions to /etc/grub.d/40_custom..."
+chmod o+w /etc/grub.d/40_custom
+
+# Add Windows entry to 40_custom
+echo "Adding Windows 11 entry to GRUB..."
+cat <<EOF >> /etc/grub.d/40_custom
+
+menuentry 'Windows 11' {
+ search --fs-uuid --no-floppy --set=root $uuid
+ chainloader (\$root)/EFI/Microsoft/Boot/bootmgfw.efi
+}
+EOF
+
+# Remove write permission from the 40_custom file
+echo "Removing write permissions from /etc/grub.d/40_custom..."
+chmod o-w /etc/grub.d/40_custom
+
+# Update GRUB
+echo "Updating GRUB..."
+sudo grub-mkconfig -o /boot/grub/grub.cfg
+# Verification (Optional)
+echo "Verifying the changes..."
+grep -A 10 'Windows 11' /boot/grub/grub.cfg
+
+echo "Windows 11 entry added successfully!"
diff --git a/.scripts/spunup-vpn b/.scripts/spunup-vpn
new file mode 100755
index 0000000..80cd0dc
--- /dev/null
+++ b/.scripts/spunup-vpn
@@ -0,0 +1,13 @@
+#!/bin/bash
+VPN_USER=$(pass show OpenVPN-user)
+VPN_PASSWORD=$(pass show OpenVPN-pass)
+
+OVPN_FILES=(*.ovpn)
+if [ ${#OVPN_FILES[@]} -eq 0 ]; then
+ echo "No .ovpn files found in $OVPN_DIR."
+ exit 1
+fi
+CONFIG_FILE=${OVPN_FILES[RANDOM % ${#OVPN_FILES[@]}]}
+
+
+sudo bash -c 'openvpn --config '"$CONFIG_FILE"' --auth-user-pass <(echo -e "'"$VPN_USER"'\n'"$VPN_PASSWORD"'")'
diff --git a/.scripts/work b/.scripts/work
new file mode 100755
index 0000000..fb3f1a5
--- /dev/null
+++ b/.scripts/work
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+content="$@"
+today=$(date +%d%m%y)
+
+x "$today: $content"