Clean up install script

This commit is contained in:
Niels Geens
2025-04-01 16:30:42 +02:00
parent 130afbdd92
commit c00256f723
3 changed files with 22 additions and 22 deletions

View File

@@ -0,0 +1,18 @@
#!/bin/bash
add_to_environment() {
local path="$1"
# Check if the path is already in the environment file
if ! grep -q "$path" /etc/environment; then
# Get current PATH from environment file
current_path=$(grep "^PATH=" /etc/environment | cut -d'"' -f2)
if [ -z "$current_path" ]; then
# If PATH doesn't exist in the file, create it
echo "PATH=\"\$PATH:$path\"" >> /etc/environment
else
# Replace existing PATH line with updated one
sed -i "s|^PATH=.*|PATH=\"$path:$current_path\"|" /etc/environment
fi
fi
}