This commit is contained in:
Bob Mottram 2018-04-02 13:08:02 +01:00
parent 93a64b218f
commit 455c987a9f
1 changed files with 10 additions and 9 deletions

View File

@ -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