From ff7c38bf241b1050030a9ece5e76ef28ea5987f7 Mon Sep 17 00:00:00 2001 From: Lifailon Date: Thu, 21 Nov 2024 11:00:10 +0300 Subject: [PATCH] add auto install --- README.md | 48 ++++++++++++++++++++++++++++++------------------ install.sh | 22 ++++++++++++++++++++++ src/go.mod | 2 +- 3 files changed, 53 insertions(+), 19 deletions(-) create mode 100644 install.sh diff --git a/README.md b/README.md index bd9c4fa..0811844 100644 --- a/README.md +++ b/README.md @@ -39,17 +39,19 @@ Binaries for the Linux operating system are available on the [releases](https:// > Development is done on the Ubuntu system, also tested in WSL environment on Debian system (`amd64` platform) and Raspberry Pi (`arm64` platform). -For a quick installation, download the executable from the GitHub repository to your home directory with other executables for the current user and grant execute permissions: +Run the command in your console to quickly install or update: ```shell -version="0.1.0" -arch="amd64" # or "arm64" +curl https://raw.githubusercontent.com/Lifailon/lazyjournal/main/install.sh | bash +``` -mkdir -p ~/.local/bin -grep -F 'export PATH=$PATH:~/.local/bin' ~/.bashrc || echo 'export PATH=$PATH:~/.local/bin' >> ~/.bashrc && source ~/.bashrc +This command will run a script that will download the latest executable from the GitHub repository into your current user's home directory along with other executables (or create one) and grant execution permission. -curl -L -s https://github.com/Lifailon/lazyjournal/releases/download/$version/lazyjournal-$version-linux-$arch -o ~/.local/bin/lazyjournal -chmod +x ~/.local/bin/lazyjournal +You can also use Go for installation. To do this, the Go interpreter must be installed on the system, for example, for Ubuntu you can use the SnapCraft package manager: + +```shell +sudo snap install go --classic +go install github.com/Lifailon/lazyjournal/src@latest ``` You can launch the interface anywhere: @@ -62,20 +64,11 @@ If the current user does not have rights to read logs in the `/var/log` director ## Build -Go must be installed on the system, for example, for Ubuntu you can use the SnapCraft package manager: - -```shell -snap install go --classic -# grep -F 'export PATH=$PATH:/snap/bin' ~/.bashrc || echo 'export PATH=$PATH:/snap/bin' >> ~/.bashrc && source ~/.bashrc -go version -``` - Clone the repository, install dependencies from `go.mod` and run the project: ```shell git clone https://github.com/Lifailon/lazyjournal cd lazyjournal/src - go mod tidy go run main.go ``` @@ -88,10 +81,29 @@ arch="amd64" for arch in amd64 arm64; do GOOS=linux GOARCH=$arch go build -o bin/lazyjournal-$version-linux-$arch done - -./bin/lazyjournal-0.1.0-linux-amd64 ``` + + ## Hotkeys - `Tab` - Switch between windows. diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..ca1a862 --- /dev/null +++ b/install.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +ARCH=$(uname -m) +case $ARCH in + x86_64|amd64) ARCH="amd64" ;; + aarch64) ARCH="arm64" ;; + *) + echo -e "Processor architecture not supported:\033[31m $ARCH \033[0m" + echo -e "Create a request with a \033[31mproblem\033[0m: https://github.com/Lifailon/lazyjournal/issues" + exit 1 + ;; +esac + +mkdir -p $HOME/.local/bin +grep -F 'export PATH=$PATH:$HOME/.local/bin' $HOME/.bashrc || echo 'export PATH=$PATH:$HOME/.local/bin' >> $HOME/.bashrc && source $HOME/.bashrc + +GITHUB_LATEST_VERSION=$(curl -L -s -H 'Accept: application/json' https://github.com/Lifailon/lazyjournal/releases/latest | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/') +curl -L -s https://github.com/Lifailon/lazyjournal/releases/download/$GITHUB_LATEST_VERSION/lazyjournal-$GITHUB_LATEST_VERSION-linux-$ARCH -o $HOME/.local/bin/lazyjournal +chmod +x $HOME/.local/bin/lazyjournal + +echo -e "✔ \033[32m Installation completed successfully \033[0m" +exit 0 diff --git a/src/go.mod b/src/go.mod index bc5a5ed..bd5a749 100644 --- a/src/go.mod +++ b/src/go.mod @@ -1,4 +1,4 @@ -module lazyjournal +module github.com/Lifailon/lazyjournal/src go 1.18