source: systemd-units/blfs/services/wpa@ be67218

systemd-11177
Last change on this file since be67218 was be67218, checked in by Krejzi <krejzi@…>, 10 years ago

Merge more Christopher's work. Import systemd units.

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/branches/systemd@13507 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 2.3 KB
Line 
1#!/bin/bash
2# Begin services/wpa
3
4# Origianlly based upon lfs-bootscripts-1.12 $NETWORK_DEVICES/if{down,up}
5# Written by Armin K. <krejzi at email dot com>
6
7# Call with: IFCONFIG=<filename> /lib/services/wpa <IFACE> <up | down>
8
9#$LastChangedBy: krejzi $
10#$Date: 2013-03-24 16:39:14 +0100 (Sun, 24 Mar 2013) $
11
12. /lib/lsb/init-functions
13. $IFCONFIG
14
15CFGFILE=/etc/sysconfig/wpa_supplicant-${IFCONFIG##*.}.conf
16PIDFILE=/run/wpa_supplicant/$1.pid
17CONTROL_IFACE=/run/wpa_supplicant/$1
18
19case "$2" in
20 up)
21
22 if [ -e ${PIDFILE} ]; then
23 ps $(cat ${PIDFILE}) | grep wpa_supplicant >/dev/null
24 if [ "$?" = "0" ]; then
25 log_warning_msg "\n wpa_supplicant already running on $1."
26 exit 0
27 else
28 rm ${PIDFILE}
29 fi
30 fi
31
32 if [ ! -e ${CFGFILE} ]; then
33 log_info_msg "\n wpa_supplicant configuration file ${CFGFILE} not present"
34 log_failure_msg2
35 exit 1
36 fi
37
38 log_info_msg "\n Starting wpa_supplicant on the $1 interface..."
39
40 mkdir -p /run/wpa_supplicant
41
42 /sbin/wpa_supplicant -q -B -Dnl80211,wext -P${PIDFILE} -C/run/wpa_supplicant -c${CFGFILE} -i$1 ${WPA_ARGS}
43
44 if [ "$?" != "0" ]; then
45 log_failure_msg2
46 exit 1
47 fi
48
49 log_success_msg2
50
51 if [ -n "${WPA_SERVICE}" ]; then
52 if [ ! -e /lib/services/${WPA_SERVICE} -a ! -x /lib/services/${WPA_SERVICE} ]; then
53 log_info_msg "\n Cannot start ${WPA_SERVICE} on $1"
54 log_failure_msg2
55 exit 1
56 fi
57
58 IFCONFIG=${IFCONFIG} /lib/services/${WPA_SERVICE} $1 up
59 fi
60 ;;
61
62 down)
63 if [ -n "${WPA_SERVICE}" ]; then
64 if [ ! -e /lib/services/${WPA_SERVICE} -a ! -x /lib/services/${WPA_SERVICE} ]; then
65 log_warning_msg "\n Cannot stop ${WPA_SERVICE} on $1"
66 else
67 IFCONFIG=${IFCONFIG} /lib/services/${WPA_SERVICE} $1 down
68 fi
69 fi
70
71 log_info_msg "\n Stopping wpa_supplicant on the $1 interface..."
72
73 if [ -e ${PIDFILE} ]; then
74 kill -9 $(cat ${PIDFILE})
75 rm -f ${PIDFILE} ${CONTROL_IFACE}
76 evaluate_retval
77 else
78 log_warning_msg "\n wpa_supplicant already stopped on $1"
79 exit 0
80 fi
81 ;;
82
83 *)
84 echo "Usage: $0 [interface] {up|down}"
85 exit 1
86 ;;
87esac
88
89# End services/wpa
Note: See TracBrowser for help on using the repository browser.