-
Notifications
You must be signed in to change notification settings - Fork 28
Add scripts to support Tenks network persistence #200
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
base: master
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @MaxBed4d, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a mechanism to ensure that Tenks network configurations are automatically applied and maintained across system reboots. It achieves this by integrating a systemd service that triggers a specialized bash script during the boot sequence, which in turn prepares the environment and executes the necessary Kayobe-based network configuration commands. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a systemd service and an accompanying script to ensure Tenks network settings persist across reboots. The overall approach is logical. However, I've identified a couple of significant issues. The systemd service configuration grants potentially excessive permissions, which is a security concern. Additionally, the setup script relies on hardcoded paths, which severely impacts its maintainability and portability. My review includes suggestions to address these points by adhering to the principle of least privilege and by refactoring the script to be more robust and configurable.
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 | ||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script has a couple of areas for improvement:
- Hardcoded Paths: It contains multiple hardcoded paths based on
/home/lab/deployment
. This makes the script brittle and hard to maintain or reuse in different environments. It's recommended to centralize the base path definition. - Unsetting Variables: The method for unsetting
OS_*
variables can be made more robust and efficient using modern bash features.
The suggestion below addresses both points by introducing a base path and using parameter expansion to unset variables.
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 | |
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 | |
# A base path could be set here, or sourced from an environment file. | |
# e.g. DEPLOYMENT_BASE=${DEPLOYMENT_BASE:-/home/lab/deployment} | |
DEPLOYMENT_BASE="/home/lab/deployment" | |
SRC_DIR="$DEPLOYMENT_BASE/src" | |
VENV_DIR="$DEPLOYMENT_BASE/venvs/kayobe" | |
KAYOBE_CONFIG_DIR="$SRC_DIR/kayobe-config" | |
source "$VENV_DIR/bin/activate" | |
source "$KAYOBE_CONFIG_DIR/kayobe-env" | |
cd "$SRC_DIR" | |
# Unset all shell variables and functions starting with OS_ | |
for var in "${!OS_@}"; do | |
unset "$var" | |
done | |
export KAYOBE_CONFIG_SOURCE_PATH="$KAYOBE_CONFIG_DIR" | |
export KAYOBE_VENV_PATH="$VENV_DIR" | |
export TENKS_CONFIG_PATH="$KAYOBE_CONFIG_DIR/tenks.yml" |
No description provided.