Browse Source

Create /home/csa and register uid

Suren A. Chilingaryan 6 năm trước cách đây
mục cha
commit
9afb5dca0e
3 tập tin đã thay đổi với 25 bổ sung4 xóa
  1. 6 2
      Dockerfile
  2. 12 0
      docker-entrypoint.sh
  3. 7 2
      sx.sh

+ 6 - 2
Dockerfile

@@ -18,10 +18,14 @@ RUN yum -y install \
            kubernetes-client \
            && yum clean all
 
-
-
 COPY sx.sh /bin/sx
 RUN chmod 775 /bin/sx
 
+# For ugly applications which want to resolve user name
+RUN chmod g=u /etc/passwd
+
+COPY docker-entrypoint.sh /
+ENTRYPOINT ["/docker-entrypoint.sh"]
+
 CMD [ "/bin/sx" ]
 

+ 12 - 0
docker-entrypoint.sh

@@ -0,0 +1,12 @@
+#! /bin/bash
+
+set -e
+
+if ! whoami &> /dev/null; then
+  if [ -w /etc/passwd ]; then
+    echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:${HOME}:/sbin/nologin" >> /etc/passwd
+  fi
+fi
+
+echo "Running: $@"
+exec "$@"

+ 7 - 2
sx.sh

@@ -8,6 +8,7 @@ function display_container_header {
     echo "| OS          : $(</etc/redhat-release)"
     echo "| kubernetes  : $KUBERNETES_SERVICE_HOST"
     echo "| user        : $(whoami)"
+    echo "| home        : $HOME
     echo "+====================================================="
 }
 
@@ -17,9 +18,13 @@ function start_service {
     echo "+====================================================="
     while true
     do
-      echo "live... (next try in 10sec)" & sleep 3600
+      echo "live... (next try in 1 hour)" & sleep 3600
     done
 }
 
+if [ -n "$HOME" ]; then
+    [ -d "$HOME" ] || mkdir -p $HOME
+fi
+
 display_container_header
-start_service
+start_service