bee.gdn

Docker on Debian DVD Install

This will be a quick one on how to install docker on Debian 12.

What you will need: A machine with Debian installed (Virtual, or physical) an internet connection

In this example, I am using a physical machine. I would like to try deploying docker within a VM to spec it's performance but that is for another time.

I have a laptop I am putting this on, and connecting via SSH to execute the commands. I installed Debian with only the SSH server and standard system utilities features, with the DVD installer ISO file. I noticed some hiccups.

To connect to the machine, you will need it's IP address, you can find this by running ip addr ssh username@ipaddress where the username is the account you login to your debian instance with, and the ipaddress is the ip you captured when you ran ip addr

The first thing you will need to do is escalate to root to download and install packages, this can be done with the command su

I didn't have any luck installing the packages with apt or apt-get so I made a new directory with mkdir and downloaded the files with wget after cding into that directory. wget https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/containerd.io_1.7.20-1_amd64.deb https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/docker-ce_27.1.2-1~debian.12~bookworm_amd64.deb https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/docker-ce-cli_27.1.2-1~debian.12~bookworm_amd64.deb https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/docker-buildx-plugin_0.16.2-1~debian.12~bookworm_amd64.deb https://download.docker.com/linux/debian/dists/bookworm/pool/stable/amd64/docker-compose-plugin_2.29.1-1~debian.12~bookworm_amd64.deb

After this is finished, you can try to install with dpkg -i ./containerd.io1.7.20-1amd64.deb \ ./docker-ce27.1.2-1~debian.12~bookwormamd64.deb \ ./docker-ce-cli27.1.2-1~debian.12~bookwormamd64.deb \ ./docker-buildx-plugin0.16.2-1~debian.12~bookwormamd64.deb \ ./docker-compose-plugin2.29.1-1~debian.12~bookwormamd64.deb

However, I got an error about 'ldconfig' and 'start-stop-daemon' not found in my path so I needed to update my PATH variable with export PATH=$PATH:/usr/local/sbin:/usr/sbin:/sbin

If you also used the DVD iso installer, it will have the DVD in your sources.list. You can open this file and comment out a line. First open the file with nano nano /etc/apt/sources.list Then on the first line I found what needed commented out change deb cdrom:[Debian GNU/Linux 12.6.0 Bookworm – Official amd64 DVD Binary-1 with firmware 20240629-10:19]/ bookworm main

to

# deb cdrom:[Debian GNU/Linux 12.6.0 Bookworm – Official amd64 DVD Binary-1 with firmware 20240629-10:19]/ bookworm main

Add a hashtag before the line to comment it out, then save with ctrl-x.

Then run apt-get update and apt-get install -f

This will install any missing dependencies and you should be good to install docker now with dpkg -i ./containerd.io1.7.20-1amd64.deb \ ./docker-ce27.1.2-1~debian.12~bookwormamd64.deb \ ./docker-ce-cli27.1.2-1~debian.12~bookwormamd64.deb \ ./docker-buildx-plugin0.16.2-1~debian.12~bookwormamd64.deb \ ./docker-compose-plugin2.29.1-1~debian.12~bookwormamd64.deb

You should see no error messages and can then run service docker start and then a test docker run hello-world

You should see a Hello from Docker! message.

For more information on deploying docker images, please see the Docker website documentation.

Setting up a VM with QEMU on Windows 11

So QEMU has always intimidated me. I see posts on reddit recommending this product. I've always been intimidated by the documentation, maybe just the plethora of information and lack of the quick start have always made me turn away and use other solutions like VirtualBox or Hyper-V which are much more intuitive. If anyone from QEMU reads this, I think what you're doing is great but your docs need a quickstart/cliffnotes because there are plenty of blog posts like this one that try to explain the process, and (maybe) become dated when new versions are released.

Anyways, if you are new to Virtualization or Linux I'd recommend picking up VirtualBox and playing around with installing Ubuntu with a desktop environment. I used to use VirtualBox in a former role to build Windows images to deploy to end-users laptops, and while the performance wasn't always great, it got the job done and taught me a lot about networking, computers, and virtualization.

Onto the meat and potatoes. QEMU seems like a great solution, especially since it is all command line based. This makes it a great candidate to automate Virtual Machine (VM) deployment. Virtualbox also has command line interfaces, but reddit tells me QEMU is much more performant. This is my first rodeo, so time will tell.

What you'll need: Some hard drive space QEMU QEMU Windows Installer A Linux image, I'm using the debian DVD iso https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/

Once you download each of these, you'll want to verify the SHA-512 hash to ensure the authenticity of the download. On Windows Powershell you can use the command certutil -hashfile “.\path\to\downloaded\exe” SHA512

This will spit out a hash you can verify against the one provided by QEMU and Debian, the hash in the Powershell prompt should match the hash provided in the downloads directory on the site. If it doesn't, delete the download and try another download mirror until one matches. If the hash doesn't match, someone has injected a file into the download link and its probably malware, or at least not authentic.

