-1

I am working with a Dialog GUI.

./sdvpn.sh is the code for the GUI main menu, shown below.

./killvpn.sh is a script containing only one command, sudo pkill vpn

./region.sh is a Dialog menu allowing to specify the country you desire your VPN to connect to.

When I want to kill any active OpenVPN connections, I select option 2 on the menu below:

`#!/bin/bash

#Main Menu

HEIGHT=15
WIDTH=40
CHOICE_HEIGHT=4
BACKTITLE="VPN"
TITLE="Main Menu"
MENU="Choose an Option: "

OPTIONS=(1 "VPN Menu"
         2 "Kill Active VPN")

CHOICE=$(dialog --clear \
                --backtitle "$BACKTITLE" \
                --title "$TITLE" \
                --menu "$MENU" \
                $HEIGHT $WIDTH $CHOICE_HEIGHT \
                "${OPTIONS[@]}" \
                2>&1 >/dev/tty)

clear
case $CHOICE in
        1)
        cd ~/VPN/gui
        ./region.sh
        ;;
        2)
        cd ~/VPN/scripts
        ./killvpn.sh
        cd ~/VPN
        ./sdvpn.sh
        ;;

 esac`

This code for Option 2 is supposed to achieve the following:

  • lead to my Scripts directory
  • Exectute sudo pkill vpn
  • Return to the main folder where my main menu.sh is kept
  • Run the main menu, taking the process full circle.

The Problem

It will not return to the main menu, and I have no way to troubleshoot this. The same methodology worked perfectly when rolled out on Kali Linux 2018.2.

When I execute sudo pkill vpn or my killvpn.sh file, it simply kills the VPN connections as expected. However when running the same script from the Dialog GUI, I receive a message which says "Terminated."

I have tried rerouting the killvpn.sh to activate the Dialog GUI as part of its script, but the same problem occured. I have then tried, with both sudo pkill vpn and killvpn.sh to include the sleep command, as I was simply returned to the terminal, and believed this was a process it could execute in order to continue running the code, but this failed too.

I am now unable to kill the VPN from my GUI, and I would like to know if there was a way I can either remove the "Terminated." message, or a way to accomplish my task. As a bonus ball, I would be grateful if someone could explain to me under what conditions will pkill vpn display this message, so I can avoid it in the future.

0

In this case, I found that using the command sudo killall openvpn was both a more effective way of terminating OpenVPN Connections, and also avoided the dialog I got with sudo pkill vpn allowing me to return to the dialog menu without any issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy