Skip to content

Commit daf2be6

Browse files
author
Federico Turco
committed
Fixed config files, added wlan0 conf file
1 parent 395cff3 commit daf2be6

File tree

5 files changed

+63
-18
lines changed

5 files changed

+63
-18
lines changed

ModBusServerConfigurator/LinuxInstaller/dnsmasq.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
# ------------------------
66
interface=wlan0
77
dhcp-range=10.0.0.2,10.0.0.254,255.255.255.0,24h
8-
domain=wlan
8+
domain=wlan

ModBusServerConfigurator/LinuxInstaller/hostapd.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ wpa=2
1212
wpa_passphrase=pimodbus
1313
wpa_key_mgmt=WPA-PSK
1414
wpa_pairwise=TKIP
15-
rsn_pairwise=CCMP
15+
rsn_pairwise=CCMP
Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,64 @@
11

2-
sudo su
2+
# root access
3+
PATH_GIT_PROJECT="https://github.com/Fedex1515/ModBusServerConfigurator"
34

4-
PATH_GIT_PROJECT="https://github.com/Fedex1515/ModBusServerConfigurator/settings"
5+
# Installing required packages
6+
sudo apt-get install -y python3-pip
7+
sudo apt-get install -y git
8+
sudo apt-get install -y hostapd
9+
sudo apt-get install -y dnsmasq
510

6-
apt-get install -y python3-pip
7-
apt-get install -y git
8-
apt-get install -y hostapd
9-
apt-get install -y dnsmasq
11+
# Installing python libs for root (used by systemd)
12+
sudo pip3 install pymodbus
13+
sudo pip3 install pyserial
1014

15+
# Installing python libs for pi user (if you need to launch server manually from the shell)
1116
pip3 install pymodbus
1217
pip3 install pyserial
1318

14-
git clone $PATH_GIT_PROJECT
19+
# Cloning git repo in temporary directory
20+
git clone $PATH_GIT_PROJECT tmp/
1521

16-
cp ModBusServerConfigurator/LinuxInstaller/hostapd.conf /etc/hostapd/hostapd.conf
17-
cp ModBusServerConfigurator/LinuxInstaller/dnsmasq.conf /etc/dnsmasq.conf
18-
19-
cp ModBusServerConfigurator/PythonEngine /home/pi/ModBusServerConfigurator
22+
# Copying config files for hostapd (hotspot wifi) and dnsmasq (dhcp server wlan side)
23+
sudo cp tmp/ModBusServerConfigurator/LinuxInstaller/hostapd.conf /etc/hostapd/hostapd.conf
24+
sudo cp tmp/ModBusServerConfigurator/LinuxInstaller/dnsmasq.conf /etc/dnsmasq.conf
25+
sudo cp tmp/ModBusServerConfigurator/LinuxInstaller/wlan0 /etc/network/interfaces.d/wlan0
2026

27+
# Copying python server in home directory
28+
cp -r tmp/ModBusServerConfigurator/PythonEngine /home/pi/ModBusServerConfigurator
2129
chown pi /home/pi/ModBusServerConfigurator/config.json
2230

23-
ln -s /home/pi/ModBusServerConfigurator/modbus.service /etc/systemd/system/modbus.service
24-
systemctl enable modbus.service
31+
# Creating symlink for systemd service file
32+
sudo rm /etc/systemd/system/modbus.service
33+
sudo ln -s /home/pi/ModBusServerConfigurator/modbus.service /etc/systemd/system/modbus.service
34+
sudo systemctl enable modbus.service
2535

26-
exit
36+
# Removing temporary files
37+
rm -r -f tmp/
2738

28-
pip3 install pymodbus
29-
pip3 install pyserial
39+
# Sometimes the hostapd service is masked after the installation so i solve this checking the actual status
40+
if sudo service hostapd status | grep "Loaded: masked" -q;
41+
then
42+
echo "Hostapd status masked, it needs to be unmasked, ..."
43+
sudo systemctl unmask hostapd.service
44+
sudo systemctl enable hostapd.service
45+
#sudo service hostapd status
46+
sudo service hostapd status | grep "Loaded: masked"
47+
sudo service hostapd start
48+
#sudo service hostapd status
49+
sudo service hostapd status | grep "Loaded: masked"
50+
51+
if sudo service hostapd status | grep "Loaded: masked" -q;
52+
then
53+
echo "Error running unmask command on hostapd.service"
54+
else
55+
echo "Hostapd status OK"
56+
fi
57+
else
58+
echo "Hostapd status OK"
59+
fi
60+
61+
# Now i configure wlan0 manually
62+
sudo ifconfig wlan0 10.0.0.1 netmask 255.255.255.0
63+
64+
# But i also add the config entry in th network file
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#/etc/network/interfaces.d/wlan0
2+
3+
# ------------------------
4+
# ------ WIFI WLAN0 ------
5+
# ------------------------
6+
auto wlan0
7+
iface wlan0 inet static
8+
address 10.0.0.1
9+
netmask 255.255.255.0

ModBusServerConfigurator/ModBusServerConfigurator.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
<Generator>ResXFileCodeGenerator</Generator>
118118
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
119119
</EmbeddedResource>
120+
<None Include="LinuxInstaller\wlan0" />
120121
<None Include="LinuxInstaller\dnsmasq.conf" />
121122
<None Include="LinuxInstaller\hostapd.conf" />
122123
<None Include="LinuxInstaller\installer.sh" />

0 commit comments

Comments
 (0)