Page tree
Skip to end of metadata
Go to start of metadata

Packages to Install

  • apt-get update
  • apt-get install hostapd       (looks like already installed on base Image)
  • apt-get install bridge-utils  (May not be used after all, but useful to have just in case ...)
  • apt-get install dnsmasq
  • apt-get install curl

Network interfaces

Strategy:  Get the OS network automation scripts to do all the work they can so we don't have to manage scripts in our application.  NOTE: The Wifi chipset is not turned on at bootup.  Also it is enumerated as mlan not wlan...

Let's try to avoid bridging, and use MASQUERADE, this will give us much more control of what is allowed to do what... We may want to remove the bridge then ...

  • vi /etc/network/interfaces

/etc/network/interfaces

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

#--- Get a DHCP address if that's possible but also set a known static addresss
auto eth0 eth0:0
iface eth0 inet dhcp
iface eth0:0 inet static
address 192.168.77.3
netmask 255.255.255.0

allow-hotplug mlan0
iface mlan0 inet static
address 192.168.66.1
netmask 255.255.255.0
#iface mlan0:0 inet static
# address 192.168.77.11
# netmask 255.255.255.0

#allow-hotplug br0
#iface br0 inet static
#bridge_ports eth0 wlan0
# address 192.168.77.10
# netmask 255.255.255.0


  • touch /etc/network/if-up.d/access-point

  • chmod a+x /etc/network/if-up.d/access-point

  • vi /etc/network/if-up.d/access-point

/etc/network/if-up.d/access-point

#!/bin/sh

LOG_FILE=/var/log/politick.txt

if [ "$IFACE" = "lo" ]; then
echo "----BEGIN Boot----------------------------------------------" >> $LOG_FILE
fi

echo >> $LOG_FILE
echo >> $LOG_FILE

echo $IFACE $LOGICAL $ADDRFAM $METHOD $MODE $PHASE >> $LOG_FILE
env >> $LOG_FILE

if [ "$IFACE" = "--all" ]; then
echo "----End Boot----------------------------------------------" >> $LOG_FILE
fi

if [ "$IFACE" = "mlan0" ]; then
echo "/etc/network/"$0" is running" >> $LOG_FILE
iwconfig mlan0
STATUS=$?
if [ "$STATUS" = "0" ]; then
echo "Wireless is NOW UP !!!!!!!!!" >> $LOG_FILE

# Configure the Wifi as an access point
/usr/sbin/hostapd -B -P/run/hostapd.pid /etc/hostapd/hostapd.conf
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sysctl net.ipv4.ip_forward=1
iptables -P FORWARD ACCEPT
iptables -F FORWARD

else
echo "Wireless is DOWN" >> $LOG_FILE
fi
fi



exit 0



RFC2217 Serial over ethernet

  • apt install ser2net

/etc/ser2net.conf

#  /dev/ttyO4 is the DEBUG login port

2000:raw:300:/dev/ttyO1:115200 8DATABITS NONE 1STOPBIT
2001:raw:300:/dev/ttyO5:115200 8DATABITS NONE 1STOPBIT




Access Point 802.11

Use the Wifi as a AccessPoint for others to connect

  • echo  DAEMON_CONF=\"/etc/hostapd/hostapd.conf\" >> /etc/default/hostapd

  • vi /etc/default/hostapd

     make sure that 

DAEMON_CONF="/etc/hostapd/hostapd.conf"

????? remove /etc/network/if-up/wpa_supplicant ??????

  • vi /etc/hostapd/hostapd.conf

/etc/hostapd/hostapd.conf


ssid=Truck77
interface=mlan0
wpa_passphrase=SuperSecret
driver=nl80211
channel=8
ignore_broadcast_ssid=0

# Maximum number of stations allowed
max_num_sta=3
country_code=CA
hw_mode=g
wpa=2

# Key management algorithms
wpa_key_mgmt=WPA-PSK

# Set cipher suites
# TKIP = Temporal Key Integrity Protocol
# CCMP = AES in Counter mode with CBC-MAC
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
#rsn_pairwise=TKIP (Old WPA1)

# Shared Key Authentication
auth_algs=1

# Accept all MAC address
macaddr_acl=0

# hostapd event logger configuration
logger_stdout=-1
logger_stdout_level=2



  • vi /etc/dnsmasq.conf


/etc/dnsmasq.conf

interface=mlan0

dhcp-range=192.168.66.50,192.168.66.150,24h

dhcp-option=3,192.168.66.1

dhcp-option=6,192.168.66.1




./enambleHW

#Start the HostAP manually for debugging:

 /usr/sbin/hostapd  -d -P/run/hostapd.pid /etc/hostapd/hostapd.conf


#Or as a daemon in a shell script like in /etc/network/if-up/access_point

 /usr/sbin/hostapd -B -P/run/hostapd.pid /etc/hostapd/hostapd.conf


Setup a user for the application

adduser wenco

Setup a Service to Start the Firmware


/lib/systemd/system/StartFirmware.service

[Unit]
Description=Owasys 4x Firmware service
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=root
ExecStart=/home/wenco/WencoFW

[Install]
WantedBy=multi-user.target


systemctl enable StartFirmware





NGINX - For react deployment

apt update

apt install nginx

su wenco

cd ~

mkdir web

echo "Hello Politick" > web/index.html

su

cd /etc/nginx/sites-available

touch wencomine.com

vi wencomine.com

wencomine.com

server {
listen 80;
server_name wencomine.com;
server_name 192.168.10.3;
root /home/wenco/web;
index index.html;

access_log /var/log/nginx/wenco.com.access.log;
error_log /var/log/nginx/wenco.com.error.log;

location / {
try_files $uri /index.html =404;
}
}

cd ../sites-enabled/

ln -s ../sites-available/wencomine.com  .

rm default

chown -R $USER:www-data /home/wenco/web/

chmod 755 -R /home/wenco/web

service nginx reload


INSTALL Node.js  : https://github.com/nodesource/distributions/blob/master/README.md

# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_11.x | bash -
apt-get install -y nodejs


I think this downloads and installs the Socket.io library

npm install --save socket.io



DEPLOY web to target:  Ex: "npm run deploy:prod"

package.json

"deploy:prod": "rsync -avzhe ssh --progress ./build/* wenco@10.0.4.63:/home/wenco/web"


chown -R wenco:www-data /home/wenco/web








  • No labels
Write a comment…