dotfiles/.local/bin/syncclouds.sh

52 lines
1.5 KiB
Bash
Raw Normal View History

2024-01-01 16:22:03 +01:00
#!/bin/sh
# cronjob requires this
# shellcheck disable=SC1090
. ~/.zprofile
# sync moodle
echo "syncclouds.sh: moodle-dl"
{
# remove lock file if moodle-dl is not running
pgrep -x moodle-dl || [ -f ~/eth/.moodle/running.lock ] && rm ~/eth/.moodle/running.lock
cd ~/eth/.moodle && moodle-dl
} > /dev/null 2>&1 &
moodle_pid=$!
# sync nextcloud drive
echo "syncclouds.sh: nextcloudcmd"
{
nextcloudcmd -s -u "alexander@bocken.org" --password "$(pass server/seenas/nextcloud_admin_pass | head -n1)" ~/dox/nextcloud https://cloud.bocken.org
} > /dev/null 2>&1 &
nextcloud_pid=$!
# sync contacts to nextcloud
echo "syncclouds.sh: vdirsyncer"
{
vdirsyncer sync
} > /dev/null 2>&1 &
vdirsyncer_pid=$!
# sync calendar to nextcloud
echo "syncclouds.sh: calcurse-caldav"
{
# remove lock file if calcurse-caldav is not running
pgrep -x calcurse-caldav || [ -f ~/.local/share/calcurse/caldav/lock ] && rm ~/.local/share/calcurse/caldav/lock
2024-01-02 12:37:32 +01:00
CALCURSE_CALDAV_PASSWORD=$(pass server/seenas/nextcloud_admin_pass) calcurse-caldav
2024-01-01 16:22:03 +01:00
} > /dev/null 2>&1 &
calcurse_pid=$!
# Wait for all processes to complete and print a message for each one
2024-01-02 13:11:07 +01:00
# This does not print in the correct order (meaning first done first printed), but it's good enough
2024-01-01 16:22:03 +01:00
wait $vdirsyncer_pid
echo "syncclouds.sh: vdirsyncer done"
wait $nextcloud_pid
echo "syncclouds.sh: nextcloudcmd done"
wait $calcurse_pid
echo "syncclouds.sh: calcurse-caldav done"
wait $moodle_pid
echo "syncclouds.sh: moodle-dl done"
echo "syncclouds.sh done"