Overhaul the installation and detection mechanisms
This commit is contained in:
+65
-39
@@ -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
|
||||
|
||||
+23
-14
@@ -1,14 +1,33 @@
|
||||
# This file will always be taken in. .login is now
|
||||
# vestigial, and doesn't matter if first or second.
|
||||
|
||||
# These are the bits that would be in login:
|
||||
|
||||
# Reset the CSHENV_DIR
|
||||
# (TODO: Downgrade this from environment variable to shell variable)
|
||||
unsetenv CSHENV_DIR
|
||||
if( ! $?CSHENV_DIR ) then
|
||||
setenv CSHENV_DIR ~/cshenv
|
||||
if( $?CSHENV_DEBUG ) then
|
||||
echo "CSHENV_DIR is not set. Guessing it based upon "'${1}'": ${1}"
|
||||
endif
|
||||
# Done twice to strip out the hooks dir and the hook itself.
|
||||
setenv CSHENV_DIR ${1}_
|
||||
setenv CSHENV_DIR `dirname ${CSHENV_DIR}`
|
||||
setenv CSHENV_DIR `dirname ${CSHENV_DIR}`
|
||||
if( $?CSHENV_DEBUG ) then
|
||||
echo "CSHENV_DIR is auto set to ${CSHENV_DIR}"
|
||||
endif
|
||||
|
||||
if( "." == $#CSHENV_DIR ) then
|
||||
if( $?CSHENV_DEBUG ) then
|
||||
echo "CSHENV_DIR is still not set. Using guessed default."
|
||||
endif
|
||||
|
||||
set cshenv_fallback_dir
|
||||
setenv CSHENV_DIR ~/cshenv
|
||||
endif
|
||||
endif
|
||||
|
||||
if( $?CSHENV_DEBUG ) then
|
||||
echo "Set CSHENV_DIR to: " ${CSHENV_DIR}
|
||||
echo "Set (in tcshrc hook) CSHENV_DIR to: " ${CSHENV_DIR}
|
||||
endif
|
||||
|
||||
setenv LC_NUMERIC en_US.UTF-8
|
||||
@@ -25,16 +44,6 @@ if( $?CSHENV_DEBUG ) then
|
||||
echo "Starting tcshrc..."
|
||||
endif
|
||||
|
||||
#if( -z ${_} ) then
|
||||
#echo $0
|
||||
#setenv CSHENV_TCSHRC_PATH $0
|
||||
#else
|
||||
#echo ${_}
|
||||
#setenv CSHENV_TCSHRC_PATH "${_}"
|
||||
#endif
|
||||
|
||||
#echo tcshrc hook lives at: ${CSHENV_TCSHRC_PATH}
|
||||
|
||||
if( -c `tty` ) then
|
||||
if( $?CSHENV_DEBUG ) then
|
||||
echo "Going to source core tcshrc..."
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# CSHENV Aliases:
|
||||
|
||||
alias resource source ${CSHENV_DIR}/startup_hooks/tcshrc
|
||||
alias resource 'source ${CSHENV_DIR}/startup_hooks/tcshrc ${CSHENV_DIR}/startup_hooks/tcshrc'
|
||||
alias relog resource
|
||||
alias rl relog
|
||||
|
||||
|
||||
Reference in New Issue
Block a user