Tag: configuration

  • Proxmox and home assistant

    A couple of hints to get proxmox and a home assistant VM up and running on a home server.

    Installing Proxmox

    Tip: Youtube “First 11 Things on Proxmox“.

    Graphical installer doesn’t run

    If the graphical installer does not come up (after DHCP) try this:

    # FIRST START PROXMOX INSTALLATION IN   D E B U G   M O D E   ! ! !
    
    # then in the shell starting before the installer runs, do ...
    $ Xorg -configure
    
    # COULD also be under /root/xorg.conf.new - read the command output
    $ cp /xorg.conf.new /etc/X11/xorg.conf
    
    # now replace all ocurrences of `amdgpu` with `fbdev` in /etc/X11/xorg.conf
    
    # exit the shell
    $ <CTRL-D>
    

    Now the installer should just come up.

    Source: This blog post and that comment below.

    Enable updates without subscription

    Change /etc/apt/sources.list.d/pve-enterprise.list to this:

    # /etc/apt/sources.list.d/pve-enterprise.list
    deb http://download.proxmox.com/debian/pve buster pve-no-subscription
    

    Install HASS.io

    SSH into your proxmox box and use this command:

    # (I didn't need sudo, I connected as root)
    bash -c "$(wget -qLO - https://raw.githubusercontent.com/Kanga-Who/home-assistant/master/hassos_install.sh)"
    
  • Install flutter on MacOS

    I blog so I don’t forget … this:

    First, the non-CLI actions:

    • install XCode from the App Store
    • install Flutter plugin for Visual Studio Code (if you haven’t installed VS Code, do it now, you can also use “brew” for that)
    • download the latest Flutter SDK, unzip it, and move the unzipped flutter/ folder to $HOME/Dev/frameworks (or any other location you favor)
    • add $HOME/Dev/flutter/bin and $HOME/Dev/flutter/bin/.pub-cache/bin to your path

    That’s about it for now. Then do some CLI magic:

    brew tap dart-lang/dart
    brew install dart android-studio android-sdk
    sudo gem install cocoapods
    pod setup
    sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
    sudo xcodebuild -runFirstLaunch
    flutter doctor --android-licenses
    

    After that some more UI stuff:

    • Start Android Studio. It will want to install a couple of things (Intel drivers pop up, weirdly)

    And finally: A final flutter doctor will tell you if everything is all right.

    The whole process will download about 10-12 GB of data.

  • A more peaceful rant about Java & Camel

    I did it. I feel like I survived something, like I am on the path on enlightenment (and it feels like raising the foot for the first step in a yourney which I know to be several AEs long). Anyway, I’m kinda happy.

    What did I do? I succeeded to write this Java code using the Apache Camel library (and yes, that’s it – in total):

    import org.apache.camel.main.Main;
    
    public final class CamelPusher {
    
        private CamelPusher() {
        }
    
        public static void main(String[] args) throws Exception {
            Main camelMain = new Main();
            // https://is.gd/P8SzKX
            camelMain.configure().withXmlRoutes("file:*.xml");
            camelMain.run(args);
        }
    
    }
    

    Impresive, huh?

    What took me longest was to add the “file:” in the line camelMain.configure().withXmlRoutes("file:*.xml");. Yup, really.

    Code-wise, that is. It took me even longer to set this up:

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>de.company.business</groupId>
      <artifactId>camelocclient</artifactId>
      <version>1.0.0-SNAPSHOT</version>
      <name>CamelOCClient</name>
      <description>The thing that transfers payment files to OC</description>
    
      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
      </properties>
    
      <repositories>
        <repository>
          <id>spring-releases</id>
          <url>https://repo.spring.io/libs-release</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>spring-releases</id>
          <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
      </pluginRepositories>
    
      <dependencies>
        <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
        <dependency>
          <groupId>org.springframework</groupId>
          <artifactId>spring-context</artifactId>
          <version>5.2.5.RELEASE</version>
        </dependency>
    
        <dependency>
          <groupId>org.apache.camel</groupId>
          <artifactId>camel-core</artifactId>
          <version>3.2.0</version>
        </dependency>
    
        <dependency>
          <groupId>org.apache.camel</groupId>
          <artifactId>camel-ftp</artifactId>
          <version>3.2.0</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.apache.camel/camel-spring -->
        <dependency>
          <groupId>org.apache.camel</groupId>
          <artifactId>camel-spring</artifactId>
          <version>3.2.0</version>
        </dependency>
    
        <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
        <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-simple</artifactId>
          <version>1.7.30</version>
        </dependency>
    
      </dependencies>
    
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>versions-maven-plugin</artifactId>
            <version>2.7</version>
            <configuration>
              <allowMajorUpdates>false</allowMajorUpdates>
              <!-- https://stackoverflow.com/a/22174801/902327 -->
              <!-- fucking maven shit honestly those java assholes suck so badly -->
              <rulesUri>file:///${project.basedir}/pom-versions-ruleset.xml</rulesUri>
            </configuration>
          </plugin>
          <plugin>
            <!-- see here: https://is.gd/HNFI0H -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.1.12.RELEASE</version>
            <executions>
              <execution>
                <goals>
                  <goal>repackage</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.6.0</version>
            <groupId>org.codehaus.mojo</groupId>
            <executions>
              <execution>            <!-- Run our version calculation script -->
                <id>git-tag</id>
                <goals>
                  <goal>exec</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <executable>git</executable>
              <arguments>
                <argument>tag</argument>
                <argument>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}${parsedVersion.qualifier?}</argument>
              </arguments>
            </configuration>
          </plugin>
        </plugins>
      </build>
    
    </project>
    <!-- I FUCKING HATE MAVEN. -->
    

    And this, cause maybe I still don’t fully get maven (and with maybe I mean definitely, and yes I know there’s an error in the Makefile, I’m gonna fix it – later):

    all: clean build prepare-test test
    .PHONY: all
    
    clean:
        rm -rf tmp
    .PHONY: clean
    
    build:
        mvn package
    .PHONY: build
    
    prepare-test: clean
        mkdir -p tmp/from_here tmp/to_here tmp/and_from_here tmp/to_here_as_well
        echo deeply > tmp/from_here/i-want-to-be-moved.txt
        echo deeply > tmp/and_from_here/hashtag-metoo.txt
        cp target/camelocclient-SNAPSHOT.jar tmp/
        cp test-config.xml tmp/
    .PHONY: test
    
    test:
        cd tmp; pwd; java -cp . -jar camelocclient-SNAPSHOT.jar
    .PHONY: test
    
    run: test
    .PHONY: run
    
    .PHONY: _git_dirtycheck
    _git_dirtycheck:
        [[ ! -z "git status -s" ]] || (echo -e "\n\n***** working dir is dirty. *****\n\n" && false)
    
    .PHONY: _major
    _major: _git_dirtycheck
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=\$${parsedVersion.nextMajorVersion}.0.0 \
            versions:commit
    
    .PHONY: _minor
    _minor: _git_dirtycheck
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=\$${parsedVersion.majorVersion}.\$${parsedVersion.nextMinorVersion}.0 \
            versions:commit
    
    .PHONY: _patch
    _patch: _git_dirtycheck
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=\$${parsedVersion.majorVersion}.\$${parsedVersion.minorVersion}.\$${parsedVersion.nextIncrementalVersion} \
            versions:commit
    
    .PHONY: _set_version
    _set_version: _git_dirtycheck
        read -p "new version: " VERSION ; \
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=$$VERSION \
            versions:commit
    
    .PHONY: _snap
    _snap: _git_dirtycheck
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=\$${parsedVersion.majorVersion}.\$${parsedVersion.minorVersion}.\$${parsedVersion.nextIncrementalVersion}-SNAPSHOT \
            versions:commit
    
    .PHONY: _tag
    _tag:
        git commit -am "Version bump"
        mvn build-helper:parse-version exec:exec
    
    .PHONY: _snap_tag
    _snap_tag: _snap _tag
    
    .PHONY: _addsnap
    _addsnap:
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=\$${parsedVersion.majorVersion}.\$${parsedVersion.minorVersion}.\$${parsedVersion.incrementalVersion}-SNAPSHOT \
            versions:commit
    
    .PHONY: _release
    _release: _git_dirtycheck
        mvn build-helper:parse-version \
            versions:set \
            -DnewVersion=\$${parsedVersion.majorVersion}.\$${parsedVersion.minorVersion}.\$${parsedVersion.incrementalVersion} \
            versions:commit
    
    .PHONY: major
    major: _major _tag build _snap_tag
    
    .PHONY: minor
    minor: _minor _tag build _snap_tag
    
    .PHONY: patch
    patch: _patch _tag build _snap_tag
    
    .PHONY: addsnap
    addsnap: _addsnap
    
    .PHONY: rel
    rel: _release _tag build _snap_tag
    
    .PHONY: release
    release: rel
    
    .PHONY: set-version
    set-version: _set_version _tag build _snap_tag
    
    .PHONY: setver
    setver: set-version
    

    So this is it. That abomination took me days to build.

    So now I can do “make release“, get a .jar file, and place something like this next to it:

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
      DOKUMENTATION:
      https://camel.apache.org/manual/latest/spring.html
    -->
    
    <routes xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="file:from_here"/>
            <to uri="file:to_here"/>
        </route>
        <route>
            <from uri="file:and_from_here"/>
            <to uri="file:to_here_as_well"/>
        </route>
    </routes>
    

    … having a freely configurable, all-purpose, no-nonsense Camel engine to my disposal, which I can then deploy to any host of my liking to do things which are useful. In that case – it’s supposed to transfer files (the “left” side of the system, a couple of deployments) to S3, and then pull them out (the “right” side of it, one deployment) into a folder on a target machine.

    This is it, this is all, this is basically the most trivial use case ever invented, and it’s supposed to be replaced with something “real”. Let’s see how long it takes to get there.

    Now, am I happy? Yes. Is this … “good”? No. Does it work? Probably (it does with a file server / sftp transfer system).

    But the best part is: I kinda, sorta understand a little bit of what I did. And I am starting to think that Camel might actually be awesome, and maven actually useful – once you start understanding the concepts and ecosystem. But that’s just a vague possibility, given that I still don’t πŸ˜‰ .

    I published the files here as well.

  • Configure Python on Windows

    All right, I have a Windows machine. It’s a PITA, but it’s here. And for some reason I started doing some Python testing on it. So this is how I managed to do it:

    Preparation:

    • Install python with choco (choco install -y python)
    • Run PowerShell as Administrator
      • Execute Set-ExecutionPolicy -ExecutionPolicy Unrestricted (we’ll see why in a very short time)

    Now to code it’s pretty similar to *NIX:

    • Create your code folder
    • Set up a python venv (python -m venv .env)
    • In VS Code, choose this interpreter

    So why the PowerShell stuff? Cause to activate the environment VS Code needs to execute a .ps1 script. Which it can’t, cause “executing scripts is disabled on this machine”, which seems to be the default setting.

    All in all, surprisingly straightforward. And I just noticed even the *NIX keyboard shortcuts (CTRL-A, CTRL-K, for example) work in the terminal window now. Crazy.

  • Win10 & Veracrypt & systemd-boot

    There are some things seemingly nobody does. For example, …

    • double-booting Win10 and Linux
    • on an UEFI System
    • while the Win10 Partition is encrypted using VeraCrypt.

    Yes, it’s a complex scenario, but since MS in all of his (money-grabbing) wisdom does not include BitLocker in Win10 Home, this is a necessary precaution. I’ll not go over the installation of both systems (pretty straightforward, and Arch Linux has – as always – a nice Wiki entry about it).

    Unfortunately, Win10 likes to break its own boot manager on updates, which is very scary (“Your Windows partition is damaged”), and super annoying, but I think I got the solution now.

    So, the Linux-based (of course) solution for Windows 10 and VeraCrypt is:

    # esp partition - /loader/entries/winvera.conf
    title Windows 10 VeraCrypt
    efi /EFI/VeraCrypt/DcsBoot.efi
    

    This is in fact all you need to do. Now, if Windows fucks up its own boot loader, it seems systemd-boot just ignores everything, loads the correct VeraCrypt bootloader (as it is supposed to be), and all is well.

    It can happen though that Windows places its own boot manager back in front of systemd-boot again, so it’s used as the default one. Then use one of the methods described here, and you should be fine. (This did not happen to me, it always used the correct boot manager but fucked up Windows boot)

  • Arch followup actions

    Updates:

    • 2022-06-23 | add networking, update packages, add GDM

    Overview

    Once you’ve installed Arch Linux, a couple of things are … nice. But very basic. Let’s get out of basic πŸ˜‰ .

    Set up networking

    Just do the same as described in the installation post.

    Then, we set up IWD as backend for NetworkManger (NOTE: experimental!).

    ### FILE: /etc/NetworkManager/conf.d/wifi_backend.conf ###
    [device]
    wifi.backend=iwd
    

    Create user

    If you didn’t do it yet, create your user.

    useradd -m -G wheel USERNAME
    passwd USERNAME
    

    You should have sudo installed, so do this:

    # if you are really lazy and insecure
    echo "%wheel ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers.d/wheel
    
    # use this.
    echo "%wheel ALL=(ALL:ALL) ALL" >> /etc/sudoers.d/wheel
    

    Now log in as this user and check if you can become root by typing sudo -i.

    CLI packages

    Some CLI “apps”:

    pacman -S ack dnsmasq git ripgrep vim zsh git base-devel man-db man-pages
    

    Install yay (AUR helper)

    Remember: Do this as your “normal” user!

    mkdir /tmp/yay
    cd /tmp/yay
    
    # from here stolen from yay's github page:
    # https://github.com/Jguer/yay#source
    git clone https://aur.archlinux.org/yay-bin.git
    cd yay-bin
    makepkg -si
    

    Install UI

    And here it goes for UI and UI-related things:

    pacman -S gnome gnome-extra gnome-control-center \
              cups network-manager-applet \
              firefox
    

    Now some AUR packages:

    yay -S vscodium-bin
    

    Configurations

    For network manager, I prefer dnsmasq as the tool of choice, especially when using VPN connections:

    ### FILE: /etc/NetworkManager/conf.d/dns.conf ###
    [Main]
    dns=dnsmasq
    

    Enable services

    # enable
    systemctl enable iwd
    systemctl enable NetworkManager
    systemctl enable org.cups.cupsd
    
    # start
    systemctl start iwd
    systemctl start NetworkManager
    systemctl start org.cups.cupsd
    
    # to boot into GNOME
    systemctl enable gdm
    

    Some troubleshooting tricks

    Gnome-terminal does not start

    Set the locale, using “gnome control center”, and then re-login. (Source)

  • Install Arch with full disk encryption, btrfs and EFI

    Updates:

    • 2022-06-23 | some minor corrections, added wifi link
    • 2018-03-27 | fixed a typo in the HOOKS documentation, clarified kernel boot parameters

    Introduction

    I recently had to re-install my beloved Arch Linux. For security I need (and use) full disk encryption. This is a cheatsheet for the whole procedure, because although the Arch Linux Wiki is excellent, it is also huge and sometimes you must pick your stuff together from many pages.

    This is what I am doing here πŸ™‚

    NOTE: Usually you only have to follow the one subsection I link to!

    Overview

    One after another, we will do the following steps

    • Download and prepare Arch USB stick (skipped, you should know that πŸ˜‰
    • Prepare the hard disk
    • Prepare the disk partitions
    • Add LVM “inside” the crypted partition
    • Create filesystems & mount partitions
    • Install arch
    • Configure boot manager

    Prepare the hard disk

    Use parted to init the disk and …

    1. init the disk using a GPT partitioning scheme, then create
    2. a GPT boot partition and put 100% of the remaining space in another partition (the first two actions behind the link)

    Prepare the disk partitions

    Basically,

    1. use the cryptsetup command to encrypt the main (big) partition,
    2. and create a file system on the boot partition (remember: it must be FAT32 for EFI boot, and it must be _un_encrypted!)

    Add an LVM “inside” the encrypted partition

    Cause we want “properly” encrypted swap (you can also encrypt swap using a /dev/random key every time, but then you will not persist data between reboots and you can’t do things like suspend-to-disk), we need at least two “partitions” “inside” the crypted volume. Sounds like LVM on LUKS? It does. We already used it πŸ™‚ .

    1. Create LVM partitions inside the encrypted volume (Don’t forget to use cryptsetup luksOpen before, usually in step 1 in the last section πŸ™‚

    NOTE: Do not follow the above link down to “prepare the boot partition”, cause they use ext2 and we need FAT32 for EFI boot partitions. Just don’t.

    I use the name “secure” for the VG, and I use btrfs cause I am so incredibly elite, and so we don’t need to set a specific size for the / and /home “partitions” and can just use btrfs subvolumes, while still being able to wipe the system without the home directories. That’s pretty neat if you need it (I never did, but now I can ;). So that’s the final setup:

    /dev/mapper/secure-swap    40 GB, swap
    /dev/mapper/secure-system  rest, btrfs with 2 subvols: root & home
    

    Create filesystems & mount partitions

    Of course, Arch has already a wiki page section for that. I did it 3 times in a different way until I found it and had to do it again. So here is my summary.

    # CREATE BTRFS & SUBVOLUMES
    $ mkfs.btrfs /dev/mapper/secure-system
    $ mount /dev/mapper/secure-system /mnt
    $ btrfs subvolume create /mnt/@
    $ btrfs subvolume create /mnt/@home
    $ btrfs subvolume create /mnt/@snapshots
    $ umount /mnt
    
    # MOUNT PARTITIONS
    $ mount -o subvol=@ /dev/mapper/crypted-system /mnt
    $ mkdir -p /mnt/home /mnt/boot
    $ mount -o subvol=@home /dev/mapper/crypted-system /mnt/home
    $ mount /dev/sda1 /mnt/boot
    

    NOTE: /boot is not on an encrypted partition πŸ˜‰ , and the leading “@” is a convention for subvolumes which should be mounted somewhere. I also don’t use compress=...Β  parameters, cause I don’t need / want transparent compression.

    Install arch

    Set up networking

    Nowadays nobody uses LAN cables any more. And of course, with Arch you can do it over WiFi as well. This is the short form:

    $ iwctl
    [iwd] station list
    # get the name of your "station" here
    [iwd] station wlan0 scan
    [iwd] station wlan0 get-networks
    # see the list of networks
    [iwd] station wlan0 connect NETWORK_NAME
    

    Also useful: IWD docs, connecting to the internet on the arch Wiki.

    Install base system

    Then you follow up with the usual installation procedure, but you stop at the “Initramfs” section. Here we will pick up again. In the chroot, this is what is needed and useful. (Yes, we’re installing multiple network managers, Linux “is about choice” …)

    pacman -S lvm2 vim \
              iwd netctl dialog wpa_supplicant \
              networkmanager \
              dhcclient \
              udev nano zsh sudo iproute2 net-tools \
              git
    

    Configure boot manager & boot files

    We are using systemd-boot. Or bootctl, as the binary is called. It should be already installed. The procedure is also outlined here. We also enable TRIM support, it seems to lessen security, but it raises SSD performance and life time.

    1. First, check if your system EFI is all right.
    2. Optionally install the Intel microcode updater package if you have an Intel CPU by doing pacman -S intel-ucode.
    3. Then run … bootctl -path=/boot install to install systemd-boot.
      (If you ran into this error File system ... has wrong type for EFI System Partition, then you forgot set 1 esp on on your boot partition in parted during partitioning)

    Now create/modify the files below. Remember: /mnt/boot should be a mounted directory, and since you’re in a chroot this should be /boot for you.

    FILE: /boot/loader/entries/arch.conf

    title Arch Linux
    linux /vmlinuz-linux
    initrd /intel-ucode.img       # ONLY FOR INTEL CPUs!!
    initrd /initramfs-linux.img
    options luks.uuid=FS_UUID root=/dev/mapper/secure-system rootflags=subvol=@ rd.luks.options=discard
    

    Some hints:

    • use blkid to get the UUID
    • Note that the FS_UUID is the UUID of the *encrypted luks partition* (/dev/sda2 or similar), and not the filesystem within!
    • use a mouse to copy-paste the UUID\
    • gpm -m /dev/input/mice -t imps2; you may have to disable vim’s mouse support using set mouse= and set ttymouse=
    • the list of normal and dm-crypt related kernel parameters … well, is also in the Arch wiki.

    FILE: /boot/loader/loader.conf

    default arch    # the file above without .conf extension, can have wildcards!!
    timeout 2
    editor  0
    

    FILE: /etc/mkinitcpio.conf

    # Just MODIFY that file, to be precisely this line:
    HOOKS=(base systemd autodetect modconf keyboard sd-vconsole block sd-encrypt sd-lvm2 filesystems fsck)
    

    The key idea is to use the “systemd” parameters instead of the “normal” ones. The full list of hooks is of course also available, and the order is important.

    Install boot manager

    Now execute:

    mkinitcpio -p linux
    

    If you run into some vmlinuz-linux - file not found issues, just re-install linux and intel-ucode while making sure /boot is mounted.

    Reboot

    We should be done here πŸ™‚ …

    … but we’re paranoid:

    • did you install lvm2? (if not – install it and run mkinitcpio again)
    • did you install iwd? (if not – no wifi in the final system)
    • did you set a root password? (if not, set it)

    Then you can safely …

    $ reboot
    

    Further reading πŸ˜‰

  • No password prompts for GitHub “hub” client

    GitHub has a little cli tool called “hub” which makes working with repos a bit easier (“hub pull-request” instead of a lot of clicking around on the web). Unfortunately they don’t really tell you how to prevent password inputs every time you use it.

    Unless you dig deep:

  • Linux font rendering sucks, a.k.a β€œWhere is Boohomil”?

    For some reason, the maintainer behind the “*-infinality” packages in Arch Linux “has gone missing” for a while.

    Why is that important to me? Because infinality is a patch set to a bunch of font and rendering packages, which make fonts under Linux look SO much better than the default setup. (Yes, there are still a couple of things that Linux just absolutely cannot compete in with Mac and / or Win, and font rendering is one of them. Ubuntu does a reasonable job of this, every other distro just sucks.

    Except when you were using infinality. And now it’s defunct.

    Anyway, after experiencing the unbelievably ugly phenomenon described in here, I tried this guide here now, and it seems to fix it.

  • Shortcut with β€œΓΆβ€ (o-umlaut)

    I want my clipboard history on CTRL-Γ–. Don’t ask why.

    Here’s what you can enter in GNOME to get this:

    <Ctrl>odiaeresis