diff --git a/README.md b/README.md index 4198459..48d7d24 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,14 @@ ``` # Per generare la pagina index.html contente il link giusto (richiede "attuale.txt"): +# 0. Setta la variabile "PWD_SC" in testa allo script o lasciala con "PWD" per provarla in locale + # 1. Avvia lo script manualmente ./update_link.sh # 2. o mettilo in cron 0 0 * * * /path/to/update_link.sh - #Se vuoi pubblicarla sul web, dai i permessi alla cartella contenente lo script: sudo chown -R www-data:www-data ; sudo chmod -R 755 ``` diff --git a/script_link.sh b/script_link.sh index 3796ea8..accbec2 100755 --- a/script_link.sh +++ b/script_link.sh @@ -1,9 +1,11 @@ #!/bin/bash -attuale=$(<$PWD/attuale.txt) +PWD_SC="$PWD" + +attuale=$(<$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 attuale="$nuovo" - echo "$attuale" > $PWD/attuale.txt + echo "$attuale" > $PWD_SC/attuale.txt fi echo -e "\n $attuale\n" diff --git a/update_link.sh b/update_link.sh index b8adb18..cab337e 100755 --- a/update_link.sh +++ b/update_link.sh @@ -1,20 +1,21 @@ #!/bin/bash -attuale=$( /var/www/html/scommunity/attuale.txt + echo "$attuale" > $PWD_SC/attuale.txt fi -formatted="https://$( /var/www/html/scommunity/index.html +cat <<- _EOF > $PWD_SC/index.html + @@ -98,4 +99,4 @@ cat <<- _EOF > /var/www/html/scommunity/index.html _EOF -sudo chown -R www-data:www-data /var/www/html/scommunity ; sudo chmod -R 755 /var/www/html/scommunity \ No newline at end of file +sudo chown -R www-data:www-data /$PWD_SC ; sudo chmod -R 755 $PWD_SC \ No newline at end of file