Files
StreamingCommunity/make_index.sh

109 lines
2.5 KiB
Bash
Raw Normal View History

2024-08-30 10:36:22 +02:00
#!/bin/bash
2025-01-13 18:50:02 +01:00
# SETTARE QUESTA VARIABILE CON IL PERCORSO GIUSTO:
2025-01-19 00:58:54 +01:00
# Es: PWD_SC="/var/www/html/streamingcommunity"
2025-01-13 20:03:55 +01:00
PWD_SC="$PWD"
2025-01-11 16:01:17 +01:00
2025-01-19 00:58:54 +01:00
# Se il link รจ cambiato, allora aggiorna il file "attuale.txt"
2025-01-13 18:50:02 +01:00
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+)?')
2025-01-11 16:01:17 +01:00
if [ "$attuale" != "$nuovo" ]; then
attuale="$nuovo"
2025-01-13 18:32:09 +01:00
echo "$attuale" > $PWD_SC/attuale.txt
2025-01-11 16:01:17 +01:00
fi
2025-01-13 18:50:02 +01:00
# Formatta il link e lo stampa
2025-01-13 18:32:09 +01:00
formatted="https://$(cat "$PWD_SC/attuale.txt")"
2025-01-19 00:58:54 +01:00
echo "$formatted"
2025-01-13 18:50:02 +01:00
# Crea pagina "index.html"
2025-01-13 18:32:09 +01:00
cat <<- _EOF > $PWD_SC/index.html
2024-08-30 10:36:22 +02:00
<!DOCTYPE html>
<html lang="en">
2025-01-13 18:32:09 +01:00
2024-08-30 10:36:22 +02:00
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>StreamingCommunity Link Giusto</title>
<style>
body {
box-sizing: border-box;
margin: 0;
padding: 4wh;
border: 10px solid #ccc;
2025-01-14 00:39:21 +01:00
background-color: #f4f4f4;
2024-08-30 10:36:22 +02:00
}
div {
width: 200wj;
height: 200wj;
2025-01-14 00:39:21 +01:00
background-color: #fbfbfb;
2024-08-30 10:36:22 +02:00
padding: 20px;
}
img {
max-width: 90%;
padding: 20px;
}
a {
width: 300wj;
height: 200wj;
}
h1 {
font-size: 36px;
/* Default size */
}
@media (max-width: 480px) {
h1 {
2024-08-30 14:19:39 +02:00
font-size: 17px;
2024-08-30 10:36:22 +02:00
/* Size mobile phones */
}
}
@media (max-width: 480px) {
h3 {
font-size: 15px;
/* Size mobile phones */
}
}
</style>
</head>
<body>
<center>
<br><br>
<div class="link">
2025-01-13 18:50:02 +01:00
<h3> Link aggiornato per Streaming Community: </h3>
<h1> <a href=$formatted>$formatted </a> </h1>
<h3> (cambia circa una volta al mese) </h3>
2024-08-30 10:36:22 +02:00
</div>
<br><br>
2024-11-03 00:08:20 +01:00
<a href=$formatted target="_blank">
2024-08-30 10:36:22 +02:00
<img style="display:block; margin-left: auto; margin-right: auto" src="./splash.gif">
2024-11-03 00:02:09 +01:00
</a>
2024-08-30 10:36:22 +02:00
<br><br>
<div class="link">
2025-01-13 18:50:02 +01:00
<h3> Link aggiornato per Streaming Community: </h3>
2025-01-13 17:53:14 +01:00
<h1> <a href=$formatted> $formatted </a> </h1>
2025-01-13 18:50:02 +01:00
<h3> (cambia circa una volta al mese) </h3>
2024-08-30 10:36:22 +02:00
</div>
2024-11-03 00:02:09 +01:00
<br><br>
2024-08-30 10:36:22 +02:00
</center>
</body>
</html>
_EOF
2025-01-13 20:22:08 +01:00
# Da i permessi alla cartella
2025-01-13 18:50:02 +01:00
sudo chown -R www-data:www-data $PWD_SC ; sudo chmod -R 755 $PWD_SC