Category Archives: selfhosted

Installing OPNsense on an OVH VPS

Installing OPNsense on an OVH VPS

This guide walks you through installing OPNsense on an OVH VPS using a Nano image. It works for me, it might not work for you.

Prerequisites

  1. An OVH VPS with access to recovery mode.
  2. Sufficient permissions to modify /dev/sda.

Steps

Step 0: Reboot the VPS into Recovery Mode

Start by rebooting the VPS into recovery mode from the OVH control panel. This allows full access to the disk for the installation process.

Step 1: Create a Temporary Mount

Once in recovery mode, mount a temporary filesystem (tmpfs) to use as a working directory:

mount -t tmpfs -o mode=1777 tmpfs /mnt

Step 2: Download the OPNsense Nano Image

Next, download the latest OPNsense Nano image from an official mirror. This example uses LeaseWeb's mirror, but you can select one closer to your region from the OPNsense Download Page:

wget https://mirror.ams1.nl.leaseweb.net/opnsense/releases/.../your-image.img.bz2 -P /mnt

Step 3: Extract the Image

Decompress the image using bunzip2:

bunzip2 /mnt/OPNsense-23.7-nano-amd64.img.bz2

Step 4: Write the Image to Disk

Using dd, write the image directly to /dev/sda. This will overwrite any existing data, so double-check the target disk.

dd if=/mnt/OPNsense-23.7-nano-amd64.img of=/dev/sda bs=1M status=progress

Step 5: Reboot the VPS

Finally, reboot the VPS from the OVH control panel to exit recovery mode and boot into OPNsense.


This setup should get OPNsense up and running on your OVH VPS, ready for configuration. Remember to go to KVM console and assign interfaces properly. Also you might need to enable accsessing WebUI on WAN port.

Media ingestion snippets

Automating Media File Management with Linux and Command-Line Tools

Introduction

Efficiently organizing and processing media files can save significant time and effort. This blog post outlines highly technical solutions for renaming, sorting, and processing media files using Linux command-line tools. Each command is explained in detail, highlighting its purpose, caveats, and possible improvements. SEO-optimized for media management enthusiasts.


Renaming GoPro Clips Based on Creation Dates

for f in *.MP4; do mv -n $f $(date -r $f +%Y%m%d_%H%M%S).mp4; done

Explanation:

  • for f in *.MP4: Loops through all MP4 files in the current directory.
  • mv -n $f $(date -r $f +%Y%m%d_%H%M%S).mp4: Renames each file to its creation date (format: YYYYMMDD_HHMMSS)
    • -r $f: Extracts the modification time of the file.
    • +%Y%m%d_%H%M%S: Formats the timestamp.
    • -n: Prevents overwriting existing files.

Caveats:

  • Relies on file modification times, which might differ from actual creation times. If precise creation dates are required, use EXIF metadata instead. Cameras easily loose track of time due to lack of a RTC

Improvement:

  • Use exiftool for more reliable metadata extraction:

    for f in *.MP4; do mv -n "$f" $(exiftool -d '%Y%m%d_%H%M%S.mp4' -CreateDate "$f"); done
    • use find & xargsinstead of a for loop

Renaming Pictures Using EXIF Data

find . -type f ! -name '*.tmp' -print0 | xargs -0 -P 12 -n 100 exiftool -r '-FileName<\$CreateDate' -d '%Y-%m-%d %H.%M.%S%%-c.%%le'

Explanation:

  • find . -type f ! -name '*.tmp': Finds all non-temporary files recursively.
  • -print0 | xargs -0: Handles filenames with special characters.
  • -P 12: Runs 12 parallel processes for efficiency.
  • -n 100: Processes up to 100 files per command.
  • exiftool -r '-FileName<\$CreateDate': Renames files based on their EXIF CreateDate metadata.
  • -d '%Y-%m-%d %H.%M.%S%%-c.%%le': Formats the filename to include date, time, and counter for duplicates.

Caveats:

  • EXIF metadata must exist; otherwise, files won’t be renamed.

