mirror of
https://github.com/edu4rdshl/linuxscripts.git
synced 2026-07-17 23:24:52 +00:00
Make test before trying to stop the openvpn service
This commit is contained in:
parent
aa2a5a0a62
commit
bd5c92a649
1 changed files with 4 additions and 2 deletions
|
|
@ -4,18 +4,20 @@
|
|||
# Example: hk-04.conf
|
||||
|
||||
workdir="/etc/openvpn/client/"
|
||||
isopenvpn=$(command -v openvpn > /dev/null)
|
||||
issystemd=$(command -v systemctl > /dev/null)
|
||||
|
||||
if [ $UID -ne 0 ]; then
|
||||
echo "You need root privileges."
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$1" == "stop" ]; then
|
||||
if $isopenvpn && $issystemd && [ "$1" == "stop" ]; then
|
||||
systemctl stop openvpn-client@*
|
||||
exit
|
||||
fi
|
||||
|
||||
if command -v openvpn > /dev/null && command -v systemctl > /dev/null; then
|
||||
if $isopenvpn && $issystemd; then
|
||||
if [ -d "$workdir" ]; then
|
||||
cd "$workdir"
|
||||
vpn=$(shuf -ezn 1 * | xargs -0 -n1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue