Skip to content

Instantly share code, notes, and snippets.

@edigiacomo
Last active October 8, 2015 13:43
Show Gist options
  • Save edigiacomo/6fd3d70cdbd656e8467d to your computer and use it in GitHub Desktop.
Save edigiacomo/6fd3d70cdbd656e8467d to your computer and use it in GitHub Desktop.
Rescan archived section in arkimet dataset
#!/bin/bash
trap cleanup EXIT
cleanup()
{
[[ -n "$tmpdir" ]] && rm -rf $tmpdir
}
show_help()
{
echo "$0 [OPTIONS] SECTIONDIR DATASETDIR SUFFIX"
echo "Options:"
echo "-h show this help and exit"
}
while getopts :h flag
do
case $flag in
h) show_help ; exit 0 ;;
*) show_help ; exit 1 ;;
esac
done
shift $((OPTIND-1))
[[ $# == 3 ]] || { show_help; exit 1 ; }
sectiondir="$1"
datasetdir="$2"
suffix="$3"
tmpdir="$(mktemp -d)"
# Setup of temporary environment
workdsdir=$tmpdir/dataset/$(basename $sectiondir)
mkdir -p $tmpdir/dataset
mkdir -p $workdsdir
mkdir -p $tmpdir/dataset/error
cat <<EOF > $tmpdir/dataset/error/config
step = daily
type = error
EOF
sed -e '/^archive age/d' $datasetdir/config > $workdsdir/config
arki-mergeconf $tmpdir/dataset/error $workdsdir > $tmpdir/config
# Import data
find $sectiondir/ -name "*.$suffix" > $tmpdir/toimport.list
arki-scan --dispatch=$tmpdir/config --dump --files=$tmpdir/toimport.list
arki-check -f $workdsdir
arki-check -f -r $workdsdir
# Sync and reindex
rsync -av --include "*/" --include "*.${suffix}" --exclude "*" --prune-empty-dirs --delete --delete-excluded $workdsdir/ $sectiondir/
arki-check -f $datasetdir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment