Skip to content
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
15 changes: 15 additions & 0 deletions tenks-network-on-boot.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Runs a script to setup tenks host networking
After=network.target
Wants=network-online.target

[Service]
WorkingDirectory=/home/lab/deployment/src
ExecStart=/bin/tenks-network-setup

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The ExecStart path is /bin/tenks-network-setup, but this script is added at the repository root. Without a visible installation step to move it to /bin, the service will likely fail to start. Please verify the script's installation path and update ExecStart accordingly. If it's meant to be in the WorkingDirectory, the path should be tenks-network-setup.

Restart=no
User=lab
Group=root

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Setting Group=root for a service running as a non-root user (User=lab) is unusual and a potential security concern. This requires the lab user to be a member of the root group, which is generally discouraged. If elevated privileges are needed, consider alternative approaches like using sudo within the script for specific commands, or running the service as root if the entire script requires it.

Type=simple

[Install]
WantedBy=multi-user.target
15 changes: 15 additions & 0 deletions tenks-network-setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -euo pipefail

source /home/lab/deployment/venvs/kayobe/bin/activate
source /home/lab/deployment/src/kayobe-config/kayobe-env

cd /home/lab/deployment/src

for key in $( set | awk '{FS="="} /^OS_/ {print $1}' ); do unset $key ; done

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The awk command used to find environment variables to unset is incorrect. It will not correctly extract the variable names because FS is set inside the action block, which is too late for field splitting. This will cause the unset command to fail with a syntax error if any OS_* variables are set, as it will attempt to run unset "VAR=value".

A more robust and idiomatic way to unset all variables with a certain prefix in bash is to use parameter expansion.

Suggested change
for key in $( set | awk '{FS="="} /^OS_/ {print $1}' ); do unset $key ; done
for var in "${!OS_@}"; do unset "$var"; done

export KAYOBE_CONFIG_SOURCE_PATH=/home/lab/deployment/src/kayobe-config
export KAYOBE_VENV_PATH=/home/lab/deployment/venvs/kayobe
export TENKS_CONFIG_PATH=/home/lab/deployment/src/kayobe-config/tenks.yml

kayobe/dev/tenks-network-reboot-patch.sh ./tenks