From 0d4c2da0bc616f6499d728d01a1971d0de4f2d71 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Fri, 13 Apr 2018 21:19:25 +1000 Subject: [PATCH] Add sample logrotate and spec file * Logrotate file for rotating logs in /var/log/onedrive * Sample spec file to build onedrive client on RHEL/CentOS systems via mock --- logrotate/onedrive.logrotate | 21 +++++++ spec/onedrive.spec | 104 +++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 logrotate/onedrive.logrotate create mode 100644 spec/onedrive.spec diff --git a/logrotate/onedrive.logrotate b/logrotate/onedrive.logrotate new file mode 100644 index 00000000..d60339b8 --- /dev/null +++ b/logrotate/onedrive.logrotate @@ -0,0 +1,21 @@ +# Any OneDrive Client logs configured for here + +/var/log/onedrive/*log { + # rotate log files weekly + weekly + + # keep 4 weeks worth of backlogs + rotate 4 + + # create new (empty) log files after rotating old ones + create + + # use date as a suffix of the rotated file + dateext + + # compress the log files + compress + + # missing files OK + missingok +} \ No newline at end of file diff --git a/spec/onedrive.spec b/spec/onedrive.spec new file mode 100644 index 00000000..91c3dcf7 --- /dev/null +++ b/spec/onedrive.spec @@ -0,0 +1,104 @@ +# Determine based on distribution & version what options & packages to include +%if 0%{?fedora} || 0%{?rhel} >= 7 +%global with_systemd 1 +%else +%global with_systemd 0 +%endif + +Name: onedrive +Version: 1.3 +Release: 6%{?dist} +Summary: Microsoft OneDrive Client +Group: System Environment/Network +License: GPLv3 +URL: https://github.com/skilion/onedrive +Source0: %{name}-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildRequires: git +BuildRequires: dmd >= 2.079.0 +BuildRequires: sqlite-devel >= 3.7.15 +BuildRequires: libcurl-devel + +Requires: sqlite >= 3.7.15 +Requires: libcurl + +%if 0%{?with_systemd} +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd +%else +Requires(post): chkconfig +Requires(preun): chkconfig +Requires(preun): initscripts +Requires(postun): initscripts +%endif + +%define debug_package %{nil} + +%description +Microsoft OneDrive Client for Linux + +%prep + +%setup -q + +%build +cd %{_builddir}/%{name}-%{version}/ +make + +%install +# Make the destination directories +%{__mkdir_p} %{buildroot}/etc/ +%{__mkdir_p} %{buildroot}/usr/bin/ +%{__mkdir_p} %{buildroot}/etc/logrotate.d +cp %{_builddir}/%{name}-%{version}/onedrive %{buildroot}/usr/bin/onedrive +cp %{_builddir}/%{name}-%{version}/logrotate/onedrive.logrotate %{buildroot}/etc/logrotate.d/onedrive +%if 0%{?with_systemd} +%{__mkdir_p} %{buildroot}/usr/lib/systemd/user/ +cp %{_builddir}/%{name}-%{version}/onedrive.service %{buildroot}/usr/lib/systemd/user/onedrive.service +%else +%{__mkdir_p} %{buildroot}/etc/init.d +cp %{_builddir}/%{name}-%{version}/init.d/onedrive_service.sh %{buildroot}/usr/bin/onedrive_service.sh +cp %{_builddir}/%{name}-%{version}/init.d/onedrive.init %{buildroot}/etc/init.d/onedrive +%endif + +%clean + +%files +%defattr(0444,root,root,0755) +%attr(0555,root,root) /usr/bin/onedrive +%attr(0644,root,root) /etc/logrotate.d/onedrive +%if 0%{?with_systemd} +%attr(0555,root,root) /usr/lib/systemd/user/onedrive.service +%else +%attr(0555,root,root) /usr/bin/onedrive_service.sh +%attr(0555,root,root) /etc/init.d/onedrive +%endif + +%pre +rm -f /root/.config/onedrive/items.db +rm -f /root/.config/onedrive/items.sqlite3 +rm -f /root/.config/onedrive/resume_upload + +%post +mkdir -p /root/.config/onedrive +mkdir -p /root/OneDrive +%if 0%{?with_systemd} +%systemd_post onedrive.service +%else +chkconfig --add onedrive +chkconfig onedrive off +%endif + +%preun +%if 0%{?with_systemd} +%systemd_preun onedrive.service +%else +if [ $1 -eq 0 ] ; then + service onedrive stop &> /dev/null + chkconfig --del onedrive &> /dev/null +fi +%endif + +%changelog \ No newline at end of file