add removal to main script
This commit is contained in:
parent
439f925abf
commit
7d981ff6fd
3 changed files with 6 additions and 52 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Add table
Reference in a new issue