From ee6060d668081714f6ff1947fe5223ffbafc09f3 Mon Sep 17 00:00:00 2001 From: gameloader Date: Mon, 12 Jun 2023 11:24:38 +0800 Subject: [PATCH] add auto install needed package script --- install.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..59bf016 --- /dev/null +++ b/install.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# Check OS type +if [[ "$(uname)" == "Darwin" ]]; then + OS="macos" +elif [[ "$(cat /etc/*-release | grep -c "ID=debian")" -gt 0 ]]; then + OS="debian" +elif [[ "$(cat /etc/*-release | grep -c "ID=ubuntu")" -gt 0 ]]; then + OS="ubuntu" +elif [[ "$(cat /etc/*-release | grep -c "ID=manjaro")" -gt 0 ]]; then + OS="manjaro" +else + echo "Unsupported OS" + exit 1 +fi + +# Install packages +if [[ "$OS" == "macos" ]]; then + brew install unzip wget curl gzip tar ruby go node python git cargo npm +elif [[ "$OS" == "debian" ]] || [[ "$OS" == "ubuntu" ]]; then + sudo apt-get update + sudo apt-get install -y unzip wget curl gzip tar ruby git cargo npm + sudo apt-get install -y python3 python3-pip node +elif [[ "$OS" == "manjaro" ]]; then + sudo pacman -Syu --noconfirm + sudo pacman -S --noconfirm unzip wget curl gzip tar ruby git cargo npm + sudo pacman -S --noconfirm python python-pip + sudo pacman -S --noconfirm go nodejs +fi + +# Add Go to PATH +if [[ "$OS" == "macos" ]]; then + # Mac users should use Homebrew to install Go instead of this script + exit 0 +elif [[ "$OS" == "debian" ]] || [[ "$OS" == "ubuntu" ]] || [[ "$OS" == "manjaro" ]]; then + GO_LATEST=$(curl -sL https://golang.org/VERSION?m=text | sed 's/go//') + curl -s https://mirrors.aliyun.com/golang/go$GO_LATEST.linux-amd64.tar.gz | sudo tar -C /usr/local -xz + echo "export PATH=\$PATH:/usr/local/go/bin" >> ~/.bashrc +fi