Scripts to automating daily tasks http://gitea.open6hosting.com/Open6Hosting/smartos-bin
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 line
1.4 KiB

  1. #!/bin/bash
  2. usage()
  3. {
  4. echo "Usage: $0 -z UUID -h NODE -d DIR -p PORT -i KEY -s STORAGEBOX -u USER" >&2
  5. exit 1
  6. }
  7. while getopts "z:h:d:p:i:s:u:" opt;
  8. do
  9. case "$opt" in
  10. z)
  11. UUID=$OPTARG
  12. ;;
  13. h)
  14. NODE=$OPTARG
  15. ;;
  16. d)
  17. DIR=$OPTARG
  18. ;;
  19. p)
  20. PORT=$OPTARG
  21. ;;
  22. i)
  23. KEY=$OPTARG
  24. ;;
  25. s)
  26. STORAGEBOX=$OPTARG
  27. ;;
  28. u)
  29. USER=$OPTARG
  30. ;;
  31. \?)
  32. echo "Error: Invalid Option: -${OPTARG}" >&2
  33. usage
  34. ;;
  35. :)
  36. echo "Error: -${OPTARG} requires an argument."
  37. usage
  38. ;;
  39. *)
  40. usage
  41. ;;
  42. esac
  43. done
  44. shift $((OPTIND-1))
  45. if [ -z "${UUID}" ] || [ -z "${NODE}" ] || [ -z "${DIR}" ] || [ -z "${PORT}" ] || [ -z "${KEY}" ] || [ -z "${STORAGEBOX}" ] || [ -z "${USER}" ]; then
  46. usage
  47. fi
  48. VPS=$UUID
  49. #ssh -p ${PORT} -i ${KEY} -l ${USER} ${STORAGEBOX} ls -hl ${DIR}/${NODE}/${VPS}/${VPS}.zfs | awk '{ print "size;"$5",date;"$7,$6,$8 }' | tr -d '\n'
  50. SIZE="$(ssh -p ${PORT} -i ${KEY} -l ${USER} ${STORAGEBOX} du -h ${DIR}/${NODE}/${VPS}/${VPS}.zfs | awk '{ print $1 }' | tr -d '\n')"
  51. DATE="$(ssh -p ${PORT} -i ${KEY} -l ${USER} ${STORAGEBOX} ls -l ${DIR}/${NODE}/${VPS}/${VPS}.zfs | awk '{ print $7,$6,$8 }' | tr -d '\n')"
  52. echo "size; ${SIZE},date; ${DATE}" | tr -d '\n'