From 5cc7cb52b9205a89e1370b32c973580b1536558d Mon Sep 17 00:00:00 2001 From: davidovski Date: Fri, 21 Jul 2023 00:05:26 +0200 Subject: remove new.sh --- new.sh | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100755 new.sh diff --git a/new.sh b/new.sh deleted file mode 100755 index 3a05034..0000000 --- a/new.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -EDITOR=nvim -TEMPFILE=/tmp/blog_entry.md - -$EDITOR $TEMPFILE - -NAME=entries/$(head -1 $TEMPFILE | cut -d" " -f2-).html - -cp $TEMPFILE "$NAME" -rm $TEMPFILE - -chmod +x $NAME -- cgit v1.2.1 From ce018d219373b675fe1e63c323eaf06e65713f75 Mon Sep 17 00:00:00 2001 From: davidovski Date: Fri, 21 Jul 2023 11:05:15 +0200 Subject: move non-executables to site subdir --- entries/entries.sh | 5 - entries/git_compile.html | 15 -- entries/librex.html | 9 -- entries/pci_passthrough.html | 274 ------------------------------------ entries/ssh_forwarding.html | 94 ------------- entries/welcome.html | 11 -- images/bg.gif | 2 - images/bg.png | Bin 2416724 -> 0 bytes images/gif.py | 70 --------- images/remotecontrol-small.png | Bin 15993 -> 0 bytes images/remotecontrol.gif | 2 - images/remotecontrol.png | Bin 18514 -> 0 bytes index.html | 43 ------ mononoki.woff | Bin 42208 -> 0 bytes page.sh | 45 ------ rss.xml | 33 ----- site/entries/entries.sh | 5 + site/entries/git_compile.html | 15 ++ site/entries/librex.html | 9 ++ site/entries/pci_passthrough.html | 274 ++++++++++++++++++++++++++++++++++++ site/entries/ssh_forwarding.html | 94 +++++++++++++ site/entries/welcome.html | 11 ++ site/images/bg.gif | 2 + site/images/bg.png | Bin 0 -> 2416724 bytes site/images/gif.py | 70 +++++++++ site/images/remotecontrol-small.png | Bin 0 -> 15993 bytes site/images/remotecontrol.gif | 2 + site/images/remotecontrol.png | Bin 0 -> 18514 bytes site/index.html | 43 ++++++ site/mononoki.woff | Bin 0 -> 42208 bytes site/page.sh | 45 ++++++ site/rss.xml | 33 +++++ site/style.css | 160 +++++++++++++++++++++ style.css | 160 --------------------- 34 files changed, 763 insertions(+), 763 deletions(-) delete mode 100755 entries/entries.sh delete mode 100755 entries/git_compile.html delete mode 100755 entries/librex.html delete mode 100755 entries/pci_passthrough.html delete mode 100755 entries/ssh_forwarding.html delete mode 100755 entries/welcome.html delete mode 100755 images/bg.gif delete mode 100644 images/bg.png delete mode 100755 images/gif.py delete mode 100644 images/remotecontrol-small.png delete mode 100755 images/remotecontrol.gif delete mode 100644 images/remotecontrol.png delete mode 100755 index.html delete mode 100644 mononoki.woff delete mode 100755 page.sh delete mode 100755 rss.xml create mode 100755 site/entries/entries.sh create mode 100755 site/entries/git_compile.html create mode 100755 site/entries/librex.html create mode 100755 site/entries/pci_passthrough.html create mode 100755 site/entries/ssh_forwarding.html create mode 100755 site/entries/welcome.html create mode 100755 site/images/bg.gif create mode 100644 site/images/bg.png create mode 100755 site/images/gif.py create mode 100644 site/images/remotecontrol-small.png create mode 100755 site/images/remotecontrol.gif create mode 100644 site/images/remotecontrol.png create mode 100755 site/index.html create mode 100644 site/mononoki.woff create mode 100755 site/page.sh create mode 100755 site/rss.xml create mode 100644 site/style.css delete mode 100644 style.css diff --git a/entries/entries.sh b/entries/entries.sh deleted file mode 100755 index e85c454..0000000 --- a/entries/entries.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!../page.sh - -[ -z "$1" ] || { - md2html $1 -} diff --git a/entries/git_compile.html b/entries/git_compile.html deleted file mode 100755 index 48619f6..0000000 --- a/entries/git_compile.html +++ /dev/null @@ -1,15 +0,0 @@ -#!./entries.sh - -# Compiling files in a git repo - -So I decided to improve the way that that you can access some of the repos that I am hosting on this server, including the code that I use to compile the site itself. I quickly hacked together a bit of code in my existing [build.py](https://davidovski.xyz/git/davidovski/build.py.html) to clone a list of repos and go through and generate a html pages for each of the files in the repo. - -Although this means that this is only a static view of the repo at any time (needing me to rebuild the site for it to update) I can easily add any git repo to be built into my site, so as you may see, I have added a few repos from my github as well. - -I tried using cgit, but it just didn't provide exactly what I wanted and I wasn't in the mood to try configuring it to my liking, so I opted for this approach instead. - -A way that I can improve it is to serve a http server that dynamically updates the repositories when new commits are added, which would probably be a better solution; but this works.. for now. - -If you want to view all of the repos that I've listed so far, click the link at the top of the page. (sorry that the index is still the default nginx autoindex, I will change that at some point), and feel free to check out how I did it in [build.py](https://davidovski.xyz/git/davidovski/build.py.html), though Im warning you, its probably some of the hackiest code i've put together. - -Tutorial on how to host your own git repos on your server and allow people to clone them with https may be coming soon diff --git a/entries/librex.html b/entries/librex.html deleted file mode 100755 index c78c2cd..0000000 --- a/entries/librex.html +++ /dev/null @@ -1,9 +0,0 @@ -#!./entries.sh - -# LibreX - a metasearch engine - -My instance: [search.davidovski.xyz](https://search.davidovski.xyz/) - -For a while now I have been using [SearX](https://github.com/searx/searx) as my search engine, a meta search engine that cumulates search results from multiple different sites. While this is a great idea in theory, making the best of all search engines through one *privacy respecting* interface, in reality it ends up meaning that search results are quite slow. Couple this with the fact that most SearX instances are hosted by volunteers, and often have downtime, I was in the situation where I was hopping between various instances to try and find ones that worked. I always wanted to self host one myself, but the whole system seemed very bloated and complicated, and honestly I just couldn't be bothered to mess around with it. - -That's where [LibreX](https://github.com/hnhx/librex) comes in, a very small and simple meta search engine. Its still in development, but currently it has just enough functionality to actually be somewhat useful. Currently it only really supports google searches, but it still is a good layer for privacy, since all of your queries are anonymised, with google only seeing that they came from LibreX. I am curious to see how well it will handle larger amounts of search queries and if Google will limit them or something. If you want to support development, feel free to use it, find bugs and request features: [View the github repo](https://github.com/hnhx/librex) diff --git a/entries/pci_passthrough.html b/entries/pci_passthrough.html deleted file mode 100755 index 942c2b4..0000000 --- a/entries/pci_passthrough.html +++ /dev/null @@ -1,274 +0,0 @@ -#!./entries.sh - -# PCI passthrough with qemu - -QEMU is a powerful free and open source emulator which when paired with kvm can be used to create almost bare-metal performance virtual machines. In this guide I will be detailing some tips and tricks to configuring a setup on your linux system to allow a PCI device (typically a graphics card) to be passed through to a virtual machine. - -Countless guides already exist on this topic but they all rely on using virt-manager and other Redhat software, which, depending on your use case, may be completely overkill. This guide assumes that you will not be using the target GPU as a video output on your host machine from boot, so will only work in configurations where you are able to remote connect or where you have **multiple graphics cards**. However the process is mostly similar for single GPU passthrough, with extra steps if you want to bind and unbind display drivers from the host. - -This is a generic guide written to support any semi-standard Linux distributions, so adapt any instructions as you see fit to your current system. - -If you do not trust this guide or need any clarification, feel free to follow steps from other guides, or just skip to the tips at the bottom of this guide. - - -## Prerequisites - -Make sure that your motherboard is: -- supports hardware virtualisation -- supports IOMMU - -These options can be enabled within the motherboard's BIOS settings usually. - -You may also want a spare monitor or a monitor with multiple inputs so that you can switch between GPU outputs. - -Once you have enabled IOMMU, you will need to ensure that your PCI slot can actually be passed through. This is only possible if the GPU appears in its own single IOMMU group, with no other devices in that group. - -To list IOMMU groups, you may use this script from the [archwiki](https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#Ensuring_that_the_groups_are_valid) - - #!/bin/bash - shopt -s nullglob - for g in $(find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V); do - echo "IOMMU Group ${g##*/}:" - for d in $g/devices/*; do - echo -e "\t$(lspci -nns ${d##*/})" - done; - done; - -If you see that there PCI devices other than ones that correspond to your graphics card, then try using a different PCI slot. Unfortunately some motherboards don't have any isolated PCI slots, in this case you are out of luck; PCI passthrough will not be possible in this method. - - -## Setting up VFIO - -The core principle behind PCI passthrough is that you don't want the kernel from having any control over the device in the PCI slot. To do this, we tell the kernel to bind a *dummy driver* to the gpu so that when we want to pass it through to the VM, it is not in use. - -To do this, you want to find out the Device IDs of your PCI device, you can do this using the following command: - - lspci -nn - -Make sure take notes of all of the devices that appeared within the isolated IOMMU group from the previous stage. If you miss out any PCI devices, this will not work. IDs often look like this: `10de:13c2` - -Next add the following to your kernel's cmdline arguments. This can usually be found somewhere in your bootloaders settings, for example for GRUB, you can add it to `GRUB_CMDLINE_LINUX_DEFAULT=""` in `/etc/default/grub` - - vfio-pci.ids=*id1*,*id2* - -where *id1* and *id2* represent the ids that you collected in the previous step. - -Next you need to tell your initramfs (if applicable) to load the vfio modules. This is done to make sure that the vfio module is loaded and assigned to these pci devices *before* your video drivers. The process of doing this depends on your initramfs system: - -### Dracut - -in `/etc/dracut.conf.d/10-vfio.conf` - - force_drivers+=" vfio_pci vfio vfio_iommu_type1 vfio_virqfd " - -then rebuild your initramfs - - -### mkinitpcio - -in `/etc/mkinitcpio.conf` - - MODULES=(... vfio_pci vfio vfio_iommu_type1 vfio_virqfd ...) - -then rebuild your initramfs - -### booster - -in `/etc/booster.yaml` - - modules_force_load: vfio_pci,vfio,vfio_iommu_type1,vfio_virqfd - -then rebuild your initramfs - -## QEMU arguments and set-up - -In this guide I will be using qemu from the command line. I feel as if this is the easiest way to create virtual machines without any overhead, but you can use libvirt if you wish. - -Here is a script that use a to run a linux virtual machine, if you want to copy it blindly and not understand it, then thats alright, but I will include a description for each argument and why its used. - - #!/bin/sh - - ISO="/path/to/your/installer/iso" - ROOT="/path/to/your/virtual/disk" - OVMF_VARS="/path/to/your/ovmf/vars/image" - - - qemu-system-x86_64 \ - -enable-kvm \ - -m 8G \ - -smp 2 \ - -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF.fd \ - -drive if=pflash,format=raw,file="$OVMF_VARS" \ - -drive if=virtio,file="$ROOT",format=qcow2 \ - -vga none \ - -nographic \ - -monitor stdio \ - -serial none \ - -device vfio-pci,host="06:00.0" \ - -device vfio-pci,host="06:00.1" \ - -device vfio-pci,host="06:00.2" \ - -device vfio-pci,host="06:00.3" \ - -net nic,model=virtio -net user \ - -device ich9-intel-hda,addr=0x1b \ - -device hda-micro,audiodev=hda \ - -device ich9-intel-hda,addr=0x1b \ - -device hda-micro,audiodev=hda \ - -audiodev pa,id=hda,server=unix:$(pactl info | sed -rn 's/Server String: (.*)/\1/p') - -### Basic Parameters - - -enable-kvm - -This enables [KVM](https://www.linux-kvm.org/page/Main_Page) which improves performance and allows for *almost bare-metal* CPU performance. - - -m 8G - -Allocate 8 Gigabytes of memory to the virtual machine - - -smp 2 - -Allocate 2 CPU cores to the virtual machine - -### OVMF firmware - - -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF.fd \ - -drive if=pflash,format=raw,file="$OVMF_VARS" \ - -Most PCI cards require UEFI firmware to function properly. For this reason we will be using the OVMF firmware. You may need to install this on your system, typically the package is called ovmf, edk2-ovmf or something similar. Learn to use your package manager's search functionality to find it. - -Make a copy of the OVMF variables file, typically located at `/usr/share/OVMF/OVMF_VARS.fd` and place it somewhere with the rest of your virtual machine's files. You should keep these separate and unique for each virtual machine you wish to create. - -In my example script, make sure you replace `/path/to/your/ovmf/vars/image` to the path to your copy of `OVMF_VARS.fd` - -### Storage - - -drive if=virtio,file="$ROOT",format=qcow2 \ - -Next you need to create a virtual disk for your virtual machine. You can create this using the following command, replacing `32G` with the desired size of this disk. - - qemu-img create -f qcow2 myVirtualDisk.qcow2 32G - -In this example I use `if=virtio,` which provides better performance than the default drive type, however this will only work with linux guests which have the virtio module. **Remove this if you are using windows in your virtual machine** - -For your first boot, you may want to add the following before your primary virtual disk: - - -drive file="$ISO",media=cdrom - -Ensure that you have set the `ISO` and `ROOT` variables appropriately with the paths to the corresponding images. - -### Disabling virtual video output - -This next step is to ensure that qemu doesn't create a virtual VGA output for your virtual machine, nor opens a window, allowing this to be run from outside an X11 session - - -vga none - -nographic - -monitor stdio - -serial none - -### VFIO passthrough - -Next you need to find the pci ids for your device. Make sure you include all the relevant ones in your IOMMU group: - - -device vfio-pci,host="06:00.0" \ - -device vfio-pci,host="06:00.1" \ - -device vfio-pci,host="06:00.2" \ - -device vfio-pci,host="06:00.3" \ - -In this example, my PCI ids start with `06:00`, **make sure you change this for your setup.** - -### Network - -Next you want network for your virtual machine: - - -net nic,model=virtio -net user - -I use the virtio network card, which only works for Linux guests. **If you have a windows guest, do not include this line** this will use the default network card for qemu. - -### Audio - - -device ich9-intel-hda,addr=0x1b \ - -device hda-micro,audiodev=hda \ - -audiodev pa,id=hda,server=unix:$(pactl info | sed -rn 's/Server String: (.*)/\1/p') \ - -This creates a audio device for the virtual machine which connects to the currently running pulseaudio session of your client. - -You can omit this section if you wish to output audio through your PCI device. - -## Other tips and tricks - -### evdev mouse and keyboard passthrough - -Out of all of the methods of passthrough a keyboard and mouse, evdev is probably one of the best and most easiest. - -First you need to identify the input devices that linux creates for your keyboard and mouse. You can list them all using: - - ls /dev/input/by-id/ - -Identify the devices that you want to passthrough and find the ones containing `-event`. - -Then add the follow for each one as an argument to your qemu command. - - -object input-linux,id=*UNIQUE_ID*,evdev=/dev/input/by-id/*YOUR-DEVICE*,grab_all=on,repeat=on - -Then when your virtual machine is running, you will be able to switch to and from the host's control by pressing both left and right ctrl keys at the same time on your keyboard. - -### Running as an ordinary user - -To do this, I would recommend creating a group named `kvm` and adding your user to it. - - groupadd kvm - - usermod -a -G kvm *username* - -Next you will want to ensure that vfio devices have the correct permissions for the kvm group to use. In `/etc/udev/rules.d/10-vfio.rules`: - - SUBSYSTEM=="vfio", GROUP="kvm" - -Next you will probably want to increase memory limits for users of the kvm group, to allow them to allocate potentially GB for the virtual machine. To make things easier, you might want to just set this to the maximum number of megabytes available in the system. You can find this out using `free`, for example for a system with 8GB ram, its: `8100452` - -In `/etc/security/limits.d/99-memlock.conf` write: - - @kvm hard memlock 8100452 - @kvm soft memlock 8100452 - -You may need to reboot for these changes to take effect, especially ones relating to udev rules. - -### Using ddcutil to switch between monitor inputs - -Most monitors, other than laptop displays, have a Virtual Control Panel which can be controlled through i2c as per the Display Data Channel/ Command Interface Standard... DDC/CI - -Setting up ddcutil to work on your monitor will depend on a case to case basis depending on your monitor and video card. - -Depending on your monitor, you may need to enable DDC/CI in its settings. - -Make sure you have installed ddcutil and i2c-dev, again exact package names may vary. - -To detect the montors available, use `ddcutil detect`. If this doesn't work, ensure that the i2c-dev module is loaded. - -To enable the i2c module on load, you may need to add the following to `/etc/modules-load.d/i2c-dev.conf` - - i2c-dev - -To allow users of the i2c group to control i2c devices add the following to `/etc/udev/rules.d/10-i2c-group.rules`. Make sure you create this group and add your user to it. - - KERNEL=="i2c-[0-9]*", GROUP="i2c" - -Find out the Display number of your monitor using `ddcutil detect` -Next find the available inputs on this monitor: - - ddcutil -d $display_number capabilities - -Here you should be able to see `Feature: 60 (input source)`. Take note of hexadecimal values. - -You will be able to switch monitors using: - - ddcutil -d $display_number setvcp 60 0x$monitor_input_hex_value - -I have this bound to a hotkey using `sxhkd` so I can easily switch between inputs without having to reach over to buttons on my monitor.However you can configure this whichever way you want: for example, you can switch to the display output of your passthrough GPU when the virtual machine starts, and back when it shuts down. - -## Conclusion - -Hopefully, this guide has helped you set up a virtual machine with PCI passthrough. All thats left now is to install the software you want in your virtual machine and have fun. - -If there is anything that isn't clear in this guide, please contact me, or look at other guides if you need any help. The archwiki is a pretty good place to look if you are, *or aren't* using archlinux. - diff --git a/entries/ssh_forwarding.html b/entries/ssh_forwarding.html deleted file mode 100755 index d068f54..0000000 --- a/entries/ssh_forwarding.html +++ /dev/null @@ -1,94 +0,0 @@ -#!./entries.sh - -# Permanent SSH Forwarding (Tutorial) - -Take this situation: you have a cheap (or even free), low-powered remote server and a considerably better homeserver with more storage and power. For certain services that require more power, you'd obviously want to run them on that homeserver. - -However, what if you don't want to, *or can't*, directly open ports onto your home network, or you if you simply want to keep all of your site to one IP? This is where SSH port forwarding comes in handy: using ssh to forward the open port from a service from your local server to the remote one, where it can be exposed to the rest of the internet. - -## SSH Remote Port Forwarding - -SSH remote port forwarding is built right into ssh itself, and is quite simple: - -``` -ssh -R 5505:localhost:4404 user@remote.host -``` - -When this command is run on the local server, it will: -+ create an ssh connection to the remote server, as per usual -+ open the port 5505 on the remote server, -+ all traffic on this port will be forwarded to port 4404 on the local server. - -This command by itself is already everything you'd need to forward most ports easily to your remote server, of course, remember to open the port on your remote server's firewall, if applicable. - -However to ensure that that port is exposed properly on the remote server, you'd want to make sure that it is listening to all external traffic. - -You can fix this by setting `GatewayPorts yes` in `/etc/ssh/sshd_config` on the remote server. (don't forget to restart sshd after editing the config) - -## Persistent ssh forwarding - -The above is all well and good, but you'd need to keep an interactive ssh connection up at all times, so the above isn't the most ideal solution. - -To get around this, you can create a service to run on the local server to forward requested ports from the remote server. - -To begin, I'd recommend creating two users, one on each server. For sake of example, lets all them `bridge`. I'd recommend to avoid giving these users passwords, that way they can only be accessed through key based authentication. Of course you will still be able to log into them as root using `su - bridge` - -Next you should create an ssh keypair on the local server (`ssh-keygen`) and place the contents of your public key into `.ssh/authorized_keys` on the remote. This will make sure only the local server can ssh into the remote using that key. - -Then, create a script for your ssh port forwarding. I placed mine directly in the home folder on my local server, though it only matters that the bridge user can execute it. In your script you *must* use the `-nT` flag on your ssh command. These will allow you to run this script as a service, by preventing a virtual terminal being allocated. (read `man ssh` for more info) - -Here is my example of a script that you could use: - - #!/bin/sh - - PORTS="8080 25565" - DEST="bridge@remote.host" - SSH_PORT="22" - IDENTITY_FILE="~/.ssh" - - /usr/bin/ssh -nNT $(echo $PORTS | awk -v host=$LOCALHOST '{for (i = 1; i <= NF; i++){ printf "-R %d:%s:%d ",$i,host,$i}}') -p $SSH_PORT -i $IDENTITY_FILE $DEST - -Next you'd want to run this script as a service. Check your distro's service system how to do this if you have any trouble. - -### Systemd service - -Say that the script you made was `/home/bridge/tunnel.sh`, you should create a user service with systemd for the bridge user. - -To do this create the following file in `/home/bridge/.config/systemd/user/tunnel.service`: - - [Unit] - Description=SSH tunnel - - [Service] - ExecStart=/home/bridge/tunnel.sh - RestartSec=5 - Restart=always - KillMode=mixed - - [Install] - WantedBy=default.target - -Then enable and start the service with: `systemd --user enable tunnel.service` and `system --user start tunnel.service`. Ensure that it is running with `systemd --user status tunnel` - -## Forwarding ports smaller than 1024 - -As you may know, TCP/IP port numbers below 1024 are special in that normal users are not able to open, and hence forward from on the remote server. - -One solution to this is run a server on the remote that will proxy requests from port 80 to a different port (say port 8080). - -This can be achieved using `socat`. - -Say you forwarded traffic from port 8080 on remote to port 80 on local, you could then, on the remote server, run `sudo socat TCP-LISTEN:80,fork TCP:localhost:8080` to listen to traffic on port 80 and forward it to 8080, which will forward back to the local server. - -Here is an example of this in practice, forwarding port 80 and 443, by forwarding ports 8080 and 8443: - - /usr/bin/ssh -nT -R 8443:localhost:443 -R 8080:localhost:80 -i $IDENTITY_FILE -p $SSH_PORT $DEST "(sudo socat TCP-LISTEN:80,fork TCP:localhost:8080) & sudo socat TCP-LISTEN:443,fork TCP:localhost:8443" - -However this command assumes that the remote user has access to sudo with **NO PASSWORD**. Alternatively you could create a similar service (this time as a system service) on the remote server running the socat commands. - -## Video Tutorial - -Here is an example of how you can use this to host a webserver (or any other service) from anywhere: even a hotel room. - - -Credit: DenshiVideo diff --git a/entries/welcome.html b/entries/welcome.html deleted file mode 100755 index 5d34602..0000000 --- a/entries/welcome.html +++ /dev/null @@ -1,11 +0,0 @@ -#!./entries.sh - -# welcome - -welcome. i decided to turn this webpage into blog-style site... i havent got a topic or anything, so expect either: quality tutorials and very interesting techy things; or just random shitposts or rambles about things. - -originally i was going to make this blog on [b.davidovski.xyz](https://b.davidovski.xyz) using [nanoblogger](http://nanoblogger.sourceforge.net/) (you might be able to still see the start of that) but nb itself seemed quite dead, and i couldn't really be asked to customise it all myself. So i made my own script to generate this static site: [kblg](https://github.com/davidovski/kblg/). Right now its probably just the bare minimum needed for this, but I am planning to add more things to it as I go along (including rss, if anyone would be interested?) - -anyway thats all for now, cya - -~davidovski diff --git a/images/bg.gif b/images/bg.gif deleted file mode 100755 index 044324f..0000000 --- a/images/bg.gif +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./gif.py diff --git a/images/bg.png b/images/bg.png deleted file mode 100644 index d08f9ed..0000000 Binary files a/images/bg.png and /dev/null differ diff --git a/images/gif.py b/images/gif.py deleted file mode 100755 index 26e8408..0000000 --- a/images/gif.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python -import glob -import sys -import os -import math -import random -from PIL import Image - - -def color(hex_value): - h = hex_value.lstrip('#') - while len(h) < 8: - h += "f" - return tuple(int(h[i:i+2], 16) for i in (0, 2, 4, 6)) - -def rgb_to_v(c): - r, g, b = c[0]/255.0, c[1]/255.0, c[2]/255.0 - mx = max(r, g, b) - v = mx*100 - return v - -replace = color("#f58f44") -colors = [ - color("#191919"), - color("#373b41"), - ] - -def make(colors, inp=None): - p = len(colors) - w = int(128 / p) * p - h = int(128 / p) * p - - frames = [] - - for i in range(int(p*1*math.pi)): - if inp is None: - image = Image.new("RGBA", (w, h), colors[0]) - else: - image = Image.open(inp).convert("RGBA") - - for x in range(image.width): - for y in range(image.height): - f = 2 - r = random.randint(-f, f) - z = (i) - (y/(p/4)) + r - v = math.floor( (math.sin(z) + 1) * len(colors) * 0.5) - c = colors[v] - if inp is not None: - existing = image.getpixel((x, y)) - if existing[:3] == replace[:3]: - image.putpixel((x,y), c) - else: - image.putpixel((x,y), c) - - frames.append(image.convert("P")) - - - frames[0].save(sys.stdout, mode="P", format="GIF", append_images=frames[1:], save_all=True, duration=100, loop=0) - - -template = None -if len(sys.argv) > 1 and os.path.exists(sys.argv[1]): - template = sys.argv[1] - colors = colors + [ color("#f58f44") ] - -sorted(colors, key=rgb_to_v) -make(colors, inp=template) -#make("dist/images/remotecontrol.gif", colors2, inp="images/remotecontrol-small.png") - - diff --git a/images/remotecontrol-small.png b/images/remotecontrol-small.png deleted file mode 100644 index fc293d0..0000000 Binary files a/images/remotecontrol-small.png and /dev/null differ diff --git a/images/remotecontrol.gif b/images/remotecontrol.gif deleted file mode 100755 index 5e73b92..0000000 --- a/images/remotecontrol.gif +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -./gif.py remotecontrol-small.png diff --git a/images/remotecontrol.png b/images/remotecontrol.png deleted file mode 100644 index 62d6473..0000000 Binary files a/images/remotecontrol.png and /dev/null differ diff --git a/index.html b/index.html deleted file mode 100755 index 080a484..0000000 --- a/index.html +++ /dev/null @@ -1,43 +0,0 @@ -#!./page.sh - -cat << EOF -
-
- -

