Files
Server-scripts/serverhost/syncNC.sh
T
2026-09-14 12:43:38 +02:00

118 lines
3.8 KiB
Bash
Executable File

#!/bin/bash
run_cmd() {
#echo $@
if [[ "$SILENT" == "true" ]]; then
"$@" > ~/sync.log 2>&1
else
"$@" 2>&1 | tee ~/sync.log
fi
}
ret=0
count=20
PW=$(cat /home/lucas/.PW)
PW_M="multimedia123"
SYNC_MEDIA=0
SYNC_RECIPIES=1
SYNC_MEDIA_ONLY=0
SYNC_ALINA=1
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 == -al ]] && {
SYNC_ALINA=0;
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 pgrep -x "nextcloudcmd" > /dev/null; then
echo "Nextcloud Sync active, stop"
else
echo "Sync Nextcloud"
while true; do
ret=0
if [ ${SYNC_MEDIA} -eq 1 ];then
echo "Sync Multmedia"
run_cmd sudo /home/lucas/scripts/serverhost/tvbitch_user_cmd.sh nextcloudcmd --logdebug --trust --user multimedia --password ${PW_M} --path Filme/New /torrent/multimedia/Filme/New ${SERVER}
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ ${SYNC_THEMES} -eq 1 ]] && [[ ${SYNC_MEDIA_ONLY} -eq 0 ]]; then
echo "Sync Themes"
run_cmd nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Projekte/Handy/ThemeProject/SolarSystemTheme /home/lucas/Documents/Dokumente/Projekte/Handy/ThemeProject/SolarSystemTheme ${SERVER}
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ ${SYNC_ALINA} -eq 0 ]];then
echo "Sync Alina"
run_cmd nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Shared/Alina/Wachstum /home/lucas/Documents/Dokumente/Shared/Alina/Wachstum ${SERVER}
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ ${SYNC_RECIPIES} -eq 0 ]];then
echo "Sync Recipies"
run_cmd nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Shared/Diverses/Kochbuch/RecepiesLucas /home/lucas/Documents/Dokumente/Shared/Diverses/Kochbuch/RecepiesLucas ${SERVER}
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}"
run_cmd nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Projekte/Server /home/lucas/Documents/Dokumente/Projekte/Server ${SERVER}
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ ${SYNC_MEDIA_ONLY} -eq 0 ]]; then
echo "Sync Wallpaper"
run_cmd nextcloudcmd --trust --user lucas --password ${PW} --path Media/Stuff/Wallpaper /torrent/WallpaperChanger ${SERVER}
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}