[packages/linux-pstore] - ver 0.3; no need for fstab entry, mount pstore fs when needed
arekm
arekm at pld-linux.org
Thu Feb 28 10:11:09 CET 2019
commit e4d4122ec705c5283d6b4c2a44bba68981ecfd5a
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date: Thu Feb 28 10:10:34 2019 +0100
- ver 0.3; no need for fstab entry, mount pstore fs when needed
linux-pstore.py | 16 ++++++++++++++++
linux-pstore.spec | 9 ++-------
2 files changed, 18 insertions(+), 7 deletions(-)
---
diff --git a/linux-pstore.spec b/linux-pstore.spec
index 5fb959b..f5725df 100644
--- a/linux-pstore.spec
+++ b/linux-pstore.spec
@@ -1,6 +1,6 @@
Summary: Save pstore logs and make room for future logs
Name: linux-pstore
-Version: 0.2
+Version: 0.3
Release: 1
License: GPL
Group: Daemons
@@ -9,6 +9,7 @@ Source1: %{name}.crontab
BuildRequires: rpm-pythonprov
BuildRequires: rpmbuild(macros) >= 1.268
Requires: crondaemon
+Requires: mount
Requires: python3
Requires: python3-modules
Requires: python3-psutil
@@ -34,12 +35,6 @@ cp -p %{SOURCE1} $RPM_BUILD_ROOT/etc/cron.d/linux-pstore
%clean
rm -rf $RPM_BUILD_ROOT
-%post
-if [ -d /sys/fs/pstore ]; then
- grep -qE "^none.*/sys/fs/pstore" %{_sysconfdir}/fstab || (echo -e "none\t\t/sys/fs/pstore\tpstore\tdefaults\t 0 0" >> %{_sysconfdir}/fstab && grep -q "/sys/fs/pstore" /proc/self/mounts || mount /sys/fs/pstore)
- exit 0
-fi
-
%files
%defattr(644,root,root,755)
%attr(755,root,root) %{_sbindir}/linux-pstore
diff --git a/linux-pstore.py b/linux-pstore.py
index ee8a647..c9c1d34 100755
--- a/linux-pstore.py
+++ b/linux-pstore.py
@@ -6,6 +6,8 @@ import os
import re
import socket
import shutil
+import subprocess
+import sys
import time
uptime = True
@@ -19,9 +21,23 @@ archivedir = '/var/log/pstore'
os.umask(0o077)
+def mount_pstore():
+ try:
+ if open('/proc/self/mounts', 'r').read().find('/sys/fs/pstore') >= 0:
+ return
+ subprocess.run(["/bin/mount", "none", "/sys/fs/pstore", "-t", "pstore"], timeout=60, check=True, capture_output=True, text=True)
+ except subprocess.CalledProcessError as e:
+ print("%s: %s\nstdout=%s\nstderr=%s" % (sys.argv[0], e, e.stdout, e.stderr), file=sys.stderr)
+ sys.exit(1)
+ except Exception as e:
+ print("%s: %s" % (sys.argv[0], e), file=sys.stderr)
+ sys.exit(1)
+
tdate = datetime.datetime.now().strftime("%Y-%m-%d")
tdir = os.path.join(archivedir, tdate)
+mount_pstore()
+
files = sorted(os.listdir(pstoredir))
if len(files) and not os.path.isdir(tdir):
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/linux-pstore.git/commitdiff/e4d4122ec705c5283d6b4c2a44bba68981ecfd5a
More information about the pld-cvs-commit
mailing list