check deps removed

This commit is contained in:
Ste Vaidis 2022-12-24 18:56:31 +02:00
parent 9e1a065f6e
commit 78fddc8358

View File

@ -39,7 +39,7 @@ function find_usb() {
for DISK in `ls -l /dev/disk/by-id/usb* | grep -v part | awk -F/ '{print $NF}'`; do for DISK in `ls -l /dev/disk/by-id/usb* | grep -v part | awk -F/ '{print $NF}'`; do
DEV="/dev/$DISK" DEV="/dev/$DISK"
for PARTITION in `ls -1 $DEV* | grep "[0-9]$"`; do for PARTITION in `ls -1 $DEV* | grep "[0-9]$"`; do
cryptsetup isLuks $PARTITION /usr/sbin/cryptsetup isLuks $PARTITION
if [ $? = 0 ]; then if [ $? = 0 ]; then
USB_PARTITION=$PARTITION USB_PARTITION=$PARTITION
return 0 return 0
@ -53,7 +53,7 @@ function find_usb() {
} }
function mount_usb() { function mount_usb() {
echo $LUKS_PASS | cryptsetup luksOpen $USB_PARTITION crypted_usb echo $LUKS_PASS | /usr/sbin/cryptsetup luksOpen $USB_PARTITION crypted_usb
if [ $? = 0 ]; then if [ $? = 0 ]; then
log "[ OK ] $USB_PARTITION decrypted" log "[ OK ] $USB_PARTITION decrypted"
/usr/bin/mount /dev/mapper/crypted_usb /mnt/usb /usr/bin/mount /dev/mapper/crypted_usb /mnt/usb
@ -181,17 +181,6 @@ function umount() {
exit exit
} }
function check_depentencies() {
commands=(rsync cryptsetup curl jq)
for command in "${commands[@]}"
do
if ! command -v ${command} > /dev/null; then
log "Command $command not found"
exit
fi
done
}
function send_mail() { function send_mail() {
COPIED=$( cat ${LOG} | grep "Number of created files:" | awk {'print $5'} ) COPIED=$( cat ${LOG} | grep "Number of created files:" | awk {'print $5'} )
DELETED=$( cat ${LOG} | grep "Number of deleted files:" | awk {'print $5'} ) DELETED=$( cat ${LOG} | grep "Number of deleted files:" | awk {'print $5'} )
@ -207,16 +196,14 @@ function main () {
log "DESTINATION : $USB_MOUNT$DST" log "DESTINATION : $USB_MOUNT$DST"
log "WITH DELETE : ${DELETE:-"No (default)"}" log "WITH DELETE : ${DELETE:-"No (default)"}"
log "" log ""
if check_depentencies; then if get_luks_password; then
if get_luks_password; then if find_usb; then
if find_usb; then if mount_usb; then
if mount_usb; then sync_files
sync_files
fi
statistics_usb
umount_usb
send_mail
fi fi
statistics_usb
umount_usb
send_mail
fi fi
fi fi
} }