Improvement:

  • Add error handling for files without EXIF metadata:
    find . -type f ! -name '*.tmp' -print0 | xargs -0 -P 12 -n 100 exiftool -r '-FileName<\$CreateDate' -d '%Y-%m-%d %H.%M.%S%%-c.%%le' || echo "Some files lack EXIF data."

Creating a Timelapse Video from JPEG Snapshots

ffmpeg -r 12 -pattern_type glob -y -i '*.jpg' -vcodec mjpeg_qsv -crf 0 output.mp4

Explanation:

  • -r 12: Sets the frame rate to 12 frames per second.
  • -pattern_type glob -i '*.jpg': Matches all JPEG files.
  • -vcodec mjpeg_qsv: Uses Intel Quick Sync for MJPEG encoding.
  • -crf 0: Ensures lossless compression.

Caveats:

  • Requires Intel hardware with Quick Sync support.

Improvement:

  • Add resolution adjustment for consistency:
    ffmpeg -r 12 -pattern_type glob -y -i '*.jpg' -vf scale=1920:1080 -vcodec mjpeg_qsv -crf 0 output.mp4

Timelapse from Video with Motion Blur

ffmpeg -i input.mkv -filter:v tblend=average,framestep=2,setpts=0.1*PTS -r 96 -b:v 30M -crf 10 -vcodec h264_qsv -an -y output.mkv

Explanation:

  • tblend=average: Applies motion blur by blending frames.
  • framestep=2: Skips every other frame.
  • setpts=0.1*PTS: Speeds up playback to 10% of the original duration.
  • -r 96: Sets the output frame rate to 96 FPS.
  • -b:v 30M: Sets a high bitrate for quality.
  • -crf 10: Balances quality and compression.
  • -vcodec h264_qsv: Uses Intel Quick Sync for H.264 encoding.

Caveats:

  • Requires substantial processing power.

Improvement:

  • Automate bitrate calculation based on input resolution:
    ffmpeg -i input.mkv -filter:v tblend=average,framestep=2,setpts=0.1*PTS -r 96 -b:v $(expr $(ffprobe -v error -select_streams v:0 -show_entries stream=height -of csv=p=0 input.mkv) \* 100)k -crf 10 -vcodec h264_qsv -an -y output.mkv

Merging Videos Without Transcoding

ffmpeg -safe 0 -f concat -i <(find . -type f -name '*MP4' -printf file '$PWD/%p'\n | sort) -c copy output.mkv

Explanation:

  • find . -type f -name '*MP4': Finds all MP4 files.
  • -printf file '$PWD/%p'\n: Formats paths for FFmpeg.
  • -safe 0: Allows unsafe file paths.
  • -f concat -i: Concatenates video files.
  • -c copy: Merges files without re-encoding.

Caveats:

  • Files must have identical codecs, resolution, and framerate.

Improvement:

  • Validate file compatibility before merging:
    find . -type f -name '*MP4' | xargs -I {} ffprobe -v error -show_entries stream=codec_name,height,width -of csv=p=0 {} | sort | uniq -c

Sorting Pictures by Camera Model

exiftool -d '.' '-directory<${model;}/$datetimeoriginal' *.jpg

Explanation:

  • -d '.': Uses a dot separator for directories.
  • '-directory<${model;}/$datetimeoriginal': Organizes pictures into folders by camera model and original date.

Caveats:

  • Assumes consistent EXIF metadata.

Improvement:

  • Add fallback for files missing camera model metadata:
    exiftool -d '.' '-directory<${model;}/$datetimeoriginal' -if '$model' *.jpg || mv *.jpg Unknown_Model/

Sorting Pictures by Year and Month

find . -type f ! -name '*.tmp' -print0 | xargs -0 -P 12 -n 100 exiftool -d '%Y/%m' '-directory<\$CreateDate'

Explanation:

  • Organizes files into directories structured as Year/Month.
  • Multi-threaded for faster processing (-P 12).

Caveats:

  • Requires valid EXIF CreateDate metadata.

Improvement:

  • Create missing directories dynamically to prevent errors:
    find . -type f ! -name '*.tmp' -print0 | xargs -0 -P 12 -n 100 exiftool -d '%Y/%m' '-directory<\$CreateDate' || mkdir -p Unknown_Date/

