Skip to content

Commit

Permalink
Merge pull request #164 from ethz-asl/projects/piloting_feature/syste…
Browse files Browse the repository at this point in the history
…md_services

Add systemd services to the repo
  • Loading branch information
jk-ethz authored Jul 28, 2023
2 parents 2e904ca + 189f3a3 commit 4ebc2a6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions moma_demos/piloting_demo/roscore.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
After=network-online.target
[Service]
Type=forking
User=piloting
ExecStart=/bin/sh -c ". /opt/ros/noetic/setup.sh; export ROS_MASTER_URI=http://192.168.195.5:11311; export ROS_IP=192.168.195.5; echo $ROS_MASTER_URI; roscore & while ! echo exit | nc localhost 11311 > /dev/null; do sleep 1; done"
[Install]
WantedBy=multi-user.target
3 changes: 3 additions & 0 deletions moma_demos/piloting_demo/router/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Piloting Router

This script makes the SMB261-Panda NUC a router, forwarding traffic from other PCs via its WiFi connection to the internet.
11 changes: 11 additions & 0 deletions moma_demos/piloting_demo/router/piloting-router.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Piloting router
After=network.target

[Service]
ExecStart=/home/smb/router.sh
RemainAfterExit=true
Type=oneshot

[Install]
WantedBy=multi-user.target
10 changes: 10 additions & 0 deletions moma_demos/piloting_demo/router/router.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
sudo nmcli radio wifi on
sudo iptables -t nat -A POSTROUTING -o wlp0s20f3 -j MASQUERADE
sudo iptables -t nat -A POSTROUTING -o eno1 -j MASQUERADE
sudo iptables -A FORWARD -i eno0 -o wlp0s20f3 -j ACCEPT
sudo iptables -A FORWARD -i eno0 -o eno1 -j ACCEPT
sudo iptables -A FORWARD -i wlp0s20f3 -o eno0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eno1 -o eno0 -m state --state RELATED,ESTABLISHED -j ACCEPT

0 comments on commit 4ebc2a6

Please sign in to comment.