Guest User

Untitled

a guest
Feb 28th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. set -xeu
  4.  
  5. echo "No, really, don't do this."
  6. exit -1
  7.  
  8. # !!!
  9. # This will likely corrupt your Azure Cloud Shell stateful home directory.
  10. # You should not do this with a Cloud Shell (or Azure File Share) that you care about.
  11. # !!!
  12.  
  13. # This will have mounted the home dir of your Azure cloud shell locally.
  14. # This requires an SSH proxy VM in your File Share region.
  15. # When I tested, somewhat expectedly, changes made locally were not reflected in my browser
  16. # Azure Cloud Shell instance until I closed it and let it be recreated (I assume a Pod
  17. # was recycled, and the cifs mount was detached/reattached...)
  18.  
  19. MNT_POINT="$HOME/az/azure_share"
  20. MNT_POINT2="$HOME/az/azure_share_inner"
  21. MNT_POINT3="$HOME/az/azure_share_inner_bindfs"
  22.  
  23. sudo umount -lf "${MNT_POINT3}" || true
  24. sudo umount -lf "${MNT_POINT2}" || true
  25. sudo umount -lf "${MNT_POINT}" || true
  26. rm -rf "${MNT_POINT}" "${MNT_POINT2}" "${MNT_POINT3}"
  27. mkdir -p "${MNT_POINT}" "${MNT_POINT2}" "${MNT_POINT3}"
  28.  
  29. SSH_PUBLIC_KEY="$HOME/.azure/id_rsa"
  30.  
  31. # Booted with:
  32. # az group create --name "test" --location "westus" # note loc must be same as cloud shell file share loc
  33. # az vm create --name "test" --image "coreos" --admin-username "${USERNAME}" --ssh-key "${SSH_PUBLIC_KEY}"
  34. PROXY_VM_IP="13.91.104.38"
  35.  
  36. SHARE_NAME="cs-cole-mickens-gmail-com-10033fff877a6a35"
  37. SHARE_USERNAME="cs4aff271eee9bex4441xb9b"
  38. SHARE_PASSWORD="REDACTED"
  39.  
  40. sudo ssh -N -i "${SSH_PUBLIC_KEY}" \
  41. -L "138:${SHARE_USERNAME}.file.core.windows.net:138" \
  42. -L "139:${SHARE_USERNAME}.file.core.windows.net:139" \
  43. -L "445:${SHARE_USERNAME}.file.core.windows.net:445" \
  44. "${USERNAME}@${PROXY_VM_IP}" &
  45.  
  46. sudo mount \
  47. -t cifs \
  48. "//127.0.0.1/${SHARE_NAME}" \
  49. "${MNT_POINT}" \
  50. -o "vers=3.0,username=${SHARE_USERNAME},password=${SHARE_PASSWORD},dir_mode=0777,file_mode=0777,sec=ntlmssp"
  51.  
  52. sudo mount "${MNT_POINT}/.cloudconsole/acc_${USERNAME}.img" "${MNT_POINT2}"
  53. sudo bindfs -u "${USERNAME}" "${MNT_POINT2}" "${MNT_POINT3}"
Add Comment
Please, Sign In to add comment