
Suite à mon tuto sur la mise en place d'un serveur Left 4 Dead 2 sur Debian Squeeze, je me suis dit que ça pourrait être sympa que le serveur vérifie les mises à jours du jeu disponibles chaque jour.
Et pour cela rien de tel qu'un petit script.
Celui que je vous ai préparé vérifiera l'intégrité des fichiers et fera la mise à jour si il y en a une de disponible. Une fois cela fait, un fichier de log journalier sera créé dans le répertoire de logs du jeu (le même que celui de lancement du serveur). Un e-mail vous sera également envoyé une fois l'opération terminée avec un récapitulatif du log.
On va donc créer notre script dans /etc/cron.daily/ qui est un dossier de rotation de logs du crontab journalier.
root@server:~# vi /etc/cron.daily/l4d2_update
Et collez-y ces quelques lignes :
#! /bin/bash
##################################################################################
# #
# Crazy CRON Steam update #
# #
# Author: CrazyMax #
# Date: 2012-08-25 #
# Version: 1.0 #
# #
# Contact: https://www.crazyws.fr #
# Related article: http://goo.gl/q6JUN #
# #
# This program is free software: you can redistribute it and/or modify it #
# under the terms of the GNU General Public License as published by the Free #
# Software Foundation, either version 3 of the License, or (at your option) #
# any later version. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more #
# details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program. If not, see http://www.gnu.org/licenses/. #
# #
##################################################################################
SRCDS_USER="steam"
DIR=/srv/steam
DAEMON=steam
LOGFILE=$DIR/left4dead2/left4dead2/logs/update_`date +%Y%m%d`.log
EMAIL="monitoring@foo.com"
# Do not change this path
PATH=/bin:/usr/bin:/sbin:/usr/sbin
su - $SRCDS_USER -c "cd $DIR ; ./$DAEMON -command update -game left4dead2 -dir . -verify_all -retry > $LOGFILE"
cat $LOGFILE | mail -s "L4D2 Server Update for $(hostname -f)" $EMAIL
exit 1
Bien sûr ce script est facilement adaptable pour tous les dedicated server Steam mais ici j'ai pris pour exemple Left 4 Dead 2. Vous aurez juste à adapter les variables suivant vos besoins.