Skip to content

Instantly share code, notes, and snippets.

@llccing
Created April 17, 2024 07:05
Show Gist options
  • Save llccing/77b8a629812ec3ca5ac8606c873c39b7 to your computer and use it in GitHub Desktop.
Save llccing/77b8a629812ec3ca5ac8606c873c39b7 to your computer and use it in GitHub Desktop.
#!/bin/bash
# 更新系统软件包列表
sudo apt update
# 安装必需的软件包
for pkg in curl wget git vim; do
if ! command -v $pkg &> /dev/null; then
echo "Installing $pkg..."
sudo apt install -y $pkg
else
echo "$pkg is already installed."
fi
done
# 安装 Node.js version 21(如果可用)和 pm2
if ! command -v nvm &> /dev/null; then
echo "Installing nvm..."
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
fi
source "$HOME/.nvm/nvm.sh"
if nvm list | grep -q "v21."; then
echo "Node.js 21 is already installed."
else
echo "Installing Node.js 21..."
nvm install 21
fi
if ! command -v pm2 &> /dev/null; then
echo "Installing pm2..."
npm install -g pm2
else
echo "pm2 is already installed."
fi
# 安装 pyenv 和 Python 3.10.13, sometimes this can't install, because internet issue.
if ! command -v pyenv &> /dev/null; then
echo "Installing pyenv..."
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
source ~/.bashrc
fi
if pyenv versions | grep -q 3.10.13; then
echo "Python 3.10.13 is already installed."
else
echo "Installing Python 3.10.13..."
pyenv install 3.10.13
pyenv global 3.10.13
fi
# manual install pyenv
if ! command -v pyenv &> /dev/null; then
echo "Manual Installing pyenv..."
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
source ~/.bashrc
fi
if pyenv versions | grep -q 3.10.13; then
echo "Python 3.10.13 is already installed."
else
echo "Installing Python 3.10.13..."
pyenv install 3.10.13
pyenv global 3.10.13
fi
# 安装 otree5
if ! python -m pip show otree &> /dev/null; then
echo "Installing otree5..."
pip install otree
else
echo "otree5 is already installed."
fi
# 检查并生成SSH Ed25519密钥对
if [ ! -f ~/.ssh/id_ed25519 ]; then
echo "Generating SSH Ed25519 key pair..."
ssh-keygen -t ed25519 -a 100 -N "" -f ~/.ssh/id_ed25519
echo "SSH Ed25519 key pair generated."
else
echo "SSH Ed25519 key pair already exists."
fi
echo "所有指定的软件已安装完成。"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment