-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitial_config.sh
More file actions
158 lines (130 loc) · 4.5 KB
/
initial_config.sh
File metadata and controls
158 lines (130 loc) · 4.5 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
# Update and upgrade the system
read -p "Would you like to update system first? (y/n): " update_sys
if [ "$update_sys" == "y" ]; then
echo "Updating system..."
sudo apt update && sudo apt upgrade -y
else
echo "Skipping system updates..."
fi
# Install required packages
echo "Installing packages..."
sudo apt install ufw
sudo apt install -y dnsmasq docker-compose
sudo apt install mosquitto mosquitto-clients # Check with sudo systemctl status mosquitto
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs npm
sudo apt-install build-essential clang
sudo apt-get install libboost-all-dev libpaho-mqttpp-dev
git clone https://github.com/mccdaq/daqhats.git
sudo ./daqhats/install.sh
# If the Wifi-Adapter isn't plugged in, select & install the driver for the AC5L model
sh -c 'wget linux.brostrend.com/install -O /tmp/install && sh /tmp/install'
sudo nmcli device wifi hotspot ssid hotspot password rocketry ifname wlan1
# Backup existing dhcpcd.conf and create a new one
echo "Backing up Files..."
sudo cp /etc/dhcpcd.conf /etc/dhcpcd.conf.v1
# Install dhcpcd5 and desktop ui
echo "Installing packages..."
sudo apt install dhcpcd5 --fix-missing
sudo apt install --reinstall raspberrypi-ui-mods
#firewall set up
echo "Setting up firewall ..."
sudo ufw allow 8000/tcp
sudo ufw allow 8000/udp
sudo ufw disable
# sudo ufw status
# Backup existing dhcpcd.conf,dnsmasq.conf, and host files
echo "Backing up Files..."
sudo mv /etc/dhcpcd.conf /etc/dhcpcd.conf.v2
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo cp /etc/hosts /etc/hosts.orig
# Set a static IP address for Ethernet (eth0)
echo "Configuring static IP address for for the Raspberry Pi Ethernet..."
sudo bash -c '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
# vendorclassid is set to blank to avoid sending the default of
# dhcpcd-<version>:<os>:<machine>:<platform>
vendorclassid
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu
# Request a hostname from the network
option host_name
# Most distributions have NTP support.
#option ntp_servers
# 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 ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private
interface eth0
static ip_address=192.168.0.1
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 8.8.8.8
EOF'
# Configure dnsmasq for DHCP
echo "Setting up dnsmasq for DHCP..."
sudo bash -c 'cat << EOF > /etc/dnsmasq.conf
interface=eth0
bind-dynamic
domain-needed
bogus-priv
expand-hosts
domain=local
dhcp-range=192.168.0.2,192.168.0.150,255.255.255.0,12h
EOF'
#Add a local host to the hosts file
echo "Adding local host..."
sudo bash -c 'cat << EOF > /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
EOF'
# Add custom Mosquitto configuration file
echo "Customizing Mosquitto configuration..."
sudo touch /etc/mosquitto/conf.D/novamqtt.conf
sudo bash -c 'cat << EOF > /etc/mosquitto/conf.D/novamqtt.conf
listener 1883
allow_anonymous true
EOF'
echo "Restarting Mosquitto..."
sudo systemctl restart mosquitto
# Check if Docker is installed
echo "Installing Docker..."
if command -v docker &> /dev/null
then
echo "Docker is already installed."
else
echo "Docker is not installed. Installing Docker..."
# Install Docker
curl -sSL https://get.docker.com | sh
# Add the current user to the Docker group
sudo usermod -aG docker {$USER}
echo "Docker installation complete. Please log out and log back in to apply group changes."
fi
#reboot
echo "Rebooting Raspberry Pi..."
sudo reboot