Name: log2ram License: ramlog like for systemd (Put log into a ram folder) Group: Applications/System Summary: ramlog Version: 1.7.2 Release: 1%{?dist} URL: https://github.com/azlux/log2ram %undefine _disable_source_fetch Source0: https://github.com/azlux/log2ram/archive/refs/tags/1.7.2.tar.gz %define debug_package %nil BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Requires: logrotate,systemd %description Log2Ram works just like ramlog for systemd (on Debian 8 Jessie for example) Useful for RaspberryPi for not writing on the SD card all the time. You need it because your SD card doesn't want to suffer anymore! Explanations: The script creates a /var/log mount point in RAM. So any writing of the log to the /var/log folder will not actually be written to disk (in this case to the SD card on a Raspberry Pi) but directly to RAM. By default, every day the CRON will synchronize the contents in RAM with the folder located on the physical disk. The script will also make this copy of RAM to disk in case of machine shutdowns (but, of course, it still won't do it in case of power failures). This way you can avoid excessive writing on the SD card and extend its life. Log2Ram's script works on every Linux system. If you don't have Systemd, you can still use Log2Ram with your own daemon manager. %prep %setup -q %build %install [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT install -v -m 0755 -d $RPM_BUILD_ROOT/usr/lib/systemd/system/ install -v -m 0755 -d $RPM_BUILD_ROOT/etc install -v -m 0755 -d $RPM_BUILD_ROOT/usr/local/bin install -v -m 0755 -d $RPM_BUILD_ROOT/etc/logrotate.d install -v -m 644 -t $RPM_BUILD_ROOT/usr/lib/systemd/system/ log2ram.service install -v -m 644 -t $RPM_BUILD_ROOT/usr/lib/systemd/system/ log2ram-daily.service install -v -m 644 -t $RPM_BUILD_ROOT/usr/lib/systemd/system/ log2ram-daily.timer install -v -m 644 -t $RPM_BUILD_ROOT/etc/ log2ram.conf install -v -m 0755 -t $RPM_BUILD_ROOT/usr/local/bin/ log2ram install -v -m 644 log2ram.logrotate $RPM_BUILD_ROOT/etc/logrotate.d/log2ram %clean [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT %post # Make sure we start clean echo "POST: $1" rm -rf /var/hdd.log if [ $1 -eq 1 ]; then echo "Update successful" #systemctl start log2ram elif [ $1 -eq 0 ]; then echo "-------------------------------------------------------" echo "Install Sucessful" echo "To Start the service: systemctl enable log2ram.service log2ram-daily.timer" echo "Config file: /etc/log2ram/log2ram.conf" echo "--------------------------------------------------------" fi echo "Reboot to activate log2ram" %postun # Commands to run after the package is uninstalled if [ $1 -ge 1 ]; then # Actions to perform only during upgrades, not uninstalls systemctl stop log2ram echo "Package updated" fi if [ $1 -eq 0 ]; then # Actions to perform only during uninstallation, not upgrades #systemctl disable log2ram.service log2ram-daily.timer %service_postun log2ram.service log2ram-daily.timer fi rm -rf /var/hdd.log # Make sure we start clean #rm -rf /var/hdd.log #echo "##### Reboot to activate log2ram #####" #echo "##### edit /etc/log2ram.conf to configure options ####" %files %doc LICENSE %config(noreplace) /etc/log2ram.conf /etc/logrotate.d/log2ram /usr/lib/systemd/system/log2ram-daily.service /usr/lib/systemd/system/log2ram-daily.timer /usr/lib/systemd/system/log2ram.service /usr/local/bin/log2ram