diff --git a/scripts/env.sh b/scripts/env.sh new file mode 100644 index 0000000..5e2610b --- /dev/null +++ b/scripts/env.sh @@ -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 \ No newline at end of file diff --git a/scripts/install_sihpc b/scripts/install_sihpc new file mode 100644 index 0000000..01e370a --- /dev/null +++ b/scripts/install_sihpc @@ -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 < "$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." \ No newline at end of file diff --git a/scripts/uninstall_sihpc b/scripts/uninstall_sihpc new file mode 100644 index 0000000..20cabe2 --- /dev/null +++ b/scripts/uninstall_sihpc @@ -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 \ No newline at end of file