Uploading of videos to peertube via syncthing
This commit is contained in:
parent
b8c927a2a6
commit
69d5e0b35f
|
@ -54,6 +54,61 @@ peertube_variables=(PEERTUBE_DOMAIN_NAME
|
||||||
ARCHITECTURE
|
ARCHITECTURE
|
||||||
MY_EMAIL_ADDRESS)
|
MY_EMAIL_ADDRESS)
|
||||||
|
|
||||||
|
function peertube_import_from_syncthing {
|
||||||
|
{ echo '#!/bin/bash';
|
||||||
|
echo '';
|
||||||
|
echo "MY_USERNAME=\$(cat /root/${PROJECT_NAME}.cfg | grep MY_USERNAME | awk -F '=' '{print \$2}')";
|
||||||
|
echo "if [ ! \"\$MY_USERNAME\" ]; then";
|
||||||
|
echo ' exit 0';
|
||||||
|
echo 'fi';
|
||||||
|
echo '';
|
||||||
|
echo "search_dir=/home/\$MY_USERNAME/Sync/peertube_upload";
|
||||||
|
echo "if [ ! -f \$search_dir/login ]; then";
|
||||||
|
echo ' exit 0';
|
||||||
|
echo 'fi';
|
||||||
|
echo "import_script=${PEERTUBE_DIR}/dist/server/tools/upload.js";
|
||||||
|
echo "if [ ! -f \$import_script ]; then";
|
||||||
|
echo ' exit 0';
|
||||||
|
echo 'fi';
|
||||||
|
echo '';
|
||||||
|
echo "peertubedomain=\"http://localhost:${PEERTUBE_PORT}\"";
|
||||||
|
echo "peertubeuser=\$(sed -n 1p < \"\$search_dir/login\")";
|
||||||
|
echo "peertubepassword=\$(sed -n 2p < \"\$search_dir/login\")";
|
||||||
|
echo 'peertubensfw=';
|
||||||
|
echo "if grep 'nsfw' \"\$search_dir/login\"; then";
|
||||||
|
echo " peertubensfw='--nsfw'";
|
||||||
|
echo 'fi';
|
||||||
|
echo '';
|
||||||
|
echo 'failed_uploads=0';
|
||||||
|
echo '';
|
||||||
|
echo "for video_file in \$search_dir/*; do";
|
||||||
|
echo " echo \"\$video_file\"";
|
||||||
|
echo " if [[ \"\$video_file\" == *'.ogv' || \"\$video_file\" == *'.mp4' || \"\$video_file\" == *'.webm' ]]; then";
|
||||||
|
echo " cd ${PEERTUBE_DIR} || exit 32468356";
|
||||||
|
echo " ";
|
||||||
|
echo " if ! grep \"\$video_file\" /root/.peertube_uploaded; then";
|
||||||
|
echo " if ! grep \"\$video_file\" /root/.peertube_uploading; then";
|
||||||
|
echo " echo \"\$video_file\" >> /root/.peertube_uploading";
|
||||||
|
echo " if node \$import_script \$peertubensfw -u \"\$peertubedomain\" -U \"\$peertubeuser\" --password \"\$peertubepassword\" -f \"\$video_file\"; then";
|
||||||
|
echo " echo \"\$video_file\" >> /root/.peertube_uploaded";
|
||||||
|
echo " sed -i \"/\$video_file/d\" /root/.peertube_uploading";
|
||||||
|
echo " exit 0";
|
||||||
|
echo ' else';
|
||||||
|
echo " sed -i \"/\$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 ' fi';
|
||||||
|
echo ' fi';
|
||||||
|
echo ' fi';
|
||||||
|
echo ' fi';
|
||||||
|
echo 'done'; } > /usr/bin/peertubesync
|
||||||
|
|
||||||
|
chmod +x /usr/bin/peertubesync
|
||||||
|
cron_add_mins 1 /usr/bin/peertubesync
|
||||||
|
}
|
||||||
|
|
||||||
function peertube_create_database {
|
function peertube_create_database {
|
||||||
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
if [ -f "$IMAGE_PASSWORD_FILE" ]; then
|
||||||
PEERTUBE_ADMIN_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
PEERTUBE_ADMIN_PASSWORD="$(printf "%s" "$(cat "$IMAGE_PASSWORD_FILE")")"
|
||||||
|
@ -326,6 +381,8 @@ function reconfigure_peertube {
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgrade_peertube {
|
function upgrade_peertube {
|
||||||
|
peertube_import_from_syncthing
|
||||||
|
|
||||||
CURR_PEERTUBE_COMMIT=$(get_completion_param "peertube commit")
|
CURR_PEERTUBE_COMMIT=$(get_completion_param "peertube commit")
|
||||||
if [[ "$CURR_PEERTUBE_COMMIT" == "$PEERTUBE_COMMIT" ]]; then
|
if [[ "$CURR_PEERTUBE_COMMIT" == "$PEERTUBE_COMMIT" ]]; then
|
||||||
return
|
return
|
||||||
|
@ -479,6 +536,14 @@ function remove_peertube {
|
||||||
remove_onion_service peertube ${PEERTUBE_ONION_PORT}
|
remove_onion_service peertube ${PEERTUBE_ONION_PORT}
|
||||||
remove_completion_param "install_peertube"
|
remove_completion_param "install_peertube"
|
||||||
sed -i '/peertube/d' "$COMPLETION_FILE"
|
sed -i '/peertube/d' "$COMPLETION_FILE"
|
||||||
|
sed -i '/peertubesync/d' /etc/crontab
|
||||||
|
|
||||||
|
if [ -f /usr/bin/peertubesync ]; then
|
||||||
|
rm /usr/bin/peertubesync
|
||||||
|
fi
|
||||||
|
if [ -f /root/peertube_uploaded ]; then
|
||||||
|
rm /root/peertube_uploaded
|
||||||
|
fi
|
||||||
|
|
||||||
function_check drop_database_postgresql
|
function_check drop_database_postgresql
|
||||||
drop_database_postgresql peertube peertube
|
drop_database_postgresql peertube peertube
|
||||||
|
|
Loading…
Reference in New Issue