2020-02-24 10:42:23 +01:00
|
|
|
#!/usr/bin/env bash
|
2020-02-23 15:19:08 +01:00
|
|
|
#
|
|
|
|
|
# Makes sure the dotfiles directory is in /var/lib/dotfiles and then calls
|
|
|
|
|
# install.sh
|
|
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
|
set -o nounset
|
|
|
|
|
|
|
|
|
|
DOTDIR="/var/lib/dotfiles"
|
|
|
|
|
|
|
|
|
|
_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
|
|
|
|
|
|
|
|
if [[ "$(readlink "${_SCRIPT_DIR}")" != "${DOTDIR}" ]] ; then
|
|
|
|
|
if [[ -e "${DOTDIR}" ]] ; then
|
|
|
|
|
2>&1 printf "${DOTDIR} already exists. This seems unsafe.\n"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
printf "Moving directory to $DOTDIR ...\n"
|
2020-12-08 23:09:09 +01:00
|
|
|
sudo=""
|
|
|
|
|
if (( $(id -u ) != 0 )) ; then
|
|
|
|
|
sudo=sudo
|
|
|
|
|
fi
|
|
|
|
|
$sudo mv --no-target-directory "${_SCRIPT_DIR}" "${DOTDIR}"
|
2020-02-23 15:19:08 +01:00
|
|
|
printf "Done\n"
|
|
|
|
|
else
|
|
|
|
|
printf "Already working in ${DOTDIR}, nothing to do\n"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cd "${DOTDIR}" && ./install.sh
|