Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setup wireguard early, then configure later #80

Open
wants to merge 1 commit into
base: humble
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fogros2/fogros2/aws_cloud_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def create(self):
self.install_ros()
self.install_colcon()
self.install_cloud_dependencies()
self.do_wireguard_preconfig()
self.push_ros_workspace()
self.info(flush_to_disk=True)
self._is_created = True
Expand Down
7 changes: 7 additions & 0 deletions fogros2/fogros2/cloud_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ def pip_install(self, args):

def install_cloud_dependencies(self):
self.apt_install("wireguard unzip docker.io python3-pip")

def do_wireguard_preconfig(self):
self.scp.execute_cmd("sudo touch /etc/wireguard/wg0.conf")
self.scp.execute_cmd("sudo chmod 770 /etc/wireguard")
self.scp.execute_cmd("sudo chmod 770 /etc/wireguard/wg0.conf")
self.scp.execute_cmd("sudo chown root:wheel /etc/wireguard/wg0.conf")
self.scp.execute_cmd("echo '%wheel ALL = (ALL) NOPASSWD: /usr/bin/wg-quick' | sudo EDITOR='tee -a' visudo")

def install_ros(self):
# setup sources
Expand Down
4 changes: 1 addition & 3 deletions fogros2/fogros2/vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ def generate_wg_config_files(self, machines):

def start_robot_vpn(self):
# Copy /tmp/fogros-local.conf to /etc/wireguard/wg0.conf locally.
# TODO: This needs root. Move this to a separate script with setuid.
os.system("sudo cp /tmp/fogros-local.conf /etc/wireguard/wg0.conf")
os.system("sudo chmod 600 /etc/wireguard/wg0.conf")
os.system("cp /tmp/fogros-local.conf /etc/wireguard/wg0.conf")
os.system("sudo wg-quick down wg0")
os.system("sudo wg-quick up wg0")