Como actualizar tu nodo PTTLink

From WLPS Wiki
Jump to navigation Jump to search

Asegúrate que nodelist se está descargando

Antes de que tu nodo se conecte, es necesario que se tenga una lista de nodos disponible. Los siguientes archivos lo harán de forma automática.

Agrega los archivos faltantes NodeUpdate.sh y NodeNameUpdate.sh

Crea el siguiente archivo /usr/local/bin/NodeUpdate.sh usando el siguiente comando:

sudo nano /usr/local/bin/NodeUpdate.sh

Copia el siguiente código en el archivo:

#!/bin/bash
#
# A cron job script for downloading the extnodes file with error reporting
# 
#
# This is intended to be run from cron every 5 min
#  Copyright 2018 Bryan Fields
#  Licensed under the GNU GPLv2

URL="http://register.pttlink.org/cgi-bin/gennodes.php"
FILEPATH=/var/lib/asterisk

#sleep for a random time of 0-300 seconds
#sleep $[( $RANDOM % 299 )  + 1 ]s


# use curl in silent and compressed mode, connect timeout of 5 and
# -f for fail with an error code of 22 on server errors
#-m 20 is a max time for the whole process of 20 seconds
curl -s --compressed --connect-timeout 5 -f -m 20 -o /tmp/rpt_extnodes-temp $URL
#curl --connect-timeout 5 -f -m 20 -o /tmp/rpt_extnodes-temp $URL
exitcode=$?
if [ "$exitcode" = "0" ]; then
    grep -q extnodes /tmp/rpt_extnodes-temp
        if [ $? -eq "0" ] ;then
            chmod 700 /tmp/rpt_extnodes-temp
            cp /tmp/rpt_extnodes-temp $FILEPATH/rpt_extnodes-temp
            mv -f $FILEPATH/rpt_extnodes-temp $FILEPATH/rpt_extnodes
            whenandwhere=`grep "Generated at" /tmp/rpt_extnodes-temp |cut -c2-100`
            #don't print out on good run
	    #echo "NodeUpdate installed a new nodes list $whenandwhere"
	    logger -i "NodeUpdate installed a new nodes list $whenandwhere"
        else
            #echo "NodeUpdate failed to parse node list; node list not updated"
	    logger -i "NodeUpdate failed to parse node list; node list not updated"
            exit 1
        fi

else
    #echo "NodeUpdate could not get nodes list from server"
    logger -i "NodeUpdate could not get nodes list from server"
    exit 1
fi
exit 0

Crea el siguiente archivo /usr/local/bin/NodeNameUpdate.sh usando el siguiente comando:

sudo nano /usr/local/bin/NodeNameUpdate.sh

Copia el siguiente código en el archivo:

#!/bin/bash
#
# A cron job script for downloading custom node announcements with error reporting 
#
# This is intended to be run from cron every 8 hours and will randomly insert a delay from 0-8 hours
#
#  Copyright 2018 Bryan Fields
#  Licensed under the GNU GPLv2

URL="rsync://rsync.pttlink.org/connect-messages"
FILEPATH="/var/lib/asterisk/sounds/rpt/nodenames"

#sleep for a random time of 0-28800 seconds (8 hours)
sleep $[ ( $RANDOM % 28799 )  + 1 ]s

#assign the filesUpdated var with the number of files changed by rsync.  This is nasty, but it works.

filesUpdated=`rsync -a --stats $URL $FILEPATH |grep "Number of regular files transferred" | cut -c 38-50`
exitcode=$?
if [ "$exitcode" = "0" ]; then
    if [ "$filesUpdated" = "0" ]; then
	echo "NodeNameUpdate run with no updates"
	logger -i "NodeNameUpdate run with no updates"
    elif [ "$filesUpdated" > "0" ]; then
	echo "NodeNameUpdate updated $filesUpdated nodenames"
        logger -i "NodeNameUpdate updated $filesUpdated nodenames" 
    fi
else
    echo "NodeNameUpdate failed"
    logger -i "NodeUpdate failed"
    exit 1
fi
exit 0

Agrega unas líneas a crontab editándolo con el siguiente comando con:

sudo nano /etc/crontab

Al final del archivo agrega estas dos líneas:

0 0,8,16 * * * 	root /usr/local/bin/NodeNameUpdate.sh > /dev/null 2>&1
*/5 * * * * 	root /usr/local/bin/NodeUpdate.sh > /dev/null 2>&1

Configuración de actualizaciones de PTTLink

Ejecuta las siguientes líneas para actualizar la dirección de los servidores PTTLink.

sudo sed -i 's/allstarlink.org/pttlink.org/g' /usr/local/bin/rc.updatenodelist
sudo sed -i 's/allstarlink.org/pttlink.org/g' /usr/local/bin/NodeNameUpdate.sh
sudo sed -i 's/allstarlink.org/pttlink.org/g' /usr/local/bin/NodeUpdate.sh
sudo sed -i 's/allstarlink.org/pttlink.org/g' /etc/asterisk/rpt.conf
sudo sed -i 's/allstarlink.org/pttlink.org/g' /etc/asterisk/iax.conf
sudo sed -i 's/allstarlink.org/pttlink.org/g' /etc/asterisk/extensions.conf
sudo service asterisk restart

Reinicia tu nodo.

sudo reboot 


Con esto tu nodo deberá estar operando.


Para más información sobre el cómo y por qué se creó PTTLink puedes leer la Carta a la comunidad publicada el 3 de enero de 2021.