2019年6月18日火曜日

VagrantでEclipse 2019-03とAdoptOpenJDK11、Xfce Desktop環境、TigerVNCがインストールされた仮想マシン(Ubuntu18.04)を構築する

EclipseはオープンソースのIDEです。

〇Eclipse 2019-03の画面


○構築方法
以下のVagrantfileを使用して、Eclipse 2019-03、Xfce Desktop環境、TigerVNCをインストールした仮想マシン(Ubuntu18.04)を構築できます。
TigerVNCがインストールされているので、VNCクライアントで接続することができます。パスワードはvagrantでログオンできます。

Vagrantfile
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "bento/ubuntu-18.04"
  config.vm.hostname = "ub1804vncxfceeclipse201903"
  config.vm.network :public_network, ip:"192.168.1.108"
  config.vm.network "private_network", ip: "192.168.55.108", :netmask => "255.255.255.0"
  config.vm.provider :virtualbox do |vbox|
     vbox.name = "ub1804vncxfceeclipse201903"
     vbox.gui = true
     vbox.cpus = 2
     vbox.memory = 4096
  end
  config.vm.provision "shell", inline: <<-SHELL
apt-get update
export DEBIAN_FRONTEND=noninteractive
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
apt-get -y install language-pack-ja fonts-ipafont-*
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
apt-get update
apt-get -y install fcitx-mozc xubuntu-desktop xfce4-terminal language-pack-ja tigervnc-standalone-server expect
apt-get -y purge light-locker
im-config -n fcitx


# set passwd for vnc
cat << EOC > /tmp/initpass.sh
/usr/bin/expect << EOF
spawn "tigervncpasswd"
expect "Password:"
send "vagrant\\r"
expect "Verify:"
send "vagrant\\r"
expect "Would you like to enter a view-only password (y/n)?"
send "n\\r"
expect eof
exit
EOF
EOC
chmod +x /tmp/initpass.sh
sudo -u vagrant -H /bin/bash -c "/tmp/initpass.sh"


mkdir -p /home/vagrant/.vnc
chown vagrant:vagrant /home/vagrant/.vnc
cat << EOF > /home/vagrant/.vnc/xstartup
#!/bin/sh
export LANG=ja_JP.UTF-8
export LC_ALL=ja_JP.UTF-8
export XMODIFIERS=@im=fcitx
export GTK_IM_MODULE=fcitx
fcitx -r -d &
exec startxfce4
EOF
chmod +x /home/vagrant/.vnc/xstartup

cat << EOF > /etc/systemd/system/vncserver@.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple
User=vagrant
PAMName=login
PIDFile=/home/%u/.vnc/%H%i.pid
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :%i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver :%i -localhost no -geometry 1152x864 -alwaysshared -fg
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl start vncserver@1.service
sudo systemctl enable vncserver@1.service

# install AdoptOpenJDK11
cd /opt
wget https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.3%2B7/OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz
tar xvfz OpenJDK11U-jdk_x64_linux_hotspot_11.0.3_7.tar.gz
cat << EOF > /etc/profile.d/jdk.sh
export JAVA_HOME=/opt/jdk-11.0.3+7
export PATH=\\$PATH:\\$JAVA_HOME/bin
EOF
update-alternatives --install /usr/bin/java java /opt/jdk-11.0.3+7/bin/java 2000
update-alternatives --install /usr/bin/javac javac /opt/jdk-11.0.3+7/bin/javac 2000

# install eclipse 201903
wget http://ftp.jaist.ac.jp/pub/eclipse/technology/epp/downloads/release/2019-03/R/eclipse-java-2019-03-R-linux-gtk-x86_64.tar.gz
tar xvfz eclipse-java-2019-03-R-linux-gtk-x86_64.tar.gz

cat << EOF > /usr/share/applications/eclipse.desktop
#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/opt/eclipse/eclipse
Name=eclipse
Categories=Development;
Icon=/opt/eclipse/icon.xpm
EOF

init 5
SHELL
end

0 件のコメント:

コメントを投稿