Support --mkconfig option
When invoked with --mkconfig <conf_file>, the options are stored in conf_file and create_ap exits.
This commit is contained in:
parent
3ca3663894
commit
13569a5a42
@ -2,6 +2,14 @@
|
||||
# Bash Completion routine for create_ap
|
||||
#
|
||||
|
||||
_use_filedir() {
|
||||
if [[ $(type -t _filedir) == "function" ]]; then
|
||||
_filedir
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
_create_ap() {
|
||||
local awk_cmd='
|
||||
($1 ~ /^-/) {
|
||||
@ -117,6 +125,9 @@ _create_ap() {
|
||||
--list)
|
||||
# No Options
|
||||
;;
|
||||
--mkconfig)
|
||||
_use_filedir && return 0
|
||||
;;
|
||||
-g)
|
||||
# Not going to implement
|
||||
;;
|
||||
|
44
create_ap
44
create_ap
@ -57,6 +57,7 @@ usage() {
|
||||
echo " you can put the PID of create_ap or the WiFi interface. You can"
|
||||
echo " get them with --list"
|
||||
echo " --list Show the create_ap processes that are already running"
|
||||
echo " --mkconfig <conf_file> Store configs in conf_file"
|
||||
echo
|
||||
echo "Non-Bridging Options:"
|
||||
echo " -g <gateway> IPv4 Gateway for the Access Point (default: 192.168.12.1)"
|
||||
@ -574,14 +575,21 @@ IEEE80211N=0
|
||||
HT_CAPAB='[HT40+]'
|
||||
DRIVER=nl80211
|
||||
NO_VIRT=0
|
||||
FIX_UNMANAGED=0
|
||||
COUNTRY=
|
||||
FREQ_BAND=2.4
|
||||
NEW_MACADDR=
|
||||
DAEMONIZE=0
|
||||
NO_HAVEGED=0
|
||||
|
||||
CONFIG_OPTS=(CHANNEL GATEWAY WPA_VERSION ETC_HOST HIDDEN SHARE_METHOD
|
||||
IEEE80211N HT_CAPAB DRIVER NO_VIRT COUNTRY FREQ_BAND
|
||||
NEW_MACADDR DAEMONIZE NO_HAVEGED)
|
||||
|
||||
FIX_UNMANAGED=0
|
||||
LIST_RUNNING=0
|
||||
STOP_ID=
|
||||
NO_HAVEGED=0
|
||||
|
||||
STORE_CONFIG=
|
||||
|
||||
CONFDIR=
|
||||
WIFI_IFACE=
|
||||
@ -806,8 +814,31 @@ send_stop() {
|
||||
mutex_unlock
|
||||
}
|
||||
|
||||
# Storing configs
|
||||
write_config() {
|
||||
local i=1
|
||||
|
||||
if ! eval 'echo -n > "$STORE_CONFIG"' > /dev/null 2>&1; then
|
||||
echo "ERROR: Unable to create config file $STORE_CONFIG" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for config_opt in "${CONFIG_OPTS[@]}"; do
|
||||
eval echo $config_opt=\$$config_opt
|
||||
done >> "$STORE_CONFIG"
|
||||
|
||||
while [[ $# -ne 0 ]]; do
|
||||
echo "ARG$i=$1"
|
||||
shift
|
||||
((i++))
|
||||
done >> "$STORE_CONFIG"
|
||||
|
||||
echo -e "\nConfigs written to $STORE_CONFIG"
|
||||
exit 0
|
||||
}
|
||||
|
||||
ARGS=( "$@" )
|
||||
GETOPT_ARGS=$(getopt -o hc:w:g:dnm: -l "help","hidden","ieee80211n","ht_capab:","driver:","no-virt","fix-unmanaged","country:","freq-band:","mac:","daemon","stop:","list","version","no-haveged" -n "$PROGNAME" -- "$@")
|
||||
GETOPT_ARGS=$(getopt -o hc:w:g:dnm: -l "help","hidden","ieee80211n","ht_capab:","driver:","no-virt","fix-unmanaged","country:","freq-band:","mac:","daemon","stop:","list","version","no-haveged","mkconfig:" -n "$PROGNAME" -- "$@")
|
||||
[[ $? -ne 0 ]] && exit 1
|
||||
eval set -- "$GETOPT_ARGS"
|
||||
|
||||
@ -908,6 +939,11 @@ while :; do
|
||||
shift
|
||||
NO_HAVEGED=1
|
||||
;;
|
||||
--mkconfig)
|
||||
shift
|
||||
STORE_CONFIG="$1"
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
@ -934,6 +970,8 @@ trap "clean_exit" SIGINT SIGUSR1
|
||||
# if we get USR2 signal then run die().
|
||||
trap "die" SIGUSR2
|
||||
|
||||
[[ -n "$STORE_CONFIG" ]] && write_config "$@"
|
||||
|
||||
if [[ $LIST_RUNNING -eq 1 ]]; then
|
||||
echo -e "List of running $PROGNAME instances:\n"
|
||||
list_running
|
||||
|
Loading…
Reference in New Issue
Block a user