Skip to content

Commit

Permalink
Update startup script
Browse files Browse the repository at this point in the history
  • Loading branch information
lcarvajal committed Jul 26, 2024
1 parent f0c6b19 commit 282b478
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion startup.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/bin/sh

# Export all environment variables safely
printenv | awk -F= '{ print "export " $1 "=\"" $2 "\"" }' > /etc/profile.d/env.sh
printenv | while IFS= read -r line; do
key=$(echo "$line" | cut -d '=' -f 1)
value=$(echo "$line" | cut -d '=' -f 2-)
# Ensure the key is valid and the value is quoted properly
if [ -n "$key" ] && [[ "$key" =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then
echo "export $key=\"$value\"" >> /etc/profile.d/env.sh
fi
done

# Source the environment variables
. /etc/profile.d/env.sh
Expand Down

0 comments on commit 282b478

Please sign in to comment.