161 lines
3.6 KiB
Bash
Executable file
161 lines
3.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
_location=".config/yadm/shell-minimal.d/04-install-go-stuff.sh"
|
|
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>
|
|
|
|
# {{{ <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}"
|
|
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
|
|
}
|
|
# }}} </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 [ -e "$file" ]; then
|
|
_mordo "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"
|
|
|
|
_mordu "Using yadm to clone ${_repo}."
|
|
$_yadm clone "$_repo"
|
|
_mordu "${_repo} cloned."
|
|
}
|
|
# }}} </clone yadm dotz>
|
|
|
|
# {{{ <install x if asked>
|
|
_install_x_if_asked() {
|
|
# Check if -x was passed to setup-dotz, and if it was, install x.
|
|
if [[ "$1" == "-x" ]]; then
|
|
"${HOME}/.config/yadm/scripts/install-xorg.sh"
|
|
fi
|
|
}
|
|
# }}} </install x if asked>
|
|
|
|
# {{{ <yadm bootstrap>
|
|
_yadm_bootstrap() {
|
|
_mordu "Performing yadm bootstrap."
|
|
$_yadm bootstrap
|
|
}
|
|
# }}} <yadm bootstrap>
|
|
|
|
# {{{ <main loop>
|
|
_main() {
|
|
_install_golang
|
|
_install_ghq
|
|
_clone_yadm
|
|
_link_yadm_script
|
|
#_move_old_init_to_backup
|
|
#_clone_yadm_dotz
|
|
#_install_x_if_asked "$@"
|
|
#_yadm_bootstrap
|
|
}
|
|
_main
|
|
# }}} </main loop>
|
|
|
|
_mordu "Completed script."
|