From 30d8fd5888c8bc3f271264ed662eb679f9822c8d Mon Sep 17 00:00:00 2001 From: Sune Date: Thu, 7 Sep 2023 00:54:12 +0200 Subject: [PATCH] init commit --- README.md | 76 ++++++++++++++++++++++++++++++++++- data/org.asamk.Signal.conf | 16 ++++++++ data/org.asamk.Signal.service | 4 ++ data/signal-cli.service | 18 +++++++++ 4 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 data/org.asamk.Signal.conf create mode 100644 data/org.asamk.Signal.service create mode 100644 data/signal-cli.service diff --git a/README.md b/README.md index f7efd1d..6e9e0cb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,76 @@ -# Signal-cli +# signal-cli +This guide is for installing and running signal-cli as a daemon and setting up a system-wide dbus. +signal-cli is a commandline interface for the [Signal messenger](https://signal.org/). +It supports registering, verifying, sending and receiving messages. +signal-cli uses a [patched libsignal-service-java](https://github.com/Turasa/libsignal-service-java), +extracted from the [Signal-Android source code](https://github.com/signalapp/Signal-Android/tree/main/libsignal/service). +For registering you need a phone number where you can receive SMS or incoming calls. +## Installation + +System requirements: + +- at least Java Runtime Environment (JRE) 17 +- wget +```sh +debian: $ sudo apt install wget openjdk-17-jre +``` + +### Install system-wide on Linux + +See [latest version](https://github.com/AsamK/signal-cli/releases). + +```sh +export VERSION= +wget https://github.com/AsamK/signal-cli/releases/download/v"${VERSION}"/signal-cli-"${VERSION}"-Linux.tar.gz +sudo tar xf signal-cli-"${VERSION}"-Linux.tar.gz -C /opt +sudo ln -sf /opt/signal-cli-"${VERSION}"/bin/signal-cli /usr/local/bin/ +``` + +## Initial Setup +Create user for running the service, --systen creates a system user without home dir and password. : +```sh +# adduser --system --group signal-cli +``` +Create a folder for signal account configs: +```sh +# mkdir /var/lib/signal-cli +# chown signal-cli: /var/lib/signal-cli +``` + +## Register Account +```sh +# su signal-cli -s /bin/bash + +signal-cli$ /usr/local/bin/signal-cli --config /var/lib/signal-cli -u register +``` +Registering may require solving a CAPTCHA challenge: [Registration with captcha](https://github.com/AsamK/signal-cli/wiki/Registration-with-captcha) + +Verify the number using the code received via SMS or voice, optionally add `--pin PIN_CODE` if you've added a pin code to your account: +```sh +signal-cli$ /usr/local/bin/signal-cli --config /var/lib/signal-cli -u verify +``` + +## Setup systemd service and dbus +To run on the system bus you need to take some additional steps. It’s advisable to run signal-cli as a separate unix user, the following steps assume you created a user named signal-cli. To run a service on the system bus, a config file is needed to allow the signal-cli user to take a name on the system bus. An example config file can be found in data/org.asamk.Signal.conf. This file also configures that any user can talk with the signal-cli daemon. The data/org.asamk.Signal.service and data/signal-cli.service files configure a dbus activated systemd service for signal-cli, so the service is automatically started when the dbus service is requested. + +These steps, executed as root, should work on all distributions using systemd. + +Git clone this repo as you will need files from the data folder. +```sh +git clone +``` +move the files: +```sh +# mv data/org.asamk.Signal.conf /etc/dbus-1/system.d/ +# mv data/org.asamk.Signal.service /usr/share/dbus-1/system-services/ +# mv data/signal-cli.service /etc/systemd/system/ +``` +edit service file to match phone number and enable systemd service: +```sh +sed -i -e "s|%number%||" /etc/systemd/system/signal-cli.service +systemctl daemon-reload +systemctl enable signal-cli.service +systemctl reload dbus.service +systemctl start signal-cli.service +``` diff --git a/data/org.asamk.Signal.conf b/data/org.asamk.Signal.conf new file mode 100644 index 0000000..a30c501 --- /dev/null +++ b/data/org.asamk.Signal.conf @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + diff --git a/data/org.asamk.Signal.service b/data/org.asamk.Signal.service new file mode 100644 index 0000000..89bffd8 --- /dev/null +++ b/data/org.asamk.Signal.service @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=org.asamk.Signal +Exec=/bin/false +SystemdService=dbus-org.asamk.Signal.service diff --git a/data/signal-cli.service b/data/signal-cli.service new file mode 100644 index 0000000..de891e3 --- /dev/null +++ b/data/signal-cli.service @@ -0,0 +1,18 @@ +[Unit] +Description=Send secure messages to Signal clients +Requires=dbus.socket +After=dbus.socket +Wants=network-online.target +After=network-online.target + +[Service] +Type=dbus +Environment="SIGNAL_CLI_OPTS=-Xms2m" +ExecStart=signal-cli --config /var/lib/signal-cli --trust-new-identities=always -u %number% daemon --system +User=signal-cli +BusName=org.asamk.Signal +# JVM always exits with 143 in reaction to SIGTERM signal +SuccessExitStatus=143 + +[Install] +Alias=dbus-org.asamk.Signal.service