Skip to content

Commit 1173e4c

Browse files
Copilotbytestream
andcommitted
Add logrotate configuration for SupportPal Apache logs
Co-authored-by: bytestream <1788397+bytestream@users.noreply.github.com>
1 parent c847bf4 commit 1173e4c

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

templates/linux/setup.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,35 @@ install_apache_deb() {
430430
systemd restart apache2
431431
}
432432

433+
configure_logrotate() {
434+
msg "info" "Configuring logrotate for SupportPal logs..."
435+
436+
install logrotate
437+
438+
LOGROTATE_CONFIG="/etc/logrotate.d/supportpal"
439+
backup "$LOGROTATE_CONFIG"
440+
441+
echo "${log_path}/*.log {
442+
daily
443+
missingok
444+
rotate 14
445+
compress
446+
delaycompress
447+
notifempty
448+
create 0640 $(if [[ $os_type == 'rhel' ]]; then echo "apache apache"; else echo "www-data www-data"; fi)
449+
sharedscripts
450+
postrotate
451+
if [[ $os_type == 'rhel' ]]; then
452+
/bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
453+
else
454+
/usr/sbin/invoke-rc.d apache2 reload > /dev/null 2>&1 || true
455+
fi
456+
endscript
457+
}" > "$LOGROTATE_CONFIG"
458+
459+
msg "info" "Logrotate configuration created at $LOGROTATE_CONFIG"
460+
}
461+
433462
install_apache() {
434463
msg "info" "Configuring Apache2..."
435464

@@ -441,6 +470,8 @@ install_apache() {
441470
install_apache_deb
442471
fi
443472

473+
configure_logrotate
474+
444475
install_php
445476
}
446477

0 commit comments

Comments
 (0)