handle service's stop correctly
This commit is contained in:
parent
d388c593ab
commit
92b696efcf
12
create_ap
12
create_ap
@ -242,6 +242,11 @@ die() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clean_exit() {
|
||||||
|
cleanup
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
# if the user press ctrl+c then execute die()
|
# if the user press ctrl+c then execute die()
|
||||||
trap "die" SIGINT
|
trap "die" SIGINT
|
||||||
|
|
||||||
@ -525,7 +530,9 @@ fi
|
|||||||
|
|
||||||
# start access point
|
# start access point
|
||||||
echo "hostapd command-line interface: hostapd_cli -p $CONFDIR/hostapd_ctrl"
|
echo "hostapd command-line interface: hostapd_cli -p $CONFDIR/hostapd_ctrl"
|
||||||
trap - SIGINT # reset trap
|
|
||||||
|
# from now on we exit with 0 on SIGINT
|
||||||
|
trap "clean_exit" SIGINT
|
||||||
|
|
||||||
if ! hostapd $CONFDIR/hostapd.conf; then
|
if ! hostapd $CONFDIR/hostapd.conf; then
|
||||||
echo -e "\nError: Failed to run hostapd, maybe a program is interfering." >&2
|
echo -e "\nError: Failed to run hostapd, maybe a program is interfering." >&2
|
||||||
@ -542,5 +549,4 @@ if ! hostapd $CONFDIR/hostapd.conf; then
|
|||||||
die
|
die
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cleanup
|
clean_exit
|
||||||
exit 0
|
|
||||||
|
@ -4,8 +4,7 @@ After=network.target
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/usr/bin/bash create_ap -n -g 10.0.0.1 wlan0 AccessPointSSID
|
ExecStart=/usr/bin/create_ap -n -g 10.0.0.1 wlan0 AccessPointSSID
|
||||||
ExecStop=pkill hostapd
|
|
||||||
KillSignal=SIGINT
|
KillSignal=SIGINT
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartSec=5
|
RestartSec=5
|
||||||
|
Loading…
Reference in New Issue
Block a user