chore(scripts): add install scripts

This commit is contained in:
xlliu-scitix 2025-12-21 03:12:56 +00:00
parent 1fb35de24e
commit a7444d2ed8
3 changed files with 97 additions and 0 deletions

6
scripts/env.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
export SIHPC_HOME=/usr/local/sihpc
export PATH=$SIHPC_HOME/bin:$PATH
export LD_LIBRARY_PATH=$SIHPC_HOME/lib:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export OMPI_MCA_opal_prefix=$SIHPC_HOME
export OPAL_PREFIX=$SIHPC_HOME

66
scripts/install_sihpc Normal file
View File

@ -0,0 +1,66 @@
#!/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."

25
scripts/uninstall_sihpc Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash
# sihpc-uninstaller.sh
set -e
SIHPC_ROOT="/usr/local/sihpc"
if [ ! -d "$SIHPC_ROOT" ]; then
echo "sihpc install dir $SIHPC_ROOT not exist."
exit 1
fi
echo "=============================="
echo " uninstall sihpc"
echo " install dir: $SIHPC_ROOT"
echo "=============================="
echo "deleting $SIHPC_ROOT ..."
rm -rf "$SIHPC_ROOT"
echo "please check shell config~/.bashrc, ~/.zshrc etc."
echo "remove $SIHPC_ROOT/bin from PATH"
echo "sihpc unintall done"
exit 0