瀏覽代碼

Update entrypoint.sh

Stefan Pejcic 1 年之前
父節點
當前提交
e3e1e17859
共有 1 個文件被更改,包括 14 次插入5 次删除
  1. 14 5
      docker/nginx/entrypoint.sh

+ 14 - 5
docker/nginx/entrypoint.sh

@@ -1,14 +1,15 @@
 #!/bin/bash
 echo "Container is starting..."
 
-# Get the current container's IP address
-CONTAINER_IP=$(hostname -i)
 
-# Get the container's gateway IP address
+: '
+CONFIGURATION
+On restart grant sudo if set, store random ip
+'
+CONTAINER_IP=$(hostname -i)
 GATEWAY_IP=$(ip route | awk '/default/ { print $3 }')
-
-# Old IP address to be replaced on docker run
 OLD_IP="tst"
+SUDO="NO"
 
 
 : '
@@ -120,5 +121,13 @@ else
 fi
 
 
+
+
+# sudo
+if grep -q 'SUDO="YES"' /etc/entrypoint.sh; then
+    # Add user with UID 1000 to the sudo group
+    usermod -aG sudo -u 1000 $(getent passwd 1000 | cut -d: -f1)
+fi
+
 # Save the current IP for reuse
 sed -i "s/$OLD_IP/$CONTAINER_IP/g" "$0"