From 455c987a9f33f8f68e87c66c496d3a1406121264 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 2 Apr 2018 13:08:02 +0100 Subject: [PATCH] Tidying --- src/freedombone-app-peertube | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/freedombone-app-peertube b/src/freedombone-app-peertube index 75c4aea7..afb5e13b 100755 --- a/src/freedombone-app-peertube +++ b/src/freedombone-app-peertube @@ -64,13 +64,15 @@ function peertube_import_from_syncthing { fi { echo '#!/bin/bash'; + echo ''; + echo 'LOCKFILE=/root/.peertube.lock'; echo ''; echo 'if [ -f /root/.peertube.lock ]; then'; - echo " lockctr=\$(cat /root/.peertube.lock)"; + echo " lockctr=\$(cat \$LOCKFILE)"; echo " lockctr=\$((lockctr+1))"; - echo " echo \"\$lockctr\" > /root/.peertube.lock"; + echo " echo \"\$lockctr\" > \$LOCKFILE"; echo " if [ \$lockctr -ge 30 ]; then"; - echo " rm /root/.peertube.lock"; + echo " rm \$LOCKFILE"; echo ' else'; echo ' exit 0'; echo ' fi'; @@ -111,22 +113,21 @@ function peertube_import_from_syncthing { echo ''; echo 'failed_uploads=0'; echo ''; - echo 'echo "0" > /root/.peertube.lock'; + echo "cd ${PEERTUBE_DIR} || exit 32468356"; + echo "echo \"0\" > \$LOCKFILE"; echo ''; echo "for video_file in \$search_dir/*; do"; echo " if [[ \"\$video_file\" == *'.ogv' || \"\$video_file\" == *'.mp4' || \"\$video_file\" == *'.webm' ]]; then"; - echo " cd ${PEERTUBE_DIR} || exit 32468356"; - echo " "; echo " if ! grep -q \"\$video_file\" /root/.peertube_uploaded; then"; echo " peertubetitle=\$(basename \"\$video_file\" | awk -F '.' '{print \$1}' | sed 's|_| |g' | sed 's|-| |g')"; echo " if $nodecmd \$import_script -n \"\$peertubetitle\" \$peertubensfw \$peertubeprivate -u \"\$peertubedomain\" -U \"\$peertubeuser\" --password \"\$peertubepassword\" -f \"\$video_file\"; then"; echo " echo \"\$video_file\" >> /root/.peertube_uploaded"; - echo ' rm /root/.peertube.lock'; + echo " rm \$LOCKFILE"; echo " exit 0"; echo ' else'; echo " failed_uploads=\$((failed_uploads+1))"; echo " if [ \$failed_uploads -gt 1 ]; then"; - echo ' rm /root/.peertube.lock'; + echo " rm \$LOCKFILE"; echo ' exit 0'; echo ' fi'; echo ' fi'; @@ -134,7 +135,7 @@ function peertube_import_from_syncthing { echo ' fi'; echo 'done'; } > /usr/bin/peertubesync echo ''; - echo 'rm /root/.peertube.lock'; + echo "rm \$LOCKFILE"; chmod +x /usr/bin/peertubesync cron_add_mins 1 /usr/bin/peertubesync