Get parent of script call (may not be pacman)

Check for pre or post args, since no longer checking command. Update manpage.
This commit is contained in:
James Barnett 2017-03-19 21:05:16 -05:00
parent 613a1a3552
commit c41c294dba
No known key found for this signature in database
GPG key ID: E4B5E45AA3B8C5C3
2 changed files with 4 additions and 4 deletions

View file

@ -56,14 +56,14 @@ Default is "number".
.RS 4
snapper description used for the pacman pre snapshot.
Default is the pacman command that called the snapshot.
Default is the parent program (usually pacman) that called the snapshot script.
.RE
\fBPACMAN_POST_DESCRIPTION=\fR\fB\fIstring\fR\fR
.RS 4
snapper description used for the pacman post snapshot.
Default is the pacman command that called the snapshot.
Default is the parent program (usually pacman) that called the snapshot script.
.RE
The following setting can be changed in the snapper configuration file

View file

@ -24,7 +24,7 @@ declare -r SNAPPER_CONFIG_FILE=/etc/conf.d/snapper
declare -r DESC_LIMIT=48
declare -r name="snap-pac"
declare PACMAN_ABORT_ON_FAIL="no"
declare -r pacman_cmd="$(sed 's./usr/bin/pacman.pacman.g' <(ps -C pacman -o args=))"
declare -r pacman_cmd="$(ps -q $(ps -p "$$" -o ppid=) -o args=)"
declare -i x=0
declare -r pre_or_post=$1
@ -59,7 +59,7 @@ set_defaults() {
trap error_exit ERR
trap kill_exit SIGTERM SIGINT
[[ -z "$pacman_cmd" ]] && die "snap-pac should only be called via provided pacman hooks."
[[ "$pre_or_post" != "pre" ]] && [[ "$pre_or_post" != "post" ]] && die "First argument must be 'pre' or 'post'."
[[ ! -d /var/run/dbus ]] && die "No dbus available. Are you in a chroot environment?"
source "$SNAPPER_CONFIG_FILE"