2022-03-31 14:12:20 +02:00
#!/bin/sh
# Install the latest version of the Katenary detecting the right OS and architecture.
# Can be launched with the following command:
2025-07-13 00:39:25 +02:00
# sh <(curl -sSL https://raw.githubusercontent.com/Katenary/katenary/master/install.sh)
2022-03-31 14:12:20 +02:00
set -e
# Detect the OS and architecture
OS = $( uname)
ARCH = $( uname -m)
2025-09-05 10:11:16 +02:00
for c in curl grep cut tr; do
if ! command -v $c >/dev/null 2>& 1; then
echo " Error: $c is not installed "
exit 1
fi
done
2024-04-22 13:55:53 +02:00
# Detect the home directory "bin" directory, it is commonly:
# - $HOME/.local/bin
# - $HOME/.bin
# - $HOME/bin
COMON_INSTALL_PATHS = " $HOME /.local/bin $HOME /.bin $HOME /bin "
INSTALL_PATH = ""
for p in $COMON_INSTALL_PATHS ; do
2025-07-06 10:52:35 +02:00
if [ -d $p ] ; then
INSTALL_PATH = $p
break
fi
2024-04-22 13:55:53 +02:00
done
# check if the user has write access to the INSTALL_PATH
if [ -z " $INSTALL_PATH " ] ; then
2025-07-06 10:52:35 +02:00
INSTALL_PATH = "/usr/local/bin"
if [ ! -w $INSTALL_PATH ] ; then
echo " You don't have write access to $INSTALL_PATH "
echo "Please, run with sudo or install locally"
exit 1
fi
2024-04-22 13:55:53 +02:00
fi
# ensure that $INSTALL_PATH is in the PATH
2025-07-06 10:52:35 +02:00
if ! echo " $PATH " | grep -q " $INSTALL_PATH " ; then
echo " Sorry, ${ INSTALL_PATH } is not in the PATH "
echo "Please, add it to your PATH in your shell configuration file"
echo "then restart your shell and run this script again"
exit 1
2024-04-22 13:55:53 +02:00
fi
2022-03-31 14:12:20 +02:00
# Where to download the binary
2025-09-05 10:11:16 +02:00
TAG = $( curl -sLf https://repo.katenary.io/api/v1/repos/katenary/katenary/releases/latest 2>/dev/null | grep -Po '"tag_name":\s*"[^"]*"' | cut -d ":" -f2 | tr -d '"' )
TAG = 3.0.0-rc7
2024-04-22 13:55:53 +02:00
# for compatibility with older ARM versions
2022-03-31 14:12:20 +02:00
if [ $ARCH = "x86_64" ] ; then
2025-07-06 10:52:35 +02:00
ARCH = "amd64"
2022-03-31 14:12:20 +02:00
fi
2025-09-05 10:11:16 +02:00
BIN_URL = " https://repo.katenary.io/api/packages/Katenary/generic/katenary/ $TAG /katenary- $OS - $ARCH "
2022-03-31 14:12:20 +02:00
echo
echo " Downloading $BIN_URL "
T = $( mktemp -u)
2025-09-05 10:11:16 +02:00
curl -sLf -# $BIN_URL -o $T 2>/dev/null || ( echo -e " Failed to download katenary version $TAG .\n\nPlease open an issue and explain the problem, following the link:\nhttps://repo.katenary.io/Katenary/katenary/issues/new?title=[install.sh]%20Install%20 $TAG %20failed " && rm -f $T && exit 1)
2022-03-31 14:12:20 +02:00
2025-07-06 10:52:35 +02:00
mv " $T " " ${ INSTALL_PATH } /katenary "
chmod +x " ${ INSTALL_PATH } /katenary "
2022-03-31 14:12:20 +02:00
echo
2024-04-22 13:55:53 +02:00
echo " Installed to $INSTALL_PATH /katenary "
echo "Installation complete! Run 'katenary help' to get started."