-
Notifications
You must be signed in to change notification settings - Fork 0
Add CLI flags, default NeoVim to PPA, and install LazyGit #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,13 +35,35 @@ USR_BIN_DIR=/usr/local/bin | |
| # -f, --fail Fail silently (no output at all) on HTTP errors | ||
| CURL_CMD="curl -sSLf" | ||
|
|
||
| NVIM_USE_DEB=false | ||
| SPINNER_PID="" | ||
|
|
||
| UBUNTU_SUPPORTED_VERSIONS=( | ||
| "22.04" | ||
| "24.04" | ||
| ) | ||
|
|
||
| ############################################################################### | ||
| # Usage | ||
| ############################################################################### | ||
|
|
||
| # Print usage information and available options | ||
| # Usage: usage | ||
| # Arguments: none | ||
| # Returns: 0 | ||
| # Example: usage | ||
| function usage() { | ||
| echo "Usage: $(basename "${0}") [OPTIONS]" | ||
| echo | ||
| echo "Bootstrap an Ubuntu server with development and DevOps tools." | ||
| echo | ||
| echo "Options:" | ||
| echo " --nvim-deb Install NeoVim from GitHub releases .deb package" | ||
| echo " (default: install from PPA unstable)" | ||
| echo " --help Show this help message and exit" | ||
| echo | ||
| } | ||
|
|
||
| ############################################################################### | ||
| # Utils | ||
| ############################################################################### | ||
|
|
@@ -293,6 +315,7 @@ function stepSetLocales() { | |
| function stepInstallTools() { | ||
| logStep "Installing tools..." | ||
| runCmdAndLog ${APT_INSTALL} \ | ||
| build-essential \ | ||
| byobu \ | ||
| curl \ | ||
| fd-find \ | ||
|
|
@@ -384,6 +407,35 @@ function stepInstallDockerSwitch() { | |
| fi | ||
| } | ||
|
|
||
| # Install LazyGit TUI from GitHub releases | ||
| # Usage: stepInstallLazyGit | ||
| # Arguments: none | ||
| # Returns: 0 on success, non-zero on error | ||
| # Example: stepInstallLazyGit | ||
| function stepInstallLazyGit() { | ||
| local LAZYGIT_BIN="${USR_BIN_DIR}/lazygit" | ||
| local LAZYGIT_REPO="jesseduffield/lazygit" | ||
| local LAZYGIT_TMP_FILE="/tmp/lazygit.tar.gz" | ||
| if ! [ -e "${LAZYGIT_BIN}" ]; then | ||
| logStep "Installing LazyGit..." | ||
| local LAZYGIT_VERSION | ||
| LAZYGIT_VERSION=$(getLatestReleaseForRepo "${LAZYGIT_REPO}") | ||
| # Remove v prefix from version string | ||
| LAZYGIT_VERSION="${LAZYGIT_VERSION#v}" | ||
| local LAZYGIT_ASSET="lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz" | ||
| downloadLatestReleaseArtifact \ | ||
| "${LAZYGIT_REPO}" \ | ||
| "${LAZYGIT_ASSET}" \ | ||
| "${LAZYGIT_TMP_FILE}" | ||
| runCmdAndLog tar xf "${LAZYGIT_TMP_FILE}" -C /tmp lazygit | ||
| runCmdAndLog install /tmp/lazygit -D -t "${USR_BIN_DIR}/" | ||
| runCmdAndLog rm -rf "${LAZYGIT_TMP_FILE}" /tmp/lazygit | ||
|
Comment on lines
+417
to
+432
|
||
| log "LazyGit installed." | ||
| else | ||
| logStep "LazyGit already installed." | ||
| fi | ||
| } | ||
|
|
||
| # Install NeoVim and set it as the default vi/vim editor | ||
| # Usage: stepInstallNeoVim | ||
| # Arguments: none | ||
|
|
@@ -392,10 +444,21 @@ function stepInstallDockerSwitch() { | |
| function stepInstallNeoVim() { | ||
| if ! [ -e "$(command -v nvim)" ]; then | ||
| logStep "Installing NeoVim..." | ||
| # Adds repo for latest neovim version | ||
| runCmdAndLog add-apt-repository -y ppa:neovim-ppa/unstable | ||
| runCmdAndLog ${APT_CMD} update | ||
| runCmdAndLog ${APT_INSTALL} neovim | ||
| if [ "${NVIM_USE_DEB}" = true ]; then | ||
| # Install from GitHub releases .deb package | ||
| local NVIM_TMP_FILE="/tmp/nvim.deb" | ||
| downloadLatestReleaseArtifact \ | ||
| "neovim/neovim-releases" \ | ||
| "nvim-linux-x86_64.deb" \ | ||
| "${NVIM_TMP_FILE}" | ||
| runCmdAndLog ${APT_INSTALL} "${NVIM_TMP_FILE}" | ||
| runCmdAndLog rm -f "${NVIM_TMP_FILE}" | ||
| else | ||
| # Install from PPA (default) | ||
| runCmdAndLog add-apt-repository -y ppa:neovim-ppa/unstable | ||
| runCmdAndLog ${APT_CMD} update | ||
| runCmdAndLog ${APT_INSTALL} neovim | ||
| fi | ||
| # Set neovim as default vim | ||
| local NVIM_BIN | ||
| NVIM_BIN="$(command -v nvim)" | ||
|
|
@@ -537,6 +600,25 @@ if [ "$(uname -m)" != "x86_64" ]; then | |
| exit 1 | ||
| fi | ||
|
|
||
| # Parse command-line arguments | ||
| while [ $# -gt 0 ]; do | ||
| case "${1}" in | ||
| --nvim-deb) | ||
| NVIM_USE_DEB=true | ||
| ;; | ||
| --help) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| *) | ||
| logError "Unknown option: ${1}" | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| shift | ||
| done | ||
|
|
||
| STEPS=( | ||
| stepUpgradePackages | ||
| stepSetTimezone | ||
|
|
@@ -545,6 +627,7 @@ STEPS=( | |
| stepInstallDocker | ||
| stepInstallDockerCompose | ||
| stepInstallDockerSwitch | ||
| stepInstallLazyGit | ||
| stepInstallNeoVim | ||
| stepInstallSpeedTest | ||
| stepSetupPython | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
stepInstallLazyGit, you callgetLatestReleaseForRepodirectly to buildLAZYGIT_ASSETand then calldownloadLatestReleaseArtifact, which internally callsgetLatestReleaseForRepoagain to compute the release tag. If a new LazyGit release is published between these two calls, the asset name (derived from the first version value) may no longer exist under the tag returned by the second call, causing a 404/download failure. To avoid this potential version mismatch and the redundant API call, refactor so that the version is resolved exactly once (either by passing a version into the download helper or by having the helper return both tag and asset name), and ensure the asset name and release tag are always computed from the same version value.