Files
Server-scripts/serverhost/syncNC.sh
T

99 lines
3.2 KiB
Bash
Raw Normal View History

2026-04-14 23:55:21 +02:00
#!/bin/bash
ret=0
count=20
PW=$(cat /home/lucas/.PW)
SYNC_MEDIA=0
SYNC_RECIPIES=1
SYNC_MEDIA_ONLY=0
SYNC_THEMES=0
SILENT=true
SERVER="https://someoneslinux.ddns.net"
while [[ ${1:0:1} == - ]]; do
echo "Param: $1"
[[ $1 == -l ]] && {
SILENT=false;
shift 1;
continue;
};
[[ $1 == -o ]] && {
SYNC_MEDIA_ONLY=1;
shift 1;
continue;
};
[[ $1 == -m ]] && {
SYNC_MEDIA=1;
shift 1;
continue;
};
[[ $1 == -t ]] && {
SYNC_THEMES=1;
shift 1;
continue;
};
[[ $1 == -del ]] && {
if [ -f /tmp/nextcloud_sync ]; then
rm /tmp/nextcloud_sync
echo "File removed"
fi
shift 1;
continue;
};
echo "Parameter $1 discarded"
shift 1;
done
if $SILENT; then
target='>/dev/null 2>&1'
fi
2026-04-20 12:03:19 +02:00
if pgrep -x "nextcloudcmd" > /dev/null; then
echo "Nextcloud Sync active, stop"
else
2026-04-14 23:55:21 +02:00
echo "Sync Nextcloud"
while true; do
ret=0
if [ ${SYNC_MEDIA} -eq 1 ];then
echo "Sync Multmedia"
sudo /home/lucas/scripts/serverhost/tvbitch_user_cmd.sh nextcloudcmd --trust --user multimedia --password multimedia123 --path Filme/New /torrent/multimedia/Filme/New ${SERVER} >/dev/null 2>&1
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ ${SYNC_THEMES} -eq 1 ]] && [[ ${SYNC_MEDIA_ONLY} -eq 0 ]]; then
echo "Sync Themes"
nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Projekte/Handy/ThemeProject/SolarSystemTheme /home/lucas/Documents/Dokumente/Projekte/Handy/ThemeProject/SolarSystemTheme ${SERVER} >/dev/null 2>&1
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ ${SYNC_RECIPIES} -eq 0 ]];then
echo "Sync Recipies"
nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Shared/Diverses/Kochbuch/RecepiesLucas /home/lucas/Documents/Dokumente/Shared/Diverses/Kochbuch/RecepiesLucas ${SERVER} >/dev/null 2>&1
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ "$1" != "-W" ]] && [[ ${SYNC_MEDIA_ONLY} -eq 0 ]];then
echo "Sync Server"
# echo "nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Projekte/Server /home/lucas/Documents/Dokumente/Projekte/Server ${SERVER}" #>/dev/null 2>&1
2026-04-20 12:03:19 +02:00
nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Projekte/Server /home/lucas/Documents/Dokumente/Projekte/Server ${SERVER} #>/dev/null 2>&1
2026-04-14 23:55:21 +02:00
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ ${SYNC_MEDIA_ONLY} -eq 0 ]]; then
echo "Sync Wallpaper"
nextcloudcmd --trust --user lucas --password ${PW} --path Media/Stuff/Wallpaper /torrent/WallpaperChanger ${SERVER} >/dev/null 2>&1
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ "${ret}" == "0" ]]; then
echo "Sucess"
break
elif [[ ${count} -gt 15 ]]; then
echo "Massive Fail"
break
else
echo "Fail"
sleep 5
fi
((count++))
done
fi
exit ${ret}