"test sys_refresh_ref_cron.sh"
This commit is contained in:
parent
b456a24eaf
commit
80f1253005
@ -23,6 +23,7 @@
|
||||
# Ce script n'accepte *aucune* option
|
||||
#
|
||||
# @OPT: f:force:force:1/1:false:::
|
||||
# @OPT: f:show-only:show-only:1/1:false:::
|
||||
#
|
||||
#------------------------------------------------------------------------------------------------------------------
|
||||
# Liste des erreurs:
|
||||
@ -68,6 +69,9 @@
|
||||
## Lorsqu'un cron job est supprimé, forcer une régénération complète des entrées de la base est
|
||||
## donc nécessaire (sys_refresh_ref_cron.sh -force true)
|
||||
##
|
||||
## L'option show-only permet de lister les cronjobs installés sur les VM sans les enregistrer
|
||||
## dans la base de données.
|
||||
##
|
||||
## Les informations de connexion à la base de données doivent être stockées dans
|
||||
## le fichier PGPASSFILE sur sousetsuken au format suivant:
|
||||
##
|
||||
@ -176,27 +180,29 @@ function refresh_cronjobs
|
||||
COLOR="vert"
|
||||
fi
|
||||
fct_message ${MESSAGE} -color ${COLOR}
|
||||
if [ ${#CRONJOB} -gt 0 ]; then
|
||||
fct_message " Checking database:"
|
||||
MINUTES=$(echo ${CRONJOB} | cut -d' ' -f1)
|
||||
HOURS=$(echo ${CRONJOB} | cut -d' ' -f2)
|
||||
DAYS=$(echo ${CRONJOB} | cut -d' ' -f3)
|
||||
MONTHS=$(echo ${CRONJOB} | cut -d' ' -f4)
|
||||
DAYSOFWEEK=$(echo ${CRONJOB} | cut -d' ' -f5)
|
||||
COMMAND=$(echo ${CRONJOB} | cut -d' ' -f6-)
|
||||
REQUEST_ID_PARAMS="host='${VM}' and s_user='${TETALAB_USER}' and minutes='${MINUTES}' and hours='${HOURS}'
|
||||
and days='${DAYS}' and months='${MONTHS}' and daysofweek='${DAYSOFWEEK}' and command='${COMMAND}'"
|
||||
RESULT=$(psql -q -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "select ID from
|
||||
ref_cron where ${REQUEST_ID_PARAMS};")
|
||||
if [ ${#RESULT} -eq 0 ]; then
|
||||
fct_message " -> Cronjob not in database, inserting..."
|
||||
REQUEST_INSERT_PARAMS="'${VM}', '${TETALAB_USER}', '${MINUTES}',
|
||||
'${HOURS}', '${DAYS}', '${MONTHS}', '${DAYSOFWEEK}', '${COMMAND}'"
|
||||
psql -q -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "insert into ref_cron
|
||||
(\"host\", \"s_user\", \"minutes\", \"hours\", \"days\", \"months\", \"daysofweek\", \"command\")
|
||||
values (${REQUEST_INSERT_PARAMS});"
|
||||
else
|
||||
fct_message " -> Cronjob already in database"
|
||||
if [ "${show-only}" == "false" ]; then
|
||||
if [ ${#CRONJOB} -gt 0 ]; then
|
||||
fct_message " Checking database:"
|
||||
MINUTES=$(echo ${CRONJOB} | cut -d' ' -f1)
|
||||
HOURS=$(echo ${CRONJOB} | cut -d' ' -f2)
|
||||
DAYS=$(echo ${CRONJOB} | cut -d' ' -f3)
|
||||
MONTHS=$(echo ${CRONJOB} | cut -d' ' -f4)
|
||||
DAYSOFWEEK=$(echo ${CRONJOB} | cut -d' ' -f5)
|
||||
COMMAND=$(echo ${CRONJOB} | cut -d' ' -f6-)
|
||||
REQUEST_ID_PARAMS="host='${VM}' and s_user='${TETALAB_USER}' and minutes='${MINUTES}' and hours='${HOURS}'
|
||||
and days='${DAYS}' and months='${MONTHS}' and daysofweek='${DAYSOFWEEK}' and command='${COMMAND}'"
|
||||
RESULT=$(psql -q -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "select ID from
|
||||
ref_cron where ${REQUEST_ID_PARAMS};")
|
||||
if [ ${#RESULT} -eq 0 ]; then
|
||||
fct_message " -> Cronjob not in database, inserting..."
|
||||
REQUEST_INSERT_PARAMS="'${VM}', '${TETALAB_USER}', '${MINUTES}',
|
||||
'${HOURS}', '${DAYS}', '${MONTHS}', '${DAYSOFWEEK}', '${COMMAND}'"
|
||||
psql -q -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "insert into ref_cron
|
||||
(\"host\", \"s_user\", \"minutes\", \"hours\", \"days\", \"months\", \"daysofweek\", \"command\")
|
||||
values (${REQUEST_INSERT_PARAMS});"
|
||||
else
|
||||
fct_message " -> Cronjob already in database"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user