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)
1116pip3 install pymodbus
1217pip3 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
2129chown 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
0 commit comments