diff --git a/install/usr/share/swarmlab.io/sec/swarmlab-sec b/install/usr/share/swarmlab.io/sec/swarmlab-sec index 79cef06..2643dfd 100755 --- a/install/usr/share/swarmlab.io/sec/swarmlab-sec +++ b/install/usr/share/swarmlab.io/sec/swarmlab-sec @@ -72,12 +72,7 @@ set -e # # ############################################## -IMAGE_local="microservice-xelatexthesis" -IMAGE_origin="hub.swarmlab.io:5480/xelatex-basegui" -GIT_origin="https://git.swarmlab.io:3000/swarmlab/swarmlab-microservice-example.git" -service_GUI=true -service_WEB=true -service_URL=http +. $SRPATH/swarmlab-template-image DOCKERuser="docker" Wdir=${cwdir}/$IMAGE_local @@ -85,7 +80,6 @@ if [ ! -d $Wdir ]; then mkdir -p $Wdir fi -# edit it - EDIT_END APTPARAM=" --no-install-recommends " HYBRID_NETWORK=$IMAGE_local @@ -177,38 +171,11 @@ if [ -d "$Wdir/project" ]; then extrapackages \ / -# ############################### -# EDIT-BEGIN -# this part must be exactly the same as that stated under create_project -# ############################### +EOF - RUN export DEBIAN_FRONTEND=noninteractive \ - && rm -rf /usr/share/doc \ - && rm -rf /usr/share/man \ - && rm -rf /usr/share/locale \ - && mkdir -p /var/run/sshd \ - && addgroup -S docker && adduser -S docker -G docker \ - && echo 'root:$ROOT_PASSWORD' | chpasswd \ - && echo "export VISIBLE=now" >> /etc/profile \ - && mkdir -p /home/docker/project \ - && mkdir -p /etc/opt \ - && echo "docker:docker" | chpasswd \ - && echo "StrictHostKeyChecking no" > \${SSHDIR}/config \ - && cat \${SSHDIR}/*.pub >> \${SSHDIR}/authorized_keys \ - && chmod -R 600 \${SSHDIR}/* \ - && chown -R \${USER1}:\${USER1} \${SSHDIR} - - COPY .vimrc /home/docker - - RUN /setup.sh - - EXPOSE 8080 -# ############################### -# EDIT-END -# ############################### + cat $Wdir/Dockerfile.tmp >> $Wdir/Dockerfile -EOF fi else echo "" @@ -275,38 +242,11 @@ if [ "$Wdir" == "$HOME" ]; then extrapackages \ / -# ############################### -# EDIT-BEGIN -# this part must be exactly the same as that stated under create_dockerfile -# ############################### +EOF - RUN export DEBIAN_FRONTEND=noninteractive \ - && addgroup -S docker && adduser -S docker -G docker \ - && rm -rf /usr/share/doc \ - && rm -rf /usr/share/man \ - && rm -rf /usr/share/locale \ - && mkdir -p /var/run/sshd \ - && echo 'root:$ROOT_PASSWORD' | chpasswd \ - && echo "export VISIBLE=now" >> /etc/profile \ - && mkdir -p /home/docker/project \ - && mkdir -p /etc/opt \ - && echo "docker:docker" | chpasswd \ - && echo "StrictHostKeyChecking no" > \${SSHDIR}/config \ - && cat \${SSHDIR}/*.pub >> \${SSHDIR}/authorized_keys \ - && chmod -R 600 \${SSHDIR}/* \ - && chown -R \${USER1}:\${USER1} \${SSHDIR} - - COPY .vimrc /home/docker - - RUN /setup.sh - - EXPOSE 8080 + cat $Wdir/Dockerfile.tmp >> $Wdir/Dockerfile -# ############################### -# EDIT-END -# ############################### -EOF fi # you do not need to edit it - BEGIN diff --git a/install/usr/share/swarmlab.io/sec/swarmlab-template.sh b/install/usr/share/swarmlab.io/sec/swarmlab-template.sh new file mode 100644 index 0000000..b00ef1b --- /dev/null +++ b/install/usr/share/swarmlab.io/sec/swarmlab-template.sh @@ -0,0 +1,62 @@ +#!/bin/bash + + + + + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink + TARGET="$(readlink "$SOURCE")" + if [[ $TARGET == /* ]]; then + SOURCE="$TARGET" + else + DIR="$( dirname "$SOURCE" )" + SOURCE="$DIR/$TARGET" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located + fi +done + +SRPATH="$( dirname "$SOURCE" )" +SFPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +if [ "$SFPATH" != "$SRPATH" ]; then + RDIR=$SRPATH # relativ path directory +fi + +cwdir=$PWD + + + + + +cat << EOF > $SRPATH/swarmlab-template-image +IMAGE_local="microservice-xelatexthesis" +IMAGE_origin="hub.swarmlab.io:5480/xelatex-basegui" +GIT_origin="https://git.swarmlab.io:3000/swarmlab/swarmlab-microservice-example.git" +service_GUI=true +service_WEB=true +service_URL=http +EOF + + +cat << EOF >> $Wdir/Dockerfile.tmp +RUN export DEBIAN_FRONTEND=noninteractive \ + && rm -rf /usr/share/doc \ + && rm -rf /usr/share/man \ + && rm -rf /usr/share/locale \ + && mkdir -p /var/run/sshd \ + && addgroup -S docker && adduser -S docker -G docker \ + && echo 'root:$ROOT_PASSWORD' | chpasswd \ + && echo "export VISIBLE=now" >> /etc/profile \ + && mkdir -p /home/docker/project \ + && mkdir -p /etc/opt \ +&& echo "docker:docker" | chpasswd \ +&& echo "StrictHostKeyChecking no" > \${SSHDIR}/config \ +&& cat \${SSHDIR}/*.pub >> \${SSHDIR}/authorized_keys \ +&& chmod -R 600 \${SSHDIR}/* \ +&& chown -R \${USER1}:\${USER1} \${SSHDIR} + +COPY .vimrc /home/docker + +RUN /setup.sh + +EXPOSE 8080 +EOF