mirror of
https://github.com/spiritLHLS/one-click-installation-script.git
synced 2024-11-16 06:52:18 +08:00
73 lines
2.6 KiB
Bash
73 lines
2.6 KiB
Bash
#!/usr/bin/env bash
|
||
#by spiritlhl
|
||
#from https://github.com/spiritLHLS/one-click-installation-script
|
||
#version: 2022.12.17
|
||
|
||
red(){ echo -e "\033[31m\033[01m$1$2\033[0m"; }
|
||
green(){ echo -e "\033[32m\033[01m$1$2\033[0m"; }
|
||
yellow(){ echo -e "\033[33m\033[01m$1$2\033[0m"; }
|
||
reading(){ read -rp "$(green "$1")" "$2"; }
|
||
|
||
|
||
# 支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+
|
||
ver="2022.12.18"
|
||
changeLog="一键安装rust,加载官方脚本"
|
||
clear
|
||
echo "#######################################################################"
|
||
echo "# ${YELLOW}一键安装rust脚本${PLAIN} #"
|
||
echo "# 版本:$ver #"
|
||
echo "# 更新日志:$changeLog #"
|
||
echo "# ${GREEN}作者${PLAIN}: spiritlhl #"
|
||
echo "# ${GREEN}仓库${PLAIN}: https://github.com/spiritLHLS/one-click-installation-script #"
|
||
echo "#######################################################################"
|
||
echo "支持系统:Ubuntu 18+,Debian 8+,centos 7+,Fedora,Almalinux 8.5+"
|
||
# Display prompt asking whether to proceed with installation
|
||
reading "Do you want to proceed with the Rust installation? [y/n] " confirm
|
||
echo ""
|
||
|
||
# Check user's input and exit if they do not want to proceed
|
||
if [ "$confirm" != "y" ]; then
|
||
exit 0
|
||
fi
|
||
|
||
# Update package manager's package list
|
||
if [ -x "$(command -v apt-get)" ]; then
|
||
sudo apt-get update -y
|
||
sudo apt-get upgrade -y
|
||
sudo apt-get install curl build-essential gcc make -y
|
||
elif [ -x "$(command -v yum)" ]; then
|
||
sudo yum update -y
|
||
sudo yum install curl make gcc-c++ -y
|
||
elif [ -x "$(command -v dnf)" ]; then
|
||
sudo dnf update -y
|
||
sudo dnf install curl make gcc-c++ -y
|
||
elif [ -x "$(command -v pacman)" ]; then
|
||
sudo pacman -Syu
|
||
sudo pacman -S curl make gcc -y
|
||
else
|
||
echo "Error: This script requires a package manager (apt, yum, dnf, pacman) to be installed on the system."
|
||
exit 1
|
||
fi
|
||
|
||
# Install Rust
|
||
echo "Loading official installation script and selecting option 1 for installation"
|
||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||
|
||
# Source Rust environment variables
|
||
if [ -f "$HOME/.cargo/env" ]; then
|
||
source "$HOME/.cargo/env"
|
||
fi
|
||
if [ -f "$HOME/.profile" ]; then
|
||
source "$HOME/.profile"
|
||
fi
|
||
|
||
# Update Rust
|
||
echo "Updating Rust"
|
||
rustup update
|
||
|
||
# Print version information for cargo, rustc, and rustdoc
|
||
echo "Printing version information for cargo, rustc, and rustdoc. If any of these tools are not found or have incorrect versions, the installation may have failed."
|
||
cargo --version
|
||
rustc --version
|
||
rustdoc --version
|