From 0f936362d801a9dcbee1989085991710cb5ea4dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoffer=20M=C3=BCller=20Madsen?= Date: Thu, 15 Jun 2017 11:26:01 +0200 Subject: [PATCH] Persistence --- docker/Dockerfile | 7 ++++--- docker/build.sh | 8 ++++++-- init_passwd.rb | 6 ++++++ run_server.sh | 4 ++++ 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 init_passwd.rb create mode 100755 run_server.sh diff --git a/docker/Dockerfile b/docker/Dockerfile index 9534a1a..7cdb58d 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,14 +9,15 @@ RUN mkdir /var/run/sshd # SSH login fix. Otherwise user is kicked off after login RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd -ADD eshell /usr/bin/ +COPY tmp/eshell /usr/bin/ -COPY Gemfile* /tmp/ +COPY tmp/Gemfile* /tmp/ WORKDIR /tmp RUN bundle install ENV app /app RUN mkdir $app +COPY tmp/run_server.sh /app/ WORKDIR $app #ENV BUNDLE_PATH /box @@ -25,4 +26,4 @@ WORKDIR $app VOLUME /home EXPOSE 22 -CMD ["/usr/sbin/sshd", "-D"] +ENTRYPOINT ["/app/run_server.sh"] diff --git a/docker/build.sh b/docker/build.sh index 3e984dd..d48dbd7 100755 --- a/docker/build.sh +++ b/docker/build.sh @@ -1,4 +1,8 @@ #!/bin/sh -cp ../eshell ./ -cp ../Gemfile* ./ +mkdir tmp +cp ../init_passwd.rb ./tmp/ +cp ../run_server.sh ./tmp/ +cp ../eshell ./tmp/ +cp ../Gemfile* ./tmp/ docker build -t emacs-collab:latest . +rm -R tmp diff --git a/init_passwd.rb b/init_passwd.rb new file mode 100644 index 0000000..466ab4c --- /dev/null +++ b/init_passwd.rb @@ -0,0 +1,6 @@ +require_relative '/emacs-collab/lib/emacscollab/collab' + +EmacsCollab.get_projects.each do |p| + `groupadd -g #{p.uid} #{p.posixname}` + `useradd -d /home/#{p.posixname} -g #{p.uid} -M -s /usr/bin/eshell -u #{p.uid} #{p.posixname}` +end diff --git a/run_server.sh b/run_server.sh new file mode 100755 index 0000000..d621e3e --- /dev/null +++ b/run_server.sh @@ -0,0 +1,4 @@ +#!/bin/sh +cd /emacs-collab +ruby init_passwd.rb +/usr/sbin/sshd -D