Hi, I'm david and this is my website.

- -

if you want to contact me, you can message me on matrix @ix:davidovski.xyz.

-
- -
- -
-
- -EOF - -cat << EOF -
-

blog posts

- -
    -EOF -# list all the files in the directory -for file in entries/*.html; do - title="$(grep '^# ' $file)" - title=${title#\# } - - printf " -
  • - -
    %s
    - %s -
    -
  • -" "${file%.*}.html" "$(stat -c %z "$file")" "$title" - done - -cat << EOF -
-
-EOF diff --git a/mononoki.woff b/mononoki.woff deleted file mode 100644 index 939ec2a..0000000 Binary files a/mononoki.woff and /dev/null differ diff --git a/page.sh b/page.sh deleted file mode 100755 index 69db1fb..0000000 --- a/page.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# set a variable to avoid this template being repeated indefinitely - -cat << EOF - - - - - - - davidovski.xyz - - -
-
- davidovski.xyz -
- -
-
- -EOF - -[ -z "$1" ] || /bin/sh $* - -cat << EOF -
- - - -EOF diff --git a/rss.xml b/rss.xml deleted file mode 100755 index d2ec426..0000000 --- a/rss.xml +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -cat << EOF - - - - - davidovski - https://davidovski.xyz - davidovski's site -EOF - -for entry in entries/*.html; do - title="$(grep '^# ' $entry)" - title=${title#\# } - - printf "\n" - printf "%s\n" "${title}" - printf "%s\n" "http://davidovski.xyz/$entry" - printf "%s\n" "$(stat -c %z "$entry")" - - - printf "\n" - - done - - -cat << EOF - - -EOF diff --git a/site/entries/entries.sh b/site/entries/entries.sh new file mode 100755 index 0000000..e85c454 --- /dev/null +++ b/site/entries/entries.sh @@ -0,0 +1,5 @@ +#!../page.sh + +[ -z "$1" ] || { + md2html $1 +} diff --git a/site/entries/git_compile.html b/site/entries/git_compile.html new file mode 100755 index 0000000..48619f6 --- /dev/null +++ b/site/entries/git_compile.html @@ -0,0 +1,15 @@ +#!./entries.sh + +# Compiling files in a git repo + +So I decided to improve the way that that you can access some of the repos that I am hosting on this server, including the code that I use to compile the site itself. I quickly hacked together a bit of code in my existing [build.py](https://davidovski.xyz/git/davidovski/build.py.html) to clone a list of repos and go through and generate a html pages for each of the files in the repo. + +Although this means that this is only a static view of the repo at any time (needing me to rebuild the site for it to update) I can easily add any git repo to be built into my site, so as you may see, I have added a few repos from my github as well. + +I tried using cgit, but it just didn't provide exactly what I wanted and I wasn't in the mood to try configuring it to my liking, so I opted for this approach instead. + +A way that I can improve it is to serve a http server that dynamically updates the repositories when new commits are added, which would probably be a better solution; but this works.. for now. + +If you want to view all of the repos that I've listed so far, click the link at the top of the page. (sorry that the index is still the default nginx autoindex, I will change that at some point), and feel free to check out how I did it in [build.py](https://davidovski.xyz/git/davidovski/build.py.html), though Im warning you, its probably some of the hackiest code i've put together. + +Tutorial on how to host your own git repos on your server and allow people to clone them with https may be coming soon diff --git a/site/entries/librex.html b/site/entries/librex.html new file mode 100755 index 0000000..c78c2cd --- /dev/null +++ b/site/entries/librex.html @@ -0,0 +1,9 @@ +#!./entries.sh + +# LibreX - a metasearch engine + +My instance: [search.davidovski.xyz](https://search.davidovski.xyz/) + +For a while now I have been using [SearX](https://github.com/searx/searx) as my search engine, a meta search engine that cumulates search results from multiple different sites. While this is a great idea in theory, making the best of all search engines through one *privacy respecting* interface, in reality it ends up meaning that search results are quite slow. Couple this with the fact that most SearX instances are hosted by volunteers, and often have downtime, I was in the situation where I was hopping between various instances to try and find ones that worked. I always wanted to self host one myself, but the whole system seemed very bloated and complicated, and honestly I just couldn't be bothered to mess around with it. + +That's where [LibreX](https://github.com/hnhx/librex) comes in, a very small and simple meta search engine. Its still in development, but currently it has just enough functionality to actually be somewhat useful. Currently it only really supports google searches, but it still is a good layer for privacy, since all of your queries are anonymised, with google only seeing that they came from LibreX. I am curious to see how well it will handle larger amounts of search queries and if Google will limit them or something. If you want to support development, feel free to use it, find bugs and request features: [View the github repo](https://github.com/hnhx/librex) diff --git a/site/entries/pci_passthrough.html b/site/entries/pci_passthrough.html new file mode 100755 index 0000000..942c2b4 --- /dev/null +++ b/site/entries/pci_passthrough.html @@ -0,0 +1,274 @@ +#!./entries.sh + +# PCI passthrough with qemu + +QEMU is a powerful free and open source emulator which when paired with kvm can be used to create almost bare-metal performance virtual machines. In this guide I will be detailing some tips and tricks to configuring a setup on your linux system to allow a PCI device (typically a graphics card) to be passed through to a virtual machine. + +Countless guides already exist on this topic but they all rely on using virt-manager and other Redhat software, which, depending on your use case, may be completely overkill. This guide assumes that you will not be using the target GPU as a video output on your host machine from boot, so will only work in configurations where you are able to remote connect or where you have **multiple graphics cards**. However the process is mostly similar for single GPU passthrough, with extra steps if you want to bind and unbind display drivers from the host. + +This is a generic guide written to support any semi-standard Linux distributions, so adapt any instructions as you see fit to your current system. + +If you do not trust this guide or need any clarification, feel free to follow steps from other guides, or just skip to the tips at the bottom of this guide. + + +## Prerequisites + +Make sure that your motherboard is: +- supports hardware virtualisation +- supports IOMMU + +These options can be enabled within the motherboard's BIOS settings usually. + +You may also want a spare monitor or a monitor with multiple inputs so that you can switch between GPU outputs. + +Once you have enabled IOMMU, you will need to ensure that your PCI slot can actually be passed through. This is only possible if the GPU appears in its own single IOMMU group, with no other devices in that group. + +To list IOMMU groups, you may use this script from the [archwiki](https://wiki.archlinux.org/title/PCI_passthrough_via_OVMF#Ensuring_that_the_groups_are_valid) + + #!/bin/bash + shopt -s nullglob + for g in $(find /sys/kernel/iommu_groups/* -maxdepth 0 -type d | sort -V); do + echo "IOMMU Group ${g##*/}:" + for d in $g/devices/*; do + echo -e "\t$(lspci -nns ${d##*/})" + done; + done; + +If you see that there PCI devices other than ones that correspond to your graphics card, then try using a different PCI slot. Unfortunately some motherboards don't have any isolated PCI slots, in this case you are out of luck; PCI passthrough will not be possible in this method. + + +## Setting up VFIO + +The core principle behind PCI passthrough is that you don't want the kernel from having any control over the device in the PCI slot. To do this, we tell the kernel to bind a *dummy driver* to the gpu so that when we want to pass it through to the VM, it is not in use. + +To do this, you want to find out the Device IDs of your PCI device, you can do this using the following command: + + lspci -nn + +Make sure take notes of all of the devices that appeared within the isolated IOMMU group from the previous stage. If you miss out any PCI devices, this will not work. IDs often look like this: `10de:13c2` + +Next add the following to your kernel's cmdline arguments. This can usually be found somewhere in your bootloaders settings, for example for GRUB, you can add it to `GRUB_CMDLINE_LINUX_DEFAULT=""` in `/etc/default/grub` + + vfio-pci.ids=*id1*,*id2* + +where *id1* and *id2* represent the ids that you collected in the previous step. + +Next you need to tell your initramfs (if applicable) to load the vfio modules. This is done to make sure that the vfio module is loaded and assigned to these pci devices *before* your video drivers. The process of doing this depends on your initramfs system: + +### Dracut + +in `/etc/dracut.conf.d/10-vfio.conf` + + force_drivers+=" vfio_pci vfio vfio_iommu_type1 vfio_virqfd " + +then rebuild your initramfs + + +### mkinitpcio + +in `/etc/mkinitcpio.conf` + + MODULES=(... vfio_pci vfio vfio_iommu_type1 vfio_virqfd ...) + +then rebuild your initramfs + +### booster + +in `/etc/booster.yaml` + + modules_force_load: vfio_pci,vfio,vfio_iommu_type1,vfio_virqfd + +then rebuild your initramfs + +## QEMU arguments and set-up + +In this guide I will be using qemu from the command line. I feel as if this is the easiest way to create virtual machines without any overhead, but you can use libvirt if you wish. + +Here is a script that use a to run a linux virtual machine, if you want to copy it blindly and not understand it, then thats alright, but I will include a description for each argument and why its used. + + #!/bin/sh + + ISO="/path/to/your/installer/iso" + ROOT="/path/to/your/virtual/disk" + OVMF_VARS="/path/to/your/ovmf/vars/image" + + + qemu-system-x86_64 \ + -enable-kvm \ + -m 8G \ + -smp 2 \ + -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF.fd \ + -drive if=pflash,format=raw,file="$OVMF_VARS" \ + -drive if=virtio,file="$ROOT",format=qcow2 \ + -vga none \ + -nographic \ + -monitor stdio \ + -serial none \ + -device vfio-pci,host="06:00.0" \ + -device vfio-pci,host="06:00.1" \ + -device vfio-pci,host="06:00.2" \ + -device vfio-pci,host="06:00.3" \ + -net nic,model=virtio -net user \ + -device ich9-intel-hda,addr=0x1b \ + -device hda-micro,audiodev=hda \ + -device ich9-intel-hda,addr=0x1b \ + -device hda-micro,audiodev=hda \ + -audiodev pa,id=hda,server=unix:$(pactl info | sed -rn 's/Server String: (.*)/\1/p') + +### Basic Parameters + + -enable-kvm + +This enables [KVM](https://www.linux-kvm.org/page/Main_Page) which improves performance and allows for *almost bare-metal* CPU performance. + + -m 8G + +Allocate 8 Gigabytes of memory to the virtual machine + + -smp 2 + +Allocate 2 CPU cores to the virtual machine + +### OVMF firmware + + -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF.fd \ + -drive if=pflash,format=raw,file="$OVMF_VARS" \ + +Most PCI cards require UEFI firmware to function properly. For this reason we will be using the OVMF firmware. You may need to install this on your system, typically the package is called ovmf, edk2-ovmf or something similar. Learn to use your package manager's search functionality to find it. + +Make a copy of the OVMF variables file, typically located at `/usr/share/OVMF/OVMF_VARS.fd` and place it somewhere with the rest of your virtual machine's files. You should keep these separate and unique for each virtual machine you wish to create. + +In my example script, make sure you replace `/path/to/your/ovmf/vars/image` to the path to your copy of `OVMF_VARS.fd` + +### Storage + + -drive if=virtio,file="$ROOT",format=qcow2 \ + +Next you need to create a virtual disk for your virtual machine. You can create this using the following command, replacing `32G` with the desired size of this disk. + + qemu-img create -f qcow2 myVirtualDisk.qcow2 32G + +In this example I use `if=virtio,` which provides better performance than the default drive type, however this will only work with linux guests which have the virtio module. **Remove this if you are using windows in your virtual machine** + +For your first boot, you may want to add the following before your primary virtual disk: + + -drive file="$ISO",media=cdrom + +Ensure that you have set the `ISO` and `ROOT` variables appropriately with the paths to the corresponding images. + +### Disabling virtual video output + +This next step is to ensure that qemu doesn't create a virtual VGA output for your virtual machine, nor opens a window, allowing this to be run from outside an X11 session + + -vga none + -nographic + -monitor stdio + -serial none + +### VFIO passthrough + +Next you need to find the pci ids for your device. Make sure you include all the relevant ones in your IOMMU group: + + -device vfio-pci,host="06:00.0" \ + -device vfio-pci,host="06:00.1" \ + -device vfio-pci,host="06:00.2" \ + -device vfio-pci,host="06:00.3" \ + +In this example, my PCI ids start with `06:00`, **make sure you change this for your setup.** + +### Network + +Next you want network for your virtual machine: + + -net nic,model=virtio -net user + +I use the virtio network card, which only works for Linux guests. **If you have a windows guest, do not include this line** this will use the default network card for qemu. + +### Audio + + -device ich9-intel-hda,addr=0x1b \ + -device hda-micro,audiodev=hda \ + -audiodev pa,id=hda,server=unix:$(pactl info | sed -rn 's/Server String: (.*)/\1/p') \ + +This creates a audio device for the virtual machine which connects to the currently running pulseaudio session of your client. + +You can omit this section if you wish to output audio through your PCI device. + +## Other tips and tricks + +### evdev mouse and keyboard passthrough + +Out of all of the methods of passthrough a keyboard and mouse, evdev is probably one of the best and most easiest. + +First you need to identify the input devices that linux creates for your keyboard and mouse. You can list them all using: + + ls /dev/input/by-id/ + +Identify the devices that you want to passthrough and find the ones containing `-event`. + +Then add the follow for each one as an argument to your qemu command. + + -object input-linux,id=*UNIQUE_ID*,evdev=/dev/input/by-id/*YOUR-DEVICE*,grab_all=on,repeat=on + +Then when your virtual machine is running, you will be able to switch to and from the host's control by pressing both left and right ctrl keys at the same time on your keyboard. + +### Running as an ordinary user + +To do this, I would recommend creating a group named `kvm` and adding your user to it. + + groupadd kvm + + usermod -a -G kvm *username* + +Next you will want to ensure that vfio devices have the correct permissions for the kvm group to use. In `/etc/udev/rules.d/10-vfio.rules`: + + SUBSYSTEM=="vfio", GROUP="kvm" + +Next you will probably want to increase memory limits for users of the kvm group, to allow them to allocate potentially GB for the virtual machine. To make things easier, you might want to just set this to the maximum number of megabytes available in the system. You can find this out using `free`, for example for a system with 8GB ram, its: `8100452` + +In `/etc/security/limits.d/99-memlock.conf` write: + + @kvm hard memlock 8100452 + @kvm soft memlock 8100452 + +You may need to reboot for these changes to take effect, especially ones relating to udev rules. + +### Using ddcutil to switch between monitor inputs + +Most monitors, other than laptop displays, have a Virtual Control Panel which can be controlled through i2c as per the Display Data Channel/ Command Interface Standard... DDC/CI + +Setting up ddcutil to work on your monitor will depend on a case to case basis depending on your monitor and video card. + +Depending on your monitor, you may need to enable DDC/CI in its settings. + +Make sure you have installed ddcutil and i2c-dev, again exact package names may vary. + +To detect the montors available, use `ddcutil detect`. If this doesn't work, ensure that the i2c-dev module is loaded. + +To enable the i2c module on load, you may need to add the following to `/etc/modules-load.d/i2c-dev.conf` + + i2c-dev + +To allow users of the i2c group to control i2c devices add the following to `/etc/udev/rules.d/10-i2c-group.rules`. Make sure you create this group and add your user to it. + + KERNEL=="i2c-[0-9]*", GROUP="i2c" + +Find out the Display number of your monitor using `ddcutil detect` +Next find the available inputs on this monitor: + + ddcutil -d $display_number capabilities + +Here you should be able to see `Feature: 60 (input source)`. Take note of hexadecimal values. + +You will be able to switch monitors using: + + ddcutil -d $display_number setvcp 60 0x$monitor_input_hex_value + +I have this bound to a hotkey using `sxhkd` so I can easily switch between inputs without having to reach over to buttons on my monitor.However you can configure this whichever way you want: for example, you can switch to the display output of your passthrough GPU when the virtual machine starts, and back when it shuts down. + +## Conclusion + +Hopefully, this guide has helped you set up a virtual machine with PCI passthrough. All thats left now is to install the software you want in your virtual machine and have fun. + +If there is anything that isn't clear in this guide, please contact me, or look at other guides if you need any help. The archwiki is a pretty good place to look if you are, *or aren't* using archlinux. + diff --git a/site/entries/ssh_forwarding.html b/site/entries/ssh_forwarding.html new file mode 100755 index 0000000..d068f54 --- /dev/null +++ b/site/entries/ssh_forwarding.html @@ -0,0 +1,94 @@ +#!./entries.sh + +# Permanent SSH Forwarding (Tutorial) + +Take this situation: you have a cheap (or even free), low-powered remote server and a considerably better homeserver with more storage and power. For certain services that require more power, you'd obviously want to run them on that homeserver. + +However, what if you don't want to, *or can't*, directly open ports onto your home network, or you if you simply want to keep all of your site to one IP? This is where SSH port forwarding comes in handy: using ssh to forward the open port from a service from your local server to the remote one, where it can be exposed to the rest of the internet. + +## SSH Remote Port Forwarding + +SSH remote port forwarding is built right into ssh itself, and is quite simple: + +``` +ssh -R 5505:localhost:4404 user@remote.host +``` + +When this command is run on the local server, it will: ++ create an ssh connection to the remote server, as per usual ++ open the port 5505 on the remote server, ++ all traffic on this port will be forwarded to port 4404 on the local server. + +This command by itself is already everything you'd need to forward most ports easily to your remote server, of course, remember to open the port on your remote server's firewall, if applicable. + +However to ensure that that port is exposed properly on the remote server, you'd want to make sure that it is listening to all external traffic. + +You can fix this by setting `GatewayPorts yes` in `/etc/ssh/sshd_config` on the remote server. (don't forget to restart sshd after editing the config) + +## Persistent ssh forwarding + +The above is all well and good, but you'd need to keep an interactive ssh connection up at all times, so the above isn't the most ideal solution. + +To get around this, you can create a service to run on the local server to forward requested ports from the remote server. + +To begin, I'd recommend creating two users, one on each server. For sake of example, lets all them `bridge`. I'd recommend to avoid giving these users passwords, that way they can only be accessed through key based authentication. Of course you will still be able to log into them as root using `su - bridge` + +Next you should create an ssh keypair on the local server (`ssh-keygen`) and place the contents of your public key into `.ssh/authorized_keys` on the remote. This will make sure only the local server can ssh into the remote using that key. + +Then, create a script for your ssh port forwarding. I placed mine directly in the home folder on my local server, though it only matters that the bridge user can execute it. In your script you *must* use the `-nT` flag on your ssh command. These will allow you to run this script as a service, by preventing a virtual terminal being allocated. (read `man ssh` for more info) + +Here is my example of a script that you could use: + + #!/bin/sh + + PORTS="8080 25565" + DEST="bridge@remote.host" + SSH_PORT="22" + IDENTITY_FILE="~/.ssh" + + /usr/bin/ssh -nNT $(echo $PORTS | awk -v host=$LOCALHOST '{for (i = 1; i <= NF; i++){ printf "-R %d:%s:%d ",$i,host,$i}}') -p $SSH_PORT -i $IDENTITY_FILE $DEST + +Next you'd want to run this script as a service. Check your distro's service system how to do this if you have any trouble. + +### Systemd service + +Say that the script you made was `/home/bridge/tunnel.sh`, you should create a user service with systemd for the bridge user. + +To do this create the following file in `/home/bridge/.config/systemd/user/tunnel.service`: + + [Unit] + Description=SSH tunnel + + [Service] + ExecStart=/home/bridge/tunnel.sh + RestartSec=5 + Restart=always + KillMode=mixed + + [Install] + WantedBy=default.target + +Then enable and start the service with: `systemd --user enable tunnel.service` and `system --user start tunnel.service`. Ensure that it is running with `systemd --user status tunnel` + +## Forwarding ports smaller than 1024 + +As you may know, TCP/IP port numbers below 1024 are special in that normal users are not able to open, and hence forward from on the remote server. + +One solution to this is run a server on the remote that will proxy requests from port 80 to a different port (say port 8080). + +This can be achieved using `socat`. + +Say you forwarded traffic from port 8080 on remote to port 80 on local, you could then, on the remote server, run `sudo socat TCP-LISTEN:80,fork TCP:localhost:8080` to listen to traffic on port 80 and forward it to 8080, which will forward back to the local server. + +Here is an example of this in practice, forwarding port 80 and 443, by forwarding ports 8080 and 8443: + + /usr/bin/ssh -nT -R 8443:localhost:443 -R 8080:localhost:80 -i $IDENTITY_FILE -p $SSH_PORT $DEST "(sudo socat TCP-LISTEN:80,fork TCP:localhost:8080) & sudo socat TCP-LISTEN:443,fork TCP:localhost:8443" + +However this command assumes that the remote user has access to sudo with **NO PASSWORD**. Alternatively you could create a similar service (this time as a system service) on the remote server running the socat commands. + +## Video Tutorial + +Here is an example of how you can use this to host a webserver (or any other service) from anywhere: even a hotel room. + + +Credit: DenshiVideo diff --git a/site/entries/welcome.html b/site/entries/welcome.html new file mode 100755 index 0000000..5d34602 --- /dev/null +++ b/site/entries/welcome.html @@ -0,0 +1,11 @@ +#!./entries.sh + +# welcome + +welcome. i decided to turn this webpage into blog-style site... i havent got a topic or anything, so expect either: quality tutorials and very interesting techy things; or just random shitposts or rambles about things. + +originally i was going to make this blog on [b.davidovski.xyz](https://b.davidovski.xyz) using [nanoblogger](http://nanoblogger.sourceforge.net/) (you might be able to still see the start of that) but nb itself seemed quite dead, and i couldn't really be asked to customise it all myself. So i made my own script to generate this static site: [kblg](https://github.com/davidovski/kblg/). Right now its probably just the bare minimum needed for this, but I am planning to add more things to it as I go along (including rss, if anyone would be interested?) + +anyway thats all for now, cya + +~davidovski diff --git a/site/images/bg.gif b/site/images/bg.gif new file mode 100755 index 0000000..044324f --- /dev/null +++ b/site/images/bg.gif @@ -0,0 +1,2 @@ +#!/bin/sh +./gif.py diff --git a/site/images/bg.png b/site/images/bg.png new file mode 100644 index 0000000..d08f9ed Binary files /dev/null and b/site/images/bg.png differ diff --git a/site/images/gif.py b/site/images/gif.py new file mode 100755 index 0000000..26e8408 --- /dev/null +++ b/site/images/gif.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +import glob +import sys +import os +import math +import random +from PIL import Image + + +def color(hex_value): + h = hex_value.lstrip('#') + while len(h) < 8: + h += "f" + return tuple(int(h[i:i+2], 16) for i in (0, 2, 4, 6)) + +def rgb_to_v(c): + r, g, b = c[0]/255.0, c[1]/255.0, c[2]/255.0 + mx = max(r, g, b) + v = mx*100 + return v + +replace = color("#f58f44") +colors = [ + color("#191919"), + color("#373b41"), + ] + +def make(colors, inp=None): + p = len(colors) + w = int(128 / p) * p + h = int(128 / p) * p + + frames = [] + + for i in range(int(p*1*math.pi)): + if inp is None: + image = Image.new("RGBA", (w, h), colors[0]) + else: + image = Image.open(inp).convert("RGBA") + + for x in range(image.width): + for y in range(image.height): + f = 2 + r = random.randint(-f, f) + z = (i) - (y/(p/4)) + r + v = math.floor( (math.sin(z) + 1) * len(colors) * 0.5) + c = colors[v] + if inp is not None: + existing = image.getpixel((x, y)) + if existing[:3] == replace[:3]: + image.putpixel((x,y), c) + else: + image.putpixel((x,y), c) + + frames.append(image.convert("P")) + + + frames[0].save(sys.stdout, mode="P", format="GIF", append_images=frames[1:], save_all=True, duration=100, loop=0) + + +template = None +if len(sys.argv) > 1 and os.path.exists(sys.argv[1]): + template = sys.argv[1] + colors = colors + [ color("#f58f44") ] + +sorted(colors, key=rgb_to_v) +make(colors, inp=template) +#make("dist/images/remotecontrol.gif", colors2, inp="images/remotecontrol-small.png") + + diff --git a/site/images/remotecontrol-small.png b/site/images/remotecontrol-small.png new file mode 100644 index 0000000..fc293d0 Binary files /dev/null and b/site/images/remotecontrol-small.png differ diff --git a/site/images/remotecontrol.gif b/site/images/remotecontrol.gif new file mode 100755 index 0000000..5e73b92 --- /dev/null +++ b/site/images/remotecontrol.gif @@ -0,0 +1,2 @@ +#!/bin/sh +./gif.py remotecontrol-small.png diff --git a/site/images/remotecontrol.png b/site/images/remotecontrol.png new file mode 100644 index 0000000..62d6473 Binary files /dev/null and b/site/images/remotecontrol.png differ diff --git a/site/index.html b/site/index.html new file mode 100755 index 0000000..080a484 --- /dev/null +++ b/site/index.html @@ -0,0 +1,43 @@ +#!./page.sh + +cat << EOF +
+
+ +

