From bf38d6cf388b687758f11c998f8eeab25fd21b25 Mon Sep 17 00:00:00 2001 From: gumi Date: Tue, 16 Jan 2018 11:45:39 -0500 Subject: add update checker to make-updates --- client/make-music.sh | 37 +++++++++++++++++++++++++++++++++---- client/make-updates | 28 +++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/client/make-music.sh b/client/make-music.sh index cca2441..5b914cf 100644 --- a/client/make-music.sh +++ b/client/make-music.sh @@ -6,11 +6,31 @@ dir=`pwd` output=~/www/updates cdata=../../client-data +http_root="http://updates.themanaworld.org/updates" LDLIBS=-lz prefix=/usr/local CC=${CC:=gcc} +function check_update() { + test_command=` \ + curl -sL \ + -w "%{http_code}\n" \ + "$1" \ + -o /dev/null \ + --connect-timeout 3 \ + --max-time 5` + + if [ ${test_command} == "200" ] ; + then + echo -e "hit $1 (\e[92m$test_command OK\e[0m)"; + else + echo -e "\e[31m!!FAILED!!\e[0m $1 ($test_command)"; + exit 1; + fi +} + + echo "======= Legacy-music =======" echo ">> Building adler32..." @@ -46,9 +66,18 @@ cp xml_header.txt resources.xml cat xml_footer.txt >>resources.xml echo ">> Moving stuff around..." +cp -v Legacy-music.zip $output/ +cp -v resources.xml $output/ + +echo ">> Giving read permissions..." +pushd $output chmod a+r Legacy-music.zip -cp Legacy-music.zip $output/ chmod a+r resources.xml -cp resources.xml $output/ -popd -popd + +echo ">> Checking updates..." +check_update "$http_root/Legacy-music.zip" +check_update "$http_root/resources.xml" + +popd # $dir/files +popd # $cdata +popd # tools/client diff --git a/client/make-updates b/client/make-updates index 0f6ea67..0cab82f 100755 --- a/client/make-updates +++ b/client/make-updates @@ -1,16 +1,36 @@ #!/usr/bin/env bash # Copyright (C) 2011-2012 Evol Online -# Author: Andrei Karas (4144) +# Author: Andrei Karas (4144), gumi dir=`pwd` output=~/www/updates cdata=../../client-data +http_root="http://updates.themanaworld.org/updates" LDLIBS=-lz prefix=/usr/local CC=${CC:=gcc} +function check_update() { + test_command=` \ + curl -sL \ + -w "%{http_code}\n" \ + "$1" \ + -o /dev/null \ + --connect-timeout 3 \ + --max-time 5` + + if [ ${test_command} == "200" ] ; + then + echo -e "hit $1 (\e[92m$test_command OK\e[0m)"; + else + echo -e "\e[31m!!FAILED!!\e[0m $1 ($test_command)"; + exit 1; + fi +} + + echo "======= Legacy =======" echo ">> Building adler32..." @@ -62,6 +82,12 @@ chmod a+r Legacy.zip chmod a+r resources2.txt chmod a+r resources.xml +echo ">> Checking updates..." +check_update "$http_root/Legacy.zip" +check_update "$http_root/resources.xml" +check_update "$http_root/resources2.txt" +check_update "$http_root/news.php" + popd # $dir/files popd # $cdata popd # tools/client -- cgit v1.2.3-60-g2f50