Skip to content

Commit ece5977

Browse files
fix(trivy): adjust installation script
1 parent f491e8f commit ece5977

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/trivy/install.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,17 @@ curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/inst
8686
# Verify installation
8787
trivy --version
8888

89-
# Set up shared TRIVY_HOME so plugins are available to all users
89+
# Set up shared TRIVY_HOME so plugins are available to all users.
90+
# Create a wrapper script that ensures TRIVY_HOME is always set, regardless
91+
# of how trivy is invoked (login shell, non-interactive sh -c, etc.).
9092
mkdir -p "${TRIVY_HOME}"
93+
mv /usr/local/bin/trivy /usr/local/bin/trivy-real
94+
cat > /usr/local/bin/trivy << WRAPPER
95+
#!/bin/sh
96+
export TRIVY_HOME="\${TRIVY_HOME:-${TRIVY_HOME}}"
97+
exec /usr/local/bin/trivy-real "\$@"
98+
WRAPPER
99+
chmod +x /usr/local/bin/trivy
91100
export TRIVY_HOME
92101

93102
# Install plugins if specified
@@ -96,9 +105,6 @@ if [ -n "${TRIVY_PLUGINS}" ]; then
96105
install_plugins "${TRIVY_PLUGINS}"
97106
fi
98107

99-
# Ensure TRIVY_HOME is set for all users at runtime
100-
echo "export TRIVY_HOME=${TRIVY_HOME}" > /etc/profile.d/trivy.sh
101-
chmod +x /etc/profile.d/trivy.sh
102108
chmod -R a+rX "${TRIVY_HOME}"
103109

104110
# Clean up

0 commit comments

Comments
 (0)