This commit is contained in:
octospacc 2024-02-18 01:58:07 +01:00
parent 1389c5bdbc
commit 0f6a0a1ff0
10 changed files with 258 additions and 51 deletions

View File

@ -35,6 +35,7 @@ const ccencryptNow = async (File, BaseKey) => {
//};
//const GitPullPush = async (user) => await ExecAs(`git pull; git add . && git commit -m "Auto-Backup ${Time}" && git push || true`, user);
const GitReclone = async (path, url) => await $`rm -rf ${path}.old || true; mv ${path} ${path}.old; git clone --depth 1 ${url}`;
const GitPullPush = async () => await $`git pull; git add .; git commit -m "Auto-Backup ${Time}" || true; git push || true`;
const BackPathCrypt = async (Folder, Key, Ext) => {
@ -44,7 +45,7 @@ const BackPathCrypt = async (Folder, Key, Ext) => {
await ccencryptNow(`./${File}`, Key);
};
const SimpleCompress = async (Dst, Src) => await $`rm ${Dst}.tar.xz || true; tar cJSf "${Dst}.tar.xz" ${Src}`;
const SimpleCompress = async (dst, src) => await $`rm ${dst}.tar.xz || true; tar cJSf "${dst}.tar.xz" ${dst || src}`;
const SimpleBackup = async (Folder, Prefix) => {
await $`mkdir -vp ./${Folder}`;
@ -55,7 +56,23 @@ const SimpleBackup = async (Folder, Prefix) => {
await $`ln -s ./${Time.Stamp}.tar.xz ./${Folder}/Latest.tar.xz`;
};
const Work = async (Job) => await within(Jobs[Job]);
const AltervistaFullBackup = async (domain) => {
const [user, pass, key] = Secrets[`${domain.replaceAll('.', '_')}_Backup_Tokens`].split(':');
cd(`./${domain}-Git`);
await $`rclone sync ${domain}:/ ./www/wp-content/ --progress || true`;
await $`curl -u ${user}:${pass} https://${domain}/wp-json/octt-export-rest/v1/xrss-export?token=${key} > ./WordPress.xml || true`;
await GitPullPush();
};
const LampBackup = async (folder, table) => {
await SimpleBackup(folder, 'www');
await $`lxc-attach Debian2023 -- mariadb-dump ${table || folder} > ./${folder}/Db.Latest.sql`;
await SimpleCompress(`./${folder}/Db.${Time.Stamp}.sql`, `./${folder}/Db.Latest.sql`);
await $`rm ./${folder}/Db.Latest.sql.tar.xz || true`;
await $`ln -s "./Db.${Time.Stamp}.sql.tar.xz" ./${folder}/Db.Latest.sql.tar.xz`;
};
const Work = async (job) => await within(Jobs[job]);
////////////////////////////////////////////////////////////////////////////////
@ -72,6 +89,7 @@ Jobs.Local_Shiori = async()=>{
};
Jobs.Local_SpaccBBS = async()=>{
// ... await LampBackup('SpaccBBS', 'phpBB');
await SimpleBackup('SpaccBBS', 'www');
await $`lxc-attach Debian2023 -- mariadb-dump phpBB > ./SpaccBBS/Db.Latest.sql`;
await SimpleCompress(`./SpaccBBS/Db.${Time.Stamp}.sql`, './SpaccBBS/Db.Latest.sql');
@ -79,31 +97,26 @@ Jobs.Local_SpaccBBS = async()=>{
await $`ln -s "./Db.${Time.Stamp}.sql.tar.xz" ./SpaccBBS/Db.Latest.sql.tar.xz`;
};
Jobs.Local_liminalgici = async()=>{
await LampBackup('pixelfed_liminalgici');
};
Jobs.Mixed_OctospaccAltervista = async()=>{
const Domain = 'octospacc.altervista.org';
cd(`./${Domain}-Git`);
await $`rclone sync ${Domain}:/ ./www/wp-content/ --progress`;
//await $`curl 'https://${Domain}/wp-admin/export.php?download=true&content=all&cat=0&post_author=0&post_start_date=0&post_end_date=0&post_status=0&page_author=0&page_start_date=0&page_end_date=0&page_status=0&attachment_start_date=0&attachment_end_date=0&submit=Scarica+il+file+di+esportazione' -H 'User-Agent: ${GenericBrowserUserAgent}' -H 'Referer: https://${Domain}/wp-admin/export.php' -H 'Connection: keep-alive' -H 'Cookie: ${Secrets.OctospaccAltervista_Backup_Cookie}' > ./WordPress.xml`;
const args = [
`https://${Domain}/wp-admin/export.php?download=true&content=all&cat=0&post_author=0&post_start_date=0&post_end_date=0&post_status=0&page_author=0&page_start_date=0&page_end_date=0&page_status=0&attachment_start_date=0&attachment_end_date=0&submit=Scarica+il+file+di+esportazione`,
'-H', 'Connection: keep-alive',
'-H', `User-Agent: ${GenericBrowserUserAgent}`,
'-H', `Referer: https://${Domain}/wp-admin/export.php`,
'-H', `Cookie: ${Secrets.OctospaccAltervista_Backup_Cookie}`,
];
await $`curl ${args} > ./WordPress.xml`;
await GitPullPush();
await AltervistaFullBackup('octospacc.altervista.org');
};
// TODO: setup FTP access and Cookie
Jobs.Mixed_SpacccraftAltervista = async()=>{
// ...
await AltervistaFullBackup('spacccraft.altervista.org', Secrets.SpacccraftAltervista_Backup_Cookie);
};
// TODO: everything
Jobs.Exter_WikiSpacc = async()=>{
// ...
};
Jobs.Cloud_ServerBackupLimited = async()=>{
await GitReclone('Server-Backup-Limited', 'https://gitlab.com/octospacc/Server-Backup-Limited/');
cd('./Server-Backup-Limited');
await BackPathCrypt('FreshRSS', Secrets.BackupKey_Git_FreshRSS);
await BackPathCrypt('n8n-data', Secrets.BackupKey_Git_n8n);
@ -130,6 +143,19 @@ Jobs.Cloud_SpaccBBS = async()=>{
await GitPullPush();
};
Jobs.Cloud_liminalgici = async()=>{
cd('./liminalgici.spacc.eu.org-Git');
await $`rm -rf ./pixelfed_liminalgici || true`;
await $`cp -rp ../pixelfed_liminalgici/Latest.d ./pixelfed_liminalgici`;
await $`cp ../pixelfed_liminalgici/Db.Latest.sql.tar.xz ./Db.sql.tar.xz`;
await SimpleCompress('./pixelfed_liminalgici/config');
await $`rm -rf ./pixelfed_liminalgici/config || true`;
for (let File of ['Db.sql.tar.xz', './pixelfed_liminalgici/.env', './pixelfed_liminalgici/config.tar.xz']) {
await ccencryptNow(`./${File}`, Secrets.BackupKey_Git_liminalgici);
};
await GitPullPush();
};
Jobs.Cloud_SpaccCraft = async()=>{
const McServer="SpaccCraft";
const McEdition="Beta-1.7.3";
@ -152,14 +178,18 @@ Jobs.Cloud_Private = async()=> await $`sudo -u tux rclone sync /Main/Clouds/octt
await Work('Local_MiscSimpleBackups');
await Work('Local_Shiori');
await Work('Local_SpaccBBS');
await Work('Local_liminalgici');
//await Work('Local_Doku');
await Work('Mixed_OctospaccAltervista');
await Work('Mixed_SpacccraftAltervista');
await Work('Exter_WikiSpacc');
//await Work('Mixed_SpacccraftAltervista');
//await Work('Exter_WikiSpacc');
await Work('Cloud_ServerBackupLimited');
await Work('Cloud_ArticlesBackupPrivate');
await Work('Cloud_SpaccBBS');
await Work('Cloud_liminalgici');
//await Work('Cloud_Doku');
await Work('Cloud_SpaccCraft');
await Work('Cloud_Private');

View File

@ -20,7 +20,9 @@ for Dir in \
done
chown -R 100033:100033 /Main/Server/www
#chmod -R 775 /Main/Server/www
chmod -R 777 /Main/Server/www
chmod -R 777 /Main/Server/WuppiMini
chown -R tux:tux /Main/Backup/
chown -R tux:tux /Main/Clouds/octt/

View File

@ -39,9 +39,9 @@ T.is = (question) => {
}[word];
if (predicate.endsWith('_') && predicate.startsWith('_')) {
!((oracle % question[predicate]) == 0) && (allTrue = false);
} else if (predicate.endsWith('_')) {
} else if (predicate.endsWith('_')) { // w_
!(oracle <= question[predicate]) && (allTrue = false);
} else if (predicate.startsWith('_')) {
} else if (predicate.startsWith('_')) { // _w
!(oracle >= question[predicate]) && (allTrue = false);
} else {
!(oracle == question[predicate]) && (allTrue = false);
@ -52,8 +52,11 @@ T.is = (question) => {
///////////////////////////////////////
T.is({ _D_:'2', h:'03', m_:'10' })
&& Work('Backup', ()=>{ $`zx /Main/Server/Scripts/BackupAll.zx.mjs` });
//T.is({ /*_D_:'2',*/ h:'03', m_:'10' }) && (T.D % 2 === 0)
//T.is({ _D_:'3', h:'12', m:'00' })
//T.is({ h:'03', m_:'10' }) && (T.D % 3 === 0)
// && Work('Backup', ()=>{ $`zx /Main/Server/Scripts/BackupAll.zx.mjs` });
T.is({ _D_:'9', h:'02', m_:'30' })
&& Work('Certs', ()=>{ $`sh /Main/Server/Scripts/RenewCerts.sh` });

View File

@ -0,0 +1,19 @@
server {
listen 80;
listen 443 ssl;
server_name WuppiMini.octt.eu.org WuppiMini.spaccsoj3trhzowrrblzb5m6hgkwu6syghnmhett7gvxbrz5zhsrs4ad.onion;
ssl_certificate /etc/letsencrypt/live/wuppimini.octt.eu.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/wuppimini.octt.eu.org/privkey.pem;
ssl_prefer_server_ciphers on;
error_log /var/log/nginx/Wuppi.error.log;
access_log /var/log/nginx/Wuppi.access.log;
location / {
proxy_http_version 1.1;
proxy_pass http://localhost:8135;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}

View File

@ -13,6 +13,10 @@ server {
# proxy_set_header Upgrade $http_upgrade;
#}
location / {
root /Main/Server/www/root-private;
}
location /phpmyadmin/ {
root /usr/share;
try_files $uri $uri/;

View File

@ -0,0 +1,42 @@
server {
listen 80;
listen 443 ssl;
server_name doku.spacc.eu.org;
ssl_certificate /etc/letsencrypt/live/doku.spacc.eu.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/doku.spacc.eu.org/privkey.pem;
ssl_prefer_server_ciphers on;
root /Main/Server/www/dokuwiki;
index doku.php;
# Loggers
error_log /var/log/nginx/Doku.error.log;
access_log /var/log/nginx/Doku.access.log;
#Remember to comment the below out when you're installing, and uncomment it when done.
#location ~ /(conf/|bin/|inc/|vendor/|install.php) { deny all; }
#Support for X-Accel-Redirect
location ~ ^/data/ { internal ; }
location ~ ^/lib.*\.(js|css|gif|png|ico|jpg|jpeg)$ {
expires 365d;
}
location / { try_files $uri $uri/ @dokuwiki; }
location @dokuwiki {
# rewrites "doku.php/" out of the URLs if you set the userwrite setting to .htaccess in dokuwiki config page
rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
rewrite ^/(.*) /doku.php?id=$1&$args last;
}
location ~ \.php$ {
try_files $uri $uri/ /doku.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REDIRECT_STATUS 200;
fastcgi_pass php;
}
}

View File

@ -39,12 +39,25 @@ server {
fastcgi_param PATH_INFO $path_info;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location / {
try_files $uri $uri/ index.php;
sub_filter '</body>' '<script> function ForceUpdateFeeds(){ var Count = 0; Array.from(document.querySelectorAll(atob("KltpZF49ImZfIl0uaXRlbS5mZWVk"))).forEach(function(El){ Count++; fetch(location.origin + "/i/?c=feed&a=actualize&id=" + El.id.split("_")[1]); }); setTimeout(function(){ location.reload(); }, Count * 4000); }; </script></body>';
sub_filter '</body>' '<link rel="stylesheet" href="/user.css"/><script src="/Res/User/FreshRSS/Tweaks.js"></script></body>';
sub_filter '<a id="actualize"' '<a class="btn" href="#" title="Force update feeds" onclick="javascript:ForceUpdateFeeds();">Force update feeds</a><a id="actualize"';
sub_filter_once on;
}
location /Res/User/FreshRSS/ {
proxy_pass http://127.0.0.1/Res/User/FreshRSS/;
proxy_set_header Host hlb0.octt.eu.org;
}
location /user.css {
add_header Content-Type text/css;
return 200 ".flux .item > a, .flux .flux_header .item { white-space: normal !important; } .state_unread .category:not(.active)[data-unread='0'], .state_unread .feed:not(.active)[data-unread='0'] { display: revert; }";
}
#location / {
# try_files $uri $uri/ index.php;
# sub_filter '</body>' '<style> .flux .item > a { white-space: normal; } </style><script> function ForceUpdateFeeds(){ var Count = 0; Array.from(document.querySelectorAll(atob("KltpZF49ImZfIl0uaXRlbS5mZWVk"))).forEach(function(El){ Count++; fetch(location.origin + "/i/?c=feed&a=actualize&id=" + El.id.split("_")[1]); }); setTimeout(function(){ location.reload(); }, Count * 4000); }; </script></body>';
# sub_filter '<a id="actualize"' '<a class="btn" href="#" title="Force update feeds" onclick="javascript:ForceUpdateFeeds();">Force update feeds</a><a id="actualize"';
# sub_filter_once on;
#}
}

View File

@ -0,0 +1,67 @@
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name liminalgici.spacc.eu.org liminalgici.spaccsoj3trhzowrrblzb5m6hgkwu6syghnmhett7gvxbrz5zhsrs4ad.onion;
root /Main/Server/www/pixelfed_liminalgici/public; # path to repo/public
ssl_certificate /etc/letsencrypt/live/liminalgici.spacc.eu.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/liminalgici.spacc.eu.org/privkey.pem;
ssl_protocols TLSv1.2;
ssl_ciphers EECDH+AESGCM:EECDH+CHACHA20:EECDH+AES;
ssl_prefer_server_ciphers on;
error_log /var/log/nginx/liminalgici.error.log warn;
access_log /var/log/nginx/liminalgici.access.log;
#add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
client_max_body_size 15M;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param REDIRECT_STATUS 200;
fastcgi_param HTTP_PROXY "";
}
location ~ /\.(?!well-known).* {
deny all;
}
}
server { # Redirect http to https
server_name liminalgici.spacc.eu.org; # change this to your fqdn
listen 80;
listen [::]:80;
return 301 https://$host$request_uri;
}

View File

@ -0,0 +1,13 @@
server {
listen 8083;
location / {
#proxy_http_version 1.1;
proxy_pass http://127.0.0.1:5283;
#proxy_set_header Host www.ecosia.org;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
#proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection "upgrade";
}
}

View File

@ -62,19 +62,19 @@ server {
error_page 500 = /error.php?code=500;
access_log /var/log/nginx/root.access.log;
error_log /var/log/nginx/root.error.log;
sub_filter '</body>' '<script>top.postMessage(location.href.slice(location.origin.length), "https://hlb0it.blogspot.com")</script></body>';
#sub_filter_once off;
location / {
add_header Access-Control-Allow-Origin *;
root /Main/Server/www/root;
if ($request_uri ~ ^([^.\?]*[^/])$) {
return 301 $1/;
}
try_files $uri $uri/ $uri.html =404;
#try_files $uri =404;
#try_files $uri $uri.html $uri/index.html index.html;
autoindex off;
#error_page 404 = /404.html;
#rewrite ^/(\?.*)?$ index.html$1 permanent;
location ~ ^.+?\.php(/.*)?$ {
fastcgi_pass php;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
@ -103,31 +103,45 @@ server {
sub_filter '</head>' '\n<meta name="viewport" content="width=device-width, initial-scale=1.0"/>\n<link rel="stylesheet" href="/Res/NginxIndex.css"/>\n</head>';
sub_filter '</h1>' '</h1>\n<input type="checkbox" id="ToggleMetadata" checked="checked"/><label for="ToggleMetadata"> Metadata</label>\n';
sub_filter '<h1>Index of /Drive/' '<h1>Index of <a href="/Drive/">/Drive</a>/';
sub_filter '</body>' '<script>top.postMessage(location.href.slice(location.origin.length), "https://hlb0it.blogspot.com")</script></body>';
sub_filter_once off;
}
location /Drive/Telegram/ {
access_log /var/log/nginx/TelegramIndex.access.log;
error_log /var/log/nginx/TelegramIndex.error.log;
rewrite ^/Drive/Telegram/(.*)$ /$1 break;
proxy_http_version 1.1;
proxy_pass http://localhost:8095;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
sub_filter '<a href="/" id="title-a"' '<a style="/*position: absolute; margin-top: 0.25em;*/ word-break: keep-all;line-break: strict;" href="/Drive/">/Drive/</a><a style="/*margin-left: 3em;*/" href="/Drive/Telegram/" id="title-a"';
sub_filter '<link href="/' '<link href="/Drive/Telegram/';
sub_filter '<a href="/' '<a href="/Drive/Telegram/';
sub_filter '<img src="/' '<img src="/Drive/Telegram/';
sub_filter '<source src="/' '<source src="/Drive/Telegram/';
sub_filter '<script src="/' '<script src="/Drive/Telegram/';
sub_filter '<meta property="og:image" content="/' '<meta property="og:image" content="https://hlb0.octt.eu.org/Drive/Telegram/';
sub_filter_once off;
}
#location /Drive/Telegram/ {
# access_log /var/log/nginx/TelegramIndex.access.log;
# error_log /var/log/nginx/TelegramIndex.error.log;
# rewrite ^/Drive/Telegram/(.*)$ /$1 break;
# proxy_http_version 1.1;
# proxy_pass http://localhost:8095;
# proxy_set_header Host $host;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header Upgrade $http_upgrade;
# sub_filter '<a href="/" id="title-a"' '<a style="/*position: absolute; margin-top: 0.25em;*/ word-break: keep-all;line-break: strict;" href="/Drive/">/Drive/</a><a style="/*margin-left: 3em;*/" href="/Drive/Telegram/" id="title-a"';
# sub_filter '<link href="/' '<link href="/Drive/Telegram/';
# sub_filter '<a href="/' '<a href="/Drive/Telegram/';
# sub_filter '<img src="/' '<img src="/Drive/Telegram/';
# sub_filter '<source src="/' '<source src="/Drive/Telegram/';
# sub_filter '<script src="/' '<script src="/Drive/Telegram/';
# sub_filter '<meta property="og:image" content="/' '<meta property="og:image" content="https://hlb0.octt.eu.org/Drive/Telegram/';
# sub_filter_once off;
#}
location /wwwroot/ {
rewrite ^/wwwroot/(.*)$ /$1 permanent;
}
}
#server {
# listen 80;
# listen 81;
# listen 443 ssl;
# server_name old;
# ssl_certificate /Main/Server/www/Temp/old/keys12/server.pem;
# ssl_certificate_key /Main/Server/www/Temp/old/keys12/private_unencrypted.pem;
# ssl_prefer_server_ciphers on;
# location / {
# root /Main/Server/www/Temp/old;
# }
#}