keep rights from current log
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2623|5|2618|5|:-1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/359//ansiblelint">Evolix » ansible-roles » unstable #359</a>
gitea/ansible-roles/pipeline/head This commit looks good

This commit is contained in:
Bruno TATU 2023-09-26 11:42:13 +02:00
parent e4a70b3c0c
commit ee6bd8cec4

View file

@ -40,9 +40,14 @@ rotate () {
} }
user_for() { user_for() {
stat -L -c '%U' $1
}
group_for() {
stat -L -c '%G' $1 stat -L -c '%G' $1
} }
delete_old() { delete_old() {
if [ ${DELETE_AFTER_RETENTION_DAYS} == "true" ]; then if [ ${DELETE_AFTER_RETENTION_DAYS} == "true" ]; then
if [ ${DRY_RUN} == "false" ]; then if [ ${DRY_RUN} == "false" ]; then
@ -67,7 +72,8 @@ for path in ${SYSTEM_LOGS_SEARCH_PATHS[@]}; do
log_paths=$(ls -1 -d ${path}/${log_name} 2>/dev/null | grep -v \.bak\.) log_paths=$(ls -1 -d ${path}/${log_name} 2>/dev/null | grep -v \.bak\.)
for file in ${log_paths}; do for file in ${log_paths}; do
user="$(user_for "${file}")" user="$(user_for "${file}")"
rotate "${file}" root:"${user}" group="$(group_for "${file}")"
rotate "${file}" "${group}":"${user}"
delete_old "$(dirname "${file}")" delete_old "$(dirname "${file}")"
done done
done done
@ -78,7 +84,8 @@ for path in ${APPLICATIVE_LOGS_SEARCH_PATHS[@]}; do
log_paths=$(ls -1 -d ${path}/${log_name} 2>/dev/null | grep -v \.bak\.) log_paths=$(ls -1 -d ${path}/${log_name} 2>/dev/null | grep -v \.bak\.)
for file in ${log_paths}; do for file in ${log_paths}; do
user="$(user_for "${file}")" user="$(user_for "${file}")"
rotate "${file}" "${user}":"${user}" group="$(group_for "${file}")"
rotate "${file}" "${group}":"${user}"
delete_old "$(dirname "${file}")" delete_old "$(dirname "${file}")"
done done
done done