You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 rivejä
1.5 KiB

  1. #!/usr/bin/env sh
  2. systemctl -q is-active log2ram && { echo "ERROR: log2ram service is still running. Please run \"sudo service log2ram stop\" to stop it."; exit 1; }
  3. [ "$(id -u)" -eq 0 ] || { echo "You need to be ROOT (sudo can be used)"; exit 1; }
  4. # log2ram
  5. mkdir -p /usr/local/bin/log2ram
  6. install -m 644 log2ram.service /etc/systemd/system/log2ram.service
  7. install -m 755 log2ram /usr/local/bin/log2ram/log2ram
  8. install -m 644 log2ram.conf /etc/log2ram.conf
  9. install -m 644 log2ram.conf /usr/local/bin/log2ram/log2ram-lastcheck
  10. install -m 644 uninstall.sh /usr/local/bin/log2ram/uninstall-log2ram.sh
  11. systemctl enable log2ram
  12. # cron
  13. install -m 755 log2ram.hourly /etc/cron.hourly/log2ram
  14. install -m 644 log2ram.logrotate /etc/logrotate.d/log2ram
  15. # Remove a previous log2ram version
  16. # ??
  17. # rm -rf /var/log.hdd
  18. # Make sure we start clean
  19. rm -rf /var/hdd.log
  20. # Make backup of pruned logs
  21. mkdir -p /var/oldlog
  22. cp -rfup /var/log/*.1 /var/oldlog/
  23. cp -rfup /var/log/*.gz /var/oldlog/
  24. cp -rfup /var/log/*.old /var/oldlog/
  25. # Prune logs
  26. rm -r /var/log/*.1
  27. rm -r /var/log/*.gz
  28. rm -r /var/log/*.old
  29. # Clone /var/log
  30. mkdir -p /var/hdd.log
  31. mkdir -p /var/log/oldlog
  32. # Prob better to use xcopy here with a --exclude
  33. rsync -a --exclude 'oldlog' /var/log/ /var/hdd.log/
  34. #cp -rfup /var/log/ -T /var/hdd.log/
  35. sed -i '/^include.*/i olddir /var/log/oldlog' /etc/logrotate.conf
  36. echo "##### Reboot to activate log2ram #####"
  37. echo "##### edit /etc/log2ram.conf to configure options #####"