Skip to content

Commit

Permalink
only dos2unix if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
mchyzer committed Aug 23, 2022
1 parent 63a6e6a commit d36796b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ENV GROUPER_VERSION=2.6.15 \
GROUPER_HOME=/opt/grouper/grouperWebapp/WEB-INF

RUN yum update -y \
&& yum install -y cron logrotate python3-pip rsync sudo patch supervisor wget tar unzip dos2unix \
&& yum install -y logrotate python3-pip rsync sudo patch supervisor wget tar unzip dos2unix file \
&& pip3 install --upgrade setuptools \
&& yum clean -y all \
&& groupadd -r tomcat \
Expand All @@ -35,7 +35,7 @@ ARG CORRETTO_RPM=amazon-corretto-8-x64-linux-jdk.rpm

#RUN cd /tmp \
# && chmod +x /opt/container_files/*.sh \
# && find /opt/container_files/ -type f -name "*.sh" -print0 | xargs -0 dos2unix \
# && if [ $(find /opt/container_files -type f -name "*.sh" -exec file "{}" ";" | grep CRLF | cut -d: -f1 | wc -l) -ne 0 ]; then dos2unix $(find /opt/container_files -type f -name "*.sh" -exec file "{}" ";" | grep CRLF | cut -d: -f1) ; fi; \
# && /opt/container_files/containerDockerfileInstallJava.sh $CORRETTO_URL_PERM $CORRETTO_RPM $JAVA_HOME $GROUPER_VERSION \
# && /opt/container_files/containerDockerfileInstallGrouper.sh $CORRETTO_URL_PERM $CORRETTO_RPM $JAVA_HOME $GROUPER_VERSION

Expand All @@ -44,12 +44,12 @@ COPY container_files/ /opt/container_files/

#RUN cd /tmp \
# && chmod +x /opt/container_files/*.sh \
# && find /opt/container_files/ -type f -name "*.sh" -print0 | xargs -0 dos2unix \
# && if [ $(find /opt/container_files -type f -name "*.sh" -exec file "{}" ";" | grep CRLF | cut -d: -f1 | wc -l) -ne 0 ]; then dos2unix $(find /opt/container_files -type f -name "*.sh" -exec file "{}" ";" | grep CRLF | cut -d: -f1) ; fi; \
# && /opt/container_files/containerDockerfileInstall.sh $CORRETTO_URL_PERM $CORRETTO_RPM $JAVA_HOME $GROUPER_VERSION

RUN cd /tmp \
&& chmod +x /opt/container_files/*.sh \
&& find /opt/container_files/ -type f -name "*.sh" -print0 | xargs -0 dos2unix \
&& if [ $(find /opt/container_files -type f -name "*.sh" -exec file "{}" ";" | grep CRLF | cut -d: -f1 | wc -l) -ne 0 ]; then dos2unix $(find /opt/container_files -type f -name "*.sh" -exec file "{}" ";" | grep CRLF | cut -d: -f1) ; fi; \
&& /opt/container_files/containerDockerfileInstallJava.sh $CORRETTO_URL_PERM $CORRETTO_RPM $JAVA_HOME $GROUPER_VERSION \
&& /opt/container_files/containerDockerfileInstallGrouper.sh $CORRETTO_URL_PERM $CORRETTO_RPM $JAVA_HOME $GROUPER_VERSION \
&& /opt/container_files/containerDockerfileInstall.sh $CORRETTO_URL_PERM $CORRETTO_RPM $JAVA_HOME $GROUPER_VERSION
Expand Down
7 changes: 7 additions & 0 deletions container_files/containerDockerfileInstallPermissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ if [ $lines -ne 0 ]; then
echo "grouperDockerfile; INFO: (containerDockerfileInstallPermissions.sh) chmod +x \$(find /opt/container_files/ /opt/grouper/ /opt/tier/ /opt/tier-support/ /opt/tomee/ /etc/httpd/conf/ /home/tomcat/ /etc/httpd/conf.d/ -type f -name \"*.sh\" ! -perm -o+x), result: $returnCode"
fi

lines=$(find /usr/local/bin -type f -name "*.sh" -exec file "{}" ";" | grep CRLF | cut -d: -f1 | wc -l)
if [ $lines -ne 0 ]; then
dos2unix $(find /usr/local/bin -type f -name "*.sh" -exec file "{}" ";" | grep CRLF | cut -d: -f1)
returnCode=$?
echo "grouperDockerfile; INFO: (containerDockerfileInstallPermissions.sh) dos2unix \$(find /usr/local/bin -type f -name \"*.sh\" -exec file \"{}\" \";\" | grep CRLF | cut -d: -f1), result: $returnCode"
fi

find /usr/local/bin/ -type f -print0 | xargs -0 dos2unix
returnCode=$?
echo "grouperDockerfile; INFO: (containerDockerfileInstallPermissions.sh) find /usr/local/bin/ -type f -print0 | xargs -0 dos2unix, result: $returnCode"
Expand Down

0 comments on commit d36796b

Please sign in to comment.