script working with vpn red on application board master
authorMazet Laurent <laurent.mazet@thalesgroup.com>
Fri, 19 Sep 2025 12:19:07 +0000 (14:19 +0200)
committerMazet Laurent <laurent.mazet@thalesgroup.com>
Fri, 19 Sep 2025 12:19:07 +0000 (14:19 +0200)
ulvpn.sh

index 993656aebbfac5c2618db90629ec4c6359a95b93..fbe7aa3f1ea0105e42086816dc5483109fc1e4b4 100755 (executable)
--- a/ulvpn.sh
+++ b/ulvpn.sh
@@ -1,10 +1,10 @@
-#!/bin/bash
+#!/bin/sh
 
 MTU=1439
 
 TEST=$(basename $0 .sh)
 PWD=$(dirname $0)
 
 MTU=1439
 
 TEST=$(basename $0 .sh)
 PWD=$(dirname $0)
-PWD=/opt/ulvpn/bin
+#PWD=/opt/ulvpn/bin
 
 CRYPTOMOD=$PWD/cryptomod.exe
 SIMULATOR=$PWD/simulator.exe
 
 CRYPTOMOD=$PWD/cryptomod.exe
 SIMULATOR=$PWD/simulator.exe
@@ -67,6 +67,8 @@ app)
         # only red vpn
         LRED=eth0://78:a1:35:10:10:10
         RRED=eth0://78:a1:35:01:01:01
         # only red vpn
         LRED=eth0://78:a1:35:10:10:10
         RRED=eth0://78:a1:35:01:01:01
+        RCRY=0809
+        RPRO=080B
         DEVS=$LRED
         ;;
     soft)
         DEVS=$LRED
         ;;
     soft)
@@ -75,6 +77,8 @@ app)
         LBLK=eth0://78:a1:35:20:20:20
         RRED=lo://00:00:00:00:00:00
         RBLK=eth0://78:a1:35:02:02:02
         LBLK=eth0://78:a1:35:20:20:20
         RRED=lo://00:00:00:00:00:00
         RBLK=eth0://78:a1:35:02:02:02
+        RCRY=0819
+        RPRO=081B
         DEVS=$RBLK
         ;;
     none)
         DEVS=$RBLK
         ;;
     none)
@@ -126,7 +130,7 @@ for DEV in $DEVS; do
     ip link set dev ${DEV/:*} up
     ip addr add 192.169.$N.1/24 dev ${DEV/:*}
     sleep 1
     ip link set dev ${DEV/:*} up
     ip addr add 192.169.$N.1/24 dev ${DEV/:*}
     sleep 1
-    #tcpdump -v -i ${DEV/:*} &
+    #tcpdump -v -i ${DEV/:*} & pid=$!; pids="$pids $pid"
 done
 
 if [ "$CM" = soft ]; then
 done
 
 if [ "$CM" = soft ]; then
@@ -135,13 +139,13 @@ if [ "$CM" = soft ]; then
         -s BYPASS_B2R -t $LRED/080D -r $LBLK/083D \
         -s BYPASS_R2B -t $LBLK/082D -r $LRED/081D \
         -s CONTROL -t $LRED/080E -r $LRED/081E \
         -s BYPASS_B2R -t $LRED/080D -r $LBLK/083D \
         -s BYPASS_R2B -t $LBLK/082D -r $LRED/081D \
         -s CONTROL -t $LRED/080E -r $LRED/081E \
-        -s CROSS_CRYPTO_B2R -t $LRED/0809 -r $LBLK/0839 \
-        -s CROSS_CRYPTO_R2B -t $LBLK/0829 -r $LRED/0819 \
+        -s CROSS_CRYPTO_B2R -t $LRED/0809 -r $LBLK/0809 \
+        -s CROSS_CRYPTO_R2B -t $LBLK/0809 -r $LRED/$RCRY \
         -s PROVISIONING -t $LRED/080B -r $LRED/081B &
     pid=$!
     pids="$pids $pid"
     sleep 1
         -s PROVISIONING -t $LRED/080B -r $LRED/081B &
     pid=$!
     pids="$pids $pid"
     sleep 1
-    ps | awk '$2 == '$pid' {exit 1}' && { fail KO; exit 1; } || pass OK
+    ps | awk '$1 == '$pid' || $2 == '$pid' {exit 1}' && { fail KO; exit 1; } || pass OK
 fi
 
 if [ "$VPNBLK" ]; then
 fi
 
 if [ "$VPNBLK" ]; then
@@ -149,12 +153,12 @@ if [ "$VPNBLK" ]; then
     $VPN -v 1 -V 1 -l vpnblk.log \
         -n tun \
         $VPNBLK \
     $VPN -v 1 -V 1 -l vpnblk.log \
         -n tun \
         $VPNBLK \
-        -x $RBLK/0829 $RBLK/0839 \
+        -x $RBLK/0809 $RBLK/0809 \
         -n red &
     pid=$!
     pids="$pids $pid"
     sleep 1
         -n red &
     pid=$!
     pids="$pids $pid"
     sleep 1
-    ps | awk '$2 == '$pid' {exit 1}' && { fail KO; exit 1; } || pass OK
+    ps | awk '$1 == '$pid' || $2 == '$pid' {exit 1}' && { fail KO; exit 1; } || pass OK
 fi
 
 if [ "$VPNRED" ]; then
 fi
 
 if [ "$VPNRED" ]; then
@@ -163,14 +167,16 @@ if [ "$VPNRED" ]; then
         $VPNRED \
         -n udp \
         -n black \
         $VPNRED \
         -n udp \
         -n black \
-        -y $RRED/0809 $RRED/0819 &
+        -y $RRED/0809 $RRED/$RCRY &
     pid=$!
     pids="$pids $pid"
     sleep 1
     pid=$!
     pids="$pids $pid"
     sleep 1
-    ps | awk '$2 == '$pid' {exit 1}' && { fail KO; exit 1; } || pass OK
+    # fix for Android
+    ip rule add from all lookup main
+    ps | awk '$1 == '$pid' || $2 == '$pid' {exit 1}' && { fail KO; exit 1; } || pass OK
 
 
-    launch provisioning software cryptomod
-    $SIMULATOR -v1 -V1 -s PROVISIONING -r $LRED/080B -t $LRED/081B provisioning.eth && pass OK || { fail KO; exit 1; }
+    launch provisioning $CM cryptomod
+    $SIMULATOR -v1 -V1 -s PROVISIONING -r $RRED/080B -t $RRED/$RPRO provisioning.eth && pass OK || { fail KO; exit 1; }
 fi
 
 title press any key to stop
 fi
 
 title press any key to stop