Last active
July 20, 2023 15:18
-
-
Save guskma/dc2ec28439adc4febee980188727017a to your computer and use it in GitHub Desktop.
さくらのクラウドシェルを使う前に動かすやつ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#****** さくらのクラウドシェル作業前スクリプト ****** | |
# さくらのクラウドシェルを使う前にとりあえず最新にしまくります。 | |
# ついでにSSH鍵(RSA、ED25519)も作ります。 | |
#****** 使い方 ****** | |
# 1. このgistをcloneします。 | |
# git clone https://gist.github.com/dc2ec28439adc4febee980188727017a.git ~/setup-script | |
# 2. 実行します。 | |
# cd ~/setup-script | |
# bash sakura-cloudshell-setup.sh | |
# 3. 結構時間かかるのでお茶でも飲んでゆっくり待ちます。 | |
# 特にaptとrbenvがむっちゃかかるので、コメントアウトしちゃってもいいかも | |
# ※全部通しで実行したら15分くらいかかったorz | |
# ※ずっとレスポンス無いとコネクション切れちゃうので注意 | |
sudo apt update | |
sudo apt upgrade -y | |
sudo apt install libyaml-dev -y | |
echo -e "\n### INSTALL python ###\n" | |
pyenv update | |
PY_LATEST=`pyenv install -l | grep -E '^\s*3\.1[0-9]\.[0-9]+\s*$' | sort | tail -n 1 | xargs echo` | |
pyenv install --skip-existing --verbose $PY_LATEST | |
[[ "$PY_LATEST" == "$(pyenv global)" ]] || pyenv global $PY_LATEST | |
pip install --upgrade pip | |
pip install ansible | |
echo -e "\n### INSTALL ruby ###\n" | |
cd ~/.rbenv | |
git pull | |
cd ./plugins/ruby-build | |
git pull | |
cd ~ | |
RB_LATEST=`rbenv install -L | grep -E '^\s*3\.[0-9]\.[0-9]+\s*$' | sort | tail -n 1 | xargs echo` | |
rbenv install --skip-existing --verbose $RB_LATEST | |
[[ "$RB_LATEST" == "$(rbenv global)" ]] || rbenv global $RB_LATEST | |
nvm install --lts | |
nvm use --lts | |
### GENERATE ssh-keys | |
[[ -e ~/.ssh/id_rsa ]] || ssh-keygen -q -t rsa -N '' -C 'CloudShell-tmp-RSA' -f ~/.ssh/id_rsa | |
[[ -e ~/.ssh/id_ed25519 ]] || ssh-keygen -q -t ed25519 -N '' -C 'CloudShell-tmp-ed25519' -f ~/.ssh/id_ed25519 | |
echo -e "\n\n***** Done\n" | |
echo -e "Python: $(pyenv global)\nRuby: $(rbenv global)\nNode.js: $(nvm current)" | |
cat ~/.ssh/id_rsa.pub | |
cat ~/.ssh/id_ed25519.pub | |
echo -e "\n****** NOTE:\n\nReload environment variables: source ~/.zshrc" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment