2021-06-18 13:54:33 +02:00
|
|
|
usage() {
|
|
|
|
echo "Usage : ./install.sh <flag>"
|
|
|
|
echo ""
|
|
|
|
echo "Where <flag> is one of the following"
|
|
|
|
echo ""
|
|
|
|
echo " --full : Do a full install"
|
|
|
|
echo " --system : Install into system"
|
|
|
|
echo ""
|
|
|
|
echo "greetings from -=<yb4f310 ..."
|
|
|
|
}
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
|
|
|
|
LAST_ERROR=$?
|
|
|
|
|
|
|
|
if [ "${LAST_ERROR}" = 1 ] ;
|
|
|
|
then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
|
|
FLAG=$1
|
|
|
|
BIN_INSTALL_PATH=/usr/local/bin/r3
|
|
|
|
COMPLETION_INSTALL_PATH=/etc/bash_completion.d/r3-completion.bash
|
|
|
|
|
|
|
|
if [ "${FLAG}" != '--full' ] && \
|
|
|
|
[ "${FLAG}" != '--system' ];
|
|
|
|
then
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "${FLAG}" = '--full' ] || [ "${FLAG}" = '--system' ];
|
|
|
|
then
|
|
|
|
|
|
|
|
echo "installing r3.sh into system"
|
|
|
|
|
|
|
|
echo "updating r3.sh"
|
|
|
|
sed -i "/^R3_INSTALL_PATH=/s/R3_INSTALL_PATH\=.*/R3_INSTALL_PATH=$(printf %q $(pwd) | sed -E 's/([+,/,@])/\\\1/g')/" r3.sh
|
|
|
|
|
|
|
|
echo "updating r3-completion.bash"
|
|
|
|
sed -i "/^R3_INSTALL_PATH=/s/R3_INSTALL_PATH\=.*/R3_INSTALL_PATH=$(printf %q $(pwd) | sed -E 's/([+,/,@])/\\\1/g')/" r3-completion.bash
|
|
|
|
|
|
|
|
echo "r3 install path set to ${PWD}"
|
|
|
|
|
|
|
|
if [ -L "${BIN_INSTALL_PATH}" ] ;
|
|
|
|
then
|
|
|
|
echo "r3 was already installed to ${BIN_INSTALL_PATH}"
|
|
|
|
else
|
|
|
|
echo "r3 was not found at ${BIN_INSTALL_PATH} - installing now"
|
|
|
|
sudo ln -s "${PWD}/"r3.sh "${BIN_INSTALL_PATH}"
|
|
|
|
echo "successfully installed r3 at ${BIN_INSTALL_PATH}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ -L "${COMPLETION_INSTALL_PATH}" ] ;
|
|
|
|
then
|
|
|
|
echo "r3-completion.bash was already installed to ${COMPLETION_INSTALL_PATH}"
|
|
|
|
else
|
|
|
|
echo "r3-completion.bash was not found at ${COMPLETION_INSTALL_PATH} - installing now"
|
|
|
|
sudo ln -s "${PWD}/"r3-completion.bash "${COMPLETION_INSTALL_PATH}"
|
|
|
|
echo "successfully installed r3-completion.bash at ${COMPLETION_INSTALL_PATH}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "${FLAG}" = '--system' ] ;
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|