This commit is contained in:
2025-01-13 18:50:02 +01:00
parent 42b93edc5c
commit b75a49e26c

View File

@@ -1,16 +1,21 @@
#!/bin/bash #!/bin/bash
PWD_SC="/var/www/scommunity" # SETTARE QUESTA VARIABILE CON IL PERCORSO GIUSTO:
attuale="$(cat "$PWD_SC/attuale.txt")" PWD_SC="/var/www/html/StreamingCommunity"
nuovo=$(curl -L $attuale | sed -n 's/.*\(https:\/\/cdn\.streamingcommunity\.[^ ]*images[^ ]*\).*/\1/p' | grep -oP 'streamingcommunity\.\w+(\.\w+)?')
# Se il link è stato aggiornato, aggiorna il file "attuale.txt"
attuale="$(cat "$PWD_SC/attuale.txt")"
nuovo=$(curl --no-progress-meter -L $attuale | sed -n 's/.*\(https:\/\/cdn\.streamingcommunity\.[^ ]*images[^ ]*\).*/\1/p' | grep -oP 'streamingcommunity\.\w+(\.\w+)?')
if [ "$attuale" != "$nuovo" ]; then if [ "$attuale" != "$nuovo" ]; then
attuale="$nuovo" attuale="$nuovo"
echo "$attuale" > $PWD_SC/attuale.txt echo "$attuale" > $PWD_SC/attuale.txt
fi fi
# Formatta il link e lo stampa
formatted="https://$(cat "$PWD_SC/attuale.txt")" formatted="https://$(cat "$PWD_SC/attuale.txt")"
echo "$formatted" echo "$formatted" #per debug
# Crea pagina "index.html"
cat <<- _EOF > $PWD_SC/index.html cat <<- _EOF > $PWD_SC/index.html
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
@@ -72,9 +77,9 @@ cat <<- _EOF > $PWD_SC/index.html
<br><br> <br><br>
<div class="link"> <div class="link">
<h3>Link aggiornato per Streaming Community:</h3> <h3> Link aggiornato per Streaming Community: </h3>
<h1><a href=$formatted>$formatted</a></h1> <h1> <a href=$formatted>$formatted </a> </h1>
<h3>(cambia circa una volta al mese)</h3> <h3> (cambia circa una volta al mese) </h3>
</div> </div>
<br><br> <br><br>
@@ -86,9 +91,9 @@ cat <<- _EOF > $PWD_SC/index.html
<br><br> <br><br>
<div class="link"> <div class="link">
<h3>Link aggiornato per Streaming Community:</h3> <h3> Link aggiornato per Streaming Community: </h3>
<h1> <a href=$formatted> $formatted </a> </h1> <h1> <a href=$formatted> $formatted </a> </h1>
<h3>(cambia circa una volta al mese)</h3> <h3> (cambia circa una volta al mese) </h3>
</div> </div>
<br><br> <br><br>
@@ -99,4 +104,5 @@ cat <<- _EOF > $PWD_SC/index.html
</html> </html>
_EOF _EOF
sudo chown -R www-data:www-data /$PWD_SC ; sudo chmod -R 755 $PWD_SC # Da i permessi alla cartella di sc
sudo chown -R www-data:www-data $PWD_SC ; sudo chmod -R 755 $PWD_SC