nccl-tests/scripts/install_sihpc
2025-12-21 03:12:56 +00:00

66 lines
1.6 KiB
Bash

#!/bin/bash
set -euo pipefail
PREFIX="/usr/local/sihpc"
LIBCONF="/etc/ld.so.conf.d/sihpc.conf"
PROFILE_SH="/etc/profile.d/sihpc.sh"
echo "Installing SiHPC runtime to: $PREFIX"
if [ ! -d "$PREFIX" ]; then
mkdir -p "$PREFIX"
fi
cp -r ./* "$PREFIX/"
echo "Files installed to $PREFIX"
if [ ! -f "$LIBCONF" ]; then
echo "$PREFIX/lib" > "$LIBCONF"
[ -d "$PREFIX/lib64" ] && echo "$PREFIX/lib64" >> "$LIBCONF"
echo "Added $LIBCONF"
else
if ! grep -q "$PREFIX/lib" "$LIBCONF"; then
echo "$PREFIX/lib" >> "$LIBCONF"
fi
if [ -d "$PREFIX/lib64" ] && ! grep -q "$PREFIX/lib64" "$LIBCONF"; then
echo "$PREFIX/lib64" >> "$LIBCONF"
fi
echo "Updated existing $LIBCONF"
fi
ldconfig
echo "ldconfig updated"
if [ ! -f "$PROFILE_SH" ]; then
cat <<EOF > "$PROFILE_SH"
# Auto-generated by SiHPC installer
if [ -f $PREFIX/env.sh ]; then
source $PREFIX/env.sh
fi
EOF
chmod +x "$PROFILE_SH"
echo "Added $PROFILE_SH"
else
echo "$PROFILE_SH already exists, skipping."
fi
for f in /etc/bash.bashrc /etc/bashrc; do
if [ -f "$f" ]; then
if ! grep -q "$PREFIX/env.sh" "$f"; then
{
echo ""
echo "# SiHPC environment"
echo "if [ -f $PREFIX/env.sh ]; then"
echo " source $PREFIX/env.sh"
echo "fi"
} >> "$f"
echo "Added SiHPC source to $f"
fi
fi
done
echo
echo "SiHPC installation completed successfully!"
echo "Installed to: $PREFIX"
echo "Library config: $LIBCONF"
echo "Auto env setup: $PROFILE_SH"
echo "Run 'source $PREFIX/env.sh' now to activate current shell."