Add separate relink command

Also rejigged install to accomodate FreeBSD, and update before installing.
This commit is contained in:
2024-11-19 10:59:09 +00:00
parent 57ec2feb3d
commit ec1ec2bbfb
2 changed files with 66 additions and 12 deletions

36
install
View File

@@ -3,6 +3,25 @@
# Adapted from Junegunn Choi (junegunn.c@gmail.com)
# https://github.com/junegunn/dotfiles/blob/master/install
BASE=$(pwd)
IS_MAC=0
IS_LINUX=0
IS_FREEBSD=0
echo "Ensuring packages/system are up to date; please enter password for sudo if requested."
case $(uname -s) in
Darwin) IS_MAC=1
brew update
;;
Linux) IS_LINUX=1
sudo apt update
;;
FreeBSD) IS_FREEBSD=1
sudo pkg upgrade
;;
*) echo "Unknown OS" ;;
esac
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
MISSING=0
@@ -16,6 +35,7 @@ check_command() {
echo "Found $FOUND."
fi
}
COMMANDS="git realpath curl"
for cmd in $COMMANDS ; do
check_command $cmd
@@ -25,18 +45,6 @@ if [ $MISSING -ne 0 ] ; then
fi
unset COMMANDS MISSING
BASE=$(pwd)
IS_MAC=0
IS_LINUX=0
if [ "$(uname -s)" == 'Darwin' ]; then
echo "Running on macOS"
IS_MAC=1
fi
if [ "$(uname -s)" == 'Linux' ]; then
echo "Running on Linux"
IS_LINUX=1
fi
# RC files
mkdir -pv bak
@@ -117,6 +125,10 @@ if [ $IS_LINUX == 1 ] ; then
sudo apt build-dep mu4e
fi
if [ $IS_FREEBSD == 1 ] ; then
sudo pkg install gmake vim rsync texinfo xsel-conrad
fi
# Just add these, for now.
ADD_ONLY="python tmux sbcl opam gohugo erlang elixir clojure"
for plugin in $ADD_ONLY ; do

42
relink Executable file
View File

@@ -0,0 +1,42 @@
#!/usr/bin/env bash
#
# Adapted from Junegunn Choi (junegunn.c@gmail.com)
# https://github.com/junegunn/dotfiles/blob/master/install
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
BASE=$(pwd)
IS_MAC=0
IS_LINUX=0
IS_FREEBSD=0
case $(uname -s) in
Darwin) IS_MAC=1 ;;
Linux) IS_LINUX=1 ;;
FreeBSD) IS_FREEBSD=1 ;;
*) echo "Unknown OS" ;;
esac
# RC files
mkdir -pv bak
for rc in *rc *profile tmux.conf bashrc.d mutt ; do
if [ ! -r $rc ] ; then
continue
fi
[ "$(realpath ~/."$rc")" == "$BASE/$rc" ]
if [ $? -ne 0 ] ; then
[ -e ~/."$rc" ] && mv -v ~/."$rc" bak/."$rc"
ln -sfv "$BASE/$rc" ~/."$rc"
fi
done
# scripts
mkdir -p ~/bin
for bin in $BASE/bin/*; do
BIN_NAME=$(basename $bin)
[ "$(realpath ~/bin/$BIN_NAME)" == "$bin" ]
if [ $? -ne 0 ] ; then
ln -svf "$bin" ~/bin
fi
done