-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
120 lines (89 loc) · 3.93 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#
# This source file is part of the JASS 2021 open source project
#
# SPDX-FileCopyrightText: 2019-2021 Paul Schmiedmayer and the JASS 2021 project authors (see CONTRIBUTORS.md) <[email protected]>
#
# SPDX-License-Identifier: MIT
#
RASPBERRYPILETTER="${1:-A}"
WIFIPASSWORD="${2:-RaspberryPi$RASPBERRYPILETTER}"
export DEBIAN_FRONTEND=noninteractive
export NEEDRESTART_MODE=a
sudo DEBIAN_FRONTEND=noninteractive apt-get -y update
sudo DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
# Access point setup based on the instructions found at https://www.raspberrypi.com/documentation/computers/configuration.html#setting-up-a-routed-wireless-access-point
printf "DNSStubListener=no" | sudo tee -a /etc/systemd/resolved.conf
sudo systemctl restart systemd-resolved
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install rfkill hostapd dnsmasq netfilter-persistent iptables-persistent
## dnsmasq
printf "interface=wlan0
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h" | sudo tee /etc/dnsmasq.conf
printf "net.ipv4.ip_forward=1" | sudo tee /etc/sysctl.d/routed-ap.conf
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo netfilter-persistent save
sudo sed -i "s/^Wants=nss-lookup.target/Wants=nss-lookup.target network-online.target/" /lib/systemd/system/dnsmasq.service
sudo sed -i "s/^After=network.target/After=network.target network-online.target/" /lib/systemd/system/dnsmasq.service
printf "# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
version: 2
ethernets:
eth0:
dhcp4: true
optional: true
wlan0:
dhcp4: false
addresses:
- 192.168.4.1/24" | sudo tee /etc/netplan/50-cloud-init.yaml
printf "127.0.0.1 localhost
127.0.1.1 ubuntu RaspberryPi$RASPBERRYPILETTER
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters" | sudo tee /etc/hostname
sudo systemctl reload dnsmasq
## hostapd
printf "country_code=DE
interface=wlan0
ssid=RaspberryPi$RASPBERRYPILETTER
hw_mode=g
channel=7
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=$WIFIPASSWORD
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP" | sudo tee /etc/hostapd/hostapd.conf
printf 'DAEMON_CONF="/etc/hostapd/hostapd.conf"' | sudo tee -a /etc/default/hostapd
sudo rfkill unblock wlan
sudo systemctl unmask hostapd
sudo systemctl enable hostapd
sudo systemctl start hostapd
# Download and start avahi
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install avahi-utils avahi-daemon
sudo sed -i "s/^publish-hinfo=.*/publish-hinfo=yes/" /etc/avahi/avahi-daemon.conf
sudo sed -i "s/^publish-workstation=.*/publish-workstation=yes/" /etc/avahi/avahi-daemon.conf
sudo systemctl enable avahi-daemon.service
sudo systemctl start avahi-daemon.service
# Install Docker
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install linux-modules-extra-raspi ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo DEBIAN_FRONTEND=noninteractive gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo DEBIAN_FRONTEND=noninteractive apt-get -y update
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install docker-ce docker-ce-cli containerd.io
sudo groupadd docker
sudo usermod -aG docker $USER
docker --version
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
# Reboot
sudo systemctl reboot