Injecting Dates into WhatsApp Media Files

exiftool -if 'not $CreateDate' -if '$filename =~ /^(?>VID|IMG)-\d{8}-WA\d{4,}\./' -r -overwrite_original_in_place -progress '-AllDates<${filename;s/WA.*//} 12:00:00' .

Explanation:

  • -if 'not $CreateDate': Ensures only files without a CreateDate are processed.
  • -if '$filename =~ /^(?>VID|IMG)-\d{8}-WA\d{4,}\./': Targets WhatsApp media files named in the format VID-YYYYMMDD-WAXXXX or IMG-YYYYMMDD-WAXXXX.
  • -r: Recursively processes all files in the specified folder.
  • -overwrite_original_in_place: Updates files directly without creating backup copies.
  • -progress: Displays progress for better monitoring.
  • '-AllDates<${filename;s/WA.*//} 12:00:00': Extracts the date from the filename and sets it as the AllDates metadata, appending a fixed time (12:00:00) for consistency.

Background and Use Case:

WhatsApp-received media often lacks proper EXIF metadata for the creation date, which can lead to incorrect grouping when imported into platforms like Immich. This command extracts the date embedded in the filename (representing the download date) and injects it into the file's metadata, ensuring accurate sorting on a timeline.

Caveats:

  • Always back up your files before modifying metadata to prevent accidental loss or corruption.
  • Ensure exiftool is installed and updated on your system.
  • Stop Immich containers before running the script to avoid file conflicts. Restart the containers afterward and rerun the \"Extract Metadata\" job for proper sorting.

Conclusion

These commands provide powerful tools for managing media files efficiently. With optimizations and error handling, they can handle large datasets with reliability and speed.

Keywords

  • Media File Management
  • Linux Media Automation
  • ffmpeg Timelapse
  • exiftool Picture Organization

Tags

  • Linux
  • ffmpeg
  • exiftool
  • Media Management

Run many services on the same port with sslh

Objective: run many services on the same port with sslh

sslh is a superb utility which greatly increased my satisfaction of self-hosting xmpp, www, vpn, ssh and other. Why? How? Let’s see!

Introduction

Sometimes it may be neccesary to run different services that listen on the same port. Often the case is with VPN, XMPP, HTTP(s), SSH.
sslh will enable us to do so in a easy and efficient way.

Continue reading

Życie z technologią – bezpiecznie, wygodnie.

Życie z technologią - bezpiecznie, wygodnie - czy to możliwe?

Technologia jest nieodłącznym elementem codziennego życia niemal każdego człowieka.
Niektórym to życie ułatwia, niektórym utrudnia. Są osoby, które nie umieją z niej korzystać, żyją w fałszywym przeświadczeniu że umieją, a całej reszczie pomaga z dnia na dzień.
Pomyślałem, że opis tego w jaki sposób sam korzystam z technologii na co dzień może być źródłem inspiracaji dla innych, jak i wszelkie komentarze cennymi uwagami dla mnie.

Continue reading

How to make use of all the great technologies?

Harnessing the Power of Technology: A Deep Dive into My Setup

Technology is becoming an indispensable part of our daily lives. It can simplify tasks, save time, and reduce stress—or, if misused, become a frustrating burden. This post details how I leverage technology to its fullest potential. My hope is that this serves as an inspiration for others looking to enhance their workflows and productivity.


How Can You Maximize the Use of Cutting-Edge Technology?

Let’s explore my setup, covering hardware, software, and techniques that make my daily tasks seamless.


1. Dell Latitude E6440: My Daily Driver

Most of my time is spent working on my Dell Latitude E6440, a reliable, compact powerhouse. Here’s what it offers:

Hardware Specifications

  • 14" IPS Display: 1600x900 resolution with LED backlight.
  • Processor: Intel® Core™ i5-4300M CPU @ 2.60GHz, dual-core with Hyper-Threading.
  • Memory: 8GB + 4GB low-voltage DDR3L RAM.
  • Storage: 128GB Corsair SSD (CSSD-V128GB2).
  • Connectivity: Built-in 3G modem for seamless internet access.