Once you have both QEMU and a Linux ISO downloaded, you then need to install QEMU. In Windows, its a graphical installer and you can click through the prompts and let the install complete. Once completed you need to locate where it installed. On my machine I located it at C:\Program Files\qemu

You then need to add this to your path variable, to do this you need to go to the Windows Settings, and About. Or you can right click on This PC and go to properties. You'll see an “Advanced System Settings” option, click on that. A window will pop up with System Properties, and under the Advanced tab there is an Environment Variables option. Click on that and a new window will pop up with User Variables and System variables. Under each is a Path option. I selected System Variable's Path option and added C:\Program Files\qemu

As an option. You could add it to the User variables if a bunch of people use your machine and you only want it configured for your account. Anyways, click OK on all the windows to confirm the update, then close any open Powershell/terminal windows and reopen them. You then should be able to run qemu-system-x86_64 -help

And you should see some help information pop up. If you see an error message, then the path variable didn't save and you should try those steps again, or possibly rebooting your machine. In the event you can't get this to work, you can just execute the software directly from it's installation path C:\Program Files\qemu\qemu-system-x86_64.exe

I am using this binary because I am on an x86_64 machine, if you are using a different architecture on your host machine, then you should review the QEMU documentation and select the appropriate binary.

Once you have QEMU installed, its time to get onto building a VM!

If you just want to test that QEMU is working you can run something like qemu-system-x86_64 -boot d -cdrom \path\to\downloaded\linux\iso -m 2048

This boots a vm with 2048 bytes (2gig) of ram, with no hard disk attached. You can use this to see if the ISO loads and for things like a live USB install of ubuntu. For more info on commands see the qemu man page.

However, if you want a disk attached to the VM then we first need to create the disk, then include the disk in the command to launch the VM. To create a disk you can use a command like qemu-img create -f vdi debian_hd.vdi 50G

Where qemu-img creates the disk, -f is the format of the disk, here I am using the VDI format since I am familiar with virtual box, and I am alloting 50gigs of space for the virtual disk.

Once this is created, you then need to boot the VM with the ISO installer as a CD-ROM: qemu-system-x8664.exe -machine type=q35,accel=tcg -m 4096 -cpu qemu64 -smp 4 -drive file=C:\Users\bee\qemuvms\debian\debianhd.vdi,format=vdi,if=virtio -cdrom C:\Users\bee\qemuvms\debian\debian-12.6.0-amd64-DVD-1.iso -boot d -device virtio-net-pci,netdev=unet -netdev user,id=unet,hostfwd=tcp::2222-:22 -serial mon:stdio

This command should boot you to the ISO installer. The -machine flag sets it the type to q35 which is a PCI express-based machine, and accel is set to tcg which is Tiny Code Generator, a software based emulator. -m 4096 sets the ram to 4gigs. -cpu qemu64 is a generic processor to emulate provided by qemu. -smp 4 sets the machine to 4 use 4 cores. -drive is the location of the virtual hard drive we created, with a vdi format and using the virtio interface. -cdrom is the path to your linux iso file. -boot sets the device to boot to the cd-rom drive d. -device virtio-net-pci,netdev=unet sets a virtual network card. -netdev user,id-unet,hostfwd=tcp::2222-:22 forwards tcp traffic from port 2222 to the host port 22 on the virtual machine for SSH access. -serial mon:stdio redirects the virtual machines serial port to the input/output of the console so it can be accessed from the current terminal window.

Once you run this command, and all goes well you should see an installer. I am installing Debian, and I have never had luck with virtualization and setting disk encryption, so do not set that option. Go through the debian installer and disable the Desktop environment and GNOME and enable SSH server and standard system utilities. I left everything else as default. The Graphical installation will eventually complete and then you will need to run a new command to boot the machine without the CD-ROM so it boots to the hard disk qemu-system-x8664.exe -machine type=q35,accel=tcg -m 4096 -cpu qemu64 -smp 4 -drive file=C:\Users\bee\qemuvms\debian\debian_hd.vdi,format=vdi,if=virtio -boot order=c -device virtio-net-pci,netdev=unet -netdev user,id=unet,hostfwd=tcp::2222-:22 -serial mon:stdio

Upon running this, if all went well you will be greeted with a prompt to login and then you have your virtual machine! The next task is to set up a bridged network adapter so other machines on my network can access this machine, as this is certainly much more useful if you can ssh into it.

This post seems to provide some insight into how to set up a TAP adapter to enable this functionality: https://gist.github.com/arvati/546617042fcf2669f330b739075c1c5d

Requirements Domain Name VPS/VM

Optional Requirements Password Manager

The first step is locating a VPS, according to Forbes the top 3 VPS services are IONOS, GoDaddy, and DreamHost. I selected to use IONOS for my project. I chose their cheapest tier, as my blog doesn't get a ton of traffic. If you wanted to use technology that is a little more agile, you could look into Azure or Amazon LightSail. Most of these folks can also sell you a domain name as well, if you need to purchase one of those.

