configmap.yaml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. ---
  2. apiVersion: v1
  3. kind: ConfigMap
  4. metadata:
  5. name: rsync-configuration
  6. immutable: true
  7. data:
  8. rsyncd.conf: |
  9. uid = 0
  10. gid = 0
  11. [downloads]
  12. read only = no
  13. path = /downloads
  14. ---
  15. apiVersion: v1
  16. kind: ConfigMap
  17. metadata:
  18. name: script
  19. immutable: true
  20. data:
  21. script.sh: |
  22. #!/bin/sh
  23. set -e
  24. download()
  25. {
  26. while [ ! -e /downloads/youtube-dl.txt ]
  27. do
  28. sleep 15
  29. done
  30. entr -r /downloads/youtube-dl.txt | youtube-dl --batch-file /downloads/youtube-dl.txt
  31. rm /downloads/youtube-dl.txt
  32. }
  33. download
  34. ---
  35. apiVersion: v1
  36. kind: ConfigMap
  37. metadata:
  38. name: youtube-dl-configuration
  39. immutable: true
  40. data:
  41. youtube-dl.conf: |
  42. --force-ipv4 --restrict-filenames --output %(title)s.%(ext)s
  43. ---
  44. apiVersion: v1
  45. kind: ConfigMap
  46. metadata:
  47. name: python-http-server
  48. immutable: true
  49. data:
  50. python-http-server.py: |
  51. #!/usr/bin/env python
  52. """Extend Python's built in HTTP server to save files
  53. curl or wget can be used to send files with options similar to the following
  54. curl -X PUT --upload-file somefile.txt http://localhost:8000
  55. wget -O- --method=PUT --body-file=somefile.txt http://localhost:8000/somefile.txt
  56. __Note__: curl automatically appends the filename onto the end of the URL so
  57. the path can be omitted.
  58. Windows upload & download
  59. powershell -ep bypass -c "$wc=New-Object Net.WebClient;$wc.UploadFile('http://target.com/upload.bin', 'PUT', 'c:\\upload.bin');"
  60. powershell -ep bypass -c "$wc=New-Object Net.WebClient;$wc.DownloadFile('http://target.com/download.bin','c:\\download.bin');"
  61. Linux upload & download
  62. curl -X PUT --upload-file upload.bin http://target.com/upload.bin
  63. wget -O- --method=PUT --body-file=upload.bin http://target.com/upload.bin
  64. wget http://target.com/download.bin -O /tmp/download.bin
  65. curl http://target.com/download.bin -o /tmp/download.bin
  66. """
  67. import os
  68. try:
  69. import http.server as server
  70. except ImportError:
  71. # Handle Python 2.x
  72. import SimpleHTTPServer as server
  73. class HTTPRequestHandler(server.SimpleHTTPRequestHandler):
  74. """Extend SimpleHTTPRequestHandler to handle PUT requests"""
  75. def do_PUT(self):
  76. """Save a file following a HTTP PUT request"""
  77. filename = os.path.basename(self.path)
  78. # Don't overwrite files
  79. if os.path.exists(filename):
  80. self.send_response(409, 'Conflict')
  81. self.end_headers()
  82. reply_body = '"%s" already exists\n' % filename
  83. self.wfile.write(reply_body.encode('utf-8'))
  84. return
  85. file_length = int(self.headers['Content-Length'])
  86. read = 0
  87. with open(filename, 'wb+') as output_file:
  88. while read < file_length:
  89. new_read = self.rfile.read(min(66556, file_length - read))
  90. read += len(new_read)
  91. output_file.write(new_read)
  92. self.send_response(201, 'Created')
  93. self.end_headers()
  94. reply_body = 'Saved "%s"\n' % filename
  95. self.wfile.write(reply_body.encode('utf-8'))
  96. def do_GET(self):
  97. self.send_response(404, 'Not Found')
  98. self.end_headers()
  99. self.wfile.write(b'')
  100. if __name__ == '__main__':
  101. server.test(HandlerClass=HTTPRequestHandler)