See the git sync library upon which this depends, and the post that explains the functioning of this tool.
#!/bin/zsh
source /home/user/bin/git-sync-lib
backup(){
rm /home/user/configs/crontab.`hostname | cut -d . -f 1`
crontab -l > /home/user/configs/crontab.`hostname | cut -d . -f 1`
cp ~/.Xdefaults /home/user/configs/archive/xorg/xdefaults.`hostname | cut -d . -f 1`
cp /etc/hosts /home/user/configs/archive/etc-hosts.`hostname | cut -d . -f 1`
if [ `hostname | cut -d . -f 1` = arendt ]; then
sudo cp /boot/grub/grub.cfg /home/user/configs/archive/grub2.`hostname | cut -d . -f 1`
sudo chown tychoish:tychoish /home/user/configs/archive/grub2.`hostname | cut -d . -f 1`
fi
}
half-sync(){
syncup >/dev/null 2>&1 &&
xmpp-notify "[`hostname | cut -d . -f 1`.sync]: all repositories are sync'd. (half)"
}
full-sync(){
backup
autoci >/dev/null 2>&1 &&
syncup >/dev/null 2>&1 &&
xmpp-notify "[`hostname | cut -d . -f 1`.sync]: all changes commited and system sync'd. (full)"
}
############################################
# TODO: rewrite the following using the `case` form
if [ "$1" = "backup" ]; then
backup
elif [ `ifconfig | grep -c "wlan"` = "1" -o `ifconfig eth0 | grep -c "inet addr"` = "1" ]; then
$1-sync
else
echo "-- The network connection may not support this operation."
echo " Use \`autoci\` \`backup\` and \`syncup\` manually."
fi