#!/usr/bin/bash
# removal only, not running before update
systemctl stop cryptoboned
systemctl disable cryptoboned
systemctl stop cryptoboneexternd
systemctl disable cryptoboneexternd
systemctl stop cryptobone-fetch.timer
systemctl disable cryptobone-fetch.timer
umount /usr/lib/cryptobone/keys 2> /dev/null
rm -f /etc/sudoers.d/cbcontrol
if [ -f /usr/lib/cryptobone/bootswitch ] ; then
     chattr -i /usr/lib/cryptobone/bootswitch
fi
rm -rf /dev/shm/RAM 2>/dev/null
rm -rf /dev/shm/EXRAM 2>/dev/null

/usr/sbin/userdel cryptobone
# delete all config files in main cryptobone directory
rm -rf /usr/lib/cryptobone/keys/* 2> /dev/null
rm -rf /usr/lib/cryptobone/cryptobone/* 2> /dev/null
rm -f /usr/lib/cryptobone/database* 2> /dev/null
rm -f /usr/lib/cryptobone/cbb.config 2> /dev/null
rm -f /usr/lib/cryptobone/bootswitch 2> /dev/null
rm -f /usr/lib/cryptobone/keys.tgz 2> /dev/null
rm -f /usr/lib/cryptobone/masterkey 2> /dev/null

exit 0
