From 7d981ff6fd0254d76595716ebf01cb90d654ae00 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Fri, 3 Feb 2017 08:42:43 -0600 Subject: [PATCH] add removal to main script --- hooks/10_snap-pac-removal.hook | 2 +- scripts/snap-pac | 7 +++-- scripts/snap-pac-remove | 49 ---------------------------------- 3 files changed, 6 insertions(+), 52 deletions(-) delete mode 100755 scripts/snap-pac-remove diff --git a/hooks/10_snap-pac-removal.hook b/hooks/10_snap-pac-removal.hook index 514c886..6ca9aae 100644 --- a/hooks/10_snap-pac-removal.hook +++ b/hooks/10_snap-pac-removal.hook @@ -25,4 +25,4 @@ Target = snap-pac Description = NOTE: You are removing snap-pac. No post transaction snapshots will be taken. Depends = snap-pac When = PreTransaction -Exec = /usr/share/libalpm/scripts/snap-pac-remove +Exec = /usr/share/libalpm/scripts/snap-pac rem diff --git a/scripts/snap-pac b/scripts/snap-pac index 2433570..136db60 100755 --- a/scripts/snap-pac +++ b/scripts/snap-pac @@ -85,8 +85,8 @@ if [[ $# -ne 1 ]]; then fi fi -if [[ $1 != "pre" ]] && [[ $1 != "post" ]]; then - printf "%b First argument should either be 'pre' or 'post'.\n" "$ERRORMSG" +if [[ $1 != "pre" ]] && [[ $1 != "post" ]] && [[ $1 != "rem" ]]; then + printf "%b First argument should either be 'pre', 'post', or 'rem'.\n" "$ERRORMSG" if [[ $PACMAN_ABORT_ON_FAIL == "yes" ]]; then exit 1 else @@ -138,6 +138,9 @@ for CONFIG in $SNAPPER_CONFIGS; do if [[ "$pre_or_post" == "pre" ]]; then $snapper_cmd --description "$PACMAN_PRE_DESCRIPTION" --print-number > "$prefile" printf "%s %s\n" "$(< "$prefile")" "$checkmark" + elif [[ "$pre_or_post" == "rem" && -f "$prefile" ]]; then + printf "N/A\n" + rm "$prefile" elif [[ -f $prefile ]]; then postnum=$($snapper_cmd --description "$PACMAN_POST_DESCRIPTION" --print-number --pre-number "$(< "$prefile")") printf "%s %s\n" "$postnum" "$checkmark" diff --git a/scripts/snap-pac-remove b/scripts/snap-pac-remove deleted file mode 100755 index 8cd6dd7..0000000 --- a/scripts/snap-pac-remove +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash - -# snap-pac -# https://github.com/wesbarnett/snap-pac -# Copyright (C) 2016 James W. Barnett - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Removes file that stores pre number when snap-pac is removed. - -set -e - -SNAPPER_CONFIG_FILE=/etc/conf.d/snapper - -ERRORMSG="\033[00;31mERROR:\033[00m" - -if [[ $EUID -ne 0 ]]; then - echo -e "$ERRORMSG Script must be run as root." - exit 1 -fi - -if [[ -f "$SNAPPER_CONFIG_FILE" ]]; then - source "$SNAPPER_CONFIG_FILE" -else - exit 1 -fi - -for CONFIG in $SNAPPER_CONFIGS; do - - prefile="/tmp/snap-pac-pre_$CONFIG" - if [[ -f "$prefile" ]]; then - rm "$prefile" - fi - -done - -exit 0