Last active
September 7, 2016 14:19
-
-
Save moznion/5613214 to your computer and use it in GitHub Desktop.
このシェルスクリプトは2013 年Perl 入学式、第一回目の環境構築を再現します。ついでに解説等も入れてありますが、本質的ではないコードも多分に含まれるので、 以下のスライドを参照するのが良いでしょう。 http://perl-entrance-org.github.io/presentation/2013/perlentrance01-2/index.html
This file contains hidden or 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 | |
# Author: moznion <[email protected]> | |
# このシェルスクリプトは2013 年Perl 入学式、第一回目の環境構築を再現します。 | |
# plenv をインストールして、perl 5.16.3 をインストールします。 | |
# ついでに解説等も入れてありますが、本質的ではないコードも多く含まれるので、 | |
# 以下のスライドを参照するのが良いでしょう。 | |
# http://perl-entrance-org.github.io/presentation/2013/perlentrance01-2/index.html | |
if ! which git > /dev/null ; then | |
cat <<EOS | |
[ERROR] 先にGit をインストールしてください | |
[Ubuntu の場合] | |
$ sudo apt-get install git | |
[CentOS の場合] | |
$ sudo yum install git-core | |
[Mac OS X の場合 (brew を使うと楽で良いでしょう)] | |
$ ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go) | |
$ brew install git | |
EOS | |
exit 1 | |
fi | |
# plenv をインストールします | |
# plenv については以下を参照ください。 | |
# http://blog.64p.org/entry/2013/01/21/134639 | |
git clone git://github.com/tokuhirom/plenv.git ~/.plenv | |
case $SHELL in | |
*/bash) | |
if echo "$(lsb_release -d)" | grep 'Ubuntu' > /dev/null ; then | |
# Ubuntu 対応 (なぜか.profile も.bash_profile も上手く動かない...) | |
profile="$HOME/.bashrc" | |
else | |
profile="$HOME/.bash_profile" | |
fi | |
;; | |
*/zsh) | |
profile="$HOME/.zshrc" | |
;; | |
*) | |
echo '[ERROR] bash,zsh 以外は適当に調べて下さい><' | |
exit 1 | |
;; | |
esac | |
# PATH の設定 | |
if ! egrep 'export PATH="\$HOME/.plenv/bin:\$PATH"' "$profile" > /dev/null ; then | |
echo 'export PATH="$HOME/.plenv/bin:$PATH"' >> $profile | |
fi | |
if ! egrep 'eval "\$\(plenv init -\)"' "$profile" > /dev/null ; then | |
echo 'eval "$(plenv init -)"' >> $profile | |
fi | |
# Perl をインストールします | |
# 以下ではv5.16.3 をインストールします | |
perl_version='5.16.3' | |
$HOME/.plenv/bin/plenv install $perl_version | |
# 使用するPerl をインストールしたバージョンに変更します | |
$HOME/.plenv/bin/plenv global $perl_version | |
# cpanm をインストールします | |
$HOME/.plenv/bin/plenv install-cpanm | |
echo '[INFO] 以下のコマンドを実行して下さい' | |
case $SHELL in | |
*/bash) | |
echo '$ source $profile' | |
;; | |
*/zsh) | |
echo '$ rehash' | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
使い方