Compare commits
11 Commits
d67a5a59df
...
462c09fc88
Author | SHA1 | Date | |
---|---|---|---|
462c09fc88 | |||
1e7eb32c39 | |||
d68d4dfad9 | |||
30473dd9ab | |||
048ca4ecf6 | |||
907db9a538 | |||
32ce3fcf02 | |||
ba6f924f4f | |||
a210bf99f7 | |||
0cf464564f | |||
805edda6b9 |
2
Makefile
2
Makefile
@ -10,6 +10,7 @@ install:
|
||||
install -Dm755 create_ap $(DESTDIR)$(BINDIR)/create_ap
|
||||
install -Dm644 create_ap.conf $(DESTDIR)/etc/create_ap.conf
|
||||
[ ! -d /lib/systemd/system ] || install -Dm644 create_ap.service $(DESTDIR)$(PREFIX)/lib/systemd/system/create_ap.service
|
||||
[ ! -e /sbin/openrc-run ] || install -Dm755 create_ap.openrc $(DESTDIR)/etc/init.d/create_ap
|
||||
install -Dm644 bash_completion $(DESTDIR)$(PREFIX)/share/bash-completion/completions/create_ap
|
||||
install -Dm644 README.md $(DESTDIR)$(PREFIX)/share/doc/create_ap/README.md
|
||||
|
||||
@ -17,5 +18,6 @@ uninstall:
|
||||
rm -f $(DESTDIR)$(BINDIR)/create_ap
|
||||
rm -f $(DESTDIR)/etc/create_ap.conf
|
||||
[ ! -f /lib/systemd/system/create_ap.service ] || rm -f $(DESTDIR)$(PREFIX)/lib/systemd/system/create_ap.service
|
||||
[ ! -e /sbin/openrc-run ] || rm -f $(DESTDIR)/etc/init.d/create_ap
|
||||
rm -f $(DESTDIR)$(PREFIX)/share/bash-completion/completions/create_ap
|
||||
rm -f $(DESTDIR)$(PREFIX)/share/doc/create_ap/README.md
|
||||
|
23
README.md
23
README.md
@ -1,4 +1,19 @@
|
||||
## NOT MAINTAINED
|
||||
|
||||
This project is no longer maintained.
|
||||
|
||||
|
||||
## Forks and continuation of this project
|
||||
|
||||
* [linux-wifi-hotspot] - Fork that is focused on providing GUI and improvements.
|
||||
* [linux-router] - Fork that is focused on providing new features and
|
||||
improvements which are not limited to WiFi. Some interesting features are:
|
||||
sharing Internet to a wired interface and sharing Internet via a transparent
|
||||
proxy using redsocks.
|
||||
|
||||
|
||||
## Features
|
||||
|
||||
* Create an AP (Access Point) at any channel.
|
||||
* Choose one of the following encryptions: WPA, WPA2, WPA/WPA2, Open (no encryption).
|
||||
* Hide your SSID.
|
||||
@ -11,7 +26,9 @@
|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
### General
|
||||
|
||||
* bash (to run this script)
|
||||
* util-linux (for getopt)
|
||||
* procps or procps-ng
|
||||
@ -22,11 +39,13 @@
|
||||
* haveged (optional)
|
||||
|
||||
### For 'NATed' or 'None' Internet sharing method
|
||||
|
||||
* dnsmasq
|
||||
* iptables
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
### Generic
|
||||
git clone https://github.com/oblique/create_ap
|
||||
cd create_ap
|
||||
@ -85,3 +104,7 @@ Using the persistent [systemd](https://wiki.archlinux.org/index.php/systemd#Basi
|
||||
|
||||
## License
|
||||
FreeBSD
|
||||
|
||||
|
||||
[linux-wifi-hotspot]: https://github.com/lakinduakash/linux-wifi-hotspot
|
||||
[linux-router]: https://github.com/garywill/linux-router
|
||||
|
58
create_ap
58
create_ap
@ -62,6 +62,8 @@ usage() {
|
||||
echo " --mac <MAC> Set MAC address"
|
||||
echo " --dhcp-dns <IP1[,IP2]> Set DNS returned by DHCP"
|
||||
echo " --daemon Run create_ap in the background"
|
||||
echo " --pidfile <pidfile> Save daemon PID to file"
|
||||
echo " --logfile <logfile> Save daemon messages to file"
|
||||
echo " --stop <id> Send stop command to an already running create_ap. For an <id>"
|
||||
echo " you can put the PID of create_ap or the WiFi interface. You can"
|
||||
echo " get them with --list-running"
|
||||
@ -101,6 +103,17 @@ usage() {
|
||||
echo " "$PROGNAME" --stop wlan0"
|
||||
}
|
||||
|
||||
# Busybox polyfills
|
||||
if cp --help 2>&1 | grep -q -- --no-clobber; then
|
||||
cp_n() {
|
||||
cp -n "$@"
|
||||
}
|
||||
else
|
||||
cp_n() {
|
||||
yes n | cp -i "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
# on success it echos a non-zero unused FD
|
||||
# on error it echos 0
|
||||
get_avail_fd() {
|
||||
@ -464,8 +477,15 @@ networkmanager_is_running() {
|
||||
[[ -n "$NMCLI_OUT" ]]
|
||||
}
|
||||
|
||||
networkmanager_knows_iface() {
|
||||
# check if the interface $1 is known to NetworkManager
|
||||
# an interface may exist but may not be known to NetworkManager if it is in a different network namespace than NetworkManager
|
||||
nmcli -t -f DEVICE d 2>&1 | grep -Fxq "$1"
|
||||
}
|
||||
|
||||
networkmanager_iface_is_unmanaged() {
|
||||
is_interface "$1" || return 2
|
||||
networkmanager_knows_iface "$1" || return 0
|
||||
(nmcli -t -f DEVICE,STATE d 2>&1 | grep -E "^$1:unmanaged$" > /dev/null 2>&1) || return 1
|
||||
}
|
||||
|
||||
@ -628,6 +648,8 @@ COUNTRY=
|
||||
FREQ_BAND=2.4
|
||||
NEW_MACADDR=
|
||||
DAEMONIZE=0
|
||||
DAEMON_PIDFILE=
|
||||
DAEMON_LOGFILE=/dev/null
|
||||
NO_HAVEGED=0
|
||||
USE_PSK=0
|
||||
|
||||
@ -636,7 +658,7 @@ REDIRECT_TO_LOCALHOST=0
|
||||
|
||||
CONFIG_OPTS=(CHANNEL GATEWAY WPA_VERSION ETC_HOSTS DHCP_DNS NO_DNS NO_DNSMASQ HIDDEN MAC_FILTER MAC_FILTER_ACCEPT ISOLATE_CLIENTS
|
||||
SHARE_METHOD IEEE80211N IEEE80211AC HT_CAPAB VHT_CAPAB DRIVER NO_VIRT COUNTRY FREQ_BAND
|
||||
NEW_MACADDR DAEMONIZE NO_HAVEGED WIFI_IFACE INTERNET_IFACE
|
||||
NEW_MACADDR DAEMONIZE DAEMON_PIDFILE DAEMON_LOGFILE NO_HAVEGED WIFI_IFACE INTERNET_IFACE
|
||||
SSID PASSPHRASE USE_PSK)
|
||||
|
||||
FIX_UNMANAGED=0
|
||||
@ -790,6 +812,10 @@ _cleanup() {
|
||||
|
||||
mutex_unlock
|
||||
cleanup_lock
|
||||
|
||||
if [[ $RUNNING_AS_DAEMON -eq 1 && -n "$DAEMON_PIDFILE" && -f "$DAEMON_PIDFILE" ]]; then
|
||||
rm $DAEMON_PIDFILE
|
||||
fi
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
@ -1028,7 +1054,7 @@ for ((i=0; i<$#; i++)); do
|
||||
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","pidfile:","logfile:","stop:","list","list-running","list-clients:","version","psk","no-haveged","no-dns","no-dnsmasq","mkconfig:","config:" -n "$PROGNAME" -- "$@")
|
||||
[[ $? -ne 0 ]] && exit 1
|
||||
eval set -- "$GETOPT_ARGS"
|
||||
|
||||
@ -1148,6 +1174,16 @@ while :; do
|
||||
shift
|
||||
DAEMONIZE=1
|
||||
;;
|
||||
--pidfile)
|
||||
shift
|
||||
DAEMON_PIDFILE="$1"
|
||||
shift
|
||||
;;
|
||||
--logfile)
|
||||
shift
|
||||
DAEMON_LOGFILE="$1"
|
||||
shift
|
||||
;;
|
||||
--stop)
|
||||
shift
|
||||
STOP_ID="$1"
|
||||
@ -1285,10 +1321,16 @@ if [[ $FIX_UNMANAGED -eq 1 ]]; then
|
||||
fi
|
||||
|
||||
if [[ $DAEMONIZE -eq 1 && $RUNNING_AS_DAEMON -eq 0 ]]; then
|
||||
echo "Running as Daemon..."
|
||||
# Assume we're running underneath a service manager if PIDFILE is set
|
||||
# and don't clobber it's output with a useless message
|
||||
if [ -z "$DAEMON_PIDFILE" ]; then
|
||||
echo "Running as Daemon..."
|
||||
fi
|
||||
# run a detached create_ap
|
||||
RUNNING_AS_DAEMON=1 setsid "$0" "${ARGS[@]}" &
|
||||
RUNNING_AS_DAEMON=1 setsid "$0" "${ARGS[@]}" >>$DAEMON_LOGFILE 2>&1 &
|
||||
exit 0
|
||||
elif [[ $RUNNING_AS_DAEMON -eq 1 && -n "$DAEMON_PIDFILE" ]]; then
|
||||
echo $$ >$DAEMON_PIDFILE
|
||||
fi
|
||||
|
||||
if [[ $FREQ_BAND != 2.4 && $FREQ_BAND != 5 ]]; then
|
||||
@ -1494,12 +1536,12 @@ mkdir -p $COMMON_CONFDIR
|
||||
|
||||
if [[ "$SHARE_METHOD" == "nat" ]]; then
|
||||
echo $INTERNET_IFACE > $CONFDIR/nat_internet_iface
|
||||
cp -n /proc/sys/net/ipv4/conf/$INTERNET_IFACE/forwarding \
|
||||
cp_n /proc/sys/net/ipv4/conf/$INTERNET_IFACE/forwarding \
|
||||
$COMMON_CONFDIR/${INTERNET_IFACE}_forwarding
|
||||
fi
|
||||
cp -n /proc/sys/net/ipv4/ip_forward $COMMON_CONFDIR
|
||||
cp_n /proc/sys/net/ipv4/ip_forward $COMMON_CONFDIR
|
||||
if [[ -e /proc/sys/net/bridge/bridge-nf-call-iptables ]]; then
|
||||
cp -n /proc/sys/net/bridge/bridge-nf-call-iptables $COMMON_CONFDIR
|
||||
cp_n /proc/sys/net/bridge/bridge-nf-call-iptables $COMMON_CONFDIR
|
||||
fi
|
||||
mutex_unlock
|
||||
|
||||
@ -1757,7 +1799,7 @@ if [[ "$SHARE_METHOD" != "none" ]]; then
|
||||
ip link add name $BRIDGE_IFACE type bridge || die
|
||||
ip link set dev $BRIDGE_IFACE up || die
|
||||
# set 0ms forward delay
|
||||
echo 0 > /sys/class/net/$BRIDGE_IFACE/bridge/forward_delay
|
||||
echo -n 0 > /sys/class/net/$BRIDGE_IFACE/bridge/forward_delay
|
||||
|
||||
# attach internet interface to bridge interface
|
||||
ip link set dev $INTERNET_IFACE promisc on || die
|
||||
|
11
create_ap.openrc
Normal file
11
create_ap.openrc
Normal file
@ -0,0 +1,11 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
name=$RC_SVCNAME
|
||||
|
||||
cfgfile=/etc/$RC_SVCNAME.conf
|
||||
pidfile=/run/$RC_SVCNAME.pid
|
||||
|
||||
command=/usr/bin/create_ap
|
||||
command_args="--config $cfgfile"
|
||||
command_args_background="--daemon --pidfile $pidfile"
|
||||
stopsig=USR1
|
Reference in New Issue
Block a user