snap


How to Run Three Instances of Signal on Ubuntu

Signal is a popular, privacy-focused messaging app. For various reasons, you might want to run multiple instances of Signal on your Ubuntu system. Here, we’ll guide you through the process of installing three different versions of Signal: the Snap package, the standard Debian-based installation, and the Signal Beta for Linux.

Prerequisites

  • Ubuntu OS (We recommend a recent version, like 20.04 or later)
  • Basic understanding of Linux terminal commands

1. Installing Signal from Snap

Snap is a package management system that makes it easy to install applications in Linux. Follow these steps to install Signal using Snap:

  1. Open Terminal: Use Ctrl+Alt+T to open the terminal.
  2. Install Signal: Enter the command: sudo snap install signal-desktop.
  3. Launch Signal: You can find Signal in your applications menu or launch it from the terminal with signal-desktop.

2. Installing Signal Using Linux (Debian-based) Install Instructions

For the second instance, we will use the Debian-based installation method (https://signal.org/download/):

  1. Add Signal’s Official Repository:
    • Open Terminal.
    • Enter:
      wget -O- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg;
      cat signal-desktop-keyring.gpg | sudo tee /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null;
    • Add the repository:
      echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' | sudo tee /etc/apt/sources.list.d/signal-xenial.list;
  2. Update and Install Signal:
    • Update package database: sudo apt update.
    • Install Signal: sudo apt install signal-desktop.
  3. Launch the Application: Find Signal in your application menu or type signal-desktop in the terminal.

3. Installing Signal Beta for Linux (Debian-based)

Finally, let’s install the Beta version (https://support.signal.org/hc/en-us/articles/360007318471-Signal-Beta):

  1. Add Signal Beta Repository:
    • Open Terminal.
    • Enter:
      wget -O- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg;
      cat signal-desktop-keyring.gpg | sudo tee -a /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null;
    • Add the Beta repository:
      echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' | sudo tee -a /etc/apt/sources.list.d/signal-xenial.list
  2. Update and Install Signal Beta:
    • Update the system: sudo apt update.
    • Install Signal Beta: sudo apt install signal-desktop-beta.
  3. Launch Signal Beta: It should appear in your applications menu or can be started from the terminal with signal-desktop-beta.

Tips for Managing Multiple Instances

  • Different Profiles: Each instance of Signal will require a different phone number for registration.
  • System Resources: Running multiple instances can consume more system resources. Monitor your system’s performance.
  • Updates: Regularly check for updates to each version to ensure security and functionality.

Conclusion

With these steps, you should now have three different versions of Signal running on your Ubuntu system. This setup is ideal for separating personal, work, and testing environments within the same machine. Enjoy your enhanced and versatile messaging experience!


Remove Disabled Snaps.

LANG=C snap list --all | awk '/disabled/{print $1" --revision "$3}' | xargs -rn3 sudo snap remove;

Let us break down the command for you:

  1. LANG=C sets the language to English (C locale), which can be helpful to ensure consistent behavior across different systems with different default languages. We used this to make sure that the word disabled will appear for disabled snaps and not some other translation.
  2. snap list --all lists all installed snaps (i.e., packages) along with their details. The output of this command is piped to the following command.
  3. awk '/disabled/{print $1" --revision "$3}' searches for lines in the output that contain the word “disabled” and prints the first field (i.e., the name of the snap) followed by the string “–revision” and the third field (i.e., the revision number). This output is piped to the next command.
  4. xargs -rn3 sudo snap remove takes groups of three arguments from the input and runs the command snap remove with those arguments. In this case, the first argument is the name of the disabled snap; the second argument is the string “–revision”, and the third argument is the revision number. This will remove all disabled snaps and their associated revisions.

So, in summary, the command searches for all disabled snaps on the system, extracts their name and revision number and then removes them using the snap remove command. This is a very useful command to free up some space without losing data or functionality.


Linux mouse jiggler

Keep-Presence is an innovative program that automatically detects when you’re away from your computer and moves the mouse or presses a key to keep it active. This is especially helpful when you need to keep your computer running but don’t want it to lock or sleep due to inactivity.

What’s excellent about Keep-Presence is that it won’t interfere with your work while using your computer. Instead, it only activates when it detects that you’re away, so you can rest assured that your computer will remain active even if you step away from your desk for a few minutes.

This program is beneficial if you’re working remotely and need to step away from your computer frequently. With Keep-Presence, you can trick your machine into thinking you’re still working on it, which can be helpful if you need to step away for a short period and don’t want to constantly re-login or restart your work.

In summary, Keep-Presence is a helpful program that keeps your computer active even when you’re away. It’s an excellent tool for those who work remotely or need to step away from their desk frequently, and it won’t interfere with your work while using your computer.

This software is available in GitHub and the snap package manager.

https://github.com/carrot69/keep-presence/

To install using snap, execute the following command:

sudo snap install keep-presence;
#Just execute the following to start the application with default settings
keep-presence;
#Use Ctrl+C to stop it.

We used it in Ubuntu 22.04LTS with success.

Optional arguments

-h, --help                        show this help message and exit
            
-s SECONDS, --seconds SECONDS     Define in seconds how long to wait after a user is
                                  considered idle. Default 300.

-p PIXELS, --pixels PIXELS        Set how many pixels the mouse should move. Default 1.

-c, --circular                    Move mouse in a circle. Default move diagonally.

-m MODE, --mode MODE              Available options: keyboard, mouse, both; default is mouse. 
                                  This is the action that will be executed when the user is idle. 
                                  If keyboard is selected, the program will press the shift key. 
                                  If mouse is selected, the program will move the mouse. 
                                  If both is selected, the program will do both actions.

-r RANDOM RANDOM, --random RANDOM RANDOM
                                  Usage: two numbers (ex. -r 3 10). Execute actions based on a 
                                  random interval between start and stop seconds. 
                                  Note: Overwrites the seconds argument.

Rough notes on setting up an Ubuntu 22.04LTS server with docker and snap 1

IP allocations

First, we set up a static IP on the network device that would handle all external traffic and a DHCP on the network device that would access the management network, which is connected for maintenance.

To do so, we created the following file:

/etc/netplan/01-netcfg.yaml

using the following command:

sudo nano /etc/netplan/01-netcfg.yaml;

and added the following content to it:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: no
      addresses: [192.168.45.13/24]
      gateway4: 192.168.45.1
      nameservers:
          addresses: [1.1.1.1,8.8.8.8]
    eth1:
      dhcp4: yes

To apply the changes, we executed the following:

sudo netplan apply;

Update everything (the operating system and all packages)

Usually, it is a good idea to update your system before making significant changes to it:

sudo apt update -y; sudo apt upgrade -y; sudo apt autoremove -y;

Install docker via snap

In this setup, we did not use the docker version available on the Ubuntu repositories, we went for the ones from the snap. To install it, we used the following commands:

sudo apt install snapd;
sudo snap install docker;

Increase network pool for docker daemon

To handle the following problem:

ERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network

We modified the following file

/var/snap/docker/current/config/daemon.json

using the command:

sudo nano /var/snap/docker/current/config/daemon.json;

and set the content to be as follows:

{
    "log-level":        "error",
    "storage-driver":   "overlay2",
    "default-address-pools": [
        {
            "base": "172.80.0.0/16",
            "size": 24
        },
        {
            "base": "172.90.0.0/16",
            "size": 24
        }
    ]
}

We executed the following command to restart the docker daemon and get the network changes applied:

sudo snap disable docker;
sudo snap enable docker;

Gave access to our user to manage the docker

We added our user to the docker group so that we could manage the docker daemon without sudo rights.

sudo addgroup --system docker;
sudo adduser $USER docker;
newgrp docker;
sudo snap disable docker;
sudo snap enable docker;

After that, we made sure that the access rights to the volumes were correct:

sudo chown -R www-data:www-data /volumes/*
sudo chown -R tux:tux /volumes/letsencrypt/ /volumes/reverse/private/

Deploying

After we copied everything in place, we executed the following command to create our containers and start them with the appropriate networks and volumes:

export COMPOSE_HTTP_TIMEOUT=600;
docker-compose up -d --remove-orphans;

We had to increase the timeout as we were getting the following error:

ERROR: for container_a  UnixHTTPConnectionPool(host='localhost', port=None): Read timed out. (read timeout=60)
ERROR: An HTTP request took too long to complete. Retry with --verbose to obtain debug information.
If you encounter this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value (current value: 60).

Updating the databases and performing any repairs

First, we connected to a terminal of the database container using the following command:

docker exec -it mariadb_c1 /bin/bash;

From there, we executed the following commands:

mysql_upgrade --user=root --password;
mysqlcheck -p -o --all-databases;

Bulk / Batch stopping docker containers

The following commands will help you stop many docker containers simultaneously. Of course, you can change the command stop to another, for example rm or whatever suits your needs.

You need to keep in mind that if you have dependencies between containers, you might need to execute the commands below more than once.

Stop all docker containers.

docker container stop $(docker container ls -q);
#This command creates a list of all containers.
#Using the -q parameter, we only get back the container ID and not all information about them.
#Then it will stop each container one by one.

Stop specific docker containers using a filter on their name.

docker container stop $(docker container ls -q --filter name=_web);
#This command finds all containers that their name contains _web.
#Using the -q parameter, we only get back the container ID and not all information about them.
#Then it will stop each container one by one.

A personal note

Check the system for things you might need to configure, like a crontab or other services.

A script that handles privileges on the docker volumes

To avoid access problems with the various external volumes we created the mysql user and group on the host machine as follows:

sudo groupadd -g 999 mysql;
sudo useradd -u 999 mysql -g mysql;

Then we execute the following to repair ownership issues with our containers. Please note that this script is custom to a particular installation and might not meet your needs.

#!/bin/bash

sudo chown -R www-data:www-data ~/volumes/*;
sudo chown -R bob:bob ~/volumes/letsencrypt/ ~/volumes/reverse/private/;
find ~/volumes/ -maxdepth 2 -type d -name mysql -exec sudo chown -R mysql:mysql '{}' \;;