Few days ago I just search for a linux script which can automatically update oxide if an update is released .
Since not found any resource I decide to create one and share it with the community .
This script was build using LGSM scripts and will check for oxide updates based on cURL header hash value and perform following actions (if no oxide updates are detected the script will exit without taking any actions):
The script can be found attached to this topic and on GIT
- stop rust server
- update rust server (if available)
- update oxide mod for rust
- start rust server
You will have only to change WDIR var according to location of LGSM rustserver script .
I have crontabed this script to run hourly at 2 and 32 minutes (in order to avoid interaction with /srv/rust/rustserver monitor)
crontab content
rust_oxide_update.sh contentCode:*/15 * * * * /srv/rust/rustserver monitor 2,32 * * * * /srv/rust/bin/rust_oxide_update.sh 0 0 * * 0 /srv/rust/rustserver update-functions */30 * * * * /bin/ocomposer update
Code:#!/bin/sh # v0.1@20140705 catalin.m # Rust oxide mod update script ## VARWDIR="/srv/rust" OFILE="https://dl.bintray.com/oxidemod/builds/Oxide-Rust.zip"# Functionsfunction oxide_get_local_hash { [ -e "${WDIR}/.rust_oxide_hash" ] || touch "${WDIR}/.rust_oxide_hash" LHASH=$(cat ${WDIR}/.rust_oxide_hash) echo Local Oxide hash : ${LHASH} } function oxide_get_remote_hash { RHASH=$(curl -sI ${OFILE} | grep -i X-Checksum-Sha1 | awk -v RS='\r\n' '{print $2}') echo Remote Oxide hash : ${RHASH} }function oxide_compare_hash { oxide_get_local_hash oxide_get_remote_hash if test ${LHASH} == ${RHASH} then return 0 else return 1 fi }function oxide_update { if oxide_compare_hash; then echo no updates! exit 0 else echo new updates oxide_perform_update fi }function oxide_perform_update { ${WDIR}/rustserver stop ; ${WDIR}/rustserver update ; ${WDIR}/rustserver mods-update ; ${WDIR}/rustserver start ; echo ${RHASH} > ${WDIR}/.rust_oxide_hash }# Execute script stepsoxide_update
Linux update Oxide automatically sh script
Discussion in 'Rust Discussion' started by EviL iNsiDe, Jul 5, 2017.
-
Code:
#!/bin/sh # v0.2@20170722 catalin.m # Rust oxide mod update script ## VARWDIR="/srv/rust" OFILE="https://dl.bintray.com/oxidemod/builds/Oxide-Rust.zip"# Functionsfunction oxide_get_local_hash { [ -e "${WDIR}/.rust_oxide_hash" ] || touch "${WDIR}/.rust_oxide_hash" LHASH=$(cat ${WDIR}/.rust_oxide_hash) echo Local Oxide eTAG : ${LHASH} } function oxide_get_remote_hash { RHASH=$(curl -sLI ${OFILE} | grep -i Etag: | awk -v RS='\r\n' '{print $2}') echo Remote Oxide eTAG : ${RHASH} }function oxide_compare_hash { oxide_get_local_hash oxide_get_remote_hash if test ${LHASH} == ${RHASH} then return 0 else return 1 fi }function oxide_update { if oxide_compare_hash; then echo no updates! exit 0 else echo new updates oxide_perform_update fi }function oxide_perform_update { ${WDIR}/rustserver stop ; ${WDIR}/rustserver update ; ${WDIR}/rustserver mods-update ; ${WDIR}/rustserver start ; echo ${RHASH} > ${WDIR}/.rust_oxide_hash }# Execute script stepsoxide_update
- updated to version 0.2
- change detection of new version from sha1 header to etag since bintray seems to use akamai and no more sha1 info can be found in header .
- git version also updated -
1) Need sudo or root for install, realy?
2) after install php and install ocomposer, errors and errors and errors... May be I need to use it as sudoer or root too? No, thanks
-
-
Code:rustserver@gameserver:~/scripts$ ./checkupd_rust ./checkupd_rust: 13: ./checkupd_rust: function: not found Local Oxide eTAG : ./checkupd_rust: 19: ./checkupd_rust: function: not found Remote Oxide eTAG : "3141971a4aed147dcd635e583f0b3803:1500848419.253408" ./checkupd_rust: 25: ./checkupd_rust: function: not found ./checkupd_rust: 27: ./checkupd_rust: oxide_get_local_hash: not found ./checkupd_rust: 28: ./checkupd_rust: oxide_get_remote_hash: not found ./checkupd_rust: 29: test: ==: unexpected operator
-
I am not sure what shell he is using but I had to make a couple of changes for bash on CentOS 7. Specifically, function was removed in favor of functionname (). Also changed how the comparision is done (f [ "${LHASH}" = "${RHASH}" ]; then). Otherwise, thanks because I was looking for the right way to do this:
Code:#!/bin/sh # v0.2@20170722 catalin.m # Rust oxide mod update script ## VARWDIR="/home/steam" OFILE="https://dl.bintray.com/oxidemod/builds/Oxide-Rust.zip"# Functionsoxide_get_local_hash () { [ -e "${WDIR}/.rust_oxide_hash" ] || touch "${WDIR}/.rust_oxide_hash" LHASH=$(cat ${WDIR}/.rust_oxide_hash) echo Local Oxide eTAG : ${LHASH} } oxide_get_remote_hash () { RHASH=$(curl -sLI ${OFILE} | grep -i Etag: | awk -v RS='\r\n' '{print $2}') echo Remote Oxide eTAG : ${RHASH} }oxide_compare_hash () { oxide_get_local_hash oxide_get_remote_hash if [ "${LHASH}" = "${RHASH}" ]; then return 0 else return 1 fi }oxide_update () { if oxide_compare_hash; then echo no updates! exit 0 else echo new updates oxide_perform_update fi }oxide_perform_update () { ${WDIR}/rustserver stop ; ${WDIR}/rustserver update ; ${WDIR}/rustserver mods-update ; ${WDIR}/rustserver start ; echo ${RHASH} > ${WDIR}/.rust_oxide_hash }# Execute script stepsoxide_update