delete uneeded

This commit is contained in:
garywill 2018-08-31 18:41:06 +08:00 committed by garywill
parent 8d75d7324e
commit 5a27e96851
1 changed files with 4 additions and 92 deletions

96
create_ap Normal file → Executable file
View File

@ -9,8 +9,6 @@
# iw # iw
# iwconfig (you only need this if 'iw' can not recognize your adapter) # iwconfig (you only need this if 'iw' can not recognize your adapter)
# haveged (optional) # haveged (optional)
# dependencies for 'nat' or 'none' Internet sharing method
# dnsmasq # dnsmasq
# iptables # iptables
@ -69,8 +67,8 @@ usage() {
echo " For an <id> you can put the PID of create_ap or the WiFi interface." echo " For an <id> you can put the PID of create_ap or the WiFi interface."
echo " If virtual WiFi interface was created, then use that one." echo " If virtual WiFi interface was created, then use that one."
echo " You can get them with --list-running" echo " You can get them with --list-running"
echo " --mkconfig <conf_file> Store configs in conf_file" #echo " --mkconfig <conf_file> Store configs in conf_file"
echo " --config <conf_file> Load configs from conf_file" #echo " --config <conf_file> Load configs from conf_file"
echo echo
echo "Non-Bridging Options:" echo "Non-Bridging Options:"
echo " --no-dns Disable dnsmasq DNS server" echo " --no-dns Disable dnsmasq DNS server"
@ -636,8 +634,6 @@ LIST_RUNNING=0
STOP_ID= STOP_ID=
LIST_CLIENTS_ID= LIST_CLIENTS_ID=
STORE_CONFIG=
LOAD_CONFIG=
CONFDIR= CONFDIR=
WIFI_IFACE= WIFI_IFACE=
@ -711,7 +707,7 @@ _cleanup() {
iptables -w -t nat -D POSTROUTING -s ${GATEWAY%.*}.0/24 ! -o ${WIFI_IFACE} -j MASQUERADE iptables -w -t nat -D POSTROUTING -s ${GATEWAY%.*}.0/24 ! -o ${WIFI_IFACE} -j MASQUERADE
iptables -w -D FORWARD -i ${WIFI_IFACE} -s ${GATEWAY%.*}.0/24 -j ACCEPT iptables -w -D FORWARD -i ${WIFI_IFACE} -s ${GATEWAY%.*}.0/24 -j ACCEPT
iptables -w -D FORWARD -i ${INTERNET_IFACE} -d ${GATEWAY%.*}.0/24 -j ACCEPT iptables -w -D FORWARD -i ${INTERNET_IFACE} -d ${GATEWAY%.*}.0/24 -j ACCEPT
fi
fi fi
@ -912,76 +908,9 @@ send_stop() {
mutex_unlock 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
WIFI_IFACE=$1
if [[ "$SHARE_METHOD" == "none" ]]; then
SSID="$2"
PASSPHRASE="$3"
else
INTERNET_IFACE="$2"
SSID="$3"
PASSPHRASE="$4"
fi
for config_opt in "${CONFIG_OPTS[@]}"; do
eval echo $config_opt=\$$config_opt
done >> "$STORE_CONFIG"
echo -e "Config options written to '$STORE_CONFIG'"
exit 0
}
is_config_opt() {
local elem opt="$1"
for elem in "${CONFIG_OPTS[@]}"; do
if [[ "$elem" == "$opt" ]]; then
return 0
fi
done
return 1
}
# Load options from config file
read_config() {
local opt_name opt_val line
while read line; do
# Read switches and their values
opt_name="${line%%=*}"
opt_val="${line#*=}"
if is_config_opt "$opt_name" ; then
eval $opt_name="\$opt_val"
else
echo "WARN: Unrecognized configuration entry $opt_name" >&2
fi
done < "$LOAD_CONFIG"
}
ARGS=( "$@" ) ARGS=( "$@" )
# Preprocessing for --config before option-parsing starts
for ((i=0; i<$#; i++)); do
if [[ "${ARGS[i]}" = "--config" ]]; then
if [[ -f "${ARGS[i+1]}" ]]; then
LOAD_CONFIG="${ARGS[i+1]}"
read_config
else
echo "ERROR: No config file found at given location" >&2
exit 1
fi
break
fi
done
GETOPT_ARGS=$(getopt -o hc:w:g:de:nm: -l "help","hidden","hostapd-debug:","redirect-to-localhost","mac-filter","mac-filter-accept:","isolate-clients","ieee80211n","ieee80211ac","ht_capab:","vht_capab:","driver:","no-virt","fix-unmanaged","country:","freq-band:","mac:","dhcp-dns:","daemon","stop:","list","list-running","list-clients:","version","psk","no-haveged","no-dns","no-dnsmasq","mkconfig:","config:" -n "$PROGNAME" -- "$@") GETOPT_ARGS=$(getopt -o hc:w:g:de:nm: -l "help","hidden","hostapd-debug:","redirect-to-localhost","mac-filter","mac-filter-accept:","isolate-clients","ieee80211n","ieee80211ac","ht_capab:","vht_capab:","driver:","no-virt","fix-unmanaged","country:","freq-band:","mac:","dhcp-dns:","daemon","stop:","list","list-running","list-clients:","version","psk","no-haveged","no-dns","no-dnsmasq","mkconfig:","config:" -n "$PROGNAME" -- "$@")
[[ $? -ne 0 ]] && exit 1 [[ $? -ne 0 ]] && exit 1
@ -1154,15 +1083,6 @@ while :; do
fi fi
shift shift
;; ;;
--mkconfig)
shift
STORE_CONFIG="$1"
shift
;;
--config)
shift
shift
;;
--) --)
shift shift
break break
@ -1209,7 +1129,6 @@ trap "clean_exit" SIGINT SIGUSR1
# if we get USR2 signal then run die(). # if we get USR2 signal then run die().
trap "die" SIGUSR2 trap "die" SIGUSR2
[[ -n "$STORE_CONFIG" ]] && write_config "$@"
if [[ $LIST_RUNNING -eq 1 ]]; then if [[ $LIST_RUNNING -eq 1 ]]; then
echo -e "List of running $PROGNAME instances:\n" echo -e "List of running $PROGNAME instances:\n"
@ -1670,7 +1589,7 @@ if [[ "$SHARE_METHOD" != "none" ]]; then
# to enable clients to establish PPTP connections we must # to enable clients to establish PPTP connections we must
# load nf_nat_pptp module # load nf_nat_pptp module
modprobe nf_nat_pptp > /dev/null 2>&1 modprobe nf_nat_pptp > /dev/null 2>&1
fi
else else
echo "No Internet sharing" echo "No Internet sharing"
fi fi
@ -1737,10 +1656,3 @@ if ! wait $HOSTAPD_PID; then
fi fi
clean_exit clean_exit
# Local Variables:
# tab-width: 4
# indent-tabs-mode: nil
# End:
# vim: et sts=4 sw=4