#!/bin/bash

# This script resets all raperca content to the default
#
# If the --internal option is passed as the first arg it resets the content
# on the internal storage.
#
# If the --local option is passed as the first arg it resets the content
# on the local storage (whatever it happens to be right now, internal or USB).
#
# If none of the above options are given as the first argument it resets the
# content at all locations

. /etc/spxmanage/init-functions

init_dirs

DIR=
if [ "$1" = "--internal" ]; then
    DIR="$SHADOWCONTENTDIR"
elif [ "$1" = "--local" ]; then
    DIR="$CONTENTDIR"
fi

# Make sure that the shadow dir is mounted
mount_shadow_dir

if [ -z "$DIR" ]; then
    clean "$SHADOWCONTENTDIR" "$CONTENTDIR"
    copy_default_content "$SHADOWCONTENTDIR" "$CONTENTDIR"
else
    clean "$DIR"
    copy_default_content "$DIR"
fi

clean_davlockdb
