DutchForeigner / signal-cli_rpi

signal-cli compiled for Raspberry Pi
GNU General Public License v3.0
16 stars 1 forks source link

You can easily build your own now: #7

Open Tsjippy opened 1 year ago

Tsjippy commented 1 year ago
#!/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//')

# 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//')

set -euxo pipefail

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
    apt install openjdk-17-jdk -y
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}"-Linux.tar.gz https://github.com/AsamK/signal-cli/releases/download/v"${VERSION}"/signal-cli-"${VERSION}"-Linux.tar.gz
tar xf /tmp/signal-cli-install/signal-cli-"${VERSION}"-Linux.tar.gz -C /opt
rm /tmp/signal-cli-install/signal-cli-"${VERSION}"-Linux.tar.gz
ln -sf /opt/signal-cli-"${VERSION}"/bin/signal-cli /usr/local/bin/

# libsignal
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}"-aarch64-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
tresmith00 commented 10 months ago

Does this script work to build signalcli on a Rpi4? I am running into an issue with the libsignal dependency error due to it being an ARM processor.

pmatuszy commented 10 months ago

not sure about that one but my repo works https://github.com/pmatuszy/signal-cli-on-Raspberry-PI---WORKS-

tresmith00 commented 10 months ago

not sure about that one but my repo works https://github.com/pmatuszy/signal-cli-on-Raspberry-PI---WORKS-

Thanks. Ill try it now.

Tsjippy commented 9 months ago

today I created the 0.12.8 version with the script found here: https://github.com/Tsjippy/signal-cli-rpi