-
Notifications
You must be signed in to change notification settings - Fork 27
/
fc-cache.sh
executable file
·60 lines (52 loc) · 989 Bytes
/
fc-cache.sh
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#! /bin/sh
SUDO_WHICH=0
SUDO=0
DOAS_WHICH=0
DOAS=1
ROOT=0
# CHECK doas(8) WITH which(1)
if which doas 1> /dev/null 2> /dev/null
then
DOAS_WHICH=1
else
DOAS_WHICH=0
fi
# CHECK sudo(8) WITH which(1)
if which sudo 1> /dev/null 2> /dev/null
then
SUDO_WHICH=1
else
SUDO_WHICH=0
fi
# CHECK USER WITH whoami(1)
if [ "$( whoami )" = "root" ]
then
ROOT=1
fi
# CHOOSE ONE FROM doas(8) AND sudo(8)
if [ ${DOAS_WHICH} -eq 1 -o ${SUDO_WHICH} -eq 1 ]
then
if [ ${DOAS} -eq 0 -a ${SUDO} -eq 1 -a ${SUDO_WHICH} -eq 1 ]
then
CMD=sudo
elif [ ${DOAS} -eq 1 -a ${SUDO} -eq 0 -a ${DOAS_WHICH} -eq 1 ]
then
CMD=doas
elif [ ${DOAS} -eq 1 -a ${SUDO} -eq 1 -a ${DOAS_WHICH} -eq 1 ]
then
CMD=doas
fi
elif [ ${ROOT} -eq 1 ]
then
CMD=''
else
echo "NOPE: This script needs 'doas' or 'sudo' to work properly."
exit 1
fi
unset SUDO_WHICH
unset DOAS_WHICH
unset ROOT
echo "Reload SYSTEM Font Cache ..."
${CMD} fc-cache -sf
echo "Reload USER Font Cache ..."
fc-cache -f