From 0205dae7d9f8942a6b6af52a6e785bf3b7294ee4 Mon Sep 17 00:00:00 2001 From: nacho Date: Sun, 22 Apr 2018 21:16:23 +0200 Subject: [PATCH] refactor installation script --- install.sh | 42 ++++++++++++++++-------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/install.sh b/install.sh index 5dc926b..629a94f 100644 --- a/install.sh +++ b/install.sh @@ -1,34 +1,24 @@ #!/usr/bin/env sh systemctl -q is-active log2ram && { echo "ERROR: log2ram service is still running. Please run \"sudo service log2ram stop\" to stop it."; exit 1; } +[ "$(id -u)" -eq 0 ] || { echo "You need to be ROOT (sudo can be used)"; exit 1; } +# log2ram +mkdir -p /usr/local/bin/ +install -m 644 log2ram.service /etc/systemd/system/log2ram.service +install -m 755 log2ram /usr/local/bin/log2ram +install -m 644 log2ram.conf /etc/log2ram.conf +install -m 644 uninstall.sh /usr/local/bin/uninstall-log2ram.sh +systemctl enable log2ram -if [ "$(id -u)" -eq 0 ] -then - [ -d /usr/local/bin/ ] || mkdir /usr/local/bin/ - cp log2ram.service /etc/systemd/system/log2ram.service - chmod 644 /etc/systemd/system/log2ram.service - cp log2ram /usr/local/bin/log2ram - chmod a+x /usr/local/bin/log2ram - cp log2ram.conf /etc/log2ram.conf - chmod 644 /etc/log2ram.conf - systemctl enable log2ram - cp log2ram.hourly /etc/cron.hourly/log2ram - chmod +x /etc/cron.hourly/log2ram - cp log2ram.logrotate /etc/logrotate.d/log2ram - chmod 644 /etc/logrotate.d/log2ram - cp uninstall.sh /usr/local/bin/uninstall-log2ram.sh +# cron +install -m 755 log2ram.hourly /etc/cron.hourly/log2ram +install -m 644 log2ram.logrotate /etc/logrotate.d/log2ram - # Remove a previous log2ram version - if [ -d /var/log.hdd ]; then - rm -r /var/log.hdd - fi +# Remove a previous log2ram version + rm -rf /var/log.hdd - if [ -d /var/hdd.log ]; then - rm -r /var/hdd.log - fi +# Make sure we start clean +rm -rf /var/hdd.log - echo "##### Reboot to activate log2ram #####" -else - echo "You need to be ROOT (sudo can be used)" -fi +echo "##### Reboot to activate log2ram #####"