generated from pavel.muhortov/template-bash
added status
This commit is contained in:
parent
d773f2bd66
commit
1c1b787d54
|
@ -1,13 +1,13 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# chkconfig: 2345 20 80
|
# chkconfig: 2345 20 80
|
||||||
|
|
||||||
### BEGIN INIT INFO
|
### BEGIN INIT INFO
|
||||||
# Provides: wireguard
|
# Provides: wireguard
|
||||||
# Required-Start: $all
|
# Required-Start: $all
|
||||||
# Required-Stop:
|
# Required-Stop:
|
||||||
# Default-Start: 2 3 4 5
|
# Default-Start: 2 3 4 5
|
||||||
# Default-Stop:
|
# Default-Stop:
|
||||||
# Short-Description: Launch Wireguard without creating route table
|
# Short-Description: Launch Wireguard without creating route table
|
||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
wifname=$(basename -s .service "$0" | cut -d'@' -f2)
|
wifname=$(basename -s .service "$0" | cut -d'@' -f2)
|
||||||
|
@ -41,7 +41,15 @@ stop() {
|
||||||
rm -f "/etc/wireguard/${wifname}.key"
|
rm -f "/etc/wireguard/${wifname}.key"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
status() {
|
||||||
|
if ip a grep -q -w "${wifname}"; then
|
||||||
|
ip a | grep -w "${wifname}"
|
||||||
|
else
|
||||||
|
echo "${wifname} down"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
|
@ -50,10 +58,14 @@ case "$1" in
|
||||||
;;
|
;;
|
||||||
restart)
|
restart)
|
||||||
stop
|
stop
|
||||||
|
sleep 1
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
|
status)
|
||||||
|
status
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {start|stop|restart}"
|
echo "Usage: $0 {start|stop|restart|status}"
|
||||||
esac
|
esac
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user