Move to using trackers within zeronet.conf

This commit is contained in:
Bob Mottram 2015-09-11 16:09:27 +01:00
parent 52d9993181
commit f138a2eb96
1 changed files with 18 additions and 7 deletions

View File

@ -45,11 +45,11 @@ if [ ! -d $ZERONET_INSTALL ]; then
fi
fi
BOOTSTRAP_FILE=$ZERONET_INSTALL/bootstrap
BLOGS_FILE=$ZERONET_INSTALL/freedombone-blogs
FORUM_FILE=$ZERONET_INSTALL/freedombone-fora
TOX_USERS_FILE=$ZERONET_INSTALL/freedombone-tox-users
ZERONET_INDEX=/home/$MY_USERNAME/mesh.html
ZERONET_CONFIG=$ZERONET_INSTALL/zeronet.conf
function create_index {
if [ -f $ZERONET_INDEX ]; then
@ -119,19 +119,24 @@ if [ ! -f $TEMPFILE ]; then
exit 1
fi
if [ -f $BOOTSTRAP_FILE.new ]; then
rm -f $BOOTSTRAP_FILE.new
if [ -f $ZERONET_CONFIG.new ]; then
rm -f $ZERONET_CONFIG.new
fi
echo '[global]' > $ZERONET_CONFIG.new
echo 'trackers =' >> $ZERONET_CONFIG.new
state=0
address=""
peer=""
tracker_ctr=0
while IFS='' read -r line || [[ -n "$line" ]]; do
if [ ${state} -eq "2" ]; then
if [[ $line == *"address ="* ]]; then
address=$(echo $line | awk -F '[' '{print $2}' | awk -F ']' '{print $1}')
echo "http $peer:$TRACKER_PORT/announce None" >> $BOOTSTRAP_FILE.new
echo " http://$peer:$TRACKER_PORT/announce" >> $ZERONET_CONFIG.new
state=0
tracker_ctr=$((tracker_ctr + 1))
fi
fi
if [ ${state} -eq "1" ]; then
@ -238,10 +243,16 @@ echo '<ol>' >> $TOX_USERS_FILE.new
rm -f $TEMPFILE_BASE
rm -f $TEMPFILE
cp -f $BOOTSTRAP_FILE.new $BOOTSTRAP_FILE
rm -f $BOOTSTRAP_FILE.new
if [ ${tracker_ctr} -gt "0" ]; then
cp -f $ZERONET_CONFIG.new $ZERONET_CONFIG
else
if [ -f $ZERONET_CONFIG ]; then
rm -f $ZERONET_CONFIG
fi
fi
rm -f $ZERONET_CONFIG.new
if [ -d $ZERONET_USER_HOME ]; then
sudo chown zeronet:zeronet $BOOTSTRAP_FILE
sudo chown zeronet:zeronet $ZERONET_CONFIG
fi
# make some html headers and footers