peertube sync lock file
This commit is contained in:
parent
c094386951
commit
6108a065e8
|
@ -64,6 +64,17 @@ function peertube_import_from_syncthing {
|
|||
fi
|
||||
|
||||
{ echo '#!/bin/bash';
|
||||
echo '';
|
||||
echo 'if [ -f /root/.peertube.lock ]; then';
|
||||
echo " lockctr=\$(cat /root/.peertube.lock)";
|
||||
echo " lockctr=\$((lockctr+1))";
|
||||
echo " echo \"\$lockctr\" > /root/.peertube.lock";
|
||||
echo " if [ \$lockctr -ge 30 ]; then";
|
||||
echo " rm /root/.peertube.lock";
|
||||
echo ' else';
|
||||
echo ' exit 0';
|
||||
echo ' fi';
|
||||
echo 'fi';
|
||||
echo '';
|
||||
echo "MY_USERNAME=\$(cat /root/${PROJECT_NAME}.cfg | grep MY_USERNAME | awk -F '=' '{print \$2}')";
|
||||
echo "if [ ! \"\$MY_USERNAME\" ]; then";
|
||||
|
@ -100,33 +111,28 @@ function peertube_import_from_syncthing {
|
|||
echo '';
|
||||
echo 'failed_uploads=0';
|
||||
echo '';
|
||||
echo 'echo "0" > /root/.peertube.lock';
|
||||
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 " if ! grep -q \"\$video_file\" /root/.peertube_uploading; then";
|
||||
echo " echo \"\$video_file\" >> /root/.peertube_uploading";
|
||||
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 " sed -i \"/\$(basename \$video_file)/d\" /root/.peertube_uploading";
|
||||
echo " exit 0";
|
||||
echo ' else';
|
||||
echo " sed -i \"/\$(basename \$video_file)/d\" /root/.peertube_uploading";
|
||||
echo " failed_uploads=\$((failed_uploads+1))";
|
||||
echo " if [ \$failed_uploads -gt 1 ]; then";
|
||||
echo ' exit 0';
|
||||
echo ' fi';
|
||||
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 " exit 0";
|
||||
echo ' else';
|
||||
echo " failed_uploads=\$((failed_uploads+1))";
|
||||
echo " if [ \$failed_uploads -gt 1 ]; then";
|
||||
echo ' exit 0';
|
||||
echo ' fi';
|
||||
echo ' fi';
|
||||
echo ' else';
|
||||
echo " if grep -q \"\$video_file\" /root/.peertube_uploading; then";
|
||||
echo " sed -i \"/\$(basename \$video_file)/d\" /root/.peertube_uploading";
|
||||
echo ' fi';
|
||||
echo ' fi';
|
||||
echo ' fi';
|
||||
echo 'done'; } > /usr/bin/peertubesync
|
||||
echo '';
|
||||
echo 'rm /root/.peertube.lock';
|
||||
|
||||
chmod +x /usr/bin/peertubesync
|
||||
cron_add_mins 1 /usr/bin/peertubesync
|
||||
|
|
Loading…
Reference in New Issue