LoginSignup
2

More than 5 years have passed since last update.

vagrantでubuntuにplenv設定

Last updated at Posted at 2015-04-02

0. 説明

vagrantでubunu 14.04にplenv環境を設定したときのメモ

1. 環境

ホストOS: windows7 64bit
ゲストOS: Ubuntu 14.04 64bit

# 内容

Vagrantfileに以下追記


 # yum install関連のシェルスクリプト
 config.vm.provision :shell, :path => "bootstrap.sh"
 # ユーザーを追加するスクリプト
 config.vm.provision :shell, :path => "useradd.sh"

bootstrap.sh

#!/usr/bin/env bash

# build-essential
apt-get install -y build-essential
apt-get install -y git

# expect ユーザー追加用
apt-get install -y expect

useradd.sh

#!/usr/bin/env bash

# -m: ホームディレクトリ作成
# -s: ログインシェル指定
useradd -m yasu -s /bin/bash;

# expectでユーザー追加
# user: yasu, pass: hogehoge
expect -c "
spawn passwd yasu
expect \"New password:\"
send -- \"hogehoge\n\"
expect \"Retype new password:\"
send -- \"hogehoge\n\"
#expect \"passwd: all authentication tokens updated successfully.\"
expect \"passwd: password updated successfully\"
send -- \"exit\n\"
";

# plenv 設定用のスクリプトを実行
sudo -u yasu -i env sh /vagrant/plenv_setup.sh;

plenv_setup.sh

#!/bin/bash

cd;
git clone git://github.com/tokuhirom/plenv.git ~/.plenv;
echo 'export PATH="$HOME/.plenv/bin:$PATH"' >> ~/.bash_profile;
echo 'eval "$(plenv init -)"' >> ~/.bash_profile;

# bash_profileの内容を反映
# source ~/.bash_profile; # for zsh?
. ~/.bash_profile

#download files
git clone git://github.com/tokuhirom/Perl-Build.git ~/.plenv/plugins/perl-build/;
plenv rehash;

plenv install 5.18.1;

plenv global 5.18.1;

plenv install-cpanm;

exit

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2