From 55b1d6b508a8cf32511b77ce6deec30c6ef1aa76 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 11 Oct 2023 15:20:55 +0200 Subject: [SSPS] Cleanup cleanup, fix wrong "...failed" messages The error checking was broken when the file to delete does not exist. Remove the exists-check entirely as it's pointless with rm -f. --- satellit_installer/includes/99-clean_install.inc | 30 +++++++----------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/satellit_installer/includes/99-clean_install.inc b/satellit_installer/includes/99-clean_install.inc index 952d4fe..84bf85b 100644 --- a/satellit_installer/includes/99-clean_install.inc +++ b/satellit_installer/includes/99-clean_install.inc @@ -1,34 +1,20 @@ # Functions for cleaning some stuff after script run clean_logfiles() { - # delete only files, not directories - find /var/log -type f -delete - ERR=$? - [ $ERR -eq 0 ] && echo " ok." || echo " error cleaning log files." + echo "# cleaning log files ..." + find /var/log -type f -delete \ + || pwarning " error cleaning log files." } -clean_authorized_hosts() { - [ -f /root/.ssh/authorized_keys ] && rm -f /root/.ssh/authorized_keys - ERR=$? - [ $ERR -eq 0 ] && echo " ok." || echo " error cleaning authorized keys file." -} -clean_idrsa() { - [ -f /root/.ssh/id_rsa ] && rm -f /root/.ssh/id_rsa # rsa will suffice for our git keys - ERR=$? - [ $ERR -eq 0 ] && echo " ok." || echo " error cleaning id_rsa identity file." +clean_root_ssh() { + echo "# wiping root's .ssh dir ..." + rm -rf -- /root/.ssh || pwarning "Error wiping root's .ssh dir" } clean_install() { GESERR=0 - echo "#" - echo "# Now, let's clean some unnecessary or harmful entries, e.g. " - echo "# entries in authorized_hosts, .bash_history and files beneath /var/log." - echo "#" - echo -n "# cleaning authorized_hosts ..." - clean_authorized_hosts - echo -n "# cleaning id_rsa private key ..." - clean_idrsa - echo -n "# cleaning log files ..." + echo "# Cleanup" + clean_root_ssh clean_logfiles } -- cgit v1.2.3-55-g7522