HOME PCB
..csinstall.shstartStream.sh
#!/usr/bin/env bash

sudo resize2fs /dev/mmcblk0p2

sudo apt-get update -y && sudo apt-get upgrade -y
#&& sudo apt-get dist-upgrade -y && sudo rpi-update -y

#pi3b /boot/config.txt dtoverlay=pi3-disable-bt & sudo systemctl disable hciuart & sudo raspi-config

# make sure to restart
sudo shutdown -r now

sudo apt-get install -y raspberrypi-kernel-headers

sudo apt-get install -y dkms build-essential bc dnsmasq hostapd

sudo systemctl stop dnsmasq
sudo systemctl stop hostapd

git clone https://github.com/abperiasamy/rtl8812AU_8821AU_linux.git

cd rtl8812AU_8821AU_linux

sudo ln -s /usr/src/linux-headers-$(uname -r)/arch/arm /usr/src/linux-headers-$(uname -r)/arch/$(uname -m)

sudo make -f Makefile.dkms install

sudo modprobe -a rtl8812au

wifi_interface_id=wlx00e04c1cd65f

sudo cat << EOF >  /etc/network/interfaces

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

    auto ${wifi_interface_id}
    allow-hotplug ${wifi_interface_id}
    iface ${wifi_interface_id} inet manual
    #address 0.0.0.0

EOF

sudo cat << EOF >  /etc/dhcpcd.conf

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

# It is possible to fall back to a static IP if DHCP fails:
# define static profile
#profile static_eth0
#static ip_address=192.168.1.23/24
#static routers=192.168.1.1
#static domain_name_servers=192.168.1.1

# fallback to static profile on eth0
#interface eth0
#fallback static_eth0


interface ${wifi_interface_id}
    static ip_address=192.168.4.1/24

EOF

sudo service dhcpcd restart

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig

sudo cat << EOF >  /etc/dnsmasq.conf

interface=${wifi_interface_id}      # Use the require wireless interface - usually wlan0
  dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h

EOF

sudo cat << EOF > /etc/hostapd/hostapd.conf

ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
interface=${wifi_interface_id}
driver=nl80211

ssid=RPIRedGroup
country_code=SE
ieee80211d=1
hw_mode=g
channel=1
macaddr_acl=0
auth_algs=3
wmm_enabled=1
#ieee80211ac=1
ieee80211n=1
#vht_capab=[SHORT-GI-80][SHORT-GI-160][VHT160-80PLUS80][MU-BEAMFORMER][MU-BEAMFORMEE][SU-BEAMFORMER][SU-BEAMFORMEE]
ht_capab=[SHORT-GI-40][HT40+][HT40-][DSSS_CCK-40]
require_vht=0
#vht_oper_chwidth=1
vht_oper_centr_freq_seg0_idx=40
#vht_oper_centr_freq_seg1_idx=44


EOF

sudo cat << EOF >  /etc/default/hostapd

# Defaults for hostapd initscript
#
# See /usr/share/doc/hostapd/README.Debian for information about alternative
# methods of managing hostapd.
#
# Uncomment and set DAEMON_CONF to the absolute path of a hostapd configuration
# file and hostapd will be started during system boot. An example configuration
# file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz
#
DAEMON_CONF="/etc/hostapd/hostapd.conf"

# Additional daemon options to be appended to hostapd command:-
# 	-d   show more debug messages (-dd for even more)
# 	-K   include key data in debug messages
# 	-t   include timestamps in some debug messages
#
# Note that -B (daemon mode) and -P (pidfile) options are automatically
# configured by the init.d script and must not be added to DAEMON_OPTS.
#
#DAEMON_OPTS=""

EOF

#sudo systemctl daemon-reload

sudo systemctl enable dhcpcd
sudo systemctl enable hostapd
sudo systemctl enable dnsmasq

sudo systemctl restart dhcpcd
sudo systemctl restart hostapd
sudo systemctl restart dnsmasq