#!/bin/bash
set -x

CONFIG_DIR="/home/fascam/.config"
SCRATCH_DIR="$CONFIG_DIR/Fastec/scratch"

/usr/bin/logger "Post-update script executing"

#=============================================
# Look for .config changes
#=============================================

# Copy files from the installation location (/etc/skel/.config) to
# our home folder, but only if they are different.
/usr/bin/rsync -acv -h /etc/skel/.config/Fastec $CONFIG_DIR

# The rsync command runs as root, but the files under ".config" should
# belong to the user (i.e. "fascam").
/usr/bin/chown -R fascam:fascam $CONFIG_DIR/Fastec

#=============================================
# Cleanup after ourselves
#=============================================

/usr/bin/rm -f /tmp/pp_u*
/usr/bin/rm -rf $SCRATCH_DIR/fi_update

/usr/bin/logger "Post-update script finished"
