Added function to close all SSH masters
This commit is contained in:
parent
13807d2300
commit
cd1cb4d92e
@ -8,14 +8,36 @@ yadm submodule foreach git pull
|
||||
# Load OS information from /etc/os-release
|
||||
eval $(awk '{print "OS_" $0}' /etc/os-release)
|
||||
|
||||
function pyenv_install() {
|
||||
if [[ ${OS_ID} == "arch" ]]; then
|
||||
sudo pacman -S --noconfirm pyenv pyenv-virtualenv
|
||||
elif [[ ${OS_ID} == "ubuntu" ]]; then
|
||||
# Install packages based on OS
|
||||
if [[ ${OS_ID} == "arch" ]]; then
|
||||
aur_helper="paru"
|
||||
# Some pacakges are AUR packages, so we need an AUR helper.
|
||||
if ! which $aur_helper &>/dev/null; then
|
||||
echo "$aur_helper not found. Installing $aur_helper..."
|
||||
cd /tmp/
|
||||
git clone https://aur.archlinux.org/${aur_helper}-bin
|
||||
cd ${aur_helper}-bin
|
||||
makepkg -si --noconfirm
|
||||
cd $HOME
|
||||
fi
|
||||
read -q "REPLY?Would you like to update the system? [Y/n] " && ${aur_helper} -Syu --noconfirm
|
||||
${aur_helper} -S --noconfirm --needed - <$HOME/.config/packages/arch.txt
|
||||
elif [[ ${OS_ID} == "ubuntu" ]]; then
|
||||
sudo apt update
|
||||
sudo apt install -y $(cat $HOME/.config/packages/ubuntu.txt)
|
||||
fi
|
||||
|
||||
function pyenv_configure() {
|
||||
if [[ ${OS_ID} == "ubuntu" ]]; then
|
||||
sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
|
||||
libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils \
|
||||
tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
|
||||
curl https://pyenv.run | bash
|
||||
# Add pyenv to current shell
|
||||
export PATH="$HOME/.pyenv/bin:$PATH"
|
||||
elif ! [[ ${OS_ID} == "arch" ]]; then
|
||||
echo "Unsupported OS for automated pyenv configuration: ${OS_PRETTY_NAME}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
pyenv install 3.10.13
|
||||
@ -43,20 +65,29 @@ function pyenv_install() {
|
||||
|
||||
# Install pyenv and configure personal and eww-modules python environments
|
||||
if [[ ! -d $HOME/.pyenv ]]; then
|
||||
pyenv_install
|
||||
pyenv_configure
|
||||
fi
|
||||
|
||||
# Git configuration
|
||||
# Assume that if the git config file exists, I've already set up my git config
|
||||
if [[ ! -f $HOME/.gitconfig ]]; then
|
||||
config_fields=(user.name commit.gpgsign init.defaultBranch pull.rebase checkout.defaultRemote log.date log.showSignature)
|
||||
config_values=(
|
||||
"Ezri Brimhall"
|
||||
true
|
||||
main
|
||||
false
|
||||
origin
|
||||
human
|
||||
true
|
||||
)
|
||||
|
||||
# Git is installed, yadm depends on git, so if this script is running, git is installed
|
||||
if ! git config --global --get user.email &>/dev/null; then
|
||||
echo "Which email address should this machine use for git?"
|
||||
read "email?> "
|
||||
git config --global user.email $email
|
||||
git config --global user.name "Ezri Brimhall"
|
||||
git config --global commit.gpgsign true
|
||||
git config --global defaultBranch main
|
||||
git config --global pull.rebase false
|
||||
git config --global checkout.defaultRemote origin
|
||||
git config --global log.date human
|
||||
git config --global log.showSignature true
|
||||
fi
|
||||
for i in {1..${#config_fields}}; do
|
||||
if ! git config --global --get ${config_fields[$i]} &>/dev/null; then
|
||||
git config --global ${config_fields[$i]} ${config_values[$i]}
|
||||
fi
|
||||
done
|
||||
|
||||
@ -34,3 +34,15 @@ function rename_window() {
|
||||
}
|
||||
|
||||
_rename_window "$DEFAULT_WINDOW_NAME"
|
||||
|
||||
function ssh-clean() {
|
||||
# Clean up ssh connection sockets
|
||||
for i in $(find ~/.ssh -type s -name 'cm-*'); do
|
||||
fname=$(basename $i)
|
||||
conn=$(echo $fname | cut -d- -f2-)
|
||||
user=$(echo $conn | cut -d@ -f1)
|
||||
host=$(echo $conn | cut -d@ -f2 | cut -d: -f1)
|
||||
echo "Closing connection to $user@$host"
|
||||
ssh -O exit -S $i -q _ 2>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user