#!/usr/bin/bash
#
# Synchronize local program directory and desktop starters
#
set -eu

if ! nslookup server; then
  exit 0
fi

#[[ -d /usr/local/lmn ]] || mkdir -p /usr/local/lmn
#rsync -rlptD --chown=pgmadmin:root --chmod=F755,D755 rsync://server:/local-program/ /usr/local/lmn

RSYNC_COMMAND=$(rsync -ai --delete --exclude=mimeinfo.cache \
	           --chown=root:root --chmod=F644,D755 "rsync://server:/desktopstarter" \
		   /usr/local/share/applications/ | sed '/ \.\//d')
if [[ $? -eq 0 ]] && [[ -n "${RSYNC_COMMAND}" ]]; then
    echo "${RSYNC_COMMAND}"
    update-desktop-database /usr/local/share/applications
fi
