Skip to content

Instantly share code, notes, and snippets.

@Tsjippy
Created November 7, 2024 10:37
Show Gist options
  • Save Tsjippy/33dae49d1b4c7092c42c68c10d225082 to your computer and use it in GitHub Desktop.
Save Tsjippy/33dae49d1b4c7092c42c68c10d225082 to your computer and use it in GitHub Desktop.
signal-cli install script
#!/bin/bash
# get lastest Signal-cli release version
export VERSION=$(curl --silent "https://api.github.com/repos/AsamK/signal-cli/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'| sed 's/v//')
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root or with sudo rights" 1>&2
exit 1
fi
# default install
if [ -d "/opt/signal-cli-${VERSION}" ]
then
echo "signal-cli is alerady installed with this version: ${VERSION}"
exit 0
fi
# script Dependencies
command_check_dependencies=(zip curl)
apt update
for i in "${apt_dependencies[@]}"
do if ! command -v $i &> /dev/null
then
apt install $i -y
fi
done
# java
if ! command -v java &> /dev/null
then
wget -q -O - https://download.bell-sw.com/pki/GPG-KEY-bellsoft | gpg --dearmor | sudo tee /etc/apt/keyrings/GPG-KEY-bellsoft.gpg > /dev/null
echo "deb [trusted=yes] https://apt.bell-sw.com/ stable main" | sudo tee /etc/apt/sources.list.d/bellsoft.list
sudo apt-get update --allow-unauthenticated --allow-insecure-repositories
sudo apt-get install bellsoft-java21
fi
# delete temp folder if it exists
if [ -d "/tmp/signal-cli-install" ]
then
rm -r /tmp/signal-cli-install
fi
mkdir /tmp/signal-cli-install
curl --proto '=https' --tlsv1.2 -L -o /tmp/signal-cli-install/signal-cli-"${VERSION}".tar.gz https://github.com/AsamK/signal-cli/releases/download/v"${VERSION}"/signal-cli-"${VERSION}"-Linux-native.tar.gz
tar xf /tmp/signal-cli-install/signal-cli-"${VERSION}".tar.gz -C /opt
rm /tmp/signal-cli-install/signal-cli-"${VERSION}".tar.gz
ln -sf /opt/signal-cli-"${VERSION}"/bin/signal-cli /usr/local/bin/
# libsignal
# get lastest libsignal release version
export LIBVERSION=$(curl --silent "https://api.github.com/repos/exquo/signal-libs-build/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'| sed 's/libsignal_v//')
export ARCH=armv7 # RPI 3
export ARCH=aarch64 # RPI 4
# If the link is not working check the url below for the correct link
# https://github.com/exquo/signal-libs-build/releases
curl --proto '=https' --tlsv1.2 -L -o /tmp/signal-cli-install/libsignal.tar.gz https://github.com/exquo/signal-libs-build/releases/download/libsignal_v"${LIBVERSION}"/libsignal_jni.so-v"${LIBVERSION}"-"${ARCH}"-unknown-linux-gnu.tar.gz
tar xf /tmp/signal-cli-install/libsignal.tar.gz -C /tmp/signal-cli-install
rm /tmp/signal-cli-install/libsignal.tar.gz
# replace libsignal_jni.so
cd
# Delete the old one
zip -d /opt/signal-cli-${VERSION}/lib/libsignal-client-*.jar libsignal_jni.so
# add the new one
zip /opt/signal-cli-${VERSION}/lib/libsignal-client-*.jar /tmp/signal-cli-install/libsignal_jni.so
# fallback of libsignal_jni.so
## create folder if it dosent exist
if [ -d "/usr/java/packages/lib" ]
then
mkdir -p /usr/java/packages/lib
fi
## copy libsignal_jni.so to Java library path
cp /tmp/signal-cli-install/libsignal_jni.so /usr/java/packages/lib
# permissions
chown root:root /usr/java/packages/lib/libsignal_jni.so
chmod 755 /usr/java/packages/lib/libsignal_jni.so
chmod 755 -R /opt/signal-cli-${VERSION}
chown root:root -R /opt/signal-cli-${VERSION}
# cleanup temp folder
rm -r /tmp/signal-cli-install
/opt/signal-cli-${VERSION}/bin/signal-cli --version
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment