diff --git a/templates/template11-minio-storage-server/Readme.md b/templates/template11-minio-storage-server/Readme.md index ef6ed80..10ec360 100644 --- a/templates/template11-minio-storage-server/Readme.md +++ b/templates/template11-minio-storage-server/Readme.md @@ -7,17 +7,19 @@ |File name | Description| | --- | --- | +| mc | Minio Client's binary file - Downloadable from https://dl.min.io/client/mc/release/linux-amd64/ | | minio | Minio Server's binary file - Downloadable from https://dl.min.io/server/minio/release/linux-amd64/minio | | minio.service | Minio Server unit file - Base file is https://raw.githubusercontent.com/minio/minio-service/master/linux-systemd/minio.service | | minio.conf |Minio Server configuration file | | `rootCA.pem` | The rootCA previously created in your host machine | | `rootCA-key.pem` | The rootCA key previously created in your host machine | - * Create folder `log` -* Open `Vagrantfile` and change the value of variable `lxd.name`. It makes sense to give the same name as the folder, in this example `minio-storage-server`. -* Open `provision.sh` - * change the value of variable `MACHINE_HOSTNAME`. It makes sense to give the same name as the folder, plus the domain, in this example `minio-storage-server.localenv.com`. +* Open `Vagrantfile` and assign a value to the following parameters and variables: + * `lxd.name` (it is recommended to give the container the same name as the folder, in this example `minio-storage-server`) + * `MACHINE_HOSTNAME` + * Run `vagrant up > log/provisioning.log` -* Make sure your system is able to resolve the domain name that you specified in variable `MACHINE_HOSTNAME`, for example by adding an entry in `/etc/hosts` +* Make sure your system is able to resolve the domain name that you specified in variable `MACHINE_HOSTNAME`, for example by adding an entry in `/etc/hosts` or by setting up the LXD nameserver * Start using your environment + diff --git a/templates/template11-minio-storage-server/Vagrantfile b/templates/template11-minio-storage-server/Vagrantfile index 87c9832..202cf05 100644 --- a/templates/template11-minio-storage-server/Vagrantfile +++ b/templates/template11-minio-storage-server/Vagrantfile @@ -4,23 +4,30 @@ Vagrant.configure("2") do |config| - config.vm.box = "isc/lxc-ubuntu-22.04" + config.vm.box = "isc/forge-clt-ubuntu-22.04" + + config.vm.box_version = "1" config.vm.box_check_update = false config.vm.provider 'lxd' do |lxd| lxd.api_endpoint = 'https://127.0.0.1:8443' lxd.timeout = 10 - lxd.name = 'your-container-name' - lxd.profiles = ['default'] + lxd.name = '' lxd.project = 'default' + lxd.profiles = ['default'] # lxd.nesting = nil # lxd.privileged = nil # lxd.ephemeral = false # lxd.environment = {} # lxd.config = {} end - - config.vm.provision :shell, path: "provision.sh" - + + config.vm.provision "shell" do |s| + s.env = { + "MACHINE_HOSTNAME" => "", + } + s.path = "provision.sh" + end end + diff --git a/templates/template11-minio-storage-server/artifacts/minio.conf b/templates/template11-minio-storage-server/artifacts/minio.conf index c50e828..bdbf980 100644 --- a/templates/template11-minio-storage-server/artifacts/minio.conf +++ b/templates/template11-minio-storage-server/artifacts/minio.conf @@ -1,5 +1,9 @@ +## MinIO configuration file MINIO_VOLUMES="#MINIO_STORAGE_FOLDER#" + MINIO_OPTS="-C /etc/minio --address #MACHINE_HOSTNAME#:9000" + MINIO_ROOT_USER="admin" + # Minimum 8 characters required for the password MINIO_ROOT_PASSWORD="admin123" diff --git a/templates/template11-minio-storage-server/artifacts/minio.service b/templates/template11-minio-storage-server/artifacts/minio.service index adb6d58..08c819c 100644 --- a/templates/template11-minio-storage-server/artifacts/minio.service +++ b/templates/template11-minio-storage-server/artifacts/minio.service @@ -1,20 +1,21 @@ [Unit] Description=MinIO -Documentation=https://docs.min.io +Documentation=https://min.io/docs/minio/linux/index.html Wants=network-online.target After=network-online.target AssertFileIsExecutable=/usr/local/bin/minio + [Service] -WorkingDirectory=/usr/local/ +WorkingDirectory=/usr/local User=root Group=root ProtectProc=invisible EnvironmentFile=/etc/minio/minio.conf -ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\"; exit 1; fi" +ExecStartPre=/bin/bash -c "if [ -z \"${MINIO_VOLUMES}\" ]; then echo \"Variable MINIO_VOLUMES not set in /etc/default/minio\"; exit 1; fi" ExecStart=/usr/local/bin/minio server $MINIO_OPTS $MINIO_VOLUMES # Let systemd restart this service always diff --git a/templates/template11-minio-storage-server/provision.sh b/templates/template11-minio-storage-server/provision.sh index 5da9bfc..7694aa3 100644 --- a/templates/template11-minio-storage-server/provision.sh +++ b/templates/template11-minio-storage-server/provision.sh @@ -6,16 +6,17 @@ echo "provisioning started: ${start_time}" -#### The user must fill these variables - START - -# Fully Qualified Name: ex. "nc.localenv.com" -MACHINE_HOSTNAME= - -#### The user must fill these variables - END - - MINIO_STORAGE_FOLDER=/usr/local/share/minio/ +MINIO_ADMIN=admin + +MINIO_ADMIN_PASSWORD=admin123 + +MINIO_NEXTCLOUD_USER=nextcloud_usr + +MINIO_NEXTCLOUD_PASSWORD=nextcloud_usr + + NETWORK_INTERFACE=eth0 hostnamectl set-hostname ${MACHINE_HOSTNAME} @@ -31,9 +32,9 @@ ##################################################################### cp /vagrant/artifacts/minio /usr/local/bin -chmod +x /usr/local/bin/minio +cp /vagrant/artifacts/mc /usr/local/bin -chown ${SYSTEM_USER}:${SYSTEM_USER} /usr/local/bin/minio +chmod +x /usr/local/bin/minio mkdir /etc/minio @@ -65,9 +66,22 @@ systemctl status minio +## Add a user for Nextcloud +sleep 10 + +mc alias remove local + +mc alias set local https://${MACHINE_HOSTNAME}:9000 ${MINIO_ADMIN} ${MINIO_ADMIN_PASSWORD} + +mc admin user add local ${MINIO_NEXTCLOUD_USER} ${MINIO_NEXTCLOUD_PASSWORD} + +mc admin policy attach local readwrite --user ${MINIO_NEXTCLOUD_USER} + end_time=`date` -echo " You can connect with user admin (password admin123) to te Minio Web Console https://${MACHINE_HOSTNAME}:9000. These are also the connection details to be used in config.php." +echo "You can connect with user '${MINIO_ADMIN}' (password: '${MINIO_ADMIN_PASSWORD}') to the MinIO Web Console https://${MACHINE_HOSTNAME}:9000" + +echo "The user created for Nextcloud is nextcloud_usr (password: 'nextcloud_usr')" echo "provisioning started: ${start_time}"