2018-02-16 01:03:18 +01:00
|
|
|
#!/usr/bin/env sh
|
2016-04-18 12:07:33 +02:00
|
|
|
|
2018-04-22 21:16:23 +02:00
|
|
|
[ "$(id -u)" -eq 0 ] || { echo "You need to be ROOT (sudo can be used)"; exit 1; }
|
2018-04-30 23:22:47 +02:00
|
|
|
|
2019-09-23 15:52:35 +02:00
|
|
|
# See if we can find out the init-system
|
2019-09-24 12:59:27 +02:00
|
|
|
echo "Try to detect init and running log2ram service..."
|
|
|
|
if [ "$(systemctl --version 2> /dev/null)" != '' ] ; then
|
2019-09-23 15:52:35 +02:00
|
|
|
INIT='systemd'
|
2019-09-24 12:59:27 +02:00
|
|
|
elif [ "$(rc-service --version 2> /dev/null)" != '' ] ; then
|
2019-09-23 15:52:35 +02:00
|
|
|
INIT='openrc'
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$INIT" in
|
|
|
|
systemd)
|
|
|
|
systemctl -q is-active log2ram && { echo "ERROR: log2ram service is still running. Please run \"sudo service log2ram stop\" to stop it."; exit 1; } ;;
|
|
|
|
openrc)
|
|
|
|
rc-service log2ram status && { echo "ERROR: log2ram service is still running. Please run \"sudo rc-service log2ram stop\" to stop it."; exit 1; } ;;
|
|
|
|
*) echo 'ERROR: could not detect init-system' ; exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2018-04-22 21:16:23 +02:00
|
|
|
# log2ram
|
|
|
|
mkdir -p /usr/local/bin/
|
|
|
|
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
|
2019-09-23 15:52:35 +02:00
|
|
|
if [ "$INIT" = 'systemd' ] ; then
|
|
|
|
install -m 644 log2ram.service /etc/systemd/system/log2ram.service
|
|
|
|
systemctl enable log2ram
|
|
|
|
elif [ "$INIT" = 'openrc' ] ; then
|
|
|
|
install -m 755 log2ram.initd /etc/init.d/log2ram
|
|
|
|
rc-update add log2ram boot
|
|
|
|
fi
|
2017-12-16 11:42:37 +01:00
|
|
|
|
2018-04-22 21:16:23 +02:00
|
|
|
# cron
|
2019-09-23 15:52:35 +02:00
|
|
|
if [ "$INIT" = 'systemd' ] ; then
|
|
|
|
install -m 755 log2ram.cron /etc/cron.daily/log2ram
|
|
|
|
elif [ "$INIT" = 'openrc' ] ; then
|
|
|
|
install -m 755 log2ram.openrc_cron /etc/cron.daily/log2ram
|
|
|
|
fi
|
2018-04-22 21:16:23 +02:00
|
|
|
install -m 644 log2ram.logrotate /etc/logrotate.d/log2ram
|
2017-12-07 17:42:40 +01:00
|
|
|
|
2018-04-22 21:16:23 +02:00
|
|
|
# Remove a previous log2ram version
|
2019-08-20 01:32:46 +02:00
|
|
|
rm -rf /var/log.hdd
|
2017-12-11 08:55:38 +01:00
|
|
|
|
2018-04-22 21:16:23 +02:00
|
|
|
# Make sure we start clean
|
|
|
|
rm -rf /var/hdd.log
|
2016-11-30 18:41:41 +01:00
|
|
|
|
2019-03-09 04:24:27 +01:00
|
|
|
echo "##### Reboot to activate log2ram #####"
|
|
|
|
echo "##### edit /etc/log2ram.conf to configure options ####"
|