Software Configuration

I’ve optimized this laptop for productivity and performance using Arch Linux with the following tools:

  • Preload: Improves application load times.
  • Prelink: Reduces library load time for applications.
  • Powerpill: Efficient package management via parallel downloads.
  • DNScrypt with dnsmasq: Encrypts DNS queries for privacy.
  • Zsh with grml-zsh config: A powerful shell setup for streamlined workflows.

Applications

  • Firefox: My browser of choice for its open-source ethos. Key extensions include:
    • HTTPS Everywhere
    • KeeFox
    • NoScript
    • Pushbullet
    • uBlock Origin
  • Gajim: XMPP client paired with a Prosody server, supporting:
    • Message Archive Management (MAM)
    • Message Carbons
    • HTTP file uploads
    • OTR and OMEMO encryption
  • Syncthing: Peer-to-peer file synchronization with versioning and encryption.
  • i3 Window Manager: A tiling window manager that redefines productivity.
  • MOSH: Persistent SSH sessions resilient to network interruptions.
  • Redshift: Adjusts screen temperature to reduce eye strain.
  • Tools like Wireshark, tcpdump, nmap, and aircrack-ng for network analysis.

Why This Setup?

  • Ergonomic keyboard with LED backlight.
  • Modular design allowing HDD/SSD or battery expansion.
  • Port replicator for enhanced connectivity.
  • Rugged chassis and portable build.

2. Google Nexus 5: A Handy Companion

My Google Nexus 5 is a reliable smartphone with:

  1. Compact size and ergonomic design.
  2. Sufficient processing power for multitasking.
  3. Official CyanogenMod support for customization.

Key Applications

  • Conversations: XMPP client for secure, private messaging.
  • Lightning Browser: Lightweight, open-source web browser.
  • OpenVPN: Quick VPN access with widget support.
  • Irssi Connectbot: Mosh-supported SSH client.
  • Utility apps like DAVdroid, K-9 Mail, Twidere, and Transdroid.

3. VPS: My Cloud Hub

I run a VPS hosting:

  • This blog and Piwik analytics.
  • XMPP server (configured with Prosody).
  • WeeChat: An IRC client that integrates with BitlBee for seamless messaging.

Plugins like Pushbullet notifications ensure I never miss important updates.


4. "Kebab": The Affordable Workhorse

A budget-friendly Kimsufi server featuring:

  • Intel® Atom™ CPU N2800 @ 1.86GHz.
  • 2GB DDR2 RAM.
  • 500GB HDD.

Use Cases

  • Arch Linux mirror hosting.
  • TeamSpeak server.
  • VPN server and torrent seedbox.
  • OwnCloud for file, contact, and calendar management.

5. "Wyvern": My Home Server

A robust home server with:

  • Intel® i3-3220, 16GB RAM.
  • RAID configurations: 3x1TB (RAID0) and 2x500GB (RAID1).

Features

  • File Server: Samba and NFS for network storage.
  • VM Hosting: Proxmox for managing:
    • ELK stack for logs.
    • Private F-Droid repository.
    • Windows VMs for testing.
  • Backup Solutions: Automated backups using borg-backup.

6. "Kundel": Kindle Paperwhite

I jailbreak my Kindle Paperwhite and use Syncthing for wireless file transfers, eliminating the need for USB connections.


Leveraging Technology for Security

Data Protection

  • TLS-encrypted synchronization with Syncthing.
  • Full-disk encryption via dm-crypt and Android’s built-in encryption.
  • Backup automation with borg-backup.

Two-Factor Authentication

All remote servers use 2FA via libpam-google-authenticator, with OTPs generated by an open-source tOTP app.

Private DNS

DNScrypt with DNSSEC validation ensures encrypted, verified DNS queries.


Communication Made Secure

I use both IRC and XMPP for messaging, with encryption provided by OTR and OMEMO protocols. The setup supports advanced features like Message Archive Management (MAM) and file uploads via HTTP components.


Conclusion

