-
Notifications
You must be signed in to change notification settings - Fork 5
/
eos-config-journal
executable file
·35 lines (29 loc) · 1.05 KB
/
eos-config-journal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash -e
# Copyright (C) 2018 Endless Technologies, Inc.
# Licensed under the GPLv2
parentdir=/var/log
# if this dir exists, the journal will be persistently stored to it
JOURNALDIR=$parentdir/journal
blockerfile=$parentdir/.no_journal_on_fragile_storage
cmdname=${0##*/}
# get the device which will hold the journal
device=$(df --output=source $parentdir | tail -n 1)
# will contain non-empty string if this device is an MMC or SD device (both of
# which are susceptible to damage with excessive writing)
subsystem=$(lsblk --noheading -o SUBSYSTEMS --inverse "$device" | grep '^block:mmc' \
|| true)
if [ "x$subsystem" != "x" ]; then
echo "$cmdname: not enabling persistent journal: non-durable storage" \
"(MMC or SD)"
touch $blockerfile
exit 0
fi
if [ -e $blockerfile ]; then
echo "$cmdname: not enabling persistent journal: $blockerfile exists"
exit 0
fi
if [ ! -d $JOURNALDIR ]; then
echo "$cmdname: enabling persistent journal on durable storage"
mkdir $JOURNALDIR
systemd-tmpfiles --create --prefix $JOURNALDIR
fi