Advertisement
marietto2020

Untitled

Jun 10th, 2021 (edited)
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.36 KB | None | 0 0
  1. this is what happens :
  2.  
  3. root@Z390-AORUS-PRO:/home/ziomario/Scrivania/Virt/dockers/ziomario-docker# ./run.sh
  4.  
  5. Hello, whats your user name ?mario
  6.  
  7. mario
  8.  
  9. No qcow2 Filesystem detected at /home/mario/budgieVM.qcow2!
  10.  
  11. No zipped Filesystem detected at /home/mario/budgieVM.zip!
  12.  
  13.  
  14. you knoow why ? I imagine that the reason is because the value of $username is empty.
  15.  
  16.  
  17. VOLUME /home/$username
  18.  
  19. COPY start.sh /start.sh
  20.  
  21. ENTRYPOINT \["/start.sh"\]
  22.  
  23. it's the same if I do :
  24.  
  25. VOLUME /home
  26.  
  27. COPY start.sh /start.sh
  28.  
  29. ENTRYPOINT \["/start.sh"\]
  30.  
  31. because it copies the file on /home,but I want it on /home/$username
  32.  
  33.  
  34. let's recap. this is how is configured everything :
  35.  
  36.  
  37. Dockerfile
  38.  
  39.  
  40. RUN chmod +x /usr/local/bin/firefox && \
  41. echo "$username:x:1000:1000:Usernames,,,:/home/$username:/bin/bash" >> /etc/passwd && \
  42. echo "$username:x:1000:" >> /etc/group && \
  43. echo "$username ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d && \
  44. chmod 0440 /etc/sudoers.d && \
  45. chown $username:$username -R /home/$username
  46.  
  47. ARG FILESYSTEM_IMAGE_URL="http://ziomario.ns0.it/budgieVM.zip"
  48. ADD $FILESYSTEM_IMAGE_URL /home/$username/budgieVM.zip
  49.  
  50. VOLUME /home
  51.  
  52. COPY start.sh /start.sh
  53. ENTRYPOINT ["/start.sh"]
  54.  
  55.  
  56. start.sh
  57.  
  58.  
  59. /bin/bash
  60.  
  61. #rm hostusername 2> /dev/null
  62. hostusername=$(whoami)
  63. echo $hostusername
  64. #echo "$hostusername" > "hostusername"
  65.  
  66. #rm username 2> /dev/null
  67. echo -n " Hello, whats your username ?"
  68. read -r
  69. username=$REPLY
  70. echo $username
  71. #echo "$username" > "username"
  72.  
  73. mkdir -p /home/$username
  74.  
  75. image_path="/home/$username/budgieVM.qcow2"
  76. zip_path="/home/$username/budgieVM.zip"
  77.  
  78. if [ ! -e $image_path ]; then
  79. echo "No qcow2 Filesystem detected at ${image_path}!"
  80. if [ -e $zip_path ]; then
  81. echo "Extracting fresh filesystem..."
  82. unzip $zip_path
  83. mv -- *.img $image_path
  84. else
  85. echo "No zipped Filesystem detected at ${zip_path}!"
  86. exit 1
  87. fi
  88. fi
  89. echo "Extracting fresh filesystem..."
  90.  
  91. #!/bin/bash
  92.  
  93.  
  94. run.sh
  95.  
  96.  
  97. XSOCK=/tmp/.X11-unix
  98. XAUTH=/tmp/.docker.xauth
  99. touch $XAUTH
  100. xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
  101.  
  102. docker run \
  103. --gpus all \
  104. --rm -it \
  105. -v $XSOCK:$XSOCK:rw \
  106. -v $XAUTH:$XAUTH:rw \
  107. -e DISPLAY=$DISPLAY \
  108. -e XAUTHORITY=$XAUTH \
  109. -v /:/home/$username/Shared-$hostusername \
  110. -t ziomario/docker
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement