From c156abf1345ea61411b4015055fcdda6fb9c351a Mon Sep 17 00:00:00 2001 From: Ibrahim <8837895+IbrahimTanyalcin@users.noreply.github.com> Date: Wed, 17 Jul 2024 21:42:45 +0000 Subject: [PATCH 01/10] rebase with latest changes to app-gum.sh --- get_arch.sh | 10 ++++++++++ install.sh | 2 +- install/desktop/app-chrome.sh | 11 +++++++---- install/desktop/app-signal.sh | 8 +++++--- install/desktop/optional/app-zoom.sh | 9 ++++++--- install/terminal/mise.sh | 8 +++++--- install/terminal/required/app-gum.sh | 4 +++- 7 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 get_arch.sh diff --git a/get_arch.sh b/get_arch.sh new file mode 100644 index 000000000..904717575 --- /dev/null +++ b/get_arch.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e; + +get_arch() { + ARCH=$(lscpu | awk -F: 'NR==1 {print $2}' | xargs) + if [ "$ARCH" == "aarch64" ]; then + ARCH="arm64" + fi + echo "$ARCH" +} \ No newline at end of file diff --git a/install.sh b/install.sh index 2d551e328..2a6f8dcc3 100644 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ set -e # Desktop software and tweaks will only be installed if we're running Gnome -RUNNING_GNOME=$([[ "$XDG_CURRENT_DESKTOP" == *"GNOME"* ]] && echo true || echo false) +RUNNING_GNOME=$([[ "${XDG_CURRENT_DESKTOP##*:}" =~ [Gg][Nn][Oo][Mm][Ee] ]] && echo true || echo false) # Check the distribution name and version and abort if incompatible source ~/.local/share/omakub/install/check-version.sh diff --git a/install/desktop/app-chrome.sh b/install/desktop/app-chrome.sh index 97e1361a1..da88546c8 100644 --- a/install/desktop/app-chrome.sh +++ b/install/desktop/app-chrome.sh @@ -1,7 +1,10 @@ # Browse the web with the most popular browser. See https://www.google.com/chrome/ cd /tmp -wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -sudo apt install -y ./google-chrome-stable_current_amd64.deb -rm google-chrome-stable_current_amd64.deb -xdg-settings set default-web-browser google-chrome.desktop +source ~/.local/share/omakub/get_arch.sh +ARCH=$(get_arch) +if wget "https://dl.google.com/linux/direct/google-chrome-stable_current_$ARCH.deb"; then + sudo apt install -y "./google-chrome-stable_current_$ARCH.deb" + rm "google-chrome-stable_current_$ARCH.deb" + xdg-settings set default-web-browser google-chrome.desktop +fi cd - diff --git a/install/desktop/app-signal.sh b/install/desktop/app-signal.sh index 924aec484..af2f0c1fe 100644 --- a/install/desktop/app-signal.sh +++ b/install/desktop/app-signal.sh @@ -1,7 +1,9 @@ +source ~/.local/share/omakub/get_arch.sh +ARCH=$(get_arch) wget -qO- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor >signal-desktop-keyring.gpg cat signal-desktop-keyring.gpg | sudo tee /usr/share/keyrings/signal-desktop-keyring.gpg >/dev/null -echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' | +echo "deb [arch=${ARCH} signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main" | sudo tee /etc/apt/sources.list.d/signal-xenial.list rm signal-desktop-keyring.gpg -sudo apt update -sudo apt install -y signal-desktop +sudo apt update || true +sudo apt install -y signal-desktop || true diff --git a/install/desktop/optional/app-zoom.sh b/install/desktop/optional/app-zoom.sh index a773e58dc..70085bd5c 100644 --- a/install/desktop/optional/app-zoom.sh +++ b/install/desktop/optional/app-zoom.sh @@ -1,6 +1,9 @@ # Make video calls using https://zoom.us/ cd /tmp -wget https://zoom.us/client/latest/zoom_amd64.deb -sudo apt install -y ./zoom_amd64.deb -rm zoom_amd64.deb +source ~/.local/share/omakub/get_arch.sh +ARCH=$(get_arch) +if wget "https://zoom.us/client/latest/zoom_${ARCH}.deb"; then + sudo apt install -y "./zoom_${ARCH}.deb" || true + rm "zoom_${ARCH}.deb" +fi cd - diff --git a/install/terminal/mise.sh b/install/terminal/mise.sh index a89332a2b..5c64c27e7 100644 --- a/install/terminal/mise.sh +++ b/install/terminal/mise.sh @@ -1,7 +1,9 @@ +source ~/.local/share/omakub/get_arch.sh +ARCH=$(get_arch) # Install mise for managing multiple versions of languages. See https://mise.jdx.dev/ sudo apt update -y && sudo apt install -y gpg sudo wget curl sudo install -dm 755 /etc/apt/keyrings wget -qO - https://mise.jdx.dev/gpg-key.pub | gpg --dearmor | sudo tee /etc/apt/keyrings/mise-archive-keyring.gpg 1>/dev/null -echo "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.gpg arch=$(dpkg --print-architecture)] https://mise.jdx.dev/deb stable main" | sudo tee /etc/apt/sources.list.d/mise.list -sudo apt update -sudo apt install -y mise +echo "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.gpg arch=${ARCH}] https://mise.jdx.dev/deb stable main" | sudo tee /etc/apt/sources.list.d/mise.list +sudo apt update || true +sudo apt install -y mise || true diff --git a/install/terminal/required/app-gum.sh b/install/terminal/required/app-gum.sh index 4fc1e3234..8b279521c 100644 --- a/install/terminal/required/app-gum.sh +++ b/install/terminal/required/app-gum.sh @@ -1,7 +1,9 @@ # Gum is used for the Omakub commands for tailoring Omakub after the initial install cd /tmp +source ~/.local/share/omakub/get_arch.sh +ARCH=$(get_arch) GUM_VERSION="0.14.3" # Use known good version -wget -qO gum.deb "https://github.com/charmbracelet/gum/releases/download/v${GUM_VERSION}/gum_${GUM_VERSION}_amd64.deb" +wget -qO gum.deb "https://github.com/charmbracelet/gum/releases/download/v${GUM_VERSION}/gum_${GUM_VERSION}_${ARCH}.deb" sudo apt-get install -y ./gum.deb rm gum.deb cd - From bd1420b3912ee0bc024460b6759d67393780232d Mon Sep 17 00:00:00 2001 From: Ibrahim <8837895+IbrahimTanyalcin@users.noreply.github.com> Date: Thu, 18 Jul 2024 19:13:48 +0000 Subject: [PATCH 02/10] enable arch aliases, remove hardcoded x86_64 --- get_arch.sh | 29 +++++++++++++++++++++++----- install/desktop/app-chrome.sh | 2 +- install/desktop/app-localsend.sh | 9 ++++++--- install/desktop/app-signal.sh | 2 +- install/desktop/optional/app-zoom.sh | 2 +- install/terminal/app-lazydocker.sh | 11 +++++++---- install/terminal/app-lazygit.sh | 11 +++++++---- install/terminal/app-zellij.sh | 20 +++++++++++-------- install/terminal/docker.sh | 12 +++++++++++- 9 files changed, 70 insertions(+), 28 deletions(-) diff --git a/get_arch.sh b/get_arch.sh index 904717575..784f4113a 100644 --- a/get_arch.sh +++ b/get_arch.sh @@ -1,10 +1,29 @@ #!/bin/bash set -e; +declare -A arch_config=( + ["chrome.x86_64"]="amd64" + ["chrome.aarch64"]="arm64" + ["signal.x86_64"]="amd64" + ["signal.aarch64"]="arm64" + ["zoom.x86_64"]="amd64" + ["zoom.aarch64"]="arm64" + ["localsend.x86_64"]="x86-64" + ["localsend.aarch64"]="arm-64" + ["lazygit.aarch64"]="arm64" + ["lazydocker.aarch64"]="arm64" +) + +get_arch_config() { + local arch="${1}" + local prog="${2:-"default"}" + local searchStr="${prog}.${arch}" + local archAlias="${arch_config[$searchStr]:-$arch}" + echo -n "$archAlias" +} + get_arch() { - ARCH=$(lscpu | awk -F: 'NR==1 {print $2}' | xargs) - if [ "$ARCH" == "aarch64" ]; then - ARCH="arm64" - fi - echo "$ARCH" + local prog="$1" + local ARCH=$(lscpu | awk -F: 'NR==1 {print $2}' | xargs) + echo -n "$(get_arch_config "$ARCH" "$prog")" } \ No newline at end of file diff --git a/install/desktop/app-chrome.sh b/install/desktop/app-chrome.sh index da88546c8..32f46c34e 100644 --- a/install/desktop/app-chrome.sh +++ b/install/desktop/app-chrome.sh @@ -1,7 +1,7 @@ # Browse the web with the most popular browser. See https://www.google.com/chrome/ cd /tmp source ~/.local/share/omakub/get_arch.sh -ARCH=$(get_arch) +ARCH=$(get_arch "chrome") if wget "https://dl.google.com/linux/direct/google-chrome-stable_current_$ARCH.deb"; then sudo apt install -y "./google-chrome-stable_current_$ARCH.deb" rm "google-chrome-stable_current_$ARCH.deb" diff --git a/install/desktop/app-localsend.sh b/install/desktop/app-localsend.sh index 56b571ec7..7b63f976c 100644 --- a/install/desktop/app-localsend.sh +++ b/install/desktop/app-localsend.sh @@ -1,6 +1,9 @@ cd /tmp +source ~/.local/share/omakub/get_arch.sh +ARCH=$(get_arch "localsend") LOCALSEND_VERSION=$(curl -s "https://api.github.com/repos/localsend/localsend/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') -wget -O localsend.deb "https://github.com/localsend/localsend/releases/latest/download/LocalSend-${LOCALSEND_VERSION}-linux-x86-64.deb" -sudo apt install -y ./localsend.deb -rm localsend.deb +if wget -O localsend.deb "https://github.com/localsend/localsend/releases/latest/download/LocalSend-${LOCALSEND_VERSION}-linux-${ARCH}.deb"; then + sudo apt install -y ./localsend.deb + rm localsend.deb +fi cd - diff --git a/install/desktop/app-signal.sh b/install/desktop/app-signal.sh index af2f0c1fe..faa4fc0ba 100644 --- a/install/desktop/app-signal.sh +++ b/install/desktop/app-signal.sh @@ -1,5 +1,5 @@ source ~/.local/share/omakub/get_arch.sh -ARCH=$(get_arch) +ARCH=$(get_arch "signal") wget -qO- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor >signal-desktop-keyring.gpg cat signal-desktop-keyring.gpg | sudo tee /usr/share/keyrings/signal-desktop-keyring.gpg >/dev/null echo "deb [arch=${ARCH} signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main" | diff --git a/install/desktop/optional/app-zoom.sh b/install/desktop/optional/app-zoom.sh index 70085bd5c..ab6fe1dd1 100644 --- a/install/desktop/optional/app-zoom.sh +++ b/install/desktop/optional/app-zoom.sh @@ -1,7 +1,7 @@ # Make video calls using https://zoom.us/ cd /tmp source ~/.local/share/omakub/get_arch.sh -ARCH=$(get_arch) +ARCH=$(get_arch "zoom") if wget "https://zoom.us/client/latest/zoom_${ARCH}.deb"; then sudo apt install -y "./zoom_${ARCH}.deb" || true rm "zoom_${ARCH}.deb" diff --git a/install/terminal/app-lazydocker.sh b/install/terminal/app-lazydocker.sh index 6f62afbbf..0c08c9d9a 100644 --- a/install/terminal/app-lazydocker.sh +++ b/install/terminal/app-lazydocker.sh @@ -1,7 +1,10 @@ cd /tmp +source ~/.local/share/omakub/get_arch.sh +ARCH=$(get_arch "lazydocker") LAZYDOCKER_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazydocker/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') -curl -sLo lazydocker.tar.gz "https://github.com/jesseduffield/lazydocker/releases/latest/download/lazydocker_${LAZYDOCKER_VERSION}_Linux_x86_64.tar.gz" -tar -xf lazydocker.tar.gz lazydocker -sudo install lazydocker /usr/local/bin -rm lazydocker.tar.gz lazydocker +if curl -sLo lazydocker.tar.gz "https://github.com/jesseduffield/lazydocker/releases/latest/download/lazydocker_${LAZYDOCKER_VERSION}_Linux_${ARCH}.tar.gz"; then + tar -xf lazydocker.tar.gz lazydocker + sudo install lazydocker /usr/local/bin + rm lazydocker.tar.gz lazydocker +fi cd - diff --git a/install/terminal/app-lazygit.sh b/install/terminal/app-lazygit.sh index 70f90fe56..e82ef376d 100644 --- a/install/terminal/app-lazygit.sh +++ b/install/terminal/app-lazygit.sh @@ -1,7 +1,10 @@ cd /tmp +source ~/.local/share/omakub/get_arch.sh +ARCH=$(get_arch "lazygit") LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') -curl -sLo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz" -tar -xf lazygit.tar.gz lazygit -sudo install lazygit /usr/local/bin -rm lazygit.tar.gz lazygit +if curl -sLo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_${ARCH}.tar.gz"; then + tar -xf lazygit.tar.gz lazygit + sudo install lazygit /usr/local/bin + rm lazygit.tar.gz lazygit +fi cd - diff --git a/install/terminal/app-zellij.sh b/install/terminal/app-zellij.sh index 170b334e8..c89609d7a 100644 --- a/install/terminal/app-zellij.sh +++ b/install/terminal/app-zellij.sh @@ -1,10 +1,14 @@ cd /tmp -wget -O zellij.tar.gz "https://github.com/zellij-org/zellij/releases/latest/download/zellij-x86_64-unknown-linux-musl.tar.gz" -tar -xf zellij.tar.gz zellij -sudo install zellij /usr/local/bin -rm zellij.tar.gz zellij -cd - +source ~/.local/share/omakub/get_arch.sh +ARCH=$(get_arch "zellij") +if wget -O zellij.tar.gz "https://github.com/zellij-org/zellij/releases/latest/download/zellij-${ARCH}-unknown-linux-musl.tar.gz"; then + ZELLIJ_SUCCESS=true + tar -xf zellij.tar.gz zellij + sudo install zellij /usr/local/bin + rm zellij.tar.gz zellij -mkdir -p ~/.config/zellij/themes -[ ! -f "$HOME/.config/zellij/config.kdl" ] && cp ~/.local/share/omakub/configs/zellij.kdl ~/.config/zellij/config.kdl -cp ~/.local/share/omakub/themes/tokyo-night/zellij.kdl ~/.config/zellij/themes/tokyo-night.kdl + mkdir -p ~/.config/zellij/themes + [ ! -f "$HOME/.config/zellij/config.kdl" ] && cp ~/.local/share/omakub/configs/zellij.kdl ~/.config/zellij/config.kdl + cp ~/.local/share/omakub/themes/tokyo-night/zellij.kdl ~/.config/zellij/themes/tokyo-night.kdl +fi +cd - diff --git a/install/terminal/docker.sh b/install/terminal/docker.sh index bd81d8172..8647e6ba5 100644 --- a/install/terminal/docker.sh +++ b/install/terminal/docker.sh @@ -1,3 +1,6 @@ +source ~/.local/share/omakub/get_arch.sh +ARCH=$(get_arch "dockercompose") + # Add the official Docker repo sudo install -m 0755 -d /etc/apt/keyrings sudo wget -qO /etc/apt/keyrings/docker.asc https://download.docker.com/linux/ubuntu/gpg @@ -6,10 +9,17 @@ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker. sudo apt update # Install Docker engine and standard plugins -sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras +sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras docker.io docker-buildx # Give this user privileged Docker access sudo usermod -aG docker ${USER} # Limit log size to avoid running out of disk echo '{"log-driver":"json-file","log-opts":{"max-size":"10m","max-file":"5"}}' | sudo tee /etc/docker/daemon.json + +DOCKER_COMPOSE_VERSION="2.27.0" +DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} +mkdir -p $DOCKER_CONFIG/cli-plugins +if curl -sSL "https://github.com/docker/compose/releases/download/v$DOCKER_COMPOSE_VERSION/docker-compose-linux-${ARCH}" -o "$DOCKER_CONFIG/cli-plugins/docker-compose"; then + chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose +fi From 3a4a6c22fcd34bf2d51c587d03deffee87caffc1 Mon Sep 17 00:00:00 2001 From: Ibrahim <8837895+IbrahimTanyalcin@users.noreply.github.com> Date: Thu, 18 Jul 2024 19:34:56 +0000 Subject: [PATCH 03/10] add arch alias for gum into get_arch.sh --- get_arch.sh | 2 ++ install/terminal/required/app-gum.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/get_arch.sh b/get_arch.sh index 784f4113a..b6b3d3ac0 100644 --- a/get_arch.sh +++ b/get_arch.sh @@ -2,6 +2,8 @@ set -e; declare -A arch_config=( + ["gum.x86_64"]="amd64" + ["gum.aarch64"]="arm64" ["chrome.x86_64"]="amd64" ["chrome.aarch64"]="arm64" ["signal.x86_64"]="amd64" diff --git a/install/terminal/required/app-gum.sh b/install/terminal/required/app-gum.sh index 8b279521c..9a61f4015 100644 --- a/install/terminal/required/app-gum.sh +++ b/install/terminal/required/app-gum.sh @@ -1,7 +1,7 @@ # Gum is used for the Omakub commands for tailoring Omakub after the initial install cd /tmp source ~/.local/share/omakub/get_arch.sh -ARCH=$(get_arch) +ARCH=$(get_arch "gum") GUM_VERSION="0.14.3" # Use known good version wget -qO gum.deb "https://github.com/charmbracelet/gum/releases/download/v${GUM_VERSION}/gum_${GUM_VERSION}_${ARCH}.deb" sudo apt-get install -y ./gum.deb From 1df9bfeabb7dd5fc4f0cf01c6ee72f5819220e1d Mon Sep 17 00:00:00 2001 From: Ibrahim <8837895+IbrahimTanyalcin@users.noreply.github.com> Date: Thu, 18 Jul 2024 19:52:44 +0000 Subject: [PATCH 04/10] add comments to get_arch --- get_arch.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/get_arch.sh b/get_arch.sh index b6b3d3ac0..3fa6e9aae 100644 --- a/get_arch.sh +++ b/get_arch.sh @@ -1,6 +1,7 @@ #!/bin/bash set -e; +#assoc array to list app specific arch aliases declare -A arch_config=( ["gum.x86_64"]="amd64" ["gum.aarch64"]="arm64" @@ -16,6 +17,7 @@ declare -A arch_config=( ["lazydocker.aarch64"]="arm64" ) +#a getter func to lookup into above assos array. Unfound keys/default value is what is returned from lscpu get_arch_config() { local arch="${1}" local prog="${2:-"default"}" @@ -24,6 +26,8 @@ get_arch_config() { echo -n "$archAlias" } +# Usage: +# echo "$(get_arch "chrome")" //for aarch64, returns arm64 get_arch() { local prog="$1" local ARCH=$(lscpu | awk -F: 'NR==1 {print $2}' | xargs) From d57d42f7a6d3830485cc5d368dfa14383e7148ad Mon Sep 17 00:00:00 2001 From: Ibrahim <8837895+IbrahimTanyalcin@users.noreply.github.com> Date: Thu, 18 Jul 2024 21:10:14 +0000 Subject: [PATCH 05/10] add aliases for vscode and neovim. If vscode keyring fails, try to download deb file directly and install via apt. Install neovim through snapd for aarch64. --- get_arch.sh | 3 ++ install/desktop/app-vscode.sh | 44 ++++++++++++++++++------ install/terminal/app-neovim.sh | 63 +++++++++++++++++++++------------- 3 files changed, 75 insertions(+), 35 deletions(-) diff --git a/get_arch.sh b/get_arch.sh index 3fa6e9aae..914da3644 100644 --- a/get_arch.sh +++ b/get_arch.sh @@ -15,6 +15,9 @@ declare -A arch_config=( ["localsend.aarch64"]="arm-64" ["lazygit.aarch64"]="arm64" ["lazydocker.aarch64"]="arm64" + ["vscode.x86_64"]="x64" + ["vscode.aarch64"]="arm64" + ["neovim.x86_64"]="x64" ) #a getter func to lookup into above assos array. Unfound keys/default value is what is returned from lscpu diff --git a/install/desktop/app-vscode.sh b/install/desktop/app-vscode.sh index bb374a42a..6900c060c 100644 --- a/install/desktop/app-vscode.sh +++ b/install/desktop/app-vscode.sh @@ -1,15 +1,37 @@ cd /tmp -wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor >packages.microsoft.gpg -sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg -echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list >/dev/null -rm -f packages.microsoft.gpg -cd - -sudo apt update -y -sudo apt install -y code +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi +ARCH=$(get_arch "vscode") -mkdir -p ~/.config/Code/User -cp ~/.local/share/omakub/configs/vscode.json ~/.config/Code/User/settings.json +if wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor >packages.microsoft.gpg; then + sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg + echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list >/dev/null + rm -f packages.microsoft.gpg + cd - + + sudo apt update -y + sudo apt install -y code + + mkdir -p ~/.config/Code/User + cp ~/.local/share/omakub/configs/vscode.json ~/.config/Code/User/settings.json + + # Install default supported themes + code --install-extension enkia.tokyo-night + cd - +elif wget -O code.deb "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-${ARCH}"; then + sudo apt install -y ./code.deb + rm code.deb + + mkdir -p ~/.config/Code/User + cp ~/.local/share/omakub/configs/vscode.json ~/.config/Code/User/settings.json + + # Install default supported themes + code --install-extension enkia.tokyo-night + cd - +else + cd - + false +fi -# Install default supported themes -code --install-extension enkia.tokyo-night diff --git a/install/terminal/app-neovim.sh b/install/terminal/app-neovim.sh index a5ea1a428..044046f04 100644 --- a/install/terminal/app-neovim.sh +++ b/install/terminal/app-neovim.sh @@ -1,33 +1,48 @@ cd /tmp -wget -O nvim.tar.gz "https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz" -tar -xf nvim.tar.gz -sudo install nvim-linux64/bin/nvim /usr/local/bin/nvim -sudo cp -R nvim-linux64/lib /usr/local/ -sudo cp -R nvim-linux64/share /usr/local/ -rm -rf nvim-linux64 nvim.tar.gz +source ~/.local/share/omakub/get_arch.sh +ARCH=$(get_arch "neovim") +NEOVIM_SUCCESS=false +if [[ "${ARCH}" == "aarch64" ]]; then + if ! command -v snap &> /dev/null; then + sudo apt update + sudo apt install -y snapd + fi + sudo snap install --classic nvim && NEOVIM_SUCCESS=true +else + if wget -O nvim.tar.gz "https://github.com/neovim/neovim/releases/latest/download/nvim-linu${ARCH}.tar.gz"; then + tar -xf nvim.tar.gz + sudo install nvim-linu${ARCH}/bin/nvim /usr/local/bin/nvim + sudo cp -R nvim-linu${ARCH}/lib /usr/local/ + sudo cp -R nvim-linu${ARCH}/share /usr/local/ + rm -rf nvim-linu${ARCH} nvim.tar.gz + NEOVIM_SUCCESS=true + fi +fi cd - -# Only attempt to set configuration if Neovim has never been run -if [ ! -d "$HOME/.config/nvim" ]; then - # Use LazyVim - git clone https://github.com/LazyVim/starter ~/.config/nvim +if "${NEOVIM_SUCCESS}"; then + # Only attempt to set configuration if Neovim has never been run + if [ ! -d "$HOME/.config/nvim" ]; then + # Use LazyVim + git clone https://github.com/LazyVim/starter ~/.config/nvim - # Disable update notification popup in starter config - sed -i 's/checker = { enabled = true }/checker = { enabled = true, notify = false }/g' ~/.config/nvim/lua/config/lazy.lua + # Disable update notification popup in starter config + sed -i 's/checker = { enabled = true }/checker = { enabled = true, notify = false }/g' ~/.config/nvim/lua/config/lazy.lua - # Make everything match the terminal transparency - mkdir -p ~/.config/nvim/plugin/after - cp ~/.local/share/omakub/configs/neovim/transparency.lua ~/.config/nvim/plugin/after/ + # Make everything match the terminal transparency + mkdir -p ~/.config/nvim/plugin/after + cp ~/.local/share/omakub/configs/neovim/transparency.lua ~/.config/nvim/plugin/after/ - # Default to Tokyo Night theme - cp ~/.local/share/omakub/themes/tokyo-night/neovim.lua ~/.config/nvim/lua/plugins/theme.lua + # Default to Tokyo Night theme + cp ~/.local/share/omakub/themes/tokyo-night/neovim.lua ~/.config/nvim/lua/plugins/theme.lua - # Enable default extras - cp ~/.local/share/omakub/configs/neovim/lazyvim.json ~/.config/nvim/lazyvim.json -fi + # Enable default extras + cp ~/.local/share/omakub/configs/neovim/lazyvim.json ~/.config/nvim/lazyvim.json + fi -# Replace desktop launcher with one running inside Alacritty -if [[ -d ~/.local/share/applications ]]; then - sudo rm -rf /usr/share/applications/nvim.desktop - source ~/.local/share/omakub/applications/Neovim.sh + # Replace desktop launcher with one running inside Alacritty + if [[ -d ~/.local/share/applications ]]; then + sudo rm -rf /usr/share/applications/nvim.desktop + source ~/.local/share/omakub/applications/Neovim.sh + fi fi From a107b988cad499868163fdf0eeebd2345ddb49d2 Mon Sep 17 00:00:00 2001 From: Ibrahim <8837895+IbrahimTanyalcin@users.noreply.github.com> Date: Sun, 21 Jul 2024 00:03:12 +0000 Subject: [PATCH 06/10] add installation report, provide alternative download of 1password --- bin/omakub-sub/install.sh | 10 ++- bin/omakub-sub/update.sh | 10 ++- get_arch.sh | 38 --------- install.sh | 5 ++ install/desktop.sh | 11 ++- install/desktop/app-chrome.sh | 10 ++- install/desktop/app-localsend.sh | 9 ++- install/desktop/app-signal.sh | 8 +- install/desktop/app-vscode.sh | 1 + install/desktop/optional/app-1password.sh | 51 ++++++++---- install/desktop/optional/app-zoom.sh | 11 ++- install/desktop/select-optional-apps.sh | 10 ++- install/terminal.sh | 11 ++- install/terminal/app-lazydocker.sh | 10 ++- install/terminal/app-lazygit.sh | 9 ++- install/terminal/app-neovim.sh | 6 +- install/terminal/app-zellij.sh | 10 ++- install/terminal/docker.sh | 6 +- install/terminal/mise.sh | 8 +- install/terminal/required/app-gum.sh | 4 +- utils.sh | 94 +++++++++++++++++++++++ 21 files changed, 252 insertions(+), 80 deletions(-) delete mode 100644 get_arch.sh create mode 100644 utils.sh diff --git a/bin/omakub-sub/install.sh b/bin/omakub-sub/install.sh index 3e35081cb..8f87a0f04 100644 --- a/bin/omakub-sub/install.sh +++ b/bin/omakub-sub/install.sh @@ -1,3 +1,8 @@ +#source the utils if not sourced already +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi + CHOICES=( "Dev Language Install programming language environment" "Dev Database Install development database in Docker" @@ -40,7 +45,10 @@ else *) INSTALLER_FILE="$OMAKUB_PATH/install/desktop/optional/app-$INSTALLER.sh" ;; esac - source $INSTALLER_FILE && gum spin --spinner globe --title "Install completed!" -- sleep 3 + trap "handle_omakub_source_error $INSTALLER_FILE" ERR + source $INSTALLER_FILE && gum spin --spinner globe --title "Install completed!" -- sleep 3 \ + && handle_omakub_source_success "$INSTALLER_FILE" + trap - ERR fi clear diff --git a/bin/omakub-sub/update.sh b/bin/omakub-sub/update.sh index 1b0808c85..1b05bad6b 100644 --- a/bin/omakub-sub/update.sh +++ b/bin/omakub-sub/update.sh @@ -1,3 +1,8 @@ +#source the utils if not sourced already +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi + CHOICES=( "Omakub Update Omakub itself and run any migrations" "Ollama Run LLMs, like Meta's Llama3, locally" @@ -23,7 +28,10 @@ else *) INSTALLER_FILE="$OMAKUB_PATH/install/terminal/app-$INSTALLER.sh" ;; esac - source $INSTALLER_FILE && gum spin --spinner globe --title "Update completed!" -- sleep 3 + trap "handle_omakub_source_error $INSTALLER_FILE" ERR + source $INSTALLER_FILE && gum spin --spinner globe --title "Update completed!" -- sleep 3 \ + && handle_omakub_source_success "$INSTALLER_FILE" + trap - ERR fi clear diff --git a/get_arch.sh b/get_arch.sh deleted file mode 100644 index 914da3644..000000000 --- a/get_arch.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/bash -set -e; - -#assoc array to list app specific arch aliases -declare -A arch_config=( - ["gum.x86_64"]="amd64" - ["gum.aarch64"]="arm64" - ["chrome.x86_64"]="amd64" - ["chrome.aarch64"]="arm64" - ["signal.x86_64"]="amd64" - ["signal.aarch64"]="arm64" - ["zoom.x86_64"]="amd64" - ["zoom.aarch64"]="arm64" - ["localsend.x86_64"]="x86-64" - ["localsend.aarch64"]="arm-64" - ["lazygit.aarch64"]="arm64" - ["lazydocker.aarch64"]="arm64" - ["vscode.x86_64"]="x64" - ["vscode.aarch64"]="arm64" - ["neovim.x86_64"]="x64" -) - -#a getter func to lookup into above assos array. Unfound keys/default value is what is returned from lscpu -get_arch_config() { - local arch="${1}" - local prog="${2:-"default"}" - local searchStr="${prog}.${arch}" - local archAlias="${arch_config[$searchStr]:-$arch}" - echo -n "$archAlias" -} - -# Usage: -# echo "$(get_arch "chrome")" //for aarch64, returns arm64 -get_arch() { - local prog="$1" - local ARCH=$(lscpu | awk -F: 'NR==1 {print $2}' | xargs) - echo -n "$(get_arch_config "$ARCH" "$prog")" -} \ No newline at end of file diff --git a/install.sh b/install.sh index 2a6f8dcc3..3c5fb515a 100644 --- a/install.sh +++ b/install.sh @@ -7,6 +7,9 @@ RUNNING_GNOME=$([[ "${XDG_CURRENT_DESKTOP##*:}" =~ [Gg][Nn][Oo][Mm][Ee] ]] && ec # Check the distribution name and version and abort if incompatible source ~/.local/share/omakub/install/check-version.sh +#source the util functions +source ~/.local/share/omakub/utils.sh + if $RUNNING_GNOME; then # Ensure computer doesn't go to sleep or lock while installing gsettings set org.gnome.desktop.screensaver lock-enabled false @@ -32,3 +35,5 @@ if $RUNNING_GNOME; then gsettings set org.gnome.desktop.screensaver lock-enabled true gsettings set org.gnome.desktop.session idle-delay 300 fi + +print_omakub_report | tee ~/.local/share/omakub/omakub_report.log diff --git a/install/desktop.sh b/install/desktop.sh index 85c2006b6..70727847a 100644 --- a/install/desktop.sh +++ b/install/desktop.sh @@ -2,8 +2,17 @@ gsettings set org.gnome.desktop.screensaver lock-enabled false gsettings set org.gnome.desktop.session idle-delay 0 +#source the utils if not sourced already +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi + # Run desktop installers -for installer in ~/.local/share/omakub/install/desktop/*.sh; do source $installer; done +for installer in ~/.local/share/omakub/install/desktop/*.sh; do + trap "handle_omakub_source_error $installer" ERR + source "$installer" && handle_omakub_source_success "$installer" + trap - ERR +done # Revert to normal idle and lock settings gsettings set org.gnome.desktop.screensaver lock-enabled true diff --git a/install/desktop/app-chrome.sh b/install/desktop/app-chrome.sh index 32f46c34e..32dc183de 100644 --- a/install/desktop/app-chrome.sh +++ b/install/desktop/app-chrome.sh @@ -1,10 +1,16 @@ # Browse the web with the most popular browser. See https://www.google.com/chrome/ cd /tmp -source ~/.local/share/omakub/get_arch.sh +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi ARCH=$(get_arch "chrome") if wget "https://dl.google.com/linux/direct/google-chrome-stable_current_$ARCH.deb"; then sudo apt install -y "./google-chrome-stable_current_$ARCH.deb" rm "google-chrome-stable_current_$ARCH.deb" xdg-settings set default-web-browser google-chrome.desktop + cd - +else + cd - + false fi -cd - + diff --git a/install/desktop/app-localsend.sh b/install/desktop/app-localsend.sh index 7b63f976c..21132f8a4 100644 --- a/install/desktop/app-localsend.sh +++ b/install/desktop/app-localsend.sh @@ -1,9 +1,14 @@ cd /tmp -source ~/.local/share/omakub/get_arch.sh +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi ARCH=$(get_arch "localsend") LOCALSEND_VERSION=$(curl -s "https://api.github.com/repos/localsend/localsend/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') if wget -O localsend.deb "https://github.com/localsend/localsend/releases/latest/download/LocalSend-${LOCALSEND_VERSION}-linux-${ARCH}.deb"; then sudo apt install -y ./localsend.deb rm localsend.deb + cd - +else + cd - + false fi -cd - diff --git a/install/desktop/app-signal.sh b/install/desktop/app-signal.sh index faa4fc0ba..ce9116f34 100644 --- a/install/desktop/app-signal.sh +++ b/install/desktop/app-signal.sh @@ -1,9 +1,11 @@ -source ~/.local/share/omakub/get_arch.sh +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi ARCH=$(get_arch "signal") wget -qO- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor >signal-desktop-keyring.gpg cat signal-desktop-keyring.gpg | sudo tee /usr/share/keyrings/signal-desktop-keyring.gpg >/dev/null echo "deb [arch=${ARCH} signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main" | sudo tee /etc/apt/sources.list.d/signal-xenial.list rm signal-desktop-keyring.gpg -sudo apt update || true -sudo apt install -y signal-desktop || true +sudo apt update +sudo apt install -y signal-desktop diff --git a/install/desktop/app-vscode.sh b/install/desktop/app-vscode.sh index 6900c060c..447fd84f6 100644 --- a/install/desktop/app-vscode.sh +++ b/install/desktop/app-vscode.sh @@ -1,4 +1,5 @@ cd /tmp +<<<<<<< HEAD if [[ -z $UTILS_SOURCED ]]; then source ~/.local/share/omakub/utils.sh diff --git a/install/desktop/optional/app-1password.sh b/install/desktop/optional/app-1password.sh index f6cb80e98..793bed6db 100755 --- a/install/desktop/optional/app-1password.sh +++ b/install/desktop/optional/app-1password.sh @@ -1,18 +1,39 @@ -# Install 1password and 1password-cli single script -curl -sS https://downloads.1password.com/linux/keys/1password.asc | \ -sudo gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi +ARCH=$(get_arch) +case "$ARCH" in + --aarch64) + cd /tmp + curl -sSO https://downloads.1password.com/linux/tar/stable/aarch64/1password-latest.tar.gz + curl -sSO https://downloads.1password.com/linux/tar/stable/aarch64/1password-latest.tar.gz.sig + gpg --keyserver keyserver.ubuntu.com --recv-keys 3FEF9748469ADBE15DA7CA80AC2D62742012EA22 + gpg --verify 1password-latest.tar.gz.sig 1password-latest.tar.gz + [ $? -eq 0 ] || { cd - && false; } + sudo tar -xf 1password-latest.tar.gz + sudo mkdir -p /opt/1Password + sudo mv 1password-*/* /opt/1Password + sudo /opt/1Password/after-install.sh + cd - + ;; + --*) + # Install 1password and 1password-cli single script + curl -sS https://downloads.1password.com/linux/keys/1password.asc | \ + sudo gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg -# Add apt repository -echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/$(dpkg --print-architecture) stable main" | -sudo tee /etc/apt/sources.list.d/1password.list + # Add apt repository + echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/$(dpkg --print-architecture) stable main" | + sudo tee /etc/apt/sources.list.d/1password.list -# Add the debsig-verify policy -sudo mkdir -p /etc/debsig/policies/AC2D62742012EA22/ -curl -sS https://downloads.1password.com/linux/debian/debsig/1password.pol | \ -sudo tee /etc/debsig/policies/AC2D62742012EA22/1password.pol -sudo mkdir -p /usr/share/debsig/keyrings/AC2D62742012EA22 -curl -sS https://downloads.1password.com/linux/keys/1password.asc | \ -sudo gpg --dearmor --output /usr/share/debsig/keyrings/AC2D62742012EA22/debsig.gpg + # Add the debsig-verify policy + sudo mkdir -p /etc/debsig/policies/AC2D62742012EA22/ + curl -sS https://downloads.1password.com/linux/debian/debsig/1password.pol | \ + sudo tee /etc/debsig/policies/AC2D62742012EA22/1password.pol + sudo mkdir -p /usr/share/debsig/keyrings/AC2D62742012EA22 + curl -sS https://downloads.1password.com/linux/keys/1password.asc | \ + sudo gpg --dearmor --output /usr/share/debsig/keyrings/AC2D62742012EA22/debsig.gpg -# Install 1Password & 1password-cli -sudo apt update && sudo apt install -y 1password 1password-cli \ No newline at end of file + # Install 1Password & 1password-cli + sudo apt update && sudo apt install -y 1password 1password-cli + ;; +esac \ No newline at end of file diff --git a/install/desktop/optional/app-zoom.sh b/install/desktop/optional/app-zoom.sh index ab6fe1dd1..b02fc0d16 100644 --- a/install/desktop/optional/app-zoom.sh +++ b/install/desktop/optional/app-zoom.sh @@ -1,9 +1,14 @@ # Make video calls using https://zoom.us/ cd /tmp -source ~/.local/share/omakub/get_arch.sh +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi ARCH=$(get_arch "zoom") if wget "https://zoom.us/client/latest/zoom_${ARCH}.deb"; then - sudo apt install -y "./zoom_${ARCH}.deb" || true + sudo apt install -y "./zoom_${ARCH}.deb" rm "zoom_${ARCH}.deb" + cd - +else + cd - + false fi -cd - diff --git a/install/desktop/select-optional-apps.sh b/install/desktop/select-optional-apps.sh index a5edf13e7..37c194dbc 100644 --- a/install/desktop/select-optional-apps.sh +++ b/install/desktop/select-optional-apps.sh @@ -1,9 +1,17 @@ +#source the utils if not sourced already +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi + if [[ -v OMAKUB_FIRST_RUN_OPTIONAL_APPS ]]; then apps=$OMAKUB_FIRST_RUN_OPTIONAL_APPS if [[ -n "$apps" ]]; then for app in $apps; do - source "$OMAKUB_PATH/install/desktop/optional/app-${app,,}.sh" + trap "handle_omakub_source_error $app" ERR + source "$OMAKUB_PATH/install/desktop/optional/app-${app,,}.sh" \ + && handle_omakub_source_success "$app" + trap - ERR done fi fi diff --git a/install/terminal.sh b/install/terminal.sh index 94f5844bb..55bbd4162 100644 --- a/install/terminal.sh +++ b/install/terminal.sh @@ -3,5 +3,14 @@ sudo apt update -y sudo apt upgrade -y sudo apt install -y curl git unzip +#source the utils if not sourced already +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi + # Run terminal installers -for installer in ~/.local/share/omakub/install/terminal/*.sh; do source $installer; done +for installer in ~/.local/share/omakub/install/terminal/*.sh; do + trap "handle_omakub_source_error $installer" ERR + source "$installer" && handle_omakub_source_success "$installer" + trap - ERR +done diff --git a/install/terminal/app-lazydocker.sh b/install/terminal/app-lazydocker.sh index 0c08c9d9a..614683022 100644 --- a/install/terminal/app-lazydocker.sh +++ b/install/terminal/app-lazydocker.sh @@ -1,10 +1,16 @@ cd /tmp -source ~/.local/share/omakub/get_arch.sh +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi ARCH=$(get_arch "lazydocker") LAZYDOCKER_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazydocker/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') if curl -sLo lazydocker.tar.gz "https://github.com/jesseduffield/lazydocker/releases/latest/download/lazydocker_${LAZYDOCKER_VERSION}_Linux_${ARCH}.tar.gz"; then tar -xf lazydocker.tar.gz lazydocker sudo install lazydocker /usr/local/bin rm lazydocker.tar.gz lazydocker + cd - +else + cd - + false fi -cd - + diff --git a/install/terminal/app-lazygit.sh b/install/terminal/app-lazygit.sh index e82ef376d..6f1b512c3 100644 --- a/install/terminal/app-lazygit.sh +++ b/install/terminal/app-lazygit.sh @@ -1,10 +1,15 @@ cd /tmp -source ~/.local/share/omakub/get_arch.sh +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi ARCH=$(get_arch "lazygit") LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*') if curl -sLo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_${ARCH}.tar.gz"; then tar -xf lazygit.tar.gz lazygit sudo install lazygit /usr/local/bin rm lazygit.tar.gz lazygit + cd - +else + cd - + false fi -cd - diff --git a/install/terminal/app-neovim.sh b/install/terminal/app-neovim.sh index 044046f04..3f5fe0234 100644 --- a/install/terminal/app-neovim.sh +++ b/install/terminal/app-neovim.sh @@ -1,5 +1,7 @@ cd /tmp -source ~/.local/share/omakub/get_arch.sh +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi ARCH=$(get_arch "neovim") NEOVIM_SUCCESS=false if [[ "${ARCH}" == "aarch64" ]]; then @@ -45,4 +47,6 @@ if "${NEOVIM_SUCCESS}"; then sudo rm -rf /usr/share/applications/nvim.desktop source ~/.local/share/omakub/applications/Neovim.sh fi +else + false fi diff --git a/install/terminal/app-zellij.sh b/install/terminal/app-zellij.sh index c89609d7a..b619abe16 100644 --- a/install/terminal/app-zellij.sh +++ b/install/terminal/app-zellij.sh @@ -1,14 +1,20 @@ cd /tmp -source ~/.local/share/omakub/get_arch.sh +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi ARCH=$(get_arch "zellij") if wget -O zellij.tar.gz "https://github.com/zellij-org/zellij/releases/latest/download/zellij-${ARCH}-unknown-linux-musl.tar.gz"; then ZELLIJ_SUCCESS=true tar -xf zellij.tar.gz zellij sudo install zellij /usr/local/bin rm zellij.tar.gz zellij + cd - mkdir -p ~/.config/zellij/themes [ ! -f "$HOME/.config/zellij/config.kdl" ] && cp ~/.local/share/omakub/configs/zellij.kdl ~/.config/zellij/config.kdl cp ~/.local/share/omakub/themes/tokyo-night/zellij.kdl ~/.config/zellij/themes/tokyo-night.kdl +else + cd - + false fi -cd - + diff --git a/install/terminal/docker.sh b/install/terminal/docker.sh index 8647e6ba5..fda558d96 100644 --- a/install/terminal/docker.sh +++ b/install/terminal/docker.sh @@ -1,4 +1,6 @@ -source ~/.local/share/omakub/get_arch.sh +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi ARCH=$(get_arch "dockercompose") # Add the official Docker repo @@ -22,4 +24,6 @@ DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} mkdir -p $DOCKER_CONFIG/cli-plugins if curl -sSL "https://github.com/docker/compose/releases/download/v$DOCKER_COMPOSE_VERSION/docker-compose-linux-${ARCH}" -o "$DOCKER_CONFIG/cli-plugins/docker-compose"; then chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose +else + false fi diff --git a/install/terminal/mise.sh b/install/terminal/mise.sh index 5c64c27e7..40cf0218c 100644 --- a/install/terminal/mise.sh +++ b/install/terminal/mise.sh @@ -1,9 +1,11 @@ -source ~/.local/share/omakub/get_arch.sh +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi ARCH=$(get_arch) # Install mise for managing multiple versions of languages. See https://mise.jdx.dev/ sudo apt update -y && sudo apt install -y gpg sudo wget curl sudo install -dm 755 /etc/apt/keyrings wget -qO - https://mise.jdx.dev/gpg-key.pub | gpg --dearmor | sudo tee /etc/apt/keyrings/mise-archive-keyring.gpg 1>/dev/null echo "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.gpg arch=${ARCH}] https://mise.jdx.dev/deb stable main" | sudo tee /etc/apt/sources.list.d/mise.list -sudo apt update || true -sudo apt install -y mise || true +sudo apt update +sudo apt install -y mise diff --git a/install/terminal/required/app-gum.sh b/install/terminal/required/app-gum.sh index 9a61f4015..7d7215243 100644 --- a/install/terminal/required/app-gum.sh +++ b/install/terminal/required/app-gum.sh @@ -1,6 +1,8 @@ # Gum is used for the Omakub commands for tailoring Omakub after the initial install cd /tmp -source ~/.local/share/omakub/get_arch.sh +if [[ -z $UTILS_SOURCED ]]; then + source ~/.local/share/omakub/utils.sh +fi ARCH=$(get_arch "gum") GUM_VERSION="0.14.3" # Use known good version wget -qO gum.deb "https://github.com/charmbracelet/gum/releases/download/v${GUM_VERSION}/gum_${GUM_VERSION}_${ARCH}.deb" diff --git a/utils.sh b/utils.sh new file mode 100644 index 000000000..082b2a8b8 --- /dev/null +++ b/utils.sh @@ -0,0 +1,94 @@ +#!/bin/bash +set -e; + +UTILS_SOURCED=true + +logRED='\033[0;31m' +logGREEN='\033[0;32m' +logBLUE='\033[0;34m' +logCYAN='\033[0;36m' +logNEUT='\033[0m' +clearLINE='\033[K' + +function includes() { + local haystack=("${@:1: $#-1}") + local needle="${@: -1}" + for item in "${haystack[@]}"; do + if [[ "$item" == "$needle" ]]; then + return 0 + fi + done + return 1 +} + +#Usage: issueInfo "PROCESSING: %s" "${trgtFolder}/$d" +function issueWarning() { + printf "${logRED}---::WARNING::---\n$1\n---::---${logNEUT}\n" ${@: 2}; +} + +function issueInfo() { + printf "${logCYAN}---::INFO: ""$1 ""::---${logNEUT}\n" ${@: 2}; +} + +function issueSuccess() { + printf "${logGREEN}---::INFO: ""$1 ""::---${logNEUT}\n" ${@: 2}; +} + +#assoc array to list app specific arch aliases +declare -A arch_config=( + ["gum.x86_64"]="amd64" + ["gum.aarch64"]="arm64" + ["chrome.x86_64"]="amd64" + ["chrome.aarch64"]="arm64" + ["signal.x86_64"]="amd64" + ["signal.aarch64"]="arm64" + ["zoom.x86_64"]="amd64" + ["zoom.aarch64"]="arm64" + ["localsend.x86_64"]="x86-64" + ["localsend.aarch64"]="arm-64" + ["lazygit.aarch64"]="arm64" + ["lazydocker.aarch64"]="arm64" + ["vscode.x86_64"]="x64" + ["vscode.aarch64"]="arm64" + ["neovim.x86_64"]="x64" +) + +omakub_installation_success=() +omakub_installation_failed=() + +handle_omakub_source_error() { + local installer = "$1" + omakub_installation_failed+=("$installer") +} + +handle_omakub_source_success() { + local installer = "$1" + omakub_installation_success+=("$installer") +} + +print_omakub_report() { + for element in "${omakub_installation_success[@]}"; do + issueSuccess "[+] %s completed." "$element" + done + echo "---::::---" + for element in "${omakub_installation_failed[@]}"; do + issueWarning "[-] %s failed." "$element" + done +} + +#a getter func to lookup into above assos array. Unfound keys/default value is what is returned from lscpu +get_arch_config() { + local arch="${1}" + local prog="${2:-"default"}" + local searchStr="${prog}.${arch}" + local archAlias="${arch_config[$searchStr]:-$arch}" + echo -n "$archAlias" +} + +# Usage: +# echo "$(get_arch "chrome")" //for aarch64, returns arm64 +get_arch() { + local prog="$1" + local ARCH=$(lscpu | awk -F: 'NR==1 {print $2}' | xargs) + echo -n "$(get_arch_config "$ARCH" "$prog")" +} \ No newline at end of file From 1e47258a918c81e52f6ec62b754bd59001597f17 Mon Sep 17 00:00:00 2001 From: Ibrahim <8837895+IbrahimTanyalcin@users.noreply.github.com> Date: Sun, 21 Jul 2024 00:13:59 +0000 Subject: [PATCH 07/10] fix variable declaration white-space --- utils.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils.sh b/utils.sh index 082b2a8b8..342c179a9 100644 --- a/utils.sh +++ b/utils.sh @@ -57,12 +57,12 @@ omakub_installation_success=() omakub_installation_failed=() handle_omakub_source_error() { - local installer = "$1" + local installer="$1" omakub_installation_failed+=("$installer") } handle_omakub_source_success() { - local installer = "$1" + local installer="$1" omakub_installation_success+=("$installer") } From 0912ab217d42518ea1f4d8178aa3546d5c865a7b Mon Sep 17 00:00:00 2001 From: Ibrahim <8837895+IbrahimTanyalcin@users.noreply.github.com> Date: Mon, 22 Jul 2024 09:19:15 +0000 Subject: [PATCH 08/10] remove trap and logical chaining in favor of if source, add brave to optional --- bin/omakub-sub/install.sh | 10 ++++++---- bin/omakub-sub/update.sh | 10 ++++++---- install/desktop.sh | 8 +++++--- install/desktop/optional/app-1password.sh | 4 ++-- install/desktop/select-optional-apps.sh | 9 +++++---- install/first-run-choices.sh | 2 +- install/terminal.sh | 8 +++++--- 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/bin/omakub-sub/install.sh b/bin/omakub-sub/install.sh index 8f87a0f04..e796c8cdb 100644 --- a/bin/omakub-sub/install.sh +++ b/bin/omakub-sub/install.sh @@ -45,10 +45,12 @@ else *) INSTALLER_FILE="$OMAKUB_PATH/install/desktop/optional/app-$INSTALLER.sh" ;; esac - trap "handle_omakub_source_error $INSTALLER_FILE" ERR - source $INSTALLER_FILE && gum spin --spinner globe --title "Install completed!" -- sleep 3 \ - && handle_omakub_source_success "$INSTALLER_FILE" - trap - ERR + if source $INSTALLER_FILE; then + gum spin --spinner globe --title "Install completed!" -- sleep 3 + handle_omakub_source_success "$INSTALLER_FILE" + else + handle_omakub_source_error "$INSTALLER_FILE" + fi fi clear diff --git a/bin/omakub-sub/update.sh b/bin/omakub-sub/update.sh index 1b05bad6b..405c4e05c 100644 --- a/bin/omakub-sub/update.sh +++ b/bin/omakub-sub/update.sh @@ -28,10 +28,12 @@ else *) INSTALLER_FILE="$OMAKUB_PATH/install/terminal/app-$INSTALLER.sh" ;; esac - trap "handle_omakub_source_error $INSTALLER_FILE" ERR - source $INSTALLER_FILE && gum spin --spinner globe --title "Update completed!" -- sleep 3 \ - && handle_omakub_source_success "$INSTALLER_FILE" - trap - ERR + if source $INSTALLER_FILE; then + gum spin --spinner globe --title "Update completed!" -- sleep 3 + handle_omakub_source_success "$INSTALLER_FILE" + else + handle_omakub_source_error "$INSTALLER_FILE" + fi fi clear diff --git a/install/desktop.sh b/install/desktop.sh index 70727847a..5f355c233 100644 --- a/install/desktop.sh +++ b/install/desktop.sh @@ -9,9 +9,11 @@ fi # Run desktop installers for installer in ~/.local/share/omakub/install/desktop/*.sh; do - trap "handle_omakub_source_error $installer" ERR - source "$installer" && handle_omakub_source_success "$installer" - trap - ERR + if source "$installer"; then + handle_omakub_source_success "$installer" + else + handle_omakub_source_error "$installer" + fi done # Revert to normal idle and lock settings diff --git a/install/desktop/optional/app-1password.sh b/install/desktop/optional/app-1password.sh index 793bed6db..39912769a 100755 --- a/install/desktop/optional/app-1password.sh +++ b/install/desktop/optional/app-1password.sh @@ -3,7 +3,7 @@ if [[ -z $UTILS_SOURCED ]]; then fi ARCH=$(get_arch) case "$ARCH" in - --aarch64) + aarch64) cd /tmp curl -sSO https://downloads.1password.com/linux/tar/stable/aarch64/1password-latest.tar.gz curl -sSO https://downloads.1password.com/linux/tar/stable/aarch64/1password-latest.tar.gz.sig @@ -16,7 +16,7 @@ case "$ARCH" in sudo /opt/1Password/after-install.sh cd - ;; - --*) + *) # Install 1password and 1password-cli single script curl -sS https://downloads.1password.com/linux/keys/1password.asc | \ sudo gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg diff --git a/install/desktop/select-optional-apps.sh b/install/desktop/select-optional-apps.sh index 37c194dbc..bc593c980 100644 --- a/install/desktop/select-optional-apps.sh +++ b/install/desktop/select-optional-apps.sh @@ -8,10 +8,11 @@ if [[ -v OMAKUB_FIRST_RUN_OPTIONAL_APPS ]]; then if [[ -n "$apps" ]]; then for app in $apps; do - trap "handle_omakub_source_error $app" ERR - source "$OMAKUB_PATH/install/desktop/optional/app-${app,,}.sh" \ - && handle_omakub_source_success "$app" - trap - ERR + if source "$OMAKUB_PATH/install/desktop/optional/app-${app,,}.sh"; then + handle_omakub_source_success "$app" + else + handle_omakub_source_error "$app" + fi done fi fi diff --git a/install/first-run-choices.sh b/install/first-run-choices.sh index dc6964c7d..e9f39e5be 100644 --- a/install/first-run-choices.sh +++ b/install/first-run-choices.sh @@ -1,4 +1,4 @@ -OPTIONAL_APPS=("1password" "Spotify" "Zoom" "Dropbox") +OPTIONAL_APPS=("1password" "Spotify" "Zoom" "Dropbox" "Brave") DEFAULT_OPTIONAL_APPS='1password,Spotify,Zoom' export OMAKUB_FIRST_RUN_OPTIONAL_APPS=$(gum choose "${OPTIONAL_APPS[@]}" --no-limit --selected $DEFAULT_OPTIONAL_APPS --height 7 --header "Select optional apps" | tr ' ' '-') diff --git a/install/terminal.sh b/install/terminal.sh index 55bbd4162..8afaaf4ca 100644 --- a/install/terminal.sh +++ b/install/terminal.sh @@ -10,7 +10,9 @@ fi # Run terminal installers for installer in ~/.local/share/omakub/install/terminal/*.sh; do - trap "handle_omakub_source_error $installer" ERR - source "$installer" && handle_omakub_source_success "$installer" - trap - ERR + if source "$installer"; then + handle_omakub_source_success "$installer" + else + handle_omakub_source_error "$installer" + fi done From 411ea77211c9ce64d2bb51798431454b185a6f06 Mon Sep 17 00:00:00 2001 From: Ibrahim <8837895+IbrahimTanyalcin@users.noreply.github.com> Date: Mon, 22 Jul 2024 21:21:18 +0000 Subject: [PATCH 09/10] halt on installing 1password if signature verification fails, link -f snap neovim to usr/local/bin/nvim --- install/desktop/optional/app-1password.sh | 16 ++++++++++------ install/terminal/app-neovim.sh | 4 +++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/install/desktop/optional/app-1password.sh b/install/desktop/optional/app-1password.sh index 39912769a..c4ff07bb8 100755 --- a/install/desktop/optional/app-1password.sh +++ b/install/desktop/optional/app-1password.sh @@ -9,12 +9,16 @@ case "$ARCH" in curl -sSO https://downloads.1password.com/linux/tar/stable/aarch64/1password-latest.tar.gz.sig gpg --keyserver keyserver.ubuntu.com --recv-keys 3FEF9748469ADBE15DA7CA80AC2D62742012EA22 gpg --verify 1password-latest.tar.gz.sig 1password-latest.tar.gz - [ $? -eq 0 ] || { cd - && false; } - sudo tar -xf 1password-latest.tar.gz - sudo mkdir -p /opt/1Password - sudo mv 1password-*/* /opt/1Password - sudo /opt/1Password/after-install.sh - cd - + if [[ $? -eq 0 ]]; then + sudo tar -xf 1password-latest.tar.gz + sudo mkdir -p /opt/1Password + sudo mv 1password-*/* /opt/1Password + sudo /opt/1Password/after-install.sh + cd - + else + cd - + false + fi ;; *) # Install 1password and 1password-cli single script diff --git a/install/terminal/app-neovim.sh b/install/terminal/app-neovim.sh index 3f5fe0234..21806f7b9 100644 --- a/install/terminal/app-neovim.sh +++ b/install/terminal/app-neovim.sh @@ -9,7 +9,9 @@ if [[ "${ARCH}" == "aarch64" ]]; then sudo apt update sudo apt install -y snapd fi - sudo snap install --classic nvim && NEOVIM_SUCCESS=true + sudo snap install --classic nvim \ + && sudo ln -sf /snap/bin/nvim /usr/local/bin/nvim \ + && NEOVIM_SUCCESS=true else if wget -O nvim.tar.gz "https://github.com/neovim/neovim/releases/latest/download/nvim-linu${ARCH}.tar.gz"; then tar -xf nvim.tar.gz From f49d5551b4902e1d83a0b45c3fb2912c7d704380 Mon Sep 17 00:00:00 2001 From: Ibrahim <8837895+IbrahimTanyalcin@users.noreply.github.com> Date: Sat, 28 Sep 2024 21:07:08 +0000 Subject: [PATCH 10/10] merge both install methods for app-vscode.sh --- install/desktop/app-vscode.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/install/desktop/app-vscode.sh b/install/desktop/app-vscode.sh index 447fd84f6..828b13c9a 100644 --- a/install/desktop/app-vscode.sh +++ b/install/desktop/app-vscode.sh @@ -1,5 +1,4 @@ cd /tmp -<<<<<<< HEAD if [[ -z $UTILS_SOURCED ]]; then source ~/.local/share/omakub/utils.sh @@ -34,5 +33,4 @@ elif wget -O code.deb "https://code.visualstudio.com/sha/download?build=stable&o else cd - false -fi - +fi \ No newline at end of file