#!/bin/sh

if ! grep -q "# cifs mount backups" /etc/fstab; then
    echo "modifying fstab..."
    cp /etc/fstab /etc/fstab.$(date +"%H-%M-%S_%d-%m-%y").bak
    . /etc/ixvd/secrets/backups.cifs
cat<<EOF >>/etc/fstab
# cifs mount backups
//$domain/backup  /mnt/backups  cifs  credentials=/etc/ixvd/secrets/backups.cifs,file_mode=0777,dir_mode=0777,noperm 0       0
EOF
fi

if ! [ -d "/mnt/backups" ]; then
    echo "mounting share..."
    mkdir /mnt/backups
    mount /mnt/backups
fi