Category: Internet services

Check if a file is a valid JSON in a BASH script

So, you have downloaded a file that is supposed to be a JSON. Before processing the file, it might be wise to check if that file is actually a valid JSON file.

Here is how to check if a file is indeed a valid JSON file:

if jq empty $File 2>/dev/null; then
  ThisFileIsAValidJSONFile="true"
else
  ThisFileIsAValidJSONFile="false"
fi 

Activate maintenance mode for nextcloud from BASH command line

Sometimes, one wants to put a nextcloud installation into “Maintenance mode” from the command line. Assuming your nextcloud is installed in /var/www/nextcloud/, the following command will put it in maintenance mode:

sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on

The following command will deactivate maintenance mode:

sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --off

If you want to check the state of maintenance mode:

if [ "$(sudo -u www-data php /var/www/nextcloud/occ status | grep -c "maintenance: true")" != "0" ]; then
  echo "Nextcloud is in maintenance mode"
else
  echo "Nextcloud is not in maintenance mode"
fi

Activate maintenance mode for wordpress from BASH command line

Sometimes, one wants to put a wordpress installation into “Maintenance mode” from the command line. Assuming your wordpress blog is installed in /var/www/myblog.example.com/, the following command will put it in maintenance mode:

echo '<?php $upgrading = '"$(date +%s)"'; ?>' > /var/www/myblog.example.com/.maintenance

The following command will deactivate maintenance mode:

rm -f /var/www/myblog.example.com/.maintenance

Activate IP forwarding on Debian 13

If you want to set up some kind of routing (of IP packets) on Debian 13, you first have to ensure that “Forwarding” is activated. By default it isn’t. Activation of Forwarding means that packets coming in at one interface might be transferred to another interface.

The following two commands will show you if forwarding is activated (“1”) or not (“0”):

sysctl net.ipv4.ip_forward
sysctl net.ipv6.conf.all.forwarding

if forwarding is not activated, the following two lines will activate it temporarily (until reboot of the system):

sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv6.conf.all.forwarding=1

To make this persistent (“Survive a boot”), create a file /etc/sysctl.d/99-ip-forward.conf with the following two lines as content:

net.ipv4.ip_forward=1
net.ipv6.conf.all.forwarding=1

Finally activate this file with

sysctl -p /etc/sysctl.d/99-ip-forward.conf

To verify that it is working check it (after a reboot) with the following two commands:

sysctl net.ipv4.ip_forward
sysctl net.ipv6.conf.all.forwarding

Both commands should deliver “1”.

Rustdesk

What is Rustdesk?

RustDesk is an open-source remote desktop software that allows you to access another PC’s desktop, for example to help friends and family when they have problems, or let them help you.

It is a free alternative to TeamViewer, AnyDesk, and similar programs.

A client application is needed on both PCs. A remote desktop access is only possible when the client is started, access is impossible without the Client being started, so the user is always in control.

How to install:

Download the latest Rustdesk client from here: https://rustdesk.com
Once downloaded, start the file:

In the lower left corner, click on “Install”.

Adapt to your needs and click on “Accept and install”.

Afterwards, you should have an Icon for Rustdesk on your desktop, and Rustdesk should be running:

Click on the “three dots” (as marked in the picture), select “Network” and click on “Unlock network settings”, the select “ID/Relay server”:

Fill the fields with the following data:

rustdesk.landrocks.world
rustdesk.landrocks.world
https://rustdesk.landrocks.world
C4LDY6WziONSwEzlIiBz1x3ZFn3iR8L4kjd6ZFJZPTE=

It should look like this:

Press OK, and click on “Home” in the upper left corner.

Congratulations, you have successfully installed a Rustdesk client on your system.

How to use Rustdesk:

On the left side you see your ID and your password. If you give this to somebody else, he or she can access your desktop.

If somebody else gives you his/her ID from their left side of the window, you can access his/her desktop by entering that ID in the “Control Remote Desktop” field and clicking “connect”.