Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

41 linhas
1.4 KiB

  1. #!/bin/bash
  2. systemctl -q is-active log2zram && { echo "ERROR: log2zram service is still running. Please run \"sudo service log2zram stop\" to stop it and uninstall"; 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/log2zram
  6. install -m 644 log2zram.service /etc/systemd/system/log2zram.service
  7. install -m 755 log2zram /usr/local/bin/log2zram/log2zram
  8. install -m 644 log2zram.conf /etc/log2zram.conf
  9. install -m 644 log2zram.log /usr/local/bin/log2zram/log2zram.log
  10. install -m 644 uninstall.sh /usr/local/bin/log2zram/uninstall.sh
  11. systemctl enable log2zram
  12. # cron
  13. install -m 755 log2zram.hourly /etc/cron.hourly/log2zram
  14. install -m 644 log2zram.logrotate /etc/logrotate.d/log2zram
  15. # Make sure we start clean
  16. rm -rf /var/hdd.log
  17. # Make backup of pruned logs
  18. mkdir -p /var/oldlog
  19. cp -rfup /var/log/*.1 /var/oldlog/
  20. cp -rfup /var/log/*.gz /var/oldlog/
  21. cp -rfup /var/log/*.old /var/oldlog/
  22. # Prune logs
  23. rm -r /var/log/*.1
  24. rm -r /var/log/*.gz
  25. rm -r /var/log/*.old
  26. # Clone /var/log
  27. mkdir -p /var/hdd.log
  28. mkdir -p /var/log/oldlog
  29. # Prob better to use xcopy here with a --exclude
  30. rsync -arzh --exclude 'oldlog' /var/log/ /var/hdd.log/
  31. mkdir -p /var/hdd.log/oldlog
  32. sed -i '/^include.*/i olddir /var/log/oldlog' /etc/logrotate.conf
  33. echo "##### Reboot to activate log2ram #####"
  34. echo "##### edit /etc/log2zram.conf to configure options #####"