Files
madumlao-profile/install-rhel.sh
2024-03-29 13:06:27 +08:00

81 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
# run by install.sh
# tested on os-release 9,3
APP_DIR="$(dirname "$0")"
echo "Run a dnf update"
if sudo -l dnf > /dev/null; then
sudo dnf check-update
else
echo "Unable to run dnf commands, please install manually"
fi
echo "Install git and friends"
if sudo -l dnf > /dev/null; then
sudo dnf install -y git
else
echo "Unable to autoinstall git and friends, please install manually"
fi
echo "Install zsh and friends"
if sudo -l dnf > /dev/null; then
sudo dnf install -y zsh PackageKit-command-not-found sqlite
else
echo "Unable to autoinstall zsh and friends, please install manually"
fi
echo "Install oh-my-zsh and plugins"
if ! [ -d "$HOME/.oh-my-zsh" ]; then
git clone https://github.com/ohmyzsh/ohmyzsh "$HOME/.oh-my-zsh"
fi
(
cd "$HOME/.oh-my-zsh/plugins"
git clone https://github.com/zsh-users/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting
)
echo "Changing default shell"
ZSH_PATH="$(which zsh)"
if [ -x "$ZSH_PATH" ]; then
if sudo -l chsh -s $ZSH_PATH $USER; then
sudo chsh -s $ZSH_PATH $USER
elif sudo -l usermod -s $ZSH_PATH $USER; then
sudo usermod -s $ZSH_PATH $USER
else
echo "Cannot change shell using sudo, trying password"
if ! chsh -s "$ZSH_PATH"; then
echo "Unable to change shell to $ZSH_PATH, please change shell manually"
fi
fi
else
echo "No zsh available"
fi
SKEL_DIR="$APP_DIR/skel"
BACK_DIR="$APP_DIR/backup"
echo "Backing up original profile under $BACK_DIR"
mkdir -pv "$BACK_DIR"
cd "$SKEL_DIR"
OLDIFS="$IFS"
IFS=$'\n'
for x in $(ls -a); do
[ "$x" = '.' ] || [ "$x" = '..' ] && continue;
[ "$x" = '.profile-local' ] || [ "$x" = '.profile-private' ] && continue;
[ -r "$HOME/$x" ] && echo -ne "Backup: " && mv -v "$HOME/$x" "$BACK_DIR"
echo -ne "Linking: " && ln -srv "$(pwd)/$x" "$HOME"
done
IFS="$OLDIFS"
echo "Install vim and friends"
if sudo -l dnf > /dev/null; then
sudo dnf install -y vim-enhanced
else
echo "Unable to autoinstall vim and friends, please install manually"
fi
mkdir -pv "$HOME/.vim/bundle"
git clone https://github.com/VundleVim/Vundle.vim "$HOME/.vim/bundle/Vundle.vim"
vim +PluginInstall +qall