diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/install.sh b/install.sh index f543fe0..febd6cd 100755 --- a/install.sh +++ b/install.sh @@ -5,7 +5,7 @@ GO_VERSION="1.21.4" SINGULARITY_VERSION="4.0.2" GO_URL="https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" GO_ARCHIVE="/tmp/go${GO_VERSION}.linux-amd64.tar.gz" -SINGULARITY_URL="https://github.com/sylabs/singularity/releases/download/v${SINGULARITY_VERSION}/singularity-ce-${SINGULARITY_VERSION}.tar.gz" +SINGULARITY_URL="https://mirror.ghproxy.com/https://github.com/sylabs/singularity/releases/download/v${SINGULARITY_VERSION}/singularity-ce-${SINGULARITY_VERSION}.tar.gz" SINGULARITY_ARCHIVE="/tmp/singularity-ce-${SINGULARITY_VERSION}.tar.gz" SINGULARITY_DIR="singularity" @@ -16,13 +16,13 @@ install_dependencies() { # 在这里添加Deepin 23的依赖安装命令 echo "安装Deepin 23依赖" sudo apt-get update - sudo apt-get install -y autoconf automake cryptsetup git libfuse-dev libglib2.0-dev libseccomp-dev libtool pkg-config runc squashfs-tools uidmap wget zlib1g-dev - wget http://ftp.hk.debian.org/debian/pool/main/s/squashfs-tools-ng/squashfs-tools-ng_1.2.0-1_amd64.deb - wget http://ftp.hk.debian.org/debian/pool/main/s/squashfs-tools-ng/libsquashfs1_1.2.0-1_amd64.deb - sudo dpkg -i ./libsquashfs1_1.2.0-1_amd64.deb - sudo dpkg -i ./squashfs-tools-ng_1.2.0-1_amd64.deb - rm ./libsquashfs1_1.2.0-1_amd64.deb - rm ./squashfs-tools-ng_1.2.0-1_amd64.deb + sudo apt-get install -y autoconf automake cryptsetup git libfuse-dev libglib2.0-dev libseccomp-dev libtool pkg-config runc squashfs-tools squashfs-tools-ng uidmap wget zlib1g-dev + # wget http://ftp.hk.debian.org/debian/pool/main/s/squashfs-tools-ng/squashfs-tools-ng_1.2.0-1_amd64.deb + # wget http://ftp.hk.debian.org/debian/pool/main/s/squashfs-tools-ng/libsquashfs1_1.2.0-1_amd64.deb + # sudo dpkg -i ./libsquashfs1_1.2.0-1_amd64.deb + # sudo dpkg -i ./squashfs-tools-ng_1.2.0-1_amd64.deb + # rm ./libsquashfs1_1.2.0-1_amd64.deb + # rm ./squashfs-tools-ng_1.2.0-1_amd64.deb elif [[ -f /etc/debian_version ]]; then # Debian/Ubuntu 系统依赖安装 sudo apt-get update @@ -109,4 +109,4 @@ interactive_menu() { esac } -interactive_menu \ No newline at end of file +interactive_menu diff --git a/install_apptainer.sh b/install_apptainer.sh new file mode 100755 index 0000000..9328c68 --- /dev/null +++ b/install_apptainer.sh @@ -0,0 +1,126 @@ +#!/bin/bash + +# 定义版本变量和下载链接 +GO_VERSION="1.21.4" +APPTAINER_VERSION="1.2.5" +GO_URL="https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" +GO_ARCHIVE="/tmp/go${GO_VERSION}.linux-amd64.tar.gz" +APPTAINER_URL="https://github.com/apptainer/apptainer/archive/refs/tags/v${APPTAINER_VERSION}.tar.gz" +APPTAINER_ARCHIVE="/tmp/apptainer-${APPTAINER_VERSION}.tar.gz" +APPTAINER_DIR="apptainer-${APPTAINER_VERSION}" + +# 安装系统依赖 +install_dependencies() { + if grep -q 'PRETTY_NAME="Deepin 23"' /etc/os-release || [[ -f /etc/debian_version ]]; then + # Debian/Ubuntu/Deepin 系统依赖安装 + echo "安装 Debian/Ubuntu/Deepin 依赖" + sudo apt-get update + sudo apt-get install -y build-essential libseccomp-dev pkg-config uidmap squashfs-tools squashfuse fuse2fs fuse-overlayfs fakeroot cryptsetup curl wget git + elif [[ -f /etc/redhat-release ]]; then + # RHEL/CentOS 系统依赖安装 + echo "安装 RHEL/CentOS 依赖" + sudo yum groupinstall -y 'Development Tools' + sudo yum install -y epel-release + sudo yum install -y libseccomp-devel squashfs-tools squashfuse fuse-overlayfs fakeroot /usr/*bin/fuse2fs cryptsetup wget git + elif [[ -f /etc/SuSE-release ]]; then + # SLES/openSUSE 系统依赖安装 + echo "安装 SLES/openSUSE 依赖" + sudo zypper install -y libseccomp-devel libuuid-devel openssl-devel cryptsetup sysuser-tools gcc go + else + echo "不支持的操作系统。" + exit 1 + fi +} + +# 安装 Go +install_go() { + if [ ! -f "$GO_ARCHIVE" ]; then + wget -O "$GO_ARCHIVE" "$GO_URL" + fi + sudo rm -rf /usr/local/go + sudo tar -C /usr/local -xzf "$GO_ARCHIVE" + echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc + source ~/.bashrc +} + +# 下载并解压 Apptainer 源码 +download_apptainer() { + if [ ! -f "$APPTAINER_ARCHIVE" ]; then + wget -O "$APPTAINER_ARCHIVE" "$APPTAINER_URL" + fi + if [ ! -d "$APPTAINER_DIR" ]; then + mkdir "$APPTAINER_DIR" + tar -xzf "$APPTAINER_ARCHIVE" -C "$APPTAINER_DIR" --strip-components=1 + fi +} + +# 编译和安装 Apptainer +compile_apptainer() { + cd "$APPTAINER_DIR" + ./mconfig + make -C builddir + sudo make -C builddir install +} + +# 卸载 Apptainer +uninstall_apptainer() { + echo "正在卸载 Apptainer..." + sudo rm -rf /usr/local/bin/apptainer + sudo rm -rf /usr/local/libexec/apptainer + sudo rm -rf /usr/local/var/apptainer + sudo rm -rf /usr/local/etc/apptainer + sudo rm -rf /usr/local/lib/apptainer + echo "Apptainer 卸载完成。" +} + +# 静默安装 +silent_install() { + install_dependencies + install_go + download_apptainer + compile_apptainer + echo "Apptainer 安装完成。" +} + +# 交互式菜单 +interactive_menu() { + echo "选择操作:" + echo "1) 安装 Apptainer" + echo "2) 卸载 Apptainer" + echo "3) 退出" + read -p "请输入选项(1、2或3): " choice + + case "$choice" in + 1) + silent_install + ;; + 2) + uninstall_apptainer + ;; + 3) + exit 0 + ;; + *) + echo "无效的选项。" + exit 1 + ;; + esac +} + +# 处理传入参数 +if [[ $# -gt 0 ]]; then + case "$1" in + install) + silent_install + ;; + uninstall) + uninstall_apptainer + ;; + *) + echo "无效的参数。可用参数: install, uninstall" + exit 1 + ;; + esac +else + interactive_menu +fi