AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [Bash] Autoupdate the AMXX to the latest version [1.9 / 1.10] (https://forums.alliedmods.net/showthread.php?t=325181)

Relaxing 06-11-2020 05:27

[Bash] Autoupdate the AMXX to the latest version [1.9 / 1.10]
 
I've modified compile.sh and created update.sh to simplify the process of compiling plugins and updating AMXX on unix based operating systems.
More information and examples shown below.

compile.sh >
  • Compile single or multiple files
  • Compile all source files
  • Check compiler version

- Compile single or multiple files
Single file: ./compile.sh admin.sma
Multiple files: ./compile.sh admin.sma adminchat.sma admincmd.sma

- Compile all source files
./compile.sh
All compiled plugins are located at addons/amxmodx/scripting/compiled

- Display help menu
Code:

./compile.sh --help

  Usage:
--help    (-h) : This menu
--version (-v) : AMX MOD X Compiler version

To compile all source files in the directory
  execute the script without any parameters
To compile specific or multiple source files
  execute the script with parameters set as source files' name
  e.g ./compile.sh admin.sma admincmd.sma adminchat.sma

- Check compiler version
Code:

./compile.sh --version

AMX Mod X Compiler 1.9.0.5270
Copyright (c) 1997-2006 ITB CompuPhase
Copyright (c) 2004-2013 AMX Mod X Team

update.sh >
  • Get latest version of AMX MOD X
  • Update game files to either 1.9 or 1.10 based on your choice
  • Autoupdate the game files
  • Setup the autoupdater
  • File backup
  • Update specific files for configs folder, default: hamdata.ini (version 1.9 only)

- Display help menu
Code:

./update.sh --help

  Usage:
--help    (-h) : This menu
--latest  (-l) : Latest AMX MOD X version
--update  (-u) : Update files
--auto    (-a) : Autoupdates AMXX
--setup  (-s) : Set up autoupdater

- Check latest version of AMX MOD X
Code:

./update.sh --latest

Latest AMX MOD X version
1.9 Build: 5270
1.10 Build: 5401

- Get latest version of AMX MOD X
Spoiler


- Setup the autoupdater
Run ./update.sh --setup and specify the game that the server is currently running.
To setup the autoupdate the current version of AMXX must be either 1.9 or 1.10, which you can see it at ./compile.sh --version
If you get an error saying amxxpc does not exists then the only option is to update the game files using ./update.sh --update
The autoupdater loads a hidden file (addons/amxmodx/scripting/.save_data) that this file is created after successfully updating using ./update.sh --update.
The scripts checks if there's a new version and if so it automatically updates without user interaction.
Note: You must run --update then use --auto

- How to lauch autoupdater every server restart?
Firstly you need the .save_data file to load the configurations.
If you are missing the file, you can create one yourself or get it from updating the files: ./update.sh --update
If you are not able to use the terminal, you can create a dummy file and set the build version to a random number which will cause the autoupdater think that this is an old version and updated the files for you
Dummy file
Code:

.save_data >
game=cstrike
amxx=1.9
build=1234
configs=0000000100000000

The numbers in the configs are the files listed alphabetically, which 0 stands for 'to not replace' and 1 'to replace'.
The autoupdater will loop through each value and compare it with the files and decide if this file should be replaced or not.

After setting up .save_data modify the server start options as shown below:
bash <gamemod>/addons/amxmodx/scripting/update.sh --auto && <your-current-server-start-script>
e.g: bash cstrike/addons/amxmodx/compile.sh --auto && screen -S server ./hlds_run -game cstrike -port 27015 +map de_dust2 +maxplayers 32 +sys_tickrate 512 +fps_max 512

Or your can run a side bash script to auto update
Note: Repacing modules meanwhile the server is running may cause the server to crash.
screen -S autoupdate ./autoupdate.sh
Code:

autoupdate.sh >
#!/bin/bash

while [ true ]; then
    bash cstrike/addons/amxmodx/update.sh --auto
    sleep 24h # execute the script every 24 hours
done

How to use the commands?
If your server is running either 1.9 or 1.10, you can setup the autoupdater and run the autoupdate.sh script.
./update.sh --setup
If your server is on a older version, you can update to 1.9 or 1.10 and lauch the autoupdate.sh script.
./update.sh --update

* compile.sh Pull Request
https://github.com/alliedmodders/amxmodx/pull/870
* update.sh Pull Request
https://github.com/alliedmodders/amxmodx/pull/871
* Download compile.sh (CTRL + S)
https://raw.githubusercontent.com/Cr...ins/compile.sh
* Download update.sh (CTRL + S)
https://raw.githubusercontent.com/Cr...gins/update.sh

Stat counting
Spoiler

thEsp 06-11-2020 05:35

Re: [Bash] Autoupdate the AMXX to the latest version [1.9 / 1.10]
 
Nice job mate.

Relaxing 06-11-2020 05:40

Re: [Bash] Autoupdate the AMXX to the latest version [1.9 / 1.10]
 
Quote:

Originally Posted by thEsp (Post 2705107)
Nice job mate.

:grrr::grrr::grrr:

fysiks 06-11-2020 21:16

Re: [Bash] Autoupdate the AMXX to the latest version [1.9 / 1.10]
 
Seems like a completely inappropriate place to put auto-update code for the entirety of AMX Mod X. I think that if something like this existed, it would need to be its own script since it's has absolutely nothing to do with compiling a plugin.

Relaxing 06-17-2020 23:50

Re: [Bash] Autoupdate the AMXX to the latest version [1.9 / 1.10]
 
Updated.

XoNix 07-26-2021 17:10

Re: [Bash] Autoupdate the AMXX to the latest version [1.9 / 1.10]
 
Nice God Job Man :avast:


All times are GMT -4. The time now is 14:13.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.