Răsfoiți Sursa

Not working right

Fred Damstra (k8s1) 2 ani în urmă
părinte
comite
e0e35f74ff
3 a modificat fișierele cu 30 adăugiri și 27 ștergeri
  1. 1 1
      Dockerfile
  2. 1 0
      Jenkinsfile
  3. 28 26
      sort_and_upload.sh

+ 1 - 1
Dockerfile

@@ -4,7 +4,7 @@ LABEL version="0.1"
 LABEL description="Docker image that sorts my midjourney albums"
 
 RUN echo -e "search default.svc.cluster.local svc.cluster.local cluster.local\nnameserver 10.152.183.10\noptions ndots:2" > /etc/resolv.conf
-RUN apk add --no-cache bash bash-completion
+RUN apk add --no-cache bash bash-completion rsync
 
 COPY . /opt/midjourney/
 RUN chmod 755 /opt/midjourney/sort_and_upload.sh \

+ 1 - 0
Jenkinsfile

@@ -11,6 +11,7 @@ volumes: [
      container('kaniko') {
        sh '/kaniko/executor --context="git://git.monkeybox.org/Containers/$JOB_NAME#refs/heads/main" \
                --destination="fdamstra/$JOB_NAME:latest" \
+               --destination="fdamstra/$JOB_NAME:$BUILD_NUMBER" \
                --insecure \
                --skip-tls-verify  \
                -v=debug'

+ 28 - 26
sort_and_upload.sh

@@ -25,33 +25,35 @@ fi
 SAVEIFS=$IFS
 IFS=$(echo -en "\n\b")
 
-if compgen -G "${MIDJOURNEYDIR}/images/*.png" > /dev/null; then
-  echo New files. Sorting. 2>&1 | tee -a ${LOGFILE}
-  for i in ${MIDJOURNEYDIR}/images/*.png; do
-    maxdim=$(file "$i" | awk '{ print ($6 > $8)? $6 : $8 }' | sed 's/,$//')
-    if [ $maxdim -lt 1024 ]; then
-      echo SMALL: "$i" 2>&1 | tee -a ${LOGFILE}
-      rsync $i ${MIDJOURNEYDIR}/images.small/ 2>&1 | tee -a ${LOGFILE}
-      if [ $? -eq 0 ]; then
-        mv $i ${MIDJOURNEYDIR}/images.filtered/ 2>&1 | tee -a ${LOGFILE}
+(
+  if compgen -G "${MIDJOURNEYDIR}/images/*.png" > /dev/null; then
+    echo New files. Sorting.
+    for i in ${MIDJOURNEYDIR}/images/*.png; do
+      maxdim=$(file "$i" | awk '{ print ($6 > $8)? $6 : $8 }' | sed 's/,$//')
+      if [ $maxdim -lt 1024 ]; then
+        echo SMALL: "$i"
+        rsync $i ${MIDJOURNEYDIR}/images.small/
+        if [ $? -eq 0 ]; then
+          mv $i ${MIDJOURNEYDIR}/images.filtered/
+        fi
+      elif [ $maxdim -lt 1281 ]; then
+        echo MEDIUM: "$i"
+        rsync $i ${MIDJOURNEYDIR}/images.medium/
+        if [ $? -eq 0 ]; then
+          mv $i ${MIDJOURNEYDIR}/images.filtered/
+        fi
+      else
+        echo LARGE: "$i"
+        rsync $i ${MIDJOURNEYDIR}/images.large/
+        if [ $? -eq 0 ]; then
+          mv $i ${MIDJOURNEYDIR}/images.filtered/
+        fi
       fi
-    elif [ $maxdim -lt 1281 ]; then
-      echo MEDIUM: "$i" 2>&1 | tee -a ${LOGFILE}
-      rsync $i ${MIDJOURNEYDIR}/images.medium/ 2>&1 | tee -a ${LOGFILE}
-      if [ $? -eq 0 ]; then
-        mv $i ${MIDJOURNEYDIR}/images.filtered/ 2>&1 | tee -a ${LOGFILE}
-      fi
-    else
-      echo LARGE: "$i" 2>&1 | tee -a ${LOGFILE}
-      rsync $i ${MIDJOURNEYDIR}/images.large/ 2>&1 | tee -a ${LOGFILE}
-      if [ $? -eq 0 ]; then
-        mv $i ${MIDJOURNEYDIR}/images.filtered/ 2>&1 | tee -a ${LOGFILE}
-      fi
-    fi
-  done
-else
-  echo No new files. No need to sort. 2>&1 | tee -a ${LOGFILE}
-fi
+    done
+  else
+    echo No new files. No need to sort.
+  fi
+) 2>&1 | tee -a ${LOGFILE}
 
 echo Syncing Small 2>&1 | tee -a ${LOGFILE}
 ${GDRIVE} sync upload --keep-largest ${MIDJOURNEYDIR}/images.small/ $SMALL 2>&1 | tee -a ${LOGFILE}