MV_Jouet/Vagrantfile

126 lines
4.7 KiB
Ruby
Raw Normal View History

2024-03-28 22:03:21 +01:00
# -*- 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|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://vagrantcloud.com/search.
config.vm.box = "debian/bookworm64"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 5000, host:5000
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "public_network", use_dhcp_assigned_default_route: true, bridge: "vmbr0"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "~/scodoc", "/opt/scodoc"
#config.ssh.username = 'scodoc'
#config.ssh.insert_key = 'true'
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# # Display the VirtualBox GUI when booting the machine
# vb.gui = true
#
# # Customize the amount of memory on the VM:
vb.memory = "8192"
vb.cpus = 2
end
#config.ssh.username = "scodoc"
#config.ssh.password = "r6a06$$"
#
# View the documentation for the provider you are using for more
# information on available options.
# Enable provisioning with a shell script. Additional provisioners such as
# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "shell", inline: <<-SHELL
apt update && apt -y upgrade
apt -y install net-tools
export CONFIG=/vagrant/config
apt-get install -y gnupg
apt-get install -y git
wget -O - https://scodoc.org/misc/scodoc-repo.gpg.key | gpg --dearmor > /usr/share/keyrings/scodoc-archive-keyring.gpg
#ajout depot et installation scodoc
cp $CONFIG/scodoc.list /etc/apt/sources.list.d
apt-get update
# discard postfix dialog
export DEBIAN_FRONTEND=noninteractive
# apt-get install -y nginx
apt-get install -y scodoc9
echo '# scodoc user is created by scodoc install. configure it'
cp $CONFIG/.bashrc /home/scodoc/.bashrc
su -c "psql -c 'GRANT postgres TO scodoc;'" postgres
chpasswd <<EOF
scodoc:r6a06$$
EOF
echo "configure ssh to scodoc"
cd /home/vagrant
mkdir /home/scodoc
chown scodoc:scodoc /home/scodoc
cp -r .ssh /home/scodoc
cd /home/scodoc
chown -R scodoc:scodoc /home/scodoc
echo "%scodoc ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/scodoc
echo 'install development data'
su -c "createdb SCODOC" scodoc
rm /opt/scodoc/.env
cp $CONFIG/.env /opt/scodoc/.env
cd /opt/scodoc
yes | tools/restore_scodoc9_data.sh /$CONFIG/SCODOC.tgz
# iniitalise repo
cd /opt/scodoc
su -c "git init" scodoc
su -c "git remote add origin https://gitlab.univ-lille.fr/Jean-Marie.Place/scodoc_r6a06.git" scodoc
su -c "git fetch" scodoc
su -c "git switch master --force" scodoc
echo -n "Adresse ip: " >> $CONFIG/ip
ip a >> $CONFIG/ip
SHELL
VAGRANT_COMMAND = ARGV[0]
if VAGRANT_COMMAND == "ssh"
config.ssh.username = 'scodoc'
end
end