Skip to content

Commit

Permalink
feat: adjust run and clean script
Browse files Browse the repository at this point in the history
  • Loading branch information
andy89923 committed Jun 5, 2024
1 parent d3f6e79 commit 0cf15b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
20 changes: 20 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

sudo ip xfrm policy flush
sudo ip xfrm state flush

# Remove all GRE interfaces
echo "[Info] Remove all GRE interfaces"
GREs=$(ip link show type gre | awk 'NR%2==1 {print $2}' | cut -d @ -f 1)
for GRE in ${GREs}; do
sudo ip link del ${GRE}
echo del ${GRE}
done

# Remove all XFRM interfaces
echo "[Info] Remove all XFRM interfaces"
XFRMIs=$(ip link show type xfrm | awk 'NR%2==1 {print $2}' | cut -d @ -f 1)
for XFRMI in ${XFRMIs}; do
sudo ip link del ${XFRMI}
echo del ${XFRMI}
done
20 changes: 4 additions & 16 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,7 @@ PID_LIST=()
function terminate()
{
sleep 1
sudo ip xfrm policy flush
sudo ip xfrm state flush

# Remove all GRE interfaces
GREs=$(ip link show type gre | awk 'NR%2==1 {print $2}' | cut -d @ -f 1)
for GRE in ${GREs}; do
sudo ip link del ${GRE}
done

# Remove all XFRM interfaces
XFRMIs=$(ip link show type xfrm | awk 'NR%2==1 {print $2}' | cut -d @ -f 1)
for XFRMI in ${XFRMIs}; do
sudo ip link del ${XFRMI}
done
sudo ./clean.sh

sudo kill -SIGTERM ${PID_LIST[@]}
}
Expand Down Expand Up @@ -50,9 +37,10 @@ sleep 1
sudo ./n3iwue &
SUDO_N3UE_PID=$!
sleep 0.1
echo $N3UE_PID
N3UE_PID=$(pgrep -P ${N3UE_PID})
echo SUDO_N3UE_PID $SUDO_N3UE_PID
N3UE_PID=$(pgrep -P ${SUDO_N3UE_PID})
PID_LIST+=($SUDO_N3UE_PID $N3UE_PID)
echo N3UE_PID ${N3UE_PID}

trap terminate SIGINT
wait ${PID_LIST}
Expand Down

0 comments on commit 0cf15b6

Please sign in to comment.