From 8ba00007c1ddbce71dacd73afdc99e48069ce8e0 Mon Sep 17 00:00:00 2001 From: toni Date: Mon, 21 Apr 2014 13:27:25 +0200 Subject: added activate/deactivate feature --- debian/changelog | 6 ++++++ debian/postinst | 37 ++++++++++++++++++++++++++++++++++++- debian/postrm | 4 +++- debian/prerm | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 debian/prerm diff --git a/debian/changelog b/debian/changelog index e65cd6d..4bccde7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +naskpass (1.0-2) unstable; urgency=low + + * fixed some minor issues + + -- Toni Uhlig Mon, 21 Apr 2014 11:50:15 +0200 + naskpass (1.0-1) unstable; urgency=low * replaced getch with ncurses wgetch diff --git a/debian/postinst b/debian/postinst index 6416e3e..0008ec4 100644 --- a/debian/postinst +++ b/debian/postinst @@ -9,9 +9,11 @@ set -e export RDSUM="5924c70e5c9fabf0398050349c3f4f283ab80091b23ea8c677249ee7bdd41f6e4910ce5e1bc32577e67763dc30d9b96cc3528256e1cc63dba959a5e3866ec21f" export ORGFILE="/usr/share/initramfs-tools/scripts/local-top/cryptroot" export DIVFILE="/usr/share/naskpass/cryptroot.orig" +export BCKFILE="/var/backup/cryptroot.naskpass" case "$1" in install) + rm -f ${BCKFILE} mkdir -p /usr/share/naskpass if [ ! -f ${ORGFILE} ]; then whiptail --title "Missing file" --msgbox "/usr/share/initramfs-tools/scripts/local-top/cryptroot is missing!\nabort .." 9 70 @@ -24,7 +26,40 @@ case "$1" in fi ;; - upgrade|configure) + configure) + if [ ${RDSUM} = "$(sha512sum ${ORGFILE} | grep -Eo '^[0-9a-zA-Z]*')" ]; then + active=0 + text="NOT active. Activate?" + else + active=1 + text="active. Deactivate?" + fi + whiptail --yesno "naskpass is $text" --yes-button "Yes" --no-button "No" 10 70 + choice=$? + case ${choice} in + 0) + if [ ${active} -eq 0 ]; then + echo "Activating naskpass .." >&2 + dpkg-divert --package naskpass --divert ${DIVFILE} --rename --add ${ORGFILE} + mv ${BCKFILE} ${ORGFILE} + elif [ ${active} -eq 1 ]; then + echo "Deactivating naskpass .." >&2 + mv ${ORGFILE} ${BCKFILE} + dpkg-divert --package naskpass --remove --rename ${ORGFILE} || true + else + echo "Doin' nothing .." >&2 + fi + ;; + 1) + echo "Keeping naskpass' status .." >&2 + ;; + -1|*) + echo "Unknown whiptail error occured .." >&2 + ;; + esac + ;; + + upgrade) update-initramfs -u ;; diff --git a/debian/postrm b/debian/postrm index 12bde65..6de4a05 100644 --- a/debian/postrm +++ b/debian/postrm @@ -7,12 +7,14 @@ set -e export ORGFILE="/usr/share/initramfs-tools/scripts/local-top/cryptroot" +export BCKFILE="/var/backup/cryptroot.naskpass" case "$1" in purge) + rm -f ${BCKFILE} ;; remove) - dpkg-divert --package naskpass --remove --rename ${ORGFILE} + dpkg-divert --package naskpass --remove --rename ${ORGFILE} || true update-initramfs -u ;; upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 0000000..6bb1ac9 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,33 @@ +#!/bin/sh +# postrm script for naskpass +# +# see: dh_installdeb(1) + +set -e + + +export ORGFILE="/usr/share/initramfs-tools/scripts/local-top/cryptroot" +export BCKFILE="/var/backup/cryptroot.naskpass" + +case "$1" in + purge|remove) + dpkg-divert --package naskpass --divert ${DIVFILE} --rename --add ${ORGFILE} || true + if [ -r ${BCKFILE} ]; then + mv ${BCKFILE} ${ORGFILE} + fi + ;; + upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 -- cgit v1.2.3