Overhaul the installation and detection mechanisms

This commit is contained in:
2026-06-22 09:47:14 -04:00
parent cab9f98ef9
commit 8db7a5a13e
3 changed files with 89 additions and 54 deletions
+65 -39
View File
@@ -3,47 +3,73 @@
# Yeah, my CSHENV Install script is written in Bourne shell. This is because
# CSH isn't a great scripting language, but it is a nice interactive shell.
export REALPATH=`realpath $0`
export INSTALLER_LOCATION=`dirname ${REALPATH}`
export CSHENV_LOCATION=`dirname ${INSTALLER_LOCATION}`
export RELATIVE_CSHENV_LOCATION=`realpath --relative-to=${HOME} ${CSHENV_LOCATION}`
export HOMEPATH="$(realpath ~)"
export REALPATH=$(realpath ${0})
export INSTALLER_LOCATION_REAL=$(dirname ${REALPATH})
export INSTALLER_LOCATION=$(echo ${INSTALLER_LOCATION_REAL} | sed -e 's,'"${HOMEPATH}"',~,')
export CSHENV_LOCATION_REAL=$(dirname ${INSTALLER_LOCATION_REAL})
export CSHENV_LOCATION=$(echo ${CSHENV_LOCATION_REAL} | sed -e 's,'"${HOMEPATH}"',~,')
export RELATIVE_CSHENV_LOCATION=$(echo ${CSHENV_LOCATION} | sed -e 's,~/,,')
export TMP_BASE=$(realpath ~/.cshenv/installer-backup/)
mkdir -p ${TMP_BASE}
#mkdir -p ${TMP_BASE}
export __TMP=$(mktemp -dp ${TMP_BASE})
backup_config_file()
{
__file="${1}"
mkdir -p ${__TMP}/ssh
echo "Checking for ${__file}"
if [ -e ${__file} ]
then
case ${__file} in
*ssh/config)
echo "Backing up ${__file} to ${__TMP}/ssh"
mv ${__file} ${__TMP}/ssh/$(basename ${__file} | sed -e's/\.//')
;;
*)
echo "Backing up ${__file} to ${__TMP}"
mv ${__file} ${__TMP}/$(basename ${__file} | sed -e's/\.//')
;;
esac
else
echo "${__file} does not exist, not backing up anything."
fi
}
install_shell_file()
{
__file="${1}"
backup_config_file ${1}
echo "Installing ${1}"
echo "source ${CSHENV_LOCATION}/startup_hooks/$(basename ${1} | sed -e's/\.//') "'!#:1' > ${1}
}
if [ -v CSHENV_DEBUG_INSTALLER ]
then
echo HOMEPATH: $HOMEPATH
echo REALPATH: $REALPATH
echo TMP_BASE: $TMP_BASE
echo __TMP: $__TMP
echo INSTALLER_LOCATION_REAL: $INSTALLER_LOCATION_REAL
echo INSTALLER_LOCATION: $INSTALLER_LOCATION
echo CSHENV_LOCATION: $CSHENV_LOCATION
echo RELATIVE_CSHENV_LOCATION: $RELATIVE_CSHENV_LOCATION
echo $CSHENV_LOCATION
echo $RELATIVE_CSHENV_LOCATION
exit
fi
echo "Checking for ~/.login"
if [ ! -e ~/.login ]
then
echo "Installing ~/.login"
echo "setenv CSHENV_DIR ${CSHENV_LOCATION}" >> ~/.login
echo 'source ${CSHENV_DIR}/startup_hooks/login' >> ~/.login
fi
install_shell_file ~/.login
echo "Checking for ~/.tcshrc"
if [ ! -e ~/.tcshrc ]
then
echo "Installing ~/.tcshrc"
echo "setenv CSHENV_DIR ${CSHENV_LOCATION}" >> ~/.tcshrc
echo "setenv CSHENV_HIDE_SHELL_LEVEL_AT_ONE" >> ~/.tcshrc
echo 'source ${CSHENV_DIR}/startup_hooks/tcshrc' >> ~/.tcshrc
fi
install_shell_file ~/.tcshrc
echo "Checking for vim setup"
if [ -e ~/.vimrc ]
then
echo "Relocating vimrc"
mv ~/.vimrc ~/.vim/vimrc.old
fi
if [ -e ~/.vim ]
then
echo "Relocating vim setup"
mv ~/.vim ~/.vim.old
fi
backup_config_file ~/.vimrc
backup_config_file ~/.vim
echo "Installing vim setup"
pushd ~ >& /dev/null
@@ -51,11 +77,7 @@ ln -s `echo ${RELATIVE_CSHENV_LOCATION}`/vim .vim
ln -s .vim/vimrc .vimrc
popd >& /dev/null
if [ -e ~/.gitconfig ]
then
echo "Relocating git setup"
mv ~/.gitconfig ~/.gitconfig-old
fi
backup_config_file ~/.gitconfig
echo "Installing git configuration"
@@ -73,6 +95,10 @@ echo "" >> ~/.gitconfig
echo "[commit]" >> ~/.gitconfig
echo " gpgSign = true" >> ~/.gitconfig
echo "Do not forget to add the following lines at the top and bottom of your ssh config:"
echo "Match all\n Include ${CSHENV_LOCATION}/ssh/config"
echo "Match all\n Include ${CSHENV_LOCATION}/ssh/config"
backup_config_file ~/.ssh/config
echo "Match all" >> ~/.ssh/config
echo " Include ${CSHENV_LOCATION}/ssh/prologue" >> ~/.ssh/config
echo "Match all" >> ~/.ssh/config
echo " Include ${CSHENV_LOCATION}/ssh/epilogue" >> ~/.ssh/config