#!/bin/bash

# usage: lander_relocate.sh <NEWLANDERTOP>

NEWTOPDIR=$1

LANDERCONF=~plander/lander.conf
[ -e $LANDERCONF ] || {
    echo $LANDERCONF is not found, your installation seems incomplete, exitting
    exit 1
}

source $LANDERCONF

cd -P $LANDER_TOPDIR

OLDTOPDIR=$PWD

cd

if [ -d $NEWTOPDIR ]; then
    mv $OLDTOPDIR/* $NEWTOPDIR/
    chown plander:${LANDER_GROUPS[main]} $NEWTOPDIR
    chmod 2775 $NEWTOP
    rmdir $OLDTOPDIR
else
    mv $OLDTOPDIR $NEWTOPDIR
fi

ln -fs $NEWTOPDIR $LANDER_TOPDIR

exit 0
