From a7429f8838cc66e627b8f416c4f056ebf2de3fd9 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Wed, 31 Aug 2016 20:27:31 -0500 Subject: [PATCH] add snap-pac-remove --- ...-removal.hook => 10_snap-pac-removal.hook} | 2 +- scripts/snap-pac-remove | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) rename hooks/{00_snap-pac-removal.hook => 10_snap-pac-removal.hook} (95%) create mode 100755 scripts/snap-pac-remove diff --git a/hooks/00_snap-pac-removal.hook b/hooks/10_snap-pac-removal.hook similarity index 95% rename from hooks/00_snap-pac-removal.hook rename to hooks/10_snap-pac-removal.hook index aaabf28..eb636f6 100644 --- a/hooks/00_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/bin/true +Exec = /usr/share/libalpm/script/snap-pac-remove diff --git a/scripts/snap-pac-remove b/scripts/snap-pac-remove new file mode 100755 index 0000000..6ff81f6 --- /dev/null +++ b/scripts/snap-pac-remove @@ -0,0 +1,50 @@ +#!/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. + +# Main script. + +set -e + +SNAPPER_CONFIG_FILE=/etc/conf.d/snapper + +ERRORMSG="\033[00;31mERROR:\033[00m" +WARNINGMSG="\033[00;33mWARNING:\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