From 738a686936a5675b530a193c0249ac0ecd1836d7 Mon Sep 17 00:00:00 2001 From: Jean-Marie Place Date: Thu, 28 Mar 2024 21:56:46 +0100 Subject: [PATCH] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20vers=20?= =?UTF-8?q?"config"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/.gitignore | 6 +++ config/README.md | 2 + config/Vagrantfile | 125 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 config/.gitignore create mode 100644 config/README.md create mode 100644 config/Vagrantfile diff --git a/config/.gitignore b/config/.gitignore new file mode 100644 index 0000000..e86be61 --- /dev/null +++ b/config/.gitignore @@ -0,0 +1,6 @@ +.vagrant/ +boxes/ +data/ +rgloader/ +setup_version +insecure_private_key diff --git a/config/README.md b/config/README.md new file mode 100644 index 0000000..55c17a5 --- /dev/null +++ b/config/README.md @@ -0,0 +1,2 @@ +# Creation d'un machine virtuelle scodoc 9.6 sur debian 12 +installe également uine base de donnée jouet depuis le fichier config/SCODOC.tgz diff --git a/config/Vagrantfile b/config/Vagrantfile new file mode 100644 index 0000000..7a5d752 --- /dev/null +++ b/config/Vagrantfile @@ -0,0 +1,125 @@ +# -*- 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 < /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 +