"test sys_refresh_ref_cron.sh"
This commit is contained in:
parent
8f80c1105b
commit
725f042087
@ -147,6 +147,15 @@ function get_db_info
|
|||||||
DB_USER=$(cat ${PGPASSFILE} | cut -d: -f4)
|
DB_USER=$(cat ${PGPASSFILE} | cut -d: -f4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clean_table
|
||||||
|
{
|
||||||
|
if [ "${force}" == "true" ]; then
|
||||||
|
fct_message "Option -force activée: Suppression des données dans la table." -color orange
|
||||||
|
SQL="delete from ref_cron where id > 0;"
|
||||||
|
psql -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "${SQL}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function refresh_cronjobs
|
function refresh_cronjobs
|
||||||
{
|
{
|
||||||
fct_message "Récupération des cronjobs:" -color jaune
|
fct_message "Récupération des cronjobs:" -color jaune
|
||||||
@ -168,7 +177,7 @@ function refresh_cronjobs
|
|||||||
fi
|
fi
|
||||||
fct_message ${MESSAGE} -color ${COLOR}
|
fct_message ${MESSAGE} -color ${COLOR}
|
||||||
if [ ${#CRONJOB} -gt 0 ]; then
|
if [ ${#CRONJOB} -gt 0 ]; then
|
||||||
fct_message "Checking database:"
|
fct_message " Checking database:"
|
||||||
MINUTES=$(echo ${CRONJOB} | cut -d' ' -f1)
|
MINUTES=$(echo ${CRONJOB} | cut -d' ' -f1)
|
||||||
HOURS=$(echo ${CRONJOB} | cut -d' ' -f2)
|
HOURS=$(echo ${CRONJOB} | cut -d' ' -f2)
|
||||||
DAYS=$(echo ${CRONJOB} | cut -d' ' -f3)
|
DAYS=$(echo ${CRONJOB} | cut -d' ' -f3)
|
||||||
@ -180,14 +189,14 @@ function refresh_cronjobs
|
|||||||
RESULT=$(psql -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "select ID from
|
RESULT=$(psql -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "select ID from
|
||||||
ref_cron where ${REQUEST_ID_PARAMS};")
|
ref_cron where ${REQUEST_ID_PARAMS};")
|
||||||
if [ ${#RESULT} -eq 0 ]; then
|
if [ ${#RESULT} -eq 0 ]; then
|
||||||
fct_message "Cronjob not in database, inserting..."
|
fct_message " -> Cronjob not in database, inserting..."
|
||||||
REQUEST_INSERT_PARAMS="'${VM}', '${TETALAB_USER}', '${MINUTES}',
|
REQUEST_INSERT_PARAMS="'${VM}', '${TETALAB_USER}', '${MINUTES}',
|
||||||
'${HOURS}', '${DAYS}', '${MONTHS}', '${DAYSOFWEEKS}', '${COMMAND}'"
|
'${HOURS}', '${DAYS}', '${MONTHS}', '${DAYSOFWEEKS}', '${COMMAND}'"
|
||||||
psql -e -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "insert into ref_cron
|
psql -t -h ${DB_HOST} -U ${DB_USER} -d ${DB_DATABASE} -c "insert into ref_cron
|
||||||
(\"host\", \"s_user\", \"minutes\", \"hours\", \"days\", \"months\", \"daysofweek\", \"command\")
|
(\"host\", \"s_user\", \"minutes\", \"hours\", \"days\", \"months\", \"daysofweek\", \"command\")
|
||||||
values (${REQUEST_INSERT_PARAMS});"
|
values (${REQUEST_INSERT_PARAMS});"
|
||||||
else
|
else
|
||||||
fct_message "Cronjob already in database"
|
fct_message " -> Cronjob already in database"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@ -206,5 +215,6 @@ DB_USER=""
|
|||||||
|
|
||||||
check_config
|
check_config
|
||||||
get_db_info
|
get_db_info
|
||||||
|
clean_table
|
||||||
refresh_cronjobs
|
refresh_cronjobs
|
||||||
fct_erreur 0
|
fct_erreur 0
|
||||||
|
Loading…
Reference in New Issue
Block a user