Skip to content

Commit 3c90732

Browse files
committed
Add the -t/-T option to run pacdiff with --threeway
If pacdiff is run via `-p` (default), one can use `-t/-T` to respective enable/disable the `--threeway` option for it. Defaults to `-T` (disable). Closes #98
1 parent 00892ab commit 3c90732

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

admin/checkservices

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ fi
4747
AUTOCONFIRM=0 # autoconfirmation
4848
FAILED=1 # display failed service at the end
4949
PACDIFF=1 # run pacdiff
50+
THREEWAY=0 # run pacdiff with --threeway
5051
RELOAD=1 # reload systemd
5152
RESTART=1 # restart services
5253
SERIALIZE=0 # run in parallel
@@ -260,6 +261,7 @@ usage() {
260261
echo " -l/-L: call systemd daemon-(reload|reexec) (default: -l / $RELOAD)" >&2
261262
echo " -f/-F: display failed services before quit (default: -f / $FAILED)" >&2
262263
echo " -p/-P: call pacdiff before act (default: -p / $PACDIFF)" >&2
264+
echo " -t/-T: view diffs in 3-way fashion with pacdiff (default: -T / $THREEWAY)" >&2
263265
echo " -r/-R: restart services with updated files (default: -r / $RESTART)" >&2
264266
echo " -s/-S: display status of restarted service (default: -s / $STATUS)" >&2
265267
echo " -u/-U: act on services in users slice (default: -U / $USER_SLICE)" >&2
@@ -273,14 +275,15 @@ usage() {
273275
# set options as global vars
274276
argparse() {
275277
local opt
276-
while getopts 'AahFfLlPpRrSsUuMmZzi:' opt; do
278+
while getopts 'AahFfLlPpRrSsTtUuMmZzi:' opt; do
277279
case $opt in
278280
A) AUTOCONFIRM=0;; a) AUTOCONFIRM=1;;
279281
F) FAILED=0;; f) FAILED=1;;
280282
L) RELOAD=0;; l) RELOAD=1;;
281283
P) PACDIFF=0;; p) PACDIFF=1;;
282284
R) RESTART=0;; r) RESTART=1;;
283285
S) STATUS=0;; s) STATUS=1;;
286+
T) THREEWAY=0;; t) THREEWAY=1;;
284287
U) USER_SLICE=0;; u) USER_SLICE=1;;
285288
M) MACHINE_SLICE=0;; m) MACHINE_SLICE=1;;
286289
Z) SERIALIZE=0;; z) SERIALIZE=1;;
@@ -308,10 +311,19 @@ main() {
308311
# from now, we need to be root
309312
(( UID != 0 )) && error 'You need to be root' && exit 1
310313

311-
# call pacdiff to ensure config files are updated before restart
314+
# call pacdiff unless explicitly disabled to ensure config files are updated before restart
312315
if (( PACDIFF )); then
313316
arrow 'Run pacdiff'
314-
pacdiff
317+
if command -v pacdiff &> /dev/null ; then
318+
arrow 'Run pacdiff'
319+
if (( THREEWAY )); then
320+
pacdiff --threeway
321+
else
322+
pacdiff
323+
fi
324+
else
325+
warn 'skipping pacdiff as not installed'
326+
fi
315327
fi
316328

317329
# ensure systemd has been reloaded or reexectued
@@ -356,12 +368,6 @@ main() {
356368
fi
357369
}
358370

359-
# disable pacdiff by default if not installed
360-
if ! command -v pacdiff &> /dev/null ; then
361-
warn 'skipping pacdiff as not installed'
362-
PACDIFF=0
363-
fi
364-
365371
main "$@"
366372

367373
exit 0

0 commit comments

Comments
 (0)