v-delete-backup-host 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # info: delete backup ftp server
  3. # options: TYPE
  4. #
  5. # The function deletes ftp backup host
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. type=$1
  11. # Includes
  12. source $VESTA/func/main.sh
  13. source $VESTA/conf/vesta.conf
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. check_args '1' "$#" 'TYPE [HOST]'
  18. types=$(echo "$BACKUP_SYSTEM" |sed "s/,/\n/g" |grep "^$type$")
  19. if [ -z "$types" ]; then
  20. echo "Error: invalid backup type"
  21. log_event "$E_INVALID" "$ARGUMENTS"
  22. exit $E_INVALID
  23. fi
  24. #----------------------------------------------------------#
  25. # Action #
  26. #----------------------------------------------------------#
  27. # Deleting host config
  28. rm -f $VESTA/conf/$type.backup.conf
  29. #----------------------------------------------------------#
  30. # Vesta #
  31. #----------------------------------------------------------#
  32. # Updating vesta.conf
  33. bckp=$(echo "$BACKUP_SYSTEM" |\
  34. sed "s/,/\n/g"|\
  35. sed "s/^$type$//" |\
  36. sed "/^$/d"|\
  37. sed ':a;N;$!ba;s/\n/,/g')
  38. sed -i "s/BACKUP_SYSTEM=.*/BACKUP_SYSTEM='$bckp'/g" $VESTA/conf/vesta.conf
  39. # Logging
  40. log_event "$OK" "$ARGUMENTS"
  41. exit