From 92b696efcf66301d89d553ad8a3ae75a6ad10149 Mon Sep 17 00:00:00 2001 From: oblique Date: Sun, 17 Aug 2014 04:22:23 +0300 Subject: [PATCH] handle service's stop correctly --- create_ap | 12 +++++++++--- create_ap.service | 3 +-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/create_ap b/create_ap index e981980..f781957 100755 --- a/create_ap +++ b/create_ap @@ -242,6 +242,11 @@ die() { exit 1 } +clean_exit() { + cleanup + exit 0 +} + # if the user press ctrl+c then execute die() trap "die" SIGINT @@ -525,7 +530,9 @@ fi # start access point 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 echo -e "\nError: Failed to run hostapd, maybe a program is interfering." >&2 @@ -542,5 +549,4 @@ if ! hostapd $CONFDIR/hostapd.conf; then die fi -cleanup -exit 0 +clean_exit diff --git a/create_ap.service b/create_ap.service index bd5b1fe..4b49835 100644 --- a/create_ap.service +++ b/create_ap.service @@ -4,8 +4,7 @@ After=network.target [Service] Type=simple -ExecStart=/usr/bin/bash create_ap -n -g 10.0.0.1 wlan0 AccessPointSSID -ExecStop=pkill hostapd +ExecStart=/usr/bin/create_ap -n -g 10.0.0.1 wlan0 AccessPointSSID KillSignal=SIGINT Restart=on-failure RestartSec=5