From 815965501b25feee74ec55e3b71a6006540ed3b0 Mon Sep 17 00:00:00 2001
From: Adrian Amaglio <aamaglio@dbmtechnologies.com>
Date: Thu, 18 Apr 2024 16:20:53 +0200
Subject: [PATCH] wow. much updates. wow.

---
 .../roles/deploy_all/files/bin/wg-genkey.sh   | 18 ++++++
 services/association-chahut.fr/.env           |  2 +
 .../association-chahut.fr/LINKS. DO NOT EDIT  |  0
 services/association-chahut.fr/deploy.sh      |  1 +
 services/association-chahut.fr/deploy_user.sh | 20 +++++++
 .../association-chahut.fr/nginx_server.conf   |  1 +
 services/compagnienouvelle.fr/.env            |  2 +-
 services/compagnienouvelle.fr/deploy.sh       |  1 +
 services/compagnienouvelle.fr/deploy_user.sh  |  1 +
 .../compagnienouvelle.fr/docker-compose.yml   | 43 --------------
 .../compagnienouvelle.fr/nginx_server.conf    | 31 +---------
 services/compagnienouvelle.fr/tmp.log         | 58 -------------------
 services/gaia.jean-cloud.net/.env             |  1 +
 services/gaia.jean-cloud.net/deploy_user.sh   |  5 ++
 .../gaia.jean-cloud.net/nginx_server.conf     | 13 +++++
 15 files changed, 65 insertions(+), 132 deletions(-)
 create mode 100644 provisioning/roles/deploy_all/files/bin/wg-genkey.sh
 create mode 100644 services/association-chahut.fr/.env
 create mode 100644 services/association-chahut.fr/LINKS. DO NOT EDIT
 create mode 120000 services/association-chahut.fr/deploy.sh
 create mode 100755 services/association-chahut.fr/deploy_user.sh
 create mode 120000 services/association-chahut.fr/nginx_server.conf
 create mode 120000 services/compagnienouvelle.fr/deploy.sh
 create mode 120000 services/compagnienouvelle.fr/deploy_user.sh
 delete mode 100644 services/compagnienouvelle.fr/docker-compose.yml
 mode change 100755 => 120000 services/compagnienouvelle.fr/nginx_server.conf
 delete mode 100644 services/compagnienouvelle.fr/tmp.log
 create mode 100644 services/gaia.jean-cloud.net/.env
 create mode 100755 services/gaia.jean-cloud.net/deploy_user.sh
 create mode 100755 services/gaia.jean-cloud.net/nginx_server.conf

