tiny/base_install

89 lines
2.0 KiB
Bash

#!/bin/bash
apt -y install dnsmasq hostapd iptables-persistent
cat <<EOF>> /etc/dhcpcd.conf
interface uap0
static ip_address=192.168.50.1/24
nohook wpa_supplicant
EOF
mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
cat <<EOF> /etc/dnsmasq.conf
interface=lo,uap0 #Use interfaces lo and uap0
bind-interfaces #Bind to the interfaces
server=8.8.8.8 #Forward DNS requests to Google DNS
domain-needed #Don't forward short names
bogus-priv #Never forward addresses in the non-routed address spaces
# Assign IP addresses between 192.168.70.50 and 192.168.70.150 with a 12-hour lease time
dhcp-range=192.168.70.50,192.168.70.150,12h
EOF
cat <<EOF> /etc/hostapd/hostapd.conf
channel=1
ssid=farofa
wpa_passphrase=mistoquente2019#
interface=uap0
hw_mode=g
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
driver=nl80211
EOF
cat <<EOF> /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
DAEMON_OPTS="-d -t -f /var/log/hostapd.log"
EOF
cat <<EOF> /usr/local/bin/wifistart
#!/bin/bash
iw dev wlan0 interface add uap0 type __ap
ifconfig uap0 up
ifconfig uap0 192.168.70.1 netmask 255.255.255.0 broadcast 192.168.70.255
EOF
chmod +x /usr/local/bin/wifistart
cat <<EOF> /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi
/usr/local/bin/wifistart
exit 0
EOF
sed -i 's/\#net.ipv4.ip_forward\=1/net.ipv4.ip_forward\=1/g' /etc/sysctl.conf
iptables -t nat -A POSTROUTING -j MASQUERADE
netfilter-persistent save
systemctl unmask hostapd
systemctl enable hostapd
systemctl unmask dnsmasq
systemctl enable dnsmasq