.NET Core setup in Void

Here are the steps I did to get .NET core 8 setup on my Void Linux box.

$ wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
$ sudo ./dotnet-install.sh --channel 8.0$ 
$ sudo xbps-install vscode
$ sudo xbps-install nerd-fonts
$ sudo xbps-install font-emoji-one-color

$ dotnet new blazor -o BlazorApp
$ cd BlazorApp
$ dotnet watch

Now dotnet runs and the emojis render as expected:

Then  setup the prompt to be like Hanselmans post:

$ sudo xbps-install go
$ go install github.com/justjanne/powerline-go@latest

Then we install the Cascadia Font:

$ unzip CascadiaCode*.zip 
$ cd CasCadiaCode 
$ sudo mv *.ttf /usr/share/fonts/TTF/

Then modify the font settings in your terminal to use Cascadia and your prompt will look something like this :

Lessons in Rust: Part 1

I watched some videos today and here are some notes I took:

  • A function not ending in a semicolon being a expression versus a statement is odd.
  • A function having a return statement can end in semicolon and be an expression.
  • Stack is LIFO. Stack can only hold data of a fixed size. A double quoted string is fixed length. A String::from is dynamic length and stored on the Heap.
  • When a value is put in the Heap, the Heap is searched for space large enough to hold the element (out of order, versus the Stack always in LIFO order).
  • All Heap values have a ‘pointer’ value in the Stack.
  • When a variable is passed into a function the function takes ‘ownership’ of the variable. Three ways to ‘fix’ this issue:
    • Clone traight, potentially performance impacting.
    • Copy traight (which requires Clone traight). Copy is explicit and Clone is implicit (in the way its called .clone() versus not).
    • Use a READ_ONLY_REFERENCE of a variable using the “&” on the parameter name.
  • With variables to functions, the MUTABLE_REFERENCE can only be applied once, versus the READ_ONLY_REFERENCE which can have many.
  • Lifetimes
    • Begin with a single quote.
    • Are only relevant for references.
    • They dont change the lifetimes of the parameters.
    • They can be inferred

I found these videos interesting:

Getting Rusty

With the continued impressive industry reception and excitement around Rust,  I think it is time I jump and and see what all the hub·bub is about.

After watching a few starter videos, and reading documentation, here are some of my  initial thoughts:

  • Statically compilied versus interpreted (like my dear Python language.)
  • Performance is almost hard to believe compared to some other languages doing like processes.
  • Memory-safety and thread-safety design ground up sounds like a dream come true for those of us who have fought those demons.
  • Creates is to Rust what Pip is to Python.
  • A lot of people seem to have issues (or at least a hard time understanding) what Rust’s Borrowing is all about.
  • None over Null data type is interesting for a hard core C# developer.
  • The Crab logo is odd, as is the entire “cRUSTaceans” name used by those who adore Rust.
  • Linux kernel is going to have Rust support with v6.1. I never thought I would ever see anything but C in Linux kernel code.
  • Redox is an entire operation system written in Rust

I think the first thing I am going to try to tackle with Rust is media file processing for Roadie. Perhaps re-write Inspector in Rust.

Wish me luck getting Rusty!

Work Core Needs

These points are what I use to gauge how I feel about my job.

  1. I see motion towards making terrible things less terrible.
  2. I feel recognized, valued, and that my work has meaning.
  3. My direct report is not an overbearing micromanaging jerk.
  4. The work environment is not that of a sweatshop.
  5. My pay is accurate, timely, fair, and my benefits are beneficial to my family.

I have noticed that when the truthy points dip below 60%, I start wondering what I am doing and how I can make changes to get back to 80%.

Postgres on podman

Steps to getting PostgreSQL running on Endeavor via Podman.

Install Podman:

sudo pacman -S podman podman-docker

Create the PostgreSQL container:


sudo podman run -d --rm -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=dapassword -e PGDATA=/opt/pgdata --volume /opt/postgres:/opt/pgdata postgres

Copy the backup to the container:

sudo podman cp /home/steven/Downloads/kapowey.tar kapoweypg:/tmp/

Run bash on the container and create the database as the postgres user

sudo podman exec -it 396 /bin/bash
su - postgres
createdb kapowey

Restore the backup on the container:

sudo podman exec -i 396 pg_restore -U postgres -c -v -d kapowey "/tmp/kapowey.tar"

Setup user on database:

CREATE user kapowey with encrypted password 'dapassword';

ALTER database kapowey OWNER to kapowey;

GRANT CONNECT ON DATABASE kapowey TO kapowey;

GRANT all privileges on database kapowey to kapowey;

GRANT all privileges on all tables in schema public to kapowey;

running jellyfin via podman

Here are the quick and dirty step I do to update images, containers and run Jellyfin via Podman:

  • sudo podman ps # get container id
  • sudo podman stop #
  • sudo podman rm #
  • sudo podman images # get the image id
  • sudo podman rmi -f #
  • sudo podman run -d --cgroup-manager=systemd --volume /opt/jellyfin/config:/config --volume /opt/jellyfin/cache:/cache --volume /storage/videos/:/media --volume /storage/books:/books --volume /opt/zap2xml:/zap2xml --net=host --restart=unless-stopped --device /dev/dri/renderD128:/dev/dri/renderD128 --device /dev/dri/card0:/dev/dri/card0 jellyfin/jellyfin:unstable
  • sudo podman run -d --name zap2xml -v /opt/zap2xml:/data -e USERNAME=youremail@email.com -e PASSWORD=**password** -e OPT_ARGS="-I -D" -e XMLTV_FILENAME=xmltv.xml shuaiscott/zap2xml

 

GoAccess working with Centos 7

I use Nginx as a proxy for my dotnet core application and with that I wanted to get some reporting so I installed GoAccess, which generates a nice HTML report.

Set this up in your root crontab via a “crontab -e” as root:

0 * * * * /bin/bash /opt/generate_report.sh

~

Note the extra blank line, you will go crazy trying to get this to work if you don’t add the blank line at the end.

Then edit your generate_report.sh file like this:

#!/bin/sh
/usr/bin/zcat -f /var/log/nginx/*.log* | /usr/bin/goaccess --log-format=COMBINED -o /var/www/logreport.html -

Note the extra “-” at the end of the command line without it the cron execute does not work.

Enjoy!

CentOS First Steps

First security steps when setting up any new internet facing linux server:

  • Create a new user account
    • # adduser username
    • # passwd username
    • # usermod -aG wheel username
  • Send SSH key
    • scp id_rsa.pub username@hostname:/home/username/id_rsa.pub
    • $ mkdir ~/.ssh
    • $ cat id_rsa.pub >> ~/.ssh/authorized_keys
    • $ chmod 700 ~/.ssh
    • $ chmod 600 ~/.ssh/authorized_keys
  • Ensure SSH key authentication works
    • Disconnect and then reconnect, you should get prompted for your private key password not your server password (you did provide a password for your private key, right?!)
    • Do not disable “PasswordAuthentication” option below unless you are positive you are authentication SSH via keys – you will be locked out of your server and no longer able to SSH in.
  • Disable Root SSH, Set Protocol 2 and Password SSH
    • $ sudo yum install -y nano
    • $ sudo nano /etc/ssh/sshd_config
      • PermitRootLogin no
      • Protocol 2
      • PasswordAuthentication no
    • $ sudo service sshd restart
    • Ensure you can still SSH back into the box using your key only.
  • Update packages
    • $ sudo yum upgrade
  • Reboot
    • $ sudo reboot

Ramblings of an often confused opinionated yak shaver.