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.

install.sh 1.7 KiB

8 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env sh
  2. [ "$(id -u)" -eq 0 ] || { echo "You need to be ROOT (sudo can be used)"; exit 1; }
  3. # See if we can find out the init-system
  4. echo "Try to detect init and running log2ram service..."
  5. if [ "$(systemctl --version 2> /dev/null)" != '' ] ; then
  6. INIT='systemd'
  7. elif [ "$(rc-service --version 2> /dev/null)" != '' ] ; then
  8. INIT='openrc'
  9. fi
  10. case "$INIT" in
  11. systemd)
  12. systemctl -q is-active log2ram && { echo "ERROR: log2ram service is still running. Please run \"sudo service log2ram stop\" to stop it."; exit 1; } ;;
  13. openrc)
  14. rc-service log2ram status && { echo "ERROR: log2ram service is still running. Please run \"sudo rc-service log2ram stop\" to stop it."; exit 1; } ;;
  15. *) echo 'ERROR: could not detect init-system' ; exit 1
  16. ;;
  17. esac
  18. # log2ram
  19. mkdir -p /usr/local/bin/
  20. install -m 755 log2ram /usr/local/bin/log2ram
  21. install -m 644 log2ram.conf /etc/log2ram.conf
  22. install -m 644 uninstall.sh /usr/local/bin/uninstall-log2ram.sh
  23. if [ "$INIT" = 'systemd' ] ; then
  24. install -m 644 log2ram.service /etc/systemd/system/log2ram.service
  25. systemctl enable log2ram
  26. elif [ "$INIT" = 'openrc' ] ; then
  27. install -m 755 log2ram.initd /etc/init.d/log2ram
  28. rc-update add log2ram boot
  29. fi
  30. # cron
  31. if [ "$INIT" = 'systemd' ] ; then
  32. install -m 755 log2ram.cron /etc/cron.daily/log2ram
  33. elif [ "$INIT" = 'openrc' ] ; then
  34. install -m 755 log2ram.openrc_cron /etc/cron.daily/log2ram
  35. fi
  36. install -m 644 log2ram.logrotate /etc/logrotate.d/log2ram
  37. # Remove a previous log2ram version
  38. rm -rf /var/log.hdd
  39. # Make sure we start clean
  40. rm -rf /var/hdd.log
  41. echo "##### Reboot to activate log2ram #####"
  42. echo "##### edit /etc/log2ram.conf to configure options ####"