diff --git a/provisioning/roles/deploy_all/files/bin/wg-genkey.sh b/provisioning/roles/deploy_all/files/bin/wg-genkey.sh
new file mode 100644
index 0000000..6f4ef68
--- /dev/null
+++ b/provisioning/roles/deploy_all/files/bin/wg-genkey.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+if [ "$#" -ne 1 ] ; then
+	echo "Usage: $0 <filename>"
+	exit 1
+fi
+
+keyfile="$1"    
+
+if [ ! -f "$keyfile" ] ; then    
+    touch "$keyfile"    
+    chmod 700 "$keyfile"    
+    if [ -n "$(lsof "$keyfile")" ] ; then    
+        echo "Error, key $keyfile is red"    
+        exit 1    
+    fi    
+    wg genkey > "$keyfile"    
+fi    
diff --git a/services/association-chahut.fr/.env b/services/association-chahut.fr/.env
new file mode 100644
index 0000000..0d2ff05
--- /dev/null
+++ b/services/association-chahut.fr/.env
@@ -0,0 +1,2 @@
+GIT_SOURCE_REPO="https://git.jean-cloud.net/adrian/association-chahut.fr.git"
+
diff --git a/services/association-chahut.fr/LINKS. DO NOT EDIT b/services/association-chahut.fr/LINKS. DO NOT EDIT
new file mode 100644
index 0000000..e69de29
diff --git a/services/association-chahut.fr/deploy.sh b/services/association-chahut.fr/deploy.sh
new file mode 120000
index 0000000..e8adfae
--- /dev/null
+++ b/services/association-chahut.fr/deploy.sh
@@ -0,0 +1 @@
+../hugo/deploy.sh
\ No newline at end of file
diff --git a/services/association-chahut.fr/deploy_user.sh b/services/association-chahut.fr/deploy_user.sh
new file mode 100755
index 0000000..590c0b4
--- /dev/null
+++ b/services/association-chahut.fr/deploy_user.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+set -euo pipefail
+
+# Update git repo
+git_update.sh -d "$HTTP_DIR" -b "${GIT_SOURCE_BRANCH:-main}" "$GIT_SOURCE_REPO"
+
+cd "$HTTP_DIR"
+
+# Get remote content files
+rclone_ncloud_publiclink.sh
+
+# Invalid cache
+#rm -rf "/tmp/hugo_cache_$USER"
+
+cd theme/blist
+npm install
+cd ../..
+
+# Build website
+HUGO_CACHEDIR="/tmp/hugo_cache_$USER" hugo
diff --git a/services/association-chahut.fr/nginx_server.conf b/services/association-chahut.fr/nginx_server.conf
new file mode 120000
index 0000000..8b62669
--- /dev/null
+++ b/services/association-chahut.fr/nginx_server.conf
@@ -0,0 +1 @@
+../hugo/nginx_server.conf
\ No newline at end of file
diff --git a/services/compagnienouvelle.fr/.env b/services/compagnienouvelle.fr/.env
index 10a3998..2d19674 100644
--- a/services/compagnienouvelle.fr/.env
+++ b/services/compagnienouvelle.fr/.env
@@ -1 +1 @@
-DATA_DIR=/data/compagnienouvelle.fr
+SFTP_USER=compagnienouvelle.frRO
diff --git a/services/compagnienouvelle.fr/deploy.sh b/services/compagnienouvelle.fr/deploy.sh
new file mode 120000
index 0000000..e857506
--- /dev/null
+++ b/services/compagnienouvelle.fr/deploy.sh
@@ -0,0 +1 @@
+../sftp_jc/deploy.sh
\ No newline at end of file
diff --git a/services/compagnienouvelle.fr/deploy_user.sh b/services/compagnienouvelle.fr/deploy_user.sh
new file mode 120000
index 0000000..3d4ee19
--- /dev/null
+++ b/services/compagnienouvelle.fr/deploy_user.sh
@@ -0,0 +1 @@
+../sftp_jc/deploy_user.sh
\ No newline at end of file
diff --git a/services/compagnienouvelle.fr/docker-compose.yml b/services/compagnienouvelle.fr/docker-compose.yml
deleted file mode 100644
index c599ae5..0000000
--- a/services/compagnienouvelle.fr/docker-compose.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-version: '3.1'
-
-services:
-
-  wp:
-    image: wordpress:5-apache
-    restart: unless-stopped
-    env_file: $DATA_DIR/wordpress.env
-    environment:
-      TZ: Europe/Paris
-    volumes:
-      - $DATA_DIR/wordpress:/var/www/html
-      - $DATA_DIR/static:/var/www/html/static
-    networks:
-      default:
-        ipv4_address: $NET.100
-    deploy:
-      resources:
-        limits:
-          cpus: '0.50'
-          memory: 100M
-  db:
-    image: mariadb:10.7
-    restart: unless-stopped
-    environment:
-      TZ: Europe/Paris
-    volumes:
-      - $DATA_DIR/db:/var/lib/mysql
-    networks:
-      default:
-        ipv4_address: $NET.101
-    deploy:
-      resources:
-        limits:
-          cpus: '0.50'
-          memory: 300M
-
-networks:
-  default:
-    ipam:
-      config:
-        - subnet: $NET.0/24
-
diff --git a/services/compagnienouvelle.fr/nginx_server.conf b/services/compagnienouvelle.fr/nginx_server.conf
deleted file mode 100755
index 5aa70dd..0000000
--- a/services/compagnienouvelle.fr/nginx_server.conf
+++ /dev/null
@@ -1,30 +0,0 @@
-server {
-  listen 443 ssl http2;
-  listen [::]:443 ssl http2;
-  ssl_certificate $JC_CERT/fullchain.pem;
-  ssl_certificate_key $JC_CERT/privkey.pem;
-  server_name wordpress.compagnienouvelle.fr www.wordpress.compagnienouvelle.fr;
-  location  / {
-    auth_basic           "Mot de passe !";
-    auth_basic_user_file /data/compagnienouvelle.fr/pass.txt;
-    client_max_body_size 2G;
-    #proxy_set_header X-Real-IP $remote_addr;
-    proxy_set_header Host $http_host;
-    proxy_set_header X-Forwarded-Proto https;
-    proxy_pass http://$NET.100;
-    proxy_redirect off;
-  }
-}
-
-server {
-  listen 443 ssl http2;
-  listen [::]:443 ssl http2;
-  ssl_certificate $JC_CERT/fullchain.pem;
-  ssl_certificate_key $JC_CERT/privkey.pem;
-  server_name compagnienouvelle.fr www.compagnienouvelle.fr;
-
-  location /  {
-    root /data/compagnienouvelle.fr/static;
-    try_files $uri $uri/ =404;
-  }
-}
diff --git a/services/compagnienouvelle.fr/nginx_server.conf b/services/compagnienouvelle.fr/nginx_server.conf
new file mode 120000
index 0000000..c63a303
--- /dev/null
+++ b/services/compagnienouvelle.fr/nginx_server.conf
@@ -0,0 +1 @@
+../sftp_jc/nginx_server.conf
\ No newline at end of file
diff --git a/services/compagnienouvelle.fr/tmp.log b/services/compagnienouvelle.fr/tmp.log
deleted file mode 100644
index 69589d1..0000000
--- a/services/compagnienouvelle.fr/tmp.log
+++ /dev/null
@@ -1,58 +0,0 @@
-[class-ss-plugin.php:232] Received request to start generating a static archive
-[class-ss-archive-creation-job.php:61] Starting a job; no job is presently running
-[class-ss-archive-creation-job.php:62] Here's our task list: setup, fetch_urls, transfer_files_locally, wrapup
-[class-ss-archive-creation-job.php:76] Pushing first task to queue: setup
-[class-ss-archive-creation-job.php:105] Current task: setup
-[class-ss-archive-creation-job.php:120] Performing task: setup
-[class-ss-task.php:38] Status message: [setup] Mise en place
-[class-ss-setup-task.php:23] Creating archive directory: /var/www/html/wp-content/plugins/simply-static/static-files/simply-static-1-1603638186/
-[class-ss-setup-task.php:57] Adding origin URL to queue: https://wordpress.mysite.com/
-[class-ss-setup-task.php:68] Adding additional URL to queue: https://wordpress.mysite.com/wp-includes/js/wp-emoji-release.min.js
-[class-ss-setup-task.php:99] Adding files from directory: /var/www/html/wp-content/uploads/
-[class-ss-archive-creation-job.php:142] We've found our next task: fetch_urls
-[class-ss-archive-creation-job.php:105] Current task: fetch_urls
-[class-ss-archive-creation-job.php:120] Performing task: fetch_urls
-[class-ss-fetch-urls-task.php:37] Total pages: 2; Pages remaining: 2
-[class-ss-fetch-urls-task.php:40] URL: https://wordpress.mysite.com/
-[class-ss-fetch-urls-task.php:50] URL is not being excluded
-[class-ss-url-fetcher.php:85] Fetching URL and saving it to: /tmp/5f9593ab13a6a-QXn1T1.tmp
-[class-ss-url-fetcher.php:89] Filesize: 26432 bytes
-[class-ss-url-fetcher.php:104] http_status_code: 200 | content_type: text/html; charset=UTF-8
-[class-ss-url-fetcher.php:180] New filename for static page: index.html
-[class-ss-url-fetcher.php:120] Renaming temp file from /tmp/5f9593ab13a6a-QXn1T1.tmp to /var/www/html/wp-content/plugins/simply-static/static-files/simply-static-1-1603638186/index.html
-[class-ss-fetch-urls-task.php:99] Extracting URLs and replacing URLs in the static file
-[class-ss-fetch-urls-task.php:106] Adding 0 URLs to the queue
-[class-ss-fetch-urls-task.php:117] We're saving this URL; keeping the static file
-[class-ss-fetch-urls-task.php:40] URL: https://wordpress.mysite.com/wp-includes/js/wp-emoji-release.min.js
-[class-ss-fetch-urls-task.php:50] URL is not being excluded
-[class-ss-url-fetcher.php:85] Fetching URL and saving it to: /tmp/5f9593ab2d225-A0zDVK.tmp
-[class-ss-url-fetcher.php:89] Filesize: 14246 bytes
-[class-ss-url-fetcher.php:104] http_status_code: 200 | content_type: application/javascript
-[class-ss-url-fetcher.php:180] New filename for static page: wp-includes/js/wp-emoji-release.min.js
-[class-ss-url-fetcher.php:120] Renaming temp file from /tmp/5f9593ab2d225-A0zDVK.tmp to /var/www/html/wp-content/plugins/simply-static/static-files/simply-static-1-1603638186/wp-includes/js/wp-emoji-release.min.js
-[class-ss-fetch-urls-task.php:99] Extracting URLs and replacing URLs in the static file
-[class-ss-fetch-urls-task.php:106] Adding 0 URLs to the queue
-[class-ss-fetch-urls-task.php:117] We're saving this URL; keeping the static file
-[class-ss-task.php:38] Status message: [fetch_urls] 0 pages/fichiers sur 2 générés
-[class-ss-archive-creation-job.php:147] We're not done with the fetch_urls task yet
-[class-ss-archive-creation-job.php:105] Current task: fetch_urls
-[class-ss-archive-creation-job.php:120] Performing task: fetch_urls
-[class-ss-fetch-urls-task.php:37] Total pages: 2; Pages remaining: 0
-[class-ss-task.php:38] Status message: [fetch_urls] 2 pages/fichiers sur 2 générés
-[class-ss-archive-creation-job.php:142] We've found our next task: transfer_files_locally
-[class-ss-archive-creation-job.php:105] Current task: transfer_files_locally
-[class-ss-archive-creation-job.php:120] Performing task: transfer_files_locally
-[class-ss-transfer-files-locally-task.php:64] Total pages: 2; Pages remaining: 2
-[class-ss-archive-creation-job.php:147] We're not done with the transfer_files_locally task yet
-[class-ss-archive-creation-job.php:105] Current task: transfer_files_locally
-[class-ss-archive-creation-job.php:120] Performing task: transfer_files_locally
-[class-ss-transfer-files-locally-task.php:64] Total pages: 2; Pages remaining: 0
-[class-ss-task.php:38] Status message: [transfer_files_locally] 2 fichiers sur 2 copiés
-[class-ss-archive-creation-job.php:142] We've found our next task: wrapup
-[class-ss-archive-creation-job.php:105] Current task: wrapup
-[class-ss-archive-creation-job.php:120] Performing task: wrapup
-[class-ss-wrapup-task.php:13] Deleting temporary files
-[class-ss-task.php:38] Status message: [wrapup] Fin du processus
-[class-ss-archive-creation-job.php:138] This task is done and there are no more tasks, time to complete the job
-[class-ss-archive-creation-job.php:161] Completing the job
-[class-ss-archive-creation-job.php:271] Status message: [done] Effectué ! Fini en 00:00:01
diff --git a/services/gaia.jean-cloud.net/.env b/services/gaia.jean-cloud.net/.env
new file mode 100644
index 0000000..a6bf8d9
--- /dev/null
+++ b/services/gaia.jean-cloud.net/.env
@@ -0,0 +1 @@
+GIT_SOURCE_REPO=https://git.jean-cloud.net/adrian/gaia
diff --git a/services/gaia.jean-cloud.net/deploy_user.sh b/services/gaia.jean-cloud.net/deploy_user.sh
new file mode 100755
index 0000000..c010fd4
--- /dev/null
+++ b/services/gaia.jean-cloud.net/deploy_user.sh
@@ -0,0 +1,5 @@
+#!/bin/bash
+set -euo pipefail
+
+git_update.sh -d "$HTTP_DIR" -b "${GIT_SOURCE_BRANCH:-main}" "$GIT_SOURCE_REPO"
+
diff --git a/services/gaia.jean-cloud.net/nginx_server.conf b/services/gaia.jean-cloud.net/nginx_server.conf
new file mode 100755
index 0000000..ef32fd9
--- /dev/null
+++ b/services/gaia.jean-cloud.net/nginx_server.conf
@@ -0,0 +1,13 @@
+server {
+  listen 443 ssl http2;
+  listen [::]:443 ssl http2;
+  ssl_certificate $JC_CERT/fullchain.pem;
+  ssl_certificate_key $JC_CERT/privkey.pem;
+  server_name $JC_SERVICE www.$JC_SERVICE;
+  location / {
+          add_header Content-language fr;
+          root $HTTP_DIR/src;
+          index index.html;
+          try_files $uri $uri/ =404;
+  }
+}