Once you have purchased a VPS and a domain name, you will need to connect to it to configure it. DigitalOcean has a good write up on connecting to a machine via SSH. Tools like PuTTy can be used if you are on a Windows machine.

Once you have connected you will need to create a user account, and disable the root login. This Baeldung article goes into reasoning as to why this should be disabled. Additionally, IBM has a great article on how you can set up RSA keys. Once you have tested and confirmed you can login with your key with the following command:

ssh -i /path/to/private/key user@host

To disable password login you can check your /etc/ssh/sshd_config file, there should be a PasswordAuthentication in that file, or one of its dependencies, that is set to yes and it needs to be set to no.

These commands are for Ubuntu:

$ adduser [username] $ usermod -aG sudo [username] $ passwd username

Before running this command, confirm you can login with the new username and run sudo commands, as this command will lock your root account. However, you may want to hold off on this command until after you are finished configuring WriteFreely, as file permissions between root and your user account can create a headache with automation.

$ sudo passwd -l root

Then set up sql db, I largely used this DigitalOcean article.

$ sudo apt install mysql-server $ sudo systemctl start mysql.service

Then you can open mysql, and set a password for the root account. I recommend using a password manager to keep track of passwords, KeePass, Keeper, and 1Password are great options.Additionally, I would create a service user for WriteFreely to use.

CREATE USER 'writefreely'@'localhost' IDENTIFIED BY 'password'; GRANT CREATE, ALTER, DROP, INSERT, UPDATE, INDEX, DELETE, SELECT, REFERENCES, RELOAD on . TO 'writefreely'@'localhost' WITH GRANT OPTION; COMMIT;

To get Write Freely to run on start up you need to create a service file: nano /etc/system/system/writefreely.service

[Unit] Description=Write Freely Instance After=syslog.target network.target

[Service] Type=simple StandardOutput=syslog StandardError=syslog WorkingDirectory=/var/www/[your.domain]/writefreely ExecStart=/var/www/[your.domain]/writefreely/writefreely Restart=always

[Install] WantedBy=multi-user.target

Then run: sudo systemctl enable writefreely.service sudo systemctl start writefreely.service

If you reboot the VPS, WriteFreely should start after a few minutes. If it does not then you need to make sure root owns both the WriteFreely Binary, and config.ini. You can do this by using the chown command. Additionally you may need to use the chmod command on the WriteFreely binary in order to execute it.

At this point, you should have a working WriteFreely instance. Next time, we’ll explore some ways to use Ansible to automate the process, and some backup solutions for the data.

Thanks for reading!

A few months ago I started working on a PythonOCR python version of this. However, it was slow and more importantly, it was a pain to install on other machines. My primary motivation for writing this software is because I am in graduate school, and we often have long PDF files that we need to read. My eyes aren't what they used to be and sometimes it's nice to be able to change or bold the font, along with the usual benefit of making it bigger that you get with zooming in.

The goal was to create a means to scrape the text from PDF's so I could put them into a text editor and adjust the colors, fonts, etc to be easier to read. As mentioned, the python version of this was able to convert a wide variety of PDFs since it used OpenCV and Tesseract to extract the text from an image file that was created from a page in the pdf. As you can imagine this operation is expensive and it would take a few minutes to process a fairly large pdf. More importantly, I use a few different laptops for school depending on which one wants to cooperate on the given day, so this needed to be portable. The python version required installing python, poppler, and tesseract. You also had to set environment variables.

I began looking for a better portable solution. Initially I began to look into C or possibly C++ as options, primarily since Tesseract is mostly in C++, but then I came across Rust and it seemed interesting, so I began learning more. After reading ”The Book”, going through a few rounds of Rustlings, and banging my head on the wall at a Leptos/Actix app attempt, I decided to go back to this project. This seemed like a great candidate for Rust and for me to learn more, but I needed to find a GUI framework to facilitate my build. For this project I ended up using slint. Which was a fairly enjoyable experience for this simple app. I haven't yet had to worry about converting the pdf's to images or integrating Tesseract.

This currently uses the pdf-extract crate to handle extraction, and rusty file dialog to handle cross platform file prompts. It uses the std::fs crate to write to the file system. In my testing across various environments, it is cross platform, though more particular about pdfs that its python incarnation. It seems to like PDFs where text has been particularly defined, I have not had luck with PDFs which have text that is an unselectable, such as within an image (where OCR would provide benefit). I can use this for now, and if OCR is needed, add that later, or bring out the python version. This rust version takes about 10 seconds to process a 500 page pdf. The python version took considerably longer, though I don't remember exactly, and can add benchmarks later if I build it again.

This app is a GUI, so once you download, run cargo run and it should present you with a window with an Open file button. Once you click that, you can select a file, then it will process the file. Once it's done, you'll be prompted again to save the output.

Here's the repo:

https://github.com/beedawn/spaghetti-pdf

Thanks for reading, and happy new year.

Bee