setup-dotz/setup-dotz.sh
Lord_Devi c81ed2ef6a
All checks were successful
/ deploy (push) Successful in 0s
testing local repos.
2024-07-12 04:18:25 -04:00

227 lines
5.5 KiB
Bash
Executable file

#!/usr/bin/env bash
_location=".config/yadm/shell-minimal.d/04-install-go-stuff.sh"
export GOPATH="${HOME}/.local/opt/go"
export GHQ_ROOT="${HOME}/.local/opt/git"
_ghq="${HOME}/.local/opt/go/bin/ghq"
_yadm="${HOME}/.local/bin/yadm"
#
# This script represents the start point for my dotz install.
#
# {{{ <mordu debug system>
_debug=y # Comment this out to disable debuging.
_blue="\e[34m"
_magenta="\e[35m"
_green="\e[92m"
_cyan="\e[36m"
_white="\e[97m"
_end_color="\e[0m"
# Mordu with location.
_mordu() {
[ "$_debug" ] && echo -e "${_blue}>>> ${_magenta}Mordu${_cyan}@${_green}${_location}${_cyan}:${_white} $*${_end_color}"
}
# Mordu with location and no new line.
_mordu_n() {
[ "$_debug" ] && echo -en "${_blue}>>> ${_magenta}Mordu${_cyan}@${_green}${_location}${_cyan}:${_white} $*${_end_color}"
}
# Echo with new line to add completion messages to _mordu_n
_mordu_nl() {
[ "$_debug" ] && echo -e "${_white}$*${_end_color}"
}
_mordu "Starting script."
# }}} </mordu debug system>
# {{{ <disable default repos>
_disable_default_repos() {
_mordu "Disabling fedora, fedora-updates, rpmfusion-free, rpmfusion-nonfree.rpo."
sudo sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/fedora.repo
sudo sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/fedora-updates.repo
if [ -f /etc/yum.repos.d/rpmfusion-free.rpo ]; then
sudo sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/rpmfusion-free.repo
fi
if [ -f /etc/yum.repos.d/rpmfusion-nonfree.rpo ]; then
sudo sed -i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/rpmfusion-nonfree.repo
fi
}
# }}}<disable default repos>
# {{{ <install local repos>
_install_local_repos () {
sudo tee /etc/yum.repos.d/mgk.repo > /dev/null << 'EOF'
[local-fedora]
name=Local Fedora 40
baseurl=https://mirrors.mgk.one/fedora/linux/releases/40/Everything/x86_64/os/
enabled=1
gpgcheck=0
[local-updates]
name=Local Fedora 40 Updates
baseurl=https://mirrors.mgk.one/fedora/linux/updates/40/Everything/x86_64/
enabled=1
gpgcheck=0
EOF
}
# }}} </install local repos>
# {{{ <install golang>
_install_golang() {
_mordu_n "Checking for go.."
if command -v go > /dev/null 2>&1 ; then
_mordu_nl "..Found. Not installing."
else
_mordu "..Not found. Installing go."
sudo dnf install -y golang
fi
}
# }}} </install golang>
# {{{ <install ghq>
## Make sure the binary directory exists already.
_install_ghq() {
if [ ! -d "${GOPATH}/bin" ]; then
_mordu "Did not find ${GOPATH}/bin. Creating."
mkdir -p "$GOPATH"/bin
fi
## Install Ghq
if [ -f "${GOPATH}/bin/ghq" ]; then
_mordu "Ghq already installed."
else
_mordu "Installing Ghq."
_mordu "GOPATH = ${GOPATH}"
go install github.com/x-motemen/ghq@latest
fi
}
# }}} </install ghq>
# {{{ <clone yadm>
_clone_yadm() {
local __repo="git.mgk.one/utils-system/thelocehiliosan.yadm"
if $_ghq list | grep -q "$__repo" ; then
_mordu "$__repo already installed. Updating."
$_ghq get -u "$__repo"
else
_mordu "$__repo not cloned yet. Cloning."
$_ghq get "$__repo"
fi
}
# }}} </clone yadm>
# {{{ <link yadm script>
_link_yadm_script() {
local __repo="git.mgk.one/utils-system/thelocehiliosan.yadm"
if [ ! -d "${HOME}/.local/bin" ]; then
_mordu "Creating ${HOME}/.local/bin."
mkdir -p "${HOME}/.local/bin"
fi
if [ -L "${HOME}/.local/bin/yadm" ]; then
_mordu "${HOME}/.local/bin/yadm already found. Not linking."
else
_mordu "${HOME}/.local/bin/yadm not found. Linking."
ln -sr "${GHQ_ROOT}/${__repo}"/yadm \
"${HOME}/.local/bin/"
fi
if [ ! -d "${HOME}/.local/share/man/man1" ]; then
_mordu "Creating ${HOME}/.local/share/man/man1."
mkdir -p "${HOME}/.local/share/man/man1"
fi
if [ -L "${HOME}/.local/share/man/man1/yadm.1" ]; then
_mordu "${HOME}/.local/share/man/man1/yadm.1 already found. Not linking."
else
_mordu "${HOME}/.local/share/man/man1/yadm.1 not found. Linking."
ln -sr "${GHQ_ROOT}/${__repo}"/yadm.1 \
"${HOME}/.local/share/man/man1/"
fi
}
# }}} </link yadm script>
# {{{ <move old init to backup>
_move_old_init_to_backup() {
_init_file=(\
"${HOME}/.bash_history" \
"${HOME}/.bash_logout" \
"${HOME}/.bash_profile" \
"${HOME}/.bashrc")
for file in "${_init_file[@]}" ; do
if [ -f "$file" ] && [ ! -L "$file" ]; then
_mordu "Found existing ${file}, moving to ${file}.bak."
mv "$file" "$file.bak"
fi
done
}
# }}} </move old init to backup>
# {{{ <clone yadm dotz>
_clone_yadm_dotz() {
local _repo="https://git.mgk.one/ld/dotz"
if [ -d "/home/ld/.local/share/yadm/repo.git" ]; then
_mordu "Yadm repo already exists. Not cloning."
else
_mordu "Using yadm to clone ${_repo}."
$_yadm clone --no-bootstrap "$_repo"
_mordu "${_repo} cloned."
fi
}
# }}} </clone yadm dotz>
# {{{ <install x if asked>
_install_x_if_asked() {
for arg in "$@"; do
if [[ "$arg" == "-x" ]]; then
"${HOME}/.config/yadm/scripts/install-xorg.sh"
return
fi
done
}
# }}} </install x if asked>
# {{{ <yadm bootstrap>
_yadm_bootstrap() {
_mordu "Performing yadm bootstrap."
$_yadm bootstrap
}
# }}} <yadm bootstrap>
# {{{ <install extras if asked>
_install_extras_if_asked() {
for arg in "$@"; do
if [[ "$arg" == "-e" ]]; then
"${HOME}/.config/yadm/scripts/install-extras.sh"
return
fi
done
}
# }}} </install extras if asked>
# {{{ <main loop>
_main() {
_disable_default_repos
_install_local_repos
#_install_golang
#_install_ghq
#_clone_yadm
#_link_yadm_script
#_move_old_init_to_backup
#_clone_yadm_dotz
#_install_x_if_asked "$@"
#_yadm_bootstrap
#_install_extras_if_asked
}
_main "$@"
# }}} </main loop>
_mordu "Completed script."