@@ -9,63 +9,64 @@ local commandaction="Update"
99local function_selfname=" $( basename $( readlink -f " ${BASH_SOURCE[0]} " ) ) "
1010
1111fn_update_mta_dl (){
12- fn_fetch_file " http://linux.mtasa.com/dl/${numversion} /multitheftauto_linux_x64-${fullversion} .tar.gz" " ${tmpdir} " " multitheftauto_linux_x64-${fullversion} .tar.gz"
13- fn_dl_extract " ${tmpdir} " " multitheftauto_linux_x64-${fullversion} .tar.gz" " ${tmpdir} "
14- echo -e " copying to ${serverfiles} ...\c"
15- fn_script_log " Copying to ${serverfiles} "
16- cp -R " ${tmpdir} /multitheftauto_linux_x64-${fullversion} /" * " ${serverfiles} "
17- local exitcode=$?
18- if [ " ${exitcode} " == " 0" ]; then
19- fn_print_ok_eol_nl
20- else
21- fn_print_fail_eol_nl
22- fi
12+ fn_fetch_file " http://linux.mtasa.com/dl/${numversion} /multitheftauto_linux_x64-${fullversion} .tar.gz" " ${tmpdir} " " multitheftauto_linux_x64-${fullversion} .tar.gz"
13+ mkdir " ${tmpdir} /multitheftauto_linux_x64-${fullversion} "
14+ fn_dl_extract " ${tmpdir} " " multitheftauto_linux_x64-${fullversion} .tar.gz" " ${tmpdir} /multitheftauto_linux_x64-${fullversion} "
15+ echo -e " copying to ${filesdir} ...\c"
16+ fn_script_log " Copying to ${filesdir} "
17+ cp -R " ${tmpdir} /multitheftauto_linux_x64-${fullversion} /multitheftauto_linux_x64-${fullversion} /" * " ${filesdir} "
18+ local exitcode=$?
19+ if [ " ${exitcode} " == " 0" ]; then
20+ fn_print_ok_eol_nl
21+ else
22+ fn_print_fail_eol_nl
23+ fi
2324}
2425
2526fn_update_mta_currentbuild (){
26- # Gets current build info
27- # Checks if current build info is available. If it fails, then a server restart will be forced to generate logs.
28- if [ ! -f " ${consolelogdir} / ${servicename} -console .log" ]; then
29- fn_print_error " Checking for update: linux.mtasa.com"
30- sleep 1
31- fn_print_error_nl " Checking for update: linux.mtasa.com: No logs with server version found"
32- fn_script_log_error " Checking for update: linux.mtasa.com: No logs with server version found"
33- sleep 1
34- fn_print_info_nl " Checking for update: linux.mtasa.com: Forcing server restart"
35- fn_script_log_info " Checking for update: linux.mtasa.com: Forcing server restart"
36- sleep 1
37- exitbypass=1
38- command_stop.sh
39- exitbypass=1
40- command_start.sh
41- sleep 1
42- # Check again and exit on failure.
43- if [ ! -f " ${consolelogdir} / ${servicename} -console .log" ]; then
44- fn_print_fail_nl " Checking for update: linux.mtasa.com: Still No logs with server version found"
45- fn_script_log_fatal " Checking for update: linux.mtasa.com: Still No logs with server version found"
46- core_exit.sh
47- fi
48- fi
27+ # Gets current build info
28+ # Checks if current build info is available. If it fails, then a server restart will be forced to generate logs.
29+ if [ ! -f " ${gamelogdir} " /server .log ]; then
30+ fn_print_error " Checking for update: linux.mtasa.com"
31+ sleep 1
32+ fn_print_error_nl " Checking for update: linux.mtasa.com: No logs with server version found"
33+ fn_script_log_error " Checking for update: linux.mtasa.com: No logs with server version found"
34+ sleep 1
35+ fn_print_info_nl " Checking for update: linux.mtasa.com: Forcing server restart"
36+ fn_script_log_info " Checking for update: linux.mtasa.com: Forcing server restart"
37+ sleep 1
38+ exitbypass=1
39+ command_stop.sh
40+ exitbypass=1
41+ command_start.sh
42+ sleep 1
43+ # Check again and exit on failure.
44+ if [ ! -f " ${gamelogdir} " /server .log ]; then
45+ fn_print_fail_nl " Checking for update: linux.mtasa.com: Still No logs with server version found"
46+ fn_script_log_fatal " Checking for update: linux.mtasa.com: Still No logs with server version found"
47+ core_exit.sh
48+ fi
49+ fi
4950
50- # Get current build from logs
51- currentbuild=$( awk -F " = Multi Theft Auto: San Andreas v" ' { print $2} ' " ${consolelogdir} " / " ${servicename} " -console.log | awk ' {print $1} ' )
52- if [ -z " ${currentbuild} " ]; then
53- fn_print_error_nl " Checking for update: linux.mtasa.com: Current build version not found"
54- fn_script_log_error " Checking for update: linux.mtasa.com: Current build version not found"
55- sleep 1
56- fn_print_info_nl " Checking for update: linux.mtasa.com: Forcing server restart"
57- fn_script_log_info " Checking for update: linux.mtasa.com: Forcing server restart"
58- exitbypass=1
59- command_stop.sh
60- exitbypass=1
61- command_start.sh
62- currentbuild=$( awk -F " = Multi Theft Auto: San Andreas v" ' { print $2} ' " ${consolelogdir} " / " ${servicename} " -console.log | awk ' {print $1} ' )
63- if [ -z " ${currentbuild} " ]; then
64- fn_print_fail_nl " Checking for update: linux.mtasa.com: Current build version still not found"
65- fn_script_log_fatal " Checking for update: linux.mtasa.com: Current build version still not found"
66- core_exit.sh
67- fi
68- fi
51+ # Get current build from logs
52+ currentbuild=$( cat " ${gamelogdir} " /server.log | grep " = Multi Theft Auto: San Andreas v" | awk ' { print $7 } ' | sed -r ' s/^.{1}// ' | tail -1 )
53+ if [ -z " ${currentbuild} " ]; then
54+ fn_print_error_nl " Checking for update: linux.mtasa.com: Current build version not found"
55+ fn_script_log_error " Checking for update: linux.mtasa.com: Current build version not found"
56+ sleep 1
57+ fn_print_info_nl " Checking for update: linux.mtasa.com: Forcing server restart"
58+ fn_script_log_info " Checking for update: linux.mtasa.com: Forcing server restart"
59+ exitbypass=1
60+ command_stop.sh
61+ exitbypass=1
62+ command_start.sh
63+ currentbuild=$( cat " ${gamelogdir} " /server.log | grep " = Multi Theft Auto: San Andreas v" | awk ' { print $7 } ' | sed -r ' s/^.{1}// ' | tail -1 )
64+ if [ -z " ${currentbuild} " ]; then
65+ fn_print_fail_nl " Checking for update: linux.mtasa.com: Current build version still not found"
66+ fn_script_log_fatal " Checking for update: linux.mtasa.com: Current build version still not found"
67+ core_exit.sh
68+ fi
69+ fi
6970}
7071
7172fn_mta_get_availablebuild (){
@@ -79,74 +80,75 @@ fn_mta_get_availablebuild(){
7980}
8081
8182fn_update_mta_compare (){
82- # Removes dots so if can compare version numbers
83- currentbuilddigit=$( echo " ${currentbuild} " | tr -cd ' [:digit:]' )
84- if [ " ${currentbuilddigit} " -ne " ${numversion} " ]|| [ " ${forceupdate} " == " 1" ]; then
85- if [ " ${forceupdate} " == " 1" ]; then
86- # forceupdate bypasses checks, useful for small build changes
87- mta_update_string=" forced"
88- else
89- mta_update_string=" available"
90- fi
91- echo -e " \n"
92- echo -e " Update ${mta_update_string} :"
93- sleep 1
94- echo -e " Current build: ${red}${currentbuild} ${default} "
95- echo -e " Available build: ${green}${fullversion} ${default} "
96- echo -e " "
97- sleep 1
98- echo " "
99- echo -en " Applying update.\r"
100- sleep 1
101- echo -en " Applying update..\r"
102- sleep 1
103- echo -en " Applying update...\r"
104- sleep 1
105- echo -en " \n"
106- fn_script_log " Update ${mta_update_string} "
107- fn_script_log " Current build: ${currentbuild} "
108- fn_script_log " Available build: ${fullversion} "
109- fn_script_log " ${currentbuild} > ${fullversion} "
83+ # Removes dots so if can compare version numbers
84+ currentbuilddigit=$( echo " ${currentbuild} " | tr -cd ' [:digit:]' )
85+ if [ " ${currentbuilddigit} " -ne " ${numversion} " ]|| [ " ${forceupdate} " == " 1" ]; then
86+ if [ " ${forceupdate} " == " 1" ]; then
87+ # forceupdate bypasses checks, useful for small build changes
88+ mta_update_string=" forced"
89+ else
90+ mta_update_string=" available"
91+ fi
92+ echo -e " \n"
93+ echo -e " Update ${mta_update_string} :"
94+ sleep 1
95+ echo -e " Current build: ${red}${currentbuild} ${default} "
96+ echo -e " Available build: ${green}${fullversion} ${default} "
97+ echo -e " "
98+ sleep 1
99+ echo " "
100+ echo -en " Applying update.\r"
101+ sleep 1
102+ echo -en " Applying update..\r"
103+ sleep 1
104+ echo -en " Applying update...\r"
105+ sleep 1
106+ echo -en " \n"
107+ fn_script_log " Update ${mta_update_string} "
108+ fn_script_log " Current build: ${currentbuild} "
109+ fn_script_log " Available build: ${fullversion} "
110+ fn_script_log " ${currentbuild} > ${fullversion} "
110111
111- unset updateonstart
112+ unset updateonstart
112113
113- check_status.sh
114- if [ " ${status} " == " 0" ]; then
115- fn_update_mta_dl
116- exitbypass=1
117- command_start.sh
118- exitbypass=1
119- command_stop.sh
120- else
121- exitbypass=1
122- command_stop.sh
123- fn_update_mta_dl
124- exitbypass=1
125- command_start.sh
126- fi
127- alert=" update"
128- alert.sh
129- else
130- echo -e " \n"
131- echo -e " No update available:"
132- echo -e " Current version: ${green}${currentbuild}${default} "
133- echo -e " Available version: ${green}${fullversion}${default} "
134- echo -e " "
135- fn_print_ok_nl " No update available"
136- fn_script_log_info " Current build: ${currentbuild} "
137- fn_script_log_info " Available build: ${fullversion} "
138- fi
114+ check_status.sh
115+ if [ " ${status} " == " 0" ]; then
116+ fn_update_mta_dl
117+ exitbypass=1
118+ command_start.sh
119+ exitbypass=1
120+ command_stop.sh
121+ else
122+ exitbypass=1
123+ command_stop.sh
124+ fn_update_mta_dl
125+ exitbypass=1
126+ command_start.sh
127+ fi
128+ alert=" update"
129+ alert.sh
130+ else
131+ echo -e " \n"
132+ echo -e " No update available:"
133+ echo -e " Current version: ${green}${currentbuild}${default} "
134+ echo -e " Available version: ${green}${fullversion}${default} "
135+ echo -e " "
136+ fn_print_ok_nl " No update available"
137+ fn_script_log_info " Current build: ${currentbuild} "
138+ fn_script_log_info " Available build: ${fullversion} "
139+ fi
139140}
140141
142+
141143if [ " ${installer} " == " 1" ]; then
142- fn_mta_get_availablebuild
143- fn_update_mta_dl
144+ fn_mta_get_availablebuild
145+ fn_update_mta_dl
144146else
145- # Checks for server update from linux.mtasa.com using the github repo.
146- fn_print_dots " Checking for update: linux.mtasa.com"
147- fn_script_log_info " Checking for update: linux.mtasa.com"
148- sleep 1
149- fn_update_mta_currentbuild
150- fn_mta_get_availablebuild
151- fn_update_mta_compare
147+ # Checks for server update from linux.mtasa.com using the github repo.
148+ fn_print_dots " Checking for update: linux.mtasa.com"
149+ fn_script_log_info " Checking for update: linux.mtasa.com"
150+ sleep 1
151+ fn_update_mta_currentbuild
152+ fn_mta_get_availablebuild
153+ fn_update_mta_compare
152154fi
0 commit comments