adds helper to "install" aka symlink scripts

This commit is contained in:
Tobias Klaus 2017-11-14 12:06:57 +01:00
parent 72a5b7fbe1
commit 2a588c9ab5
No known key found for this signature in database
GPG key ID: E490E43F6C363F6C

23
contrib/symlinkTo.sh Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env bash
TARGET=${1:-"${HOME}/bin/"}
set -e
[[ ! -d "${TARGET}" ]] && echo "${TARGET} does not exist" && exit 1
BASEDIR="$(realpath "$(dirname "$(realpath "$0")")/..")"
for scriptpath in "${BASEDIR}"/*.sh ; do
scriptname="$(basename "$scriptpath")"
targetpath="${TARGET}/${scriptname}"
if [[ -h "$targetpath" && ! -e "$(realpath "$targetpath")" ]] ; then
echo "deleting $targetpath pointing to $(realpath "$targetpath")"
rm "$targetpath"
fi
if [[ ! -e "$targetpath" ]] ; then
echo installing "${scriptname}"
ln -s "${scriptpath}" "${TARGET}"
fi
done