Hi, I'm david and this is my website.

+ +

if you want to contact me, you can message me on matrix @ix:davidovski.xyz.

+
+ +
+ +
+
+ +EOF + +cat << EOF +
+

blog posts

+ +
    +EOF +# list all the files in the directory +for file in entries/*.html; do + title="$(grep '^# ' $file)" + title=${title#\# } + + printf " +
  • + +
    %s
    + %s +
    +
  • +" "${file%.*}.html" "$(stat -c %z "$file")" "$title" + done + +cat << EOF +
+
+EOF diff --git a/site/mononoki.woff b/site/mononoki.woff new file mode 100644 index 0000000..939ec2a Binary files /dev/null and b/site/mononoki.woff differ diff --git a/site/page.sh b/site/page.sh new file mode 100755 index 0000000..69db1fb --- /dev/null +++ b/site/page.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# set a variable to avoid this template being repeated indefinitely + +cat << EOF + + + + + + + davidovski.xyz + + +
+
+ davidovski.xyz +
+ +
+
+ +EOF + +[ -z "$1" ] || /bin/sh $* + +cat << EOF +
+ + + +EOF diff --git a/site/rss.xml b/site/rss.xml new file mode 100755 index 0000000..d2ec426 --- /dev/null +++ b/site/rss.xml @@ -0,0 +1,33 @@ +#!/bin/sh + +cat << EOF + + + + + davidovski + https://davidovski.xyz + davidovski's site +EOF + +for entry in entries/*.html; do + title="$(grep '^# ' $entry)" + title=${title#\# } + + printf "\n" + printf "%s\n" "${title}" + printf "%s\n" "http://davidovski.xyz/$entry" + printf "%s\n" "$(stat -c %z "$entry")" + + + printf "\n" + + done + + +cat << EOF + + +EOF diff --git a/site/style.css b/site/style.css new file mode 100644 index 0000000..47b7d40 --- /dev/null +++ b/site/style.css @@ -0,0 +1,160 @@ +:root { + --fg: #f58F44; + --black: #707880; + --red: #cc6666; + --green: #b5bd68; + --yellow: #f0c674; + --blue: #5f819d; + --magenta: #b294bb; + --cyan: #b4d6d1; + --white: #c5c8c6; + --bg-light: #303030; + --bg: #191919; + --line: 2px; +} + + +@font-face { + font-family: mononoki; + src: url(mononoki.woff); +} + +body { + background-color: #303030; + background-image: url("/images/bg.gif"); + background-repeat: repeat; + background-attachment: fixed; + image-rendering: pixelated; + image-rendering: optimizeSpeed; + + + /*background-image: url("https://davidovski.xyz/images/bg.png");*/ + color: #f58f44; + font-family: mononoki; + font-size: 16px; + padding: 0; + margin: 0; +} + +img { + image-rendering: pixelated; + image-rendering: optimizeSpeed; +} + +a { + color: #5f819d; + text-decoration: none; +} + +a:hover { + color: #b4d6d1; + text-decoration: underline; +} + +h1 { + color: #c5c8c6; +} + +h2 { + color: #b4d6d1; +} + +h3 { + color: #5f819d; +} + + +.main { + background-color: #191919; + margin-top: 0; + margin-bottom: 0; + margin-left: auto; + margin-right: auto; + + width: 70%; + + padding: 2%; + height: 100%; + + border-left: 2px solid #f58f44; + border-right: 2px solid #f58f44; + border-bottom: 2px solid #f58f44; +} + +.header { + text-align: center; +} + +.links { + text-align: center justify; + text-justify: inter-word; + #white-space: nowrap; +} + +hr { + width: 100%; + border: 0; + border-bottom: 2px solid #f58f44; +} + +.title { + font-size: 45px; + color: #f58f44; +} + +.small { + font-size: 9px; + padding: 0; + color: #707880; +} + +a.red { + color: #cc6666; +} + +a.green { + color: #b5bd68; +} + +a.blue { + color: #5f819d; +} + +code { + background-color: #303030; + font-size: 16px; + font-family: mononoki; + word-wrap: break-word; + width: 100%; +} + +pre { + background-color: #303030; + white-space: pre-wrap; + padding: 5px; + border: 2px solid #f58f44; + +} + +.grid { + display: inline; +} + +.about { + width: auto; +} + +.image { + width: auto; + float: right; +} + +ul { + list-style-type: none; + margin-left: 0; + padding-left: 0; +} + +img { + width: 100%; +} diff --git a/style.css b/style.css deleted file mode 100644 index 47b7d40..0000000 --- a/style.css +++ /dev/null @@ -1,160 +0,0 @@ -:root { - --fg: #f58F44; - --black: #707880; - --red: #cc6666; - --green: #b5bd68; - --yellow: #f0c674; - --blue: #5f819d; - --magenta: #b294bb; - --cyan: #b4d6d1; - --white: #c5c8c6; - --bg-light: #303030; - --bg: #191919; - --line: 2px; -} - - -@font-face { - font-family: mononoki; - src: url(mononoki.woff); -} - -body { - background-color: #303030; - background-image: url("/images/bg.gif"); - background-repeat: repeat; - background-attachment: fixed; - image-rendering: pixelated; - image-rendering: optimizeSpeed; - - - /*background-image: url("https://davidovski.xyz/images/bg.png");*/ - color: #f58f44; - font-family: mononoki; - font-size: 16px; - padding: 0; - margin: 0; -} - -img { - image-rendering: pixelated; - image-rendering: optimizeSpeed; -} - -a { - color: #5f819d; - text-decoration: none; -} - -a:hover { - color: #b4d6d1; - text-decoration: underline; -} - -h1 { - color: #c5c8c6; -} - -h2 { - color: #b4d6d1; -} - -h3 { - color: #5f819d; -} - - -.main { - background-color: #191919; - margin-top: 0; - margin-bottom: 0; - margin-left: auto; - margin-right: auto; - - width: 70%; - - padding: 2%; - height: 100%; - - border-left: 2px solid #f58f44; - border-right: 2px solid #f58f44; - border-bottom: 2px solid #f58f44; -} - -.header { - text-align: center; -} - -.links { - text-align: center justify; - text-justify: inter-word; - #white-space: nowrap; -} - -hr { - width: 100%; - border: 0; - border-bottom: 2px solid #f58f44; -} - -.title { - font-size: 45px; - color: #f58f44; -} - -.small { - font-size: 9px; - padding: 0; - color: #707880; -} - -a.red { - color: #cc6666; -} - -a.green { - color: #b5bd68; -} - -a.blue { - color: #5f819d; -} - -code { - background-color: #303030; - font-size: 16px; - font-family: mononoki; - word-wrap: break-word; - width: 100%; -} - -pre { - background-color: #303030; - white-space: pre-wrap; - padding: 5px; - border: 2px solid #f58f44; - -} - -.grid { - display: inline; -} - -.about { - width: auto; -} - -.image { - width: auto; - float: right; -} - -ul { - list-style-type: none; - margin-left: 0; - padding-left: 0; -} - -img { - width: 100%; -} -- cgit v1.2.1 From a3e77b130dd9605fd226249e972833d28687dad8 Mon Sep 17 00:00:00 2001 From: davidovski Date: Fri, 21 Jul 2023 11:12:52 +0200 Subject: add build and new scripts --- build.sh | 6 ++++++ new.sh | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 build.sh create mode 100644 new.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..d0b8a2e --- /dev/null +++ b/build.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +[ -d dist ] && rm -r dist +mkdir dist + +shblg -i site -o dist diff --git a/new.sh b/new.sh new file mode 100644 index 0000000..2493cff --- /dev/null +++ b/new.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +EDITOR=nvim +TEMPFILE=/tmp/blog_entry.md + +$EDITOR $TEMPFILE + +NAME=site/entries/$(head -1 $TEMPFILE | cut -d" " -f2- | tr " " "-" | tr "[:upper:]" "[:lower:]").html + +cp $TEMPFILE "$NAME" +rm $TEMPFILE + +chmod +x $NAME -- cgit v1.2.1 From f3684961d71e6ae58fe10cf75a73e4c5089af1e9 Mon Sep 17 00:00:00 2001 From: davidovski Date: Fri, 21 Jul 2023 11:13:47 +0200 Subject: Fixed permissions on scripts --- build.sh | 0 new.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build.sh mode change 100644 => 100755 new.sh diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/new.sh b/new.sh old mode 100644 new mode 100755 -- cgit v1.2.1