info_docs_tfgrid4_tech/install.sh

48 lines
1.2 KiB
Bash
Raw Normal View History

2025-01-16 06:42:17 +00:00
#!/bin/bash
2025-01-16 15:35:26 +00:00
set -ex
2025-01-16 06:42:17 +00:00
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${script_dir}"
echo "Docs directory: $script_dir"
2025-01-27 15:02:10 +00:00
# Check if Bun is installed
2025-01-18 15:28:49 +00:00
if ! command -v bun &> /dev/null; then
echo "Bun is not installed. Installing..."
curl -fsSL https://bun.sh/install | bash
else
echo "Bun is already installed."
fi
2025-01-16 06:42:17 +00:00
2025-01-27 15:02:10 +00:00
# Variables to add to the appropriate profile
CONTENT='
# Bun installation
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
'
# Determine the user's shell and appropriate profile file
if [[ "$SHELL" == *"zsh"* ]]; then
PROFILE="$HOME/.zshrc"
elif [[ "$SHELL" == *"bash"* ]]; then
PROFILE="$HOME/.bashrc"
else
echo "Unsupported shell. Please add the following content manually to your shell profile:"
echo "$CONTENT"
exit 1
fi
2025-01-16 06:42:17 +00:00
2025-01-27 15:02:10 +00:00
# Add the content if it doesn't already exist
if grep -q 'export BUN_INSTALL="$HOME/.bun"' "$PROFILE"; then
echo "Bun environment variables already exist in $PROFILE."
else
echo "$CONTENT" >> "$PROFILE"
echo "Bun environment variables added to $PROFILE. Please restart your shell or run 'source $PROFILE' to apply the changes."
fi
# Run 'bun install'
source "$PROFILE"
echo "Running 'bun install'..."
bun install