This setup showcases how the right combination of hardware, software, and tools can transform your productivity. From secure file synchronization to efficient communication, these technologies enable seamless workflows.

Got questions or insights? Drop a comment below—I’d love to hear how you optimize your tech setup!


SEO-Optimized Tags:

  • "Maximizing Technology for Productivity"
  • "Arch Linux Customization"
  • "Secure XMPP Server Configuration"
  • "Home Server Setup Guide"
  • "TP-Link Router Bootloader Recovery"

Prosody – simple XMPP server for IM.

Objective: Prosody – A Simple XMPP Server for Instant Messaging

XMPP (Extensible Messaging and Presence Protocol) is an open-standard communication protocol based on XML, developed in 1999. Known for its decentralized nature, XMPP allows the creation of interoperable applications, meaning services can communicate with one another regardless of the underlying platform. This open approach to development ensures flexibility and extensibility.

Today, some of the key features of XMPP are:

  • Secure instant messaging: All communications are encrypted, ensuring privacy.
  • Decentralization: No central server is needed, giving users control over their own data.

Prerequisites

Before we begin, ensure you have the following:

  • A (preferably) Debian-based virtual machine or server instance. This tutorial will guide you through the initial setup.
  • A few minutes to spare for installation and configuration.

What Will We Do?

In this tutorial, we will:

  1. Install Prosody
  2. Install additional modules
  3. Modify the main Prosody configuration file
  4. Configure a virtual host section

1. Installing Prosody

Prosody developers maintain their own repository for secure installation and updates. This ensures you always have the latest version of Prosody.

1.1 Add the Repository

Add the Prosody repository to your system's package sources:

echo "deb http://packages.prosody.im/debian $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list

1.2 Add the Prosody Key to Your Keyring

To authenticate packages from the Prosody repository, add the repository’s signing key:

wget https://prosody.im/files/prosody-debian-packages.key -O - | sudo apt-key add -

1.3 Install Prosody and Required Dependencies

Install Prosody, the LuaRocks package manager, and essential Lua storage drivers:

sudo aptitude update && sudo aptitude install prosody-0.10 luarocks lua-zlib lua-dbi-common lua-dbi-sqlite3 -y

1.4 Install Required LuaRocks

For enhanced security, install the following LuaRocks:

luarocks install lua-zlib luaevent luasec luasocket

These additional Lua modules will enable forward secrecy and stream compression for your server.


2. Installing Additional Modules

Prosody supports various modules that can enhance functionality. Here’s how to install them.

2.1 Clone the Prosody Modules Repository

To access additional modules, clone the official repository:

hg clone http://prosody-modules.googlecode.com/hg/ prosody-modules

2.2 Find the Modules Directory

You can identify where Prosody looks for modules by running:

prosodyctl about

This will return various information, including the path for the module directory:

Plugin directories:
  /usr/local/lib/prosody/modules/

2.3 Choose and Enable Useful Modules

Here are some useful modules to enable for better functionality:

2.3.1 XEP-0280: Message Carbons

This module ensures that messages sent to your JID are delivered to all connected devices. It is ideal for users accessing XMPP from multiple clients.

To enable this module, use the following command:

cp prosody-modules/mod_carbons/mod_carbons.lua /usr/local/lib/prosody/modules/

2.3.2 XEP-0313: Message Archive Management

This extension stores conversations on the server, enabling synchronization across devices. It allows clients to display archived messages.

Enable this module:

cp prosody-modules/mod_mam/mod_mam.lua /usr/local/lib/prosody/modules/

2.3.3 mod_csi

This module helps mobile clients indicate inactivity, reducing unnecessary notifications. It is particularly useful for users on mobile networks.

cp prosody-modules/mod_csi/mod_csi.lua /usr/local/lib/prosody/modules/

2.3.4 XEP-0198: Stream Management

This module reduces message loss on unreliable internet connections (common with mobile networks).

cp prosody-modules/mod_smacks/mod_smacks.lua /usr/local/lib/prosody/modules/

2.3.5 mod_throttle_presence

This extension helps reduce traffic on mobile connections by limiting presence updates, which often generate significant network traffic.

