summaryrefslogtreecommitdiffstats
path: root/install.sh
diff options
context:
space:
mode:
authorJannik <jannik.peters@posteo.de>2021-12-09 00:21:41 +0100
committerGitHub <noreply@github.com>2021-12-08 23:21:41 +0000
commitc8f60b24802fb6cb866b96d78bab6ccc4b1314a3 (patch)
tree34a5ef0101e75b917d29a524e66f9ab527cb3011 /install.sh
parent4bdf4c40c292b681452c9499b9072b759073bf32 (diff)
fix: resolve some issues with install.sh (#188)
* feat: add command checks to install script Some people don't use sudo or have curl, sed or wget installed by default. This adds a check, if sudo, curl and sed are installed and changes wget to curl as this is the mostly used command in the script. If sudo is not installed it uses su. Closes: #175 * fix: add newline to printf commands The printf was missing a newline at the end, which resulted in the eval line being appended directly to the end of the previous line.
Diffstat (limited to 'install.sh')
-rwxr-xr-xinstall.sh20
1 files changed, 16 insertions, 4 deletions
diff --git a/install.sh b/install.sh
index 16f89005..c94b3d3c 100755
--- a/install.sh
+++ b/install.sh
@@ -22,6 +22,14 @@ Please file an issue if you encounter any problems!
EOF
+if ! command -v curl &> /dev/null; then
+ echo "curl not installed. Please install curl."
+ exit
+elif ! command -v sed &> /dev/null; then
+ echo "sed not installed. Please install sed."
+ exit
+fi
+
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' https://github.com/ellie/atuin/releases/latest)
# Allow sed; sometimes it's more readable than ${variable//search/replace}
# shellcheck disable=SC2001
@@ -55,8 +63,12 @@ __atuin_install_ubuntu(){
ARTIFACT_URL="https://github.com/ellie/atuin/releases/download/$LATEST_VERSION/atuin_${LATEST_VERSION//v/}_amd64.deb"
TEMP_DEB="$(mktemp)" &&
- wget -O "$TEMP_DEB" "$ARTIFACT_URL"
- sudo dpkg -i "$TEMP_DEB"
+ curl -Lo "$TEMP_DEB" "$ARTIFACT_URL"
+ if command -v sudo &> /dev/null; then
+ sudo dpkg -i "$TEMP_DEB"
+ else
+ su -l -c "dpkg -i '$TEMP_DEB'"
+ fi
rm -f "$TEMP_DEB"
}
@@ -150,10 +162,10 @@ esac
# TODO: Check which shell is in use
# Use of single quotes around $() is intentional here
# shellcheck disable=SC2016
-printf '\neval "$(atuin init zsh)"' >> ~/.zshrc
+printf '\neval "$(atuin init zsh)"\n' >> ~/.zshrc
curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ~/.bash-preexec.sh
-printf '\n[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' >> ~/.bashrc
+printf '\n[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh\n' >> ~/.bashrc
# Use of single quotes around $() is intentional here
# shellcheck disable=SC2016
echo 'eval "$(atuin init bash)"' >> ~/.bashrc