From 1907645f884b67acfdadd744054cbbfaafd75dbf Mon Sep 17 00:00:00 2001 From: octospacc Date: Mon, 6 Mar 2023 12:07:10 +0100 Subject: [PATCH] Update Server --- Server/Repo.Update.sh | 10 ++++-- .../Server/Scripts/Backup/BackupGlobals.cfg | 4 ++- .../Root/Server/Scripts/Backup/CloudBackup.sh | 26 +++++++++++++-- .../Server/Scripts/Backup/ServerDataBackup.sh | 9 +++-- Server/Root/etc/diycron | 2 +- .../etc/nginx/sites-available/analytics.conf | 18 ++++++++++ .../etc/nginx/sites-available/articles.conf | 33 +++++++++++++++++++ .../{articles => articles.wallabag.old} | 0 ....eu.org.conf => epic.octt.eu.org.conf.old} | 0 .../sites-available/{feeds => feeds.conf} | 0 ....eu.org.conf => godo.octt.eu.org.conf.old} | 0 .../sites-available/{librex => librex.conf} | 0 ....eu.org.conf => miss.octt.eu.org.conf.old} | 0 .../nginx/sites-available/{root => root.conf} | 0 14 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 Server/Root/etc/nginx/sites-available/analytics.conf create mode 100644 Server/Root/etc/nginx/sites-available/articles.conf rename Server/Root/etc/nginx/sites-available/{articles => articles.wallabag.old} (100%) rename Server/Root/etc/nginx/sites-available/{epic.octt.eu.org.conf => epic.octt.eu.org.conf.old} (100%) rename Server/Root/etc/nginx/sites-available/{feeds => feeds.conf} (100%) rename Server/Root/etc/nginx/sites-available/{godo.octt.eu.org.conf => godo.octt.eu.org.conf.old} (100%) rename Server/Root/etc/nginx/sites-available/{librex => librex.conf} (100%) rename Server/Root/etc/nginx/sites-available/{miss.octt.eu.org.conf => miss.octt.eu.org.conf.old} (100%) rename Server/Root/etc/nginx/sites-available/{root => root.conf} (100%) diff --git a/Server/Repo.Update.sh b/Server/Repo.Update.sh index 60028a6..96449e6 100755 --- a/Server/Repo.Update.sh +++ b/Server/Repo.Update.sh @@ -3,7 +3,11 @@ cd "$( dirname "$( realpath "$0" )" )" cd ./Root cp -v /etc/diycron ./etc/diycron -# nginx was done manually -cp -v /Server/Scripts/Backup/*.sh ./Server/Scripts/Backup/ -cp -v /Server/Scripts/Backup/*.cfg ./Server/Scripts/Backup/ +cp -v \ + /etc/nginx/sites-available/*.conf /etc/nginx/sites-available/*.old \ + ./etc/nginx/sites-available/ + +cp -v \ + /Server/Scripts/Backup/*.sh /Server/Scripts/Backup/*.cfg \ + ./Server/Scripts/Backup/ diff --git a/Server/Root/Server/Scripts/Backup/BackupGlobals.cfg b/Server/Root/Server/Scripts/Backup/BackupGlobals.cfg index 1a5733a..d5d6be2 100644 --- a/Server/Root/Server/Scripts/Backup/BackupGlobals.cfg +++ b/Server/Root/Server/Scripts/Backup/BackupGlobals.cfg @@ -5,11 +5,13 @@ BackupsBase="/media/Disk/Backup" # ScriptDir="$( dirname "$( realpath "$0" )" )" # cd "$ScriptDir" -RunDate="$(date +%F)" +RunDate="$(date +%F)" # Current date in YYYY-MM-DD format cd "${BackupsBase}" . ./.BackupSecrects.sec +# Generate a good key for encrypting files, based on a primary secret key and a secondary string +# NOTE to self: Use this same function to get decryption key, plugging the YYYY-MM-DD date of the Git commit as $2 Hash2() { BaseKey="$1" SecStr="$2" diff --git a/Server/Root/Server/Scripts/Backup/CloudBackup.sh b/Server/Root/Server/Scripts/Backup/CloudBackup.sh index 702f522..c68a28c 100755 --- a/Server/Root/Server/Scripts/Backup/CloudBackup.sh +++ b/Server/Root/Server/Scripts/Backup/CloudBackup.sh @@ -14,14 +14,34 @@ GitPullPushPath() { cd "${BackPath}" } +BackPathCrypt() { + Folder="$1" + Key="$2" + Ext="$([ -z "$3" ] && echo ".tar.xz" || echo "$3")" + cp "../${Folder}/Latest${Ext}" "./${Folder}${Ext}" && \ + ccencryptNow "./${Folder}${Ext}" "${Key}" +} + cd ./Server-Backup-Limited -Item="Invidious-User" && cp "../${Item}/Latest.7z" "./${Item}.7z" && ccencryptNow "./${Item}.7z" "${BackupKey_Git_Invidious}" -Item="wallabag-data" && cp "../${Item}/Latest.tar.xz" "./${Item}.tar.xz" && ccencryptNow "./${Item}.tar.xz" "${BackupKey_Git_wallabag}" -Item="FreshRSS-data" && cp "../${Item}/Latest.tar.xz" "./${Item}.tar.xz" && ccencryptNow "./${Item}.tar.xz" "${BackupKey_Git_FreshRSS}" +BackPathCrypt "Invidious-User" "${BackupKey_Git_Invidious}" ".7z" +#BackPathCrypt "wallabag-data" "${BackupKey_Git_wallabag}" +BackPathCrypt "FreshRSS-data" "${BackupKey_Git_FreshRSS}" +#BackPathCrypt "shiori-data" "${BackupKey_Git_Shiori}" +#Item="Invidious-User" && cp "../${Item}/Latest.7z" "./${Item}.7z" && ccencryptNow "./${Item}.7z" "${BackupKey_Git_Invidious}" +#Item="wallabag-data" && cp "../${Item}/Latest.tar.xz" "./${Item}.tar.xz" && ccencryptNow "./${Item}.tar.xz" "${BackupKey_Git_wallabag}" +#Item="FreshRSS-data" && cp "../${Item}/Latest.tar.xz" "./${Item}.tar.xz" && ccencryptNow "./${Item}.tar.xz" "${BackupKey_Git_FreshRSS}" +#Item="shiori-data" && cp "../${Item}/Latest.tar.xz" "./${Item}.tar.xz" && ccencryptNow "./${Item}.tar.xz" "${BackupKey_Git_Shiori}" +GitPush +cd .. + +cd ./Articles-Backup-Private +rm -rf ./shiori-data +cp -r "../shiori-data/Latest.d" "./shiori-data" GitPush cd .. GitPullPushPath "/Cloud/Repos/Personal-Game-Saves" +#GitPullPushPath "/media/Disk/Configs" #CloudDir="/home/octo/Cloud" #cd "$CloudDir" diff --git a/Server/Root/Server/Scripts/Backup/ServerDataBackup.sh b/Server/Root/Server/Scripts/Backup/ServerDataBackup.sh index 52115e1..14ba317 100755 --- a/Server/Root/Server/Scripts/Backup/ServerDataBackup.sh +++ b/Server/Root/Server/Scripts/Backup/ServerDataBackup.sh @@ -4,13 +4,18 @@ . "$(dirname "$(realpath "$0")")/BackupGlobals.cfg" SimpleBackup() { + # $1: Folder + # $2: Optional prefix in /Server path mkdir -p "./$1" - tar cvJSf "./$1/${RunDate}.tar.xz" "/Server/$1" && \ + tar cvJSf "./$1/${RunDate}.tar.xz" "/Server/$2/$1" && \ cp "./$1/${RunDate}.tar.xz" "./$1/Latest.tar.xz" + rm -rf "./$1/Latest.d" + cp -r "/Server/$2/$1" "./$1/Latest.d" } -SimpleBackup "wallabag-data" +#SimpleBackup "wallabag-data" SimpleBackup "FreshRSS-data" +SimpleBackup "shiori-data" "Shiori" # GoToSocial #Name="GoToSocial" diff --git a/Server/Root/etc/diycron b/Server/Root/etc/diycron index 0fd8443..68dbc6c 100755 --- a/Server/Root/etc/diycron +++ b/Server/Root/etc/diycron @@ -24,7 +24,7 @@ do # Declaration of all cronjobs like they are normal shell commands, made easy thanks to integrated functions. # Daily checking for if the script is working - Ifn $Job1 && If $(IsDayMin $(hm2s 5 30)) && date > /tmp/CronTest.log && Job1=1 + Ifn $Job1 && If $(IsDayMin $(hm2s 5 30)) && date > /tmp/CronTest.log && journalctl -u diycron >> /tmp/CronTest.log && Job1=1 # RSS to Misskey at HH:15 and HH:45 # If $(IsHourMin 15) || If $(IsHourMin 45) && sudo -u pi /Server/Bots/RSSToMisskey/Run.RSSToMisskey # Downsync updated content to the sitoctt and push diff --git a/Server/Root/etc/nginx/sites-available/analytics.conf b/Server/Root/etc/nginx/sites-available/analytics.conf new file mode 100644 index 0000000..a5b6ca8 --- /dev/null +++ b/Server/Root/etc/nginx/sites-available/analytics.conf @@ -0,0 +1,18 @@ +server { + listen 443 ssl; + server_name private-analytics-not-for-public-use.octt.eu.org; + ssl_certificate /etc/letsencrypt/live/private-analytics-not-for-public-use.octt.eu.org/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/private-analytics-not-for-public-use.octt.eu.org/privkey.pem; + ssl_prefer_server_ciphers on; + location /octtkb/ { + #resolver 9.9.9.9; + proxy_http_version 1.1; + proxy_pass https://octtkb.goatcounter.com/; + proxy_set_header Host "octtkb.goatcounter.com"; + 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"; + } +} diff --git a/Server/Root/etc/nginx/sites-available/articles.conf b/Server/Root/etc/nginx/sites-available/articles.conf new file mode 100644 index 0000000..7d61552 --- /dev/null +++ b/Server/Root/etc/nginx/sites-available/articles.conf @@ -0,0 +1,33 @@ +server { + listen 443 ssl; + server_name articles.octt.eu.org; + ssl_certificate /etc/letsencrypt/live/articles.octt.eu.org/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/articles.octt.eu.org/privkey.pem; + ssl_prefer_server_ciphers on; + location / { + proxy_http_version 1.1; + proxy_pass http://localhost:8076; + 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"; + } +} + +server { + listen 443 ssl; + server_name ShioriFeed.octt.eu.org; + ssl_certificate /etc/letsencrypt/live/shiorifeed.octt.eu.org/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/shiorifeed.octt.eu.org/privkey.pem; + ssl_prefer_server_ciphers on; + location / { + proxy_http_version 1.1; + proxy_pass http://localhost:8176; + 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"; + } +} diff --git a/Server/Root/etc/nginx/sites-available/articles b/Server/Root/etc/nginx/sites-available/articles.wallabag.old similarity index 100% rename from Server/Root/etc/nginx/sites-available/articles rename to Server/Root/etc/nginx/sites-available/articles.wallabag.old diff --git a/Server/Root/etc/nginx/sites-available/epic.octt.eu.org.conf b/Server/Root/etc/nginx/sites-available/epic.octt.eu.org.conf.old similarity index 100% rename from Server/Root/etc/nginx/sites-available/epic.octt.eu.org.conf rename to Server/Root/etc/nginx/sites-available/epic.octt.eu.org.conf.old diff --git a/Server/Root/etc/nginx/sites-available/feeds b/Server/Root/etc/nginx/sites-available/feeds.conf similarity index 100% rename from Server/Root/etc/nginx/sites-available/feeds rename to Server/Root/etc/nginx/sites-available/feeds.conf diff --git a/Server/Root/etc/nginx/sites-available/godo.octt.eu.org.conf b/Server/Root/etc/nginx/sites-available/godo.octt.eu.org.conf.old similarity index 100% rename from Server/Root/etc/nginx/sites-available/godo.octt.eu.org.conf rename to Server/Root/etc/nginx/sites-available/godo.octt.eu.org.conf.old diff --git a/Server/Root/etc/nginx/sites-available/librex b/Server/Root/etc/nginx/sites-available/librex.conf similarity index 100% rename from Server/Root/etc/nginx/sites-available/librex rename to Server/Root/etc/nginx/sites-available/librex.conf diff --git a/Server/Root/etc/nginx/sites-available/miss.octt.eu.org.conf b/Server/Root/etc/nginx/sites-available/miss.octt.eu.org.conf.old similarity index 100% rename from Server/Root/etc/nginx/sites-available/miss.octt.eu.org.conf rename to Server/Root/etc/nginx/sites-available/miss.octt.eu.org.conf.old diff --git a/Server/Root/etc/nginx/sites-available/root b/Server/Root/etc/nginx/sites-available/root.conf similarity index 100% rename from Server/Root/etc/nginx/sites-available/root rename to Server/Root/etc/nginx/sites-available/root.conf