# -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure("2") do |config| UBUNTU_IP = "192.168.56.101" CENTOS_IP = "192.168.56.102" DEPLOY_JAMES=' wget --quiet https://mirror.ibcp.fr/pub/apache/james/server/3.4.0/james-server-app-3.4.0-app.zip sudo unzip -q james-server-app-3.4.0-app.zip -d /opt sudo cp /vagrant/mailetcontainer.xml /opt/james-server-app-3.4.0/conf/mailetcontainer.xml sudo cp /vagrant/smtpserver.xml /opt/james-server-app-3.4.0/conf/smtpserver.xml sudo /opt/james-server-app-3.4.0/bin/james start sleep 10 WAITING_TIME=60 START_TIME=$(date +%s) until { /dev/null; do CUR_TIME=$(date +%s) if [ $((CUR_TIME-START_TIME)) -gt $WAITING_TIME ]; then echo "ERROR: waiting for JAMES for too long..."; exit 1; else sleep 5; fi; done sudo /opt/james-server-app-3.4.0/bin/james-cli.sh adddomain mymachine.vm sudo /opt/james-server-app-3.4.0/bin/james-cli.sh adduser test@mymachine.vm test mail_cmd=$( which s-nail 2> /dev/null || which mailx ) echo "Test " | ${mail_cmd} -s "Notif" -S smtp=127.0.0.1:25 0611223344@mymachine.vm sleep 5 { echo "open 127.0.0.1 143"; sleep 2; echo "a1 LOGIN test@mymachine.vm test" ;sleep 1; echo "a2 LIST \"\" \"*\"" ; sleep 1 ;echo "a3 EXAMINE INBOX" ;sleep 1; echo "a4 FETCH 1 BODY[]"; sleep 1; echo "a5 LOGOUT"; sleep 1;} | telnet tail -60 /opt/james-server-app-3.4.0/log/james-server.log ' config.vm.define "ubuntu" do |ubuntu| ubuntu.vm.box = "ubuntu/bionic64" ubuntu.vm.hostname = "ubuntu-james" # Create a private network, which allows host-only access to the machine # using a specific IP. ubuntu.vm.network "private_network", ip:"#{UBUNTU_IP}" #config.vm.synced_folder ".", "/vagrant", disabled: true #config.vm.synced_folder ".", "/vagrant_data", type: "nfs" ubuntu.vm.provision "shell", inline: <<-SHELL #!/bin/bash sudo apt update sudo apt install unzip default-jdk-headless s-nail -y #{DEPLOY_JAMES} SHELL end config.vm.define "centos" do |centos| centos.vm.box = "centos/7" centos.vm.hostname = "centos-james" # Create a private network, which allows host-only access to the machine # using a specific IP. centos.vm.network "private_network", ip:"#{CENTOS_IP}" #centos.vm.synced_folder ".", "/vagrant", disabled: true #centos.vm.synced_folder ".", "/vagrant_data", type: "nfs" centos.vm.provision "shell", inline: <<-SHELL #!/bin/bash sudo yum update #sudo yum install unzip java-11-openjdk mailx wget telnet -y sudo yum install unzip java-1.8.0-openjdk mailx wget telnet -y sudo systemctl stop postfix #{DEPLOY_JAMES} SHELL end end