From 979bdd5f83e4d323f716ba155be339e8c36055d0 Mon Sep 17 00:00:00 2001 From: Scott Gigawatt <16313565+scottgigawatt@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:06:03 -0400 Subject: [PATCH] Add tun.sh script and doc --- scripts/tun.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/tun.sh b/scripts/tun.sh index 31bdd9c..09b79a2 100755 --- a/scripts/tun.sh +++ b/scripts/tun.sh @@ -6,19 +6,42 @@ # VPNs as it allows the encapsulation of packets, creating a secure and private connection over the internet. # +echo "Starting script to ensure /dev/net/tun exists and is configured properly." + # Create the necessary file structure for /dev/net/tun if it does not already exist if [ ! -c /dev/net/tun ]; then + echo "/dev/net/tun does not exist. Creating the necessary file structure." + # Create the /dev/net directory if it does not exist if [ ! -d /dev/net ]; then + echo "/dev/net directory does not exist. Creating it." mkdir -m 755 /dev/net + else + echo "/dev/net directory already exists." fi + # Create the /dev/net/tun device node with major number 10 and minor number 200 + echo "Creating /dev/net/tun device node." mknod /dev/net/tun c 10 200 + # Set the permissions for /dev/net/tun + echo "Setting permissions for /dev/net/tun." chmod 0755 /dev/net/tun +else + echo "/dev/net/tun already exists." fi # Load the tun module if it is not already loaded if ! lsmod | grep -q "^tun\s"; then + echo "tun module is not loaded. Loading it now." insmod /lib/modules/tun.ko + if [ $? -eq 0 ]; then + echo "tun module loaded successfully." + else + echo "Failed to load tun module." + fi +else + echo "tun module is already loaded." fi + +echo "Script execution completed."