Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not sure where to put this #1622

Open
Tsjippy opened this issue Nov 4, 2024 · 1 comment
Open

Not sure where to put this #1622

Tsjippy opened this issue Nov 4, 2024 · 1 comment

Comments

@Tsjippy
Copy link

Tsjippy commented Nov 4, 2024

I have a working script to get signal-cli working on a rpi.
Just not sure how and where I can add this.
So I just put it here, can someone take care of it?

#!/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
@m-ueberall
Copy link

@Tsjippy : I'd suggest publishing this as a gist if it is not covered already by the example scripts found in this project's wiki and adding it there. (This way, you can revise it later on.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants