mise a jour vers scodoc.org

This commit is contained in:
Jean-Marie Place 2024-03-28 22:03:21 +01:00
parent 0371da401b
commit 81035e580e
7 changed files with 158 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
.vagrant/
boxes/
data/
rgloader/
setup_version
insecure_private_key

2
README.md Normal file
View File

@ -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

125
Vagrantfile vendored Normal file
View File

@ -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 <<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

3
config/.bashrc Normal file
View File

@ -0,0 +1,3 @@
#!/bin/bash
cd /opt/scodoc
source venv/bin/activate

20
config/.env Normal file
View File

@ -0,0 +1,20 @@
# Fichier à configurer et renommer en .env
# (dans /opt/scodoc)
# Il doit appartenir à (ou être lisible par) "scodoc"
FLASK_APP=scodoc.py
FLASK_ENV=development
# Envois de mails: adapter si nécessaire
# MAIL_SERVER=localhost
# Obligatoire:
SCODOC_ADMIN_MAIL="nomail@nowhere.net"
SCODOC_DATABASE_URI=postgresql:///SCODOC
# Remplacer cette chaine
# Vous pouvez utiliser
# python3 -c "import uuid; print(uuid.uuid4().hex)"
# pour en créer une de ce genre, aléatoire
SECRET_KEY="53ff5895fe64aeff44a3940dea4964d628af33dd9"

BIN
config/SCODOC.tgz Normal file

Binary file not shown.

2
config/scodoc.list Normal file
View File

@ -0,0 +1,2 @@
# ScoDoc repository for Debian 12 bullseye
deb [signed-by=/usr/share/keyrings/scodoc-archive-keyring.gpg] http://scodoc.org/deb/bookworm bookworm main