From 509cb97d31984a95c5cd08e68700e0984660dffa Mon Sep 17 00:00:00 2001
From: sspark <sspark@onioi.com>
Date: Tue, 17 Jan 2023 04:48:25 +0000
Subject: [PATCH] rel 0.9.2

---
 gwinstall.sh |   37 ++++++++++++++++++++++++++++---------
 1 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/gwinstall.sh b/gwinstall.sh
index 1150692..48b423b 100755
--- a/gwinstall.sh
+++ b/gwinstall.sh
@@ -1,20 +1,29 @@
 #!/bin/bash
 
 export FWD_PORT=10000
+export SSH_SERVER=root@onio.iptime.org
+
+install_ssh_key()
+{
+    sudo ssh-keygen
+    sudo ssh-copy-id -p 12222 $SSH_SERVER
+}
+
+test_tunnel()
+{
+    sudo /usr/bin/ssh -NT -o ServerAliveInterval=5 -o ExitOnForwardFailure=yes -gnN -R 127.0.0.1:$FWD_PORT:localhost:22 -p 12222 $SSH_SERVER
+}
 
 install_tunnel()
 {
-    sudo ssh-keygen
-    sudo ssh-copy-id -p 12222 root@onio.iptime.org
-
 echo "
 [Unit]
 Description=SSH Tunnel with target server
 After=network.target
 
 [Service]
-ExecStart=/usr/bin/ssh -NT -o ServerAliveInterval=60 -o ExitOnForwardFailure=yes -R 127.0.0.1:$FWD_PORT:localhost:22 -p 12222 root@onio.iptime.org
-RestartSec=5
+ExecStart=/usr/bin/ssh -NT -o ServerAliveInterval=5 -o ExitOnForwardFailure=yes -gnN -R 127.0.0.1:$FWD_PORT:localhost:22 -p 12222 $SSH_SERVER
+RestartSec=10
 Restart=always
 
 [Install]
@@ -22,6 +31,7 @@
 " |  sudo tee /etc/systemd/system/tunnel.service  > /dev/null
 
     sudo systemctl daemon-reload
+    sudo systemctl stop tunnel
     sudo systemctl start tunnel
     sudo systemctl enable tunnel
     sudo systemctl status tunnel
@@ -41,12 +51,21 @@
 git clone https://github.com/aircrack-ng/rtl8812au.git
 cd rtl8812au
 sed -i 's/CONFIG_PLATFORM_I386_PC = y/CONFIG_PLATFORM_I386_PC = n/g' Makefile
-sed -i 's/CONFIG_PLATFORM_ARM64_RPI = n/CONFIG_PLATFORM_ARM64_RPI = y/g' Makefile
+sed -i 's/CONFIG_PLATFORM_ARM_RPI = n/CONFIG_PLATFORM_ARM_RPI = y/g' Makefile
 
 sudo make dkms_install
 }
 
 case "$1" in
+    copykey)
+        echo -e "ssh_key copying... server: $SSH_SERVER"
+        install_ssh_key
+        ;;
+    test)
+        echo -e "tunnel test... port: $2"
+        FWD_PORT=$2
+        test_tunnel
+        ;;        
     tunnel)
         echo -e "tunnel install... port: $2"
         FWD_PORT=$2
@@ -57,11 +76,11 @@
         install_packages
         ;;
     USBWiFi)
-        echo -e "USBWiFi install..."
-        install_packages
+        echo -e "USBWiFi make install..."
+        install_USBWiFi
         ;;
     *)
-        echo -e "Usage:\n$0 {tunnel 10000|packages|USBWiFi}"
+        echo -e "Usage:\n$0 {copykey|test 10000|tunnel 10000|packages|USBWiFi}"
         exit 1
 esac
 

--
Gitblit v1.9.3