#!/bin/sh
# disable facebook-contacts service and remove the sync profile

DEF_UID=$(grep "^UID_MIN" /etc/login.defs |  tr -s " " | cut -d " " -f2)
DEVICEUSER=$(getent passwd $DEF_UID | sed 's/:.*//')
if [ ! -d "/home/$DEVICEUSER/.config/libaccounts-glib" ]; then
    # not running as nemo; return failure so that we get rescheduled.
    exit 1
fi

# exit script with error if any of the commands below exit with error
set -xe

/usr/bin/sailfish-accounts-tool --remove-profile -p facebook facebook.Contacts
/usr/bin/sailfish-accounts-tool -p facebook -s facebook-contacts -m enabled bool false

exit 0