cp prosody-modules/mod_throttle_presence/mod_throttle_presence.lua /usr/local/lib/prosody/modules/

3. Modifying the Main Prosody Configuration File

The main Prosody configuration file can be found using:

prosodyctl about

In most installations, this file is located at:

/etc/prosody/prosody.cfg.lua

To enable the modules you just installed, locate the modules_enabled section and add the following lines:

"csi";
"throttle_presence";
"smacks";
"mam";
"carbons";

You can also enable additional features like "blocklist" for blocking contacts, "bosh" for chatrooms, and "compression" for stream compression.

Before the virtualhost section, add the following line to configure your SQLite database:

sql2 = { driver = "SQLite3", database = "prosody.sqlite" }

Finally, ensure that password hashing is enabled by modifying the following line:

authentication = "internal_hashed"

This will hash and salt all user passwords for added security.


4. Preparing the VirtualHost Configuration Section

4.1 Create a VirtualHost Entry

The virtual host entry for your server should look like this:

VirtualHost "example.com"
        ssl = {
                key = "/etc/prosody/certs/localhost.key";
                certificate = "/etc/prosody/certs/localhost.crt";
        }
        storage = {
                archive2 = "sql2";
        }
        default_archive_policy = true
        max_archive_query_results = 50;

        Component "proxy.example.com" "proxy65"
                proxy65_address = "proxy.example.com"
        Component "muc.example.com" "muc"

4.1.1 SSL Configuration

Generate your own self-signed SSL certificate if you don't have one, using the following command:

openssl req -new -x509 -days 365 -nodes -out "localhost.crt" -newkey rsa:4096 -keyout "localhost.key"

4.1.2 Storage Configuration for Message Archives

The mod_mam module stores message archives in the specified SQLite database. The max_archive_query_results parameter limits the number of messages returned in a single query.

4.1.3 Proxy65 Component

The proxy65 component facilitates file sharing, particularly when clients are behind NAT.

4.1.4 MUC Component

The muc (Multi-User Chat) component enables the creation of chatrooms.


Conclusion

Once all configurations are in place, set an SRV or A DNS record for your domain pointing to your server. Then, add a user:

prosodyctl adduser [email protected] && prosodyctl start

Your Prosody instance is now up and running! Enjoy chatting securely with your contacts.

Feel free to leave comments or ask questions below!

Ograniczenia i limity nie interesują mnie, czyli życie na publicznej sieci.

Często i gęsto zdarza się, że sieci na uczelniach, w hotelach bądź restauracjach mają nałożone poważne restrykcje.
Możliwe, że kiedyś ktoś narozrabiał, i w wyniku tego konieczne było ograniczenie możliwości.
Jednak co w sytuacji, w której szerszy dostęp do internetu potrzebny jest w dobrych celach?
Sytuacja życiowa inspirująca napisanie tego artykułu: sieć na uczelni, która dopuszcza ruch z siecią Internet tylko i wyłącznie na portach 80 oraz 443 TCP.

Continue reading

Mail-in-a-box – serwer mailowy w jednym skrypcie, w kontenerze lxc

Jak łatwo i szybko postawić dobry serwer mailowy, z niemal wszystkimi możliwymi wodotryskami?
Wydawać by się mogło, że to nie możliwe, a z pewnością wymagałoby dużo pracy… jakby więc podjąć temat tak, żeby sie nie narobić..?
Z pomocą przyszedł mi całkiem niezły skrypt, mail-in-a-box!

Continue reading

ArchLinux mirror

ArchLinux mirror

archlinux mirror

Thanks to Let's Encrypt I've deployed tls-enabled ArchLinux mirror server. It is available at:

http://mirror.tyborek.pl/arch/
https://mirror.tyborek.pl/arch/

It is already added to official mirrorlist, if suitable you will use it automagically.

Qualys SSL Labs has graded this mirror as A+, improving overall security. SSL configuration is following guidelines pointed out at cipherli.st.

I think it is a good place to mention reflector, a really good tool to generate list of the best available mirrors. Speeds up pacman significantly.

Up to date ArchLinux mirror rank can be found here