Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Trigger remote run on Open Build Service without changing _service file

I like to use _service files on the OpenSUSE Open Build Service. I tend to have a very simple service file that pulls the orig.tar.gz (for dpkg) and .dsc files from git scm and those files then those files' presence indicate to the build server what to do next which is build the dpkg. Buried in the man page for osc is documentation for how to trigger a service run from the command line. When my service file points to a dev branch (see below example), the service file doesn't need to be updated at all. So I would normally have to go to the webpage and select the "trigger services" button. Screenshot of Open Build Service webpage with hand-drawn circle
indicating the "Trigger Services"
button But with the following commands, I don't need to bother logging in to the webpage:

cd ~/dev/osc/home\:bgstack15/freeipa-helper
osc service remoterun

Why this is so obscure, I don't know.

Example _service file

<services>
   <service name="tar_scm">
      <param name="scm">git</param>
      <param name="url">https://gitlab.com/bgstack15/freeipa-helper.git</param>
      <param name="subdir">debian</param>
      <param name="filename">debian</param>
      <param name="revision"> **dev** </param>
      <param name="version">_none_</param>
   </service>
   <service name="recompress">
      <param name="file">*.tar</param>
      <param name="compression">xz</param>
   </service>
   <service name="tar_scm">
      <param name="scm">git</param>
      <param name="url">https://gitlab.com/bgstack15/freeipa-helper.git</param>
      <param name="revision">dev</param>
      <param name="version">_none_</param>
   </service>
   <service name="recompress">
      <param name="file">*.tar</param>
      <param name="compression">gz</param>
   </service>
   <service name="extract_file">
      <param name="archive">*.tar.xz</param>
      <param name="files">*/*.dsc</param>
   </service>
</services>

Download voobly mods from browser

If you inspect a Voobly mods page (such as Jurassic 2 for Age of Empires II: The Conquerors) you can see that the "Download" button is a custom protocol.

<form action="voobly://client.voobly.com:17600/?service=Package&amp;uid=0&amp;session=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&amp;arg=voobly.com**gamemods*13*Jurassic[space]2" method="post">

You can inspect what your system is currently configured to use for a custom protocol of x-scheme-handler/voobly:

$ xdg-mime query default x-scheme-handler/voobly
Voobly.desktop

And if you need to manually set it, you can do so with:

xdg-mime default Voobly.desktop x-scheme-handler/voobly

Interestingly enough, I did not need to fully qualify the path to Voobly.desktop. I suspect that is because it is in one of the XDG_DATA_DIRS default locations which is the ~/.local/share/applications/ My Voobly.desktop actually calls a wrapper shell script, which I augmented to pass the parameters to voobly.exe.

$ cat ~/.local/share/applications/Voobly.desktop
[Desktop Entry]
Name=Voobly
Exec=/home/bgstack15/.wine/voobly.sh %u
Type=Application
StartupNotify=true
Path=/home/bgstack15/.wine/dosdevices/c:/Program Files/Voobly
Icon=/home/bgstack15/.local/share/icons/voobly.png
StartupWMClass=voobly.exe
Comment=Play Age of Empires 2 online
Terminal=false
Categories=Game;StrategyGame;
MimeType=x-scheme-handler/voobly;
StartupWMClass=voobly.exe

The shell script voobly.sh has that $@ (all parameters), which will pass any of those values from the %u from the Desktop file.

1
2
#!/bin/sh
env WINEPREFIX="/home/bgstack15/.wine" /usr/bin/wine C:\\Program\ Files\\Voobly\\voobly.exe $@

Side note: The STAGING_WRITECOPY=1 environment variable is not necessary for wine with versions starting approximately 2020. I cannot pinpoint the exact time or version, unfortunately. The Wine release notes make passing references to copy-on-write or similar for versions 4.4, 4.2, and 2.18 but they don't seem definitive enough to match what I recall. But for Devuan Ceres I haven't needed the winehq apt repo for a long time now. (And Fedora has always used the staging version of Wine.) Or you could just copy extant Voobly mods from one installed system to another underneath directory ~/.wine/drive_c/Program\ Files/Microsoft\ Games/Age\ of\ Empires\ II/Voobly\ Mods/AOC/. There are several directories in there, particularly Local Mods.

$ ls -al ~/.wine/drive_c/Program\ Files/Microsoft\ Games/Age\ of\ Empires\ II/Voobly\ Mods/AOC/Local\ Mods/
total 16
drwxrwxr-x. 3 bgstack15 bgstack15 4096 Jan 24  2020 Short Walls/
drwxrwxr-x. 3 bgstack15 bgstack15 4096 Jan 29  2020 Small Trees/
drwx------. 4 bgstack15 bgstack15 4096 Oct  6  2019 Spectator Dashboard/
drwx------. 4 bgstack15 bgstack15 4096 Oct  6  2019 Spectator Overlay/

Happy downloading mods! Screenshot of Voobly mods web
page

References

Weblinks

  1. xdg - Create a custom URL Protocol Handler - Unix & Linux Stack Exchange
  2. Associate steam protocol (steam://) with linux steam client | Vivaldi Forum
  3. How do I associate a protocol with a program? / Newbie Corner / Arch Linux Forums
  4. Ripped directly from How to download mods from browser (Linux)

Add custom udev hardware definition for extra keys on keyboard

My old HP keyboard has an extra row of buttons, with icons like "camera" and "music" and "shopping cart." On my exact keyboard, only the globe, magnifying glass, and envelope buttons register. Well, I finally decided to do something about it, and of course the Arch wiki has some great info. The process is more important than the output, because everybody's hardware is different.

# File: /etc/udev/hwdb.d/60-keyboard-hp5183.hwdb
# Locations:
#    /mnt/public/Support/Systems/hp-5183-keyboard/60-keyboard-hp5183.hwdb
# Author: bgstack15
# Startdate: 2021-06-04
# Title: Udev definition for extra keys on HP 5183 keyboard
# Purpose: Allow use of the extra keys on the keyboard
# Usage:
#    Place this file in /etc/udev/hwdb.d/
#    modify /usr/lib/systemd/system/systemd-hwdb-update.service by commenting out ConditionNeedsUpdate=/etc
#    sudo systemctl daemon-reload (only after that first modification to that service file)
#    sudo systemd-hwdb update
#    sudo udevadm trigger
#    Validate with: udevadm info /dev/input/by-path/platform-i8042-serio-0-event-kbd | grep KEYBOARD_KEY
# Reference:
#    evemu(1) provides the name of the device, which you prepend with "evdev:atkbd:" and trim some stuff off at the en
d.
#    /usr/lib/udev/hwdb.d/60-keyboard.hwdb
#    https://wiki.archlinux.org/title/Map_scancodes_to_keycodes
#    https://wiki.archlinux.org/title/Keyboard_input
#    just visit the CTRL+ALT+F2 console and press the keys that are not mappable/registered for xev.
#    /usr/include/linux/input-event-codes.h provides the basis for key names
#    example files at /usr/lib/udev/hwdb.d/60-keyboard.hwdb are best
evdev:atkbd:dmi:bvnHewlett-Packard:bvrK01v02.05:bd05/07/2012:br2.5:svnHewlett-Packard:pnHPCompaqElite8300SFF:pvr*
 KEYBOARD_KEY_9f=camera          # camera
 KEYBOARD_KEY_96=media           # music
 KEYBOARD_KEY_b9=switchvideomode # camcorder
 KEYBOARD_KEY_94=prog1           # "hp"
# b4 already defined: globe
 KEYBOARD_KEY_a6=help            # question mark
# e1 already defined: magnifying glass
 KEYBOARD_KEY_9e=shop            # shopping cart
# a3 already defined: mail

References

Weblinks

Local files

  1. /usr/lib/udev/hwdb.d/60-keyboard.hwdb
  2. /usr/include/linux/input-event-codes.h provides the basis for key names
  3. /usr/lib/udev/hwdb.d/60-keyboard.hwdb has the best examples

How to get useful system logs on CentOS 8

Beware the short lifespan of CentOS 8. I haven't migrated to one of the replacements yet, so go investigate for me and tell me what you think of these: Rocky Linux AlmaLinux In the mean time, my lone CentOS 8 system needs real logging. Journald doesn't seem to store logs, because it is poorly written. Or given poor defaults, and what's the difference? So in file /etc/systemd/journald.conf go set variable:

[Journal]
Storage=persistent

But to get real logging, you need to go configure rsyslog.

sudo dnf install rsyslog

And that has sane defaults that actually log messages to disk.

References

Weblinks

  1. How To Use Journalctl to View and Manipulate Systemd Logs | DigitalOcean
  2. How to Configure Rsyslog Server in CentOS 8 / RHEL 8

Sane gtk3 fixes are ready for Fedora

All of my accumulated little fixes for gtk3 from Devuan are now also available in a COPR for Fedora!

  • gtk3-nocsd
  • gtk3-nooverlayscrollbar
  • gtk3-automnemonics

All the packages are native to Devuan but not Fedora, so this gtk3-stackrpms collection is designed to make it easy to install all of these on Fedora.

gtk3-stackrpms upstreams

Because gtk3-stackrpms is a collection, there are multiple upstreams.

gtk3-nocsd

This package is the main PCMan release that helps suppress client-side decorations. Devuan GNU+Linux already packages gtk3-nocsd natively.

Fedora rpm spec:

Raw code:

gtk3-nooverlayscrollbar

This package's contents come from fsmithred of the Devuan community. It sets a few environment variables to force the scrollbars to be always visible. Devuan GNU+Linux already packages gtk3-nooverlayscrollbar natively. The package is really just one file in /etc/X11/Xsession.d that sets a few key environment variables to 0.

Fedora rpm spec: No upstream! My spec is original. Raw code: From the Devuan links above

gtk3-automnemonics

This package re-enables the gtk3 engine's ability to interpret a theme's settings.ini gtk-auto-mnemonics = 0which forces the underscores always on, to make it clear what ALT keystroke is required to select a button or menu entry. This is a module provided by Gord Squash: sgm and packaged in Devuan natively.

Fedora rpm spec: No upstream! My spec is original. Raw code: sgm

Alternatives

The Arch Linux community has tons of gtk3 tweaks and patches.

Dependencies

Basic gtk3 and build dependencies

Compile FreeFileSync with desktop notification support

FreeFileSync is a great graphical file sync tool. I talk about it a lot. Today, I'm sharing a small patch I hacked after stealing from the fabulous arch wiki.

diff -aur 11.9-1/FreeFileSync/Source/Makefile 11.9-2/FreeFileSync/Source/Makefile
--- 11.9-1/FreeFileSync/Source/Makefile 2021-05-06 16:24:53.987902373 -0400
+++ 11.9-2/FreeFileSync/Source/Makefile 2021-05-06 17:09:31.512474440 -0400
@@ -21,6 +22,13 @@
 #treat as system headers so that warnings are hidden:
 cxxFlags  += -isystem/usr/include/gtk-3.0

+with_notifications ?= NO
+ifeq ($(with_notifications),YES)
+# package libglibmm-2.4-dev or glibmm24-devel
+cxxFlags  += `pkg-config --cflags giomm-2.4` -Dwith_notifications
+linkFlags += `pkg-config --libs   giomm-2.4`
+endif
+
 #support for SELinux (optional)
 SELINUX_EXISTING=$(shell pkg-config --exists libselinux && echo YES)
 ifeq ($(SELINUX_EXISTING),YES)
diff -aur 11.9-1/FreeFileSync/Source/ui/progress_indicator.cpp 11.9-2/FreeFileSync/Source/ui/progress_indicator.cpp
--- 11.9-1/FreeFileSync/Source/ui/progress_indicator.cpp    2021-05-06 15:20:34.286831934 -0400
+++ 11.9-2/FreeFileSync/Source/ui/progress_indicator.cpp    2021-05-06 17:11:45.486004158 -0400
@@ -32,6 +32,9 @@
 #include "../perf_check.h"
 #include "../icon_buffer.h"

+#ifdef with_notifications
+#include<giomm-2.4/giomm.h>
+#endif

 using namespace zen;
 using namespace fff;
@@ -1359,6 +1362,22 @@
     pnl_.m_staticTextPhase->SetLabel(getSyncResultLabel(syncResult));
     //pnl_.m_bitmapStatus->SetToolTip(); -> redundant

+#ifdef with_notifications
+    // Desktop notification for Linux
+    char title[] = "FreeFileSync";
+    // from https://stackoverflow.com/a/12097772
+    std::wstring ssR {getSyncResultLabel(syncResult)};
+    std::string body;
+    std::transform(ssR.begin(), ssR.end(), std::back_inserter(body), [] (wchar_t c){ return (char)c;});
+    char icon[] = "freefilesync";
+    auto Application = Gio::Application::create("org.zenju.freefilesync", Gio::APPLICATION_FLAGS_NONE);
+    Application->register_application();
+    auto Notification = Gio::Notification::create(title);
+    Notification->set_body(body);
+    auto Icon = Gio::ThemedIcon::create(icon);
+    Notification->set_icon (Icon);
+    Application->send_notification(Notification);
+#endif
     //show status on Windows 7 taskbar
     if (taskbar_.get())
         switch (syncResult)

The gist of the patch is that it uses the glibmm 2.4 library to make the bare minimum connection to the notification daemon. That's pretty much it. It took me more time to compile this than hack the logic (particularly with the surely weak type conversion) required. So for the niche crowd who tolerates the notification daemon on dbus, and use the same software as me, here you go. On Fedora, the dependency package is pkgconfig(giomm-2.4) (glibmm24-devel) and on Devuan it's libglibmm-2.4-dev.

References

Weblinks

  1. The patch upstream location
  2. Desktop notifications#C++ on the Arch wiki

Use virt-install to fully automate the install for Devuan Ceres with preseed, May 2021 edition

This article is a follow-up or replacement to the following older posts: Use virt-install to fully automate the install for Devuan with preseed Use virt-install to fully automate the install for Devuan Ceres with preseed, March 2020 edition I also have a series on building RHEL-like VMs with virt-install: My kickstart for Fedora 34 VMs Install CentOS 8 with kickstart and virt-install

Installing Devuan Ceres with preseed

I use libvirt with qemu+kvm to run my virtualization environment. My latest work includes updating my Devuan Ceres VM build process to use a recent alpha release ISO for Devuan Chimaera (4.0). I had to modify my urlfetcher.py again in the libvirt files to handle the current locations (described in above article from March 2020) which you can determine with 7z. I was too lazy to investigate how to read contents of a iso file properly.

$ 7z l devuan_chimaera_4.0.alpha-20210510_amd64_netinstall.iso | grep -E '\/(linux|initrd\.gz)$'
2021-03-15 07:44:18 .....     62400333     62400333  boot/isolinux/initrd.gz
2021-03-15 07:44:18 .....      5278960      5278960  boot/isolinux/linux

So the urlfetcher.py class needs to have values:

        if self.arch == "x86_64":
            kernel_initrd_pair = ("boot/isolinux/linux",
                                  "boot/isolinux/initrd.gz")

The preseed file

So, with the libvirt configuration out of the way, I have a preseed file which I have updated to match my current needs and the answers that the Devuan installer wants to see.

# File: /mnt/public/Support/Platforms/devuan/devuan-preseed1.txt
# Locations:
#    /mnt/public/Support/Platforms/devuan/devuan-preseed1.txt
# Author: bgstack15
# Startdate: 2019-06-25
# Title: Preseed for devuan vms for ipa.internal.com
# Purpose: To provide an easy installation for VMs and other systems in the Internal network
# History:
#    2017-06 I learned how to use kickstart files for the RHCSA EX-200 exam
#    2017-08-08 Added notifyemail to --extra-args
#    2017-10-29 major revision to use local repository
#    2019-06-25 fork from centos7-ks.cfg
#    2018-12-29 fix up repos and in-target conclusion stuff
#    2020-02-27 heavy rewrite to use ascii 2.1
#    2021-05-16 bump to chimaera which upgrades self to ceres
# Usage with virt-install:
#    vm=d2-04a ; time sudo virt-install -n "${vm}" --memory 2048 --vcpus=1 --os-variant=debiantesting -v --disk path=/var/lib/libvirt/images/"${vm}".qcow2,size=20 -l /mnt/public/Support/SetupsBig/Linux/devuan_chimaera_4.0.alpha-20210510_amd64_netinstall.iso --initrd-inject=/mnt/public/Support/Platforms/devuan/preseed/preseed.cfg --extra-args "hostname=${vm} NOTIFYEMAIL=bgstack15@gmail.com interface=auto" --debug --network type=bridge,source=br0 --noautoconsole
#    vm=d2-04a; sudo virsh destroy "${vm}"; sudo virsh undefine --remove-all-storage "${vm}";
# Reference:
#    https://sysadmin.compxtreme.ro/automatically-set-the-hostname-during-kickstart-installation/
#    /mnt/public/Support/Platforms/CentOS7/install-vm.txt
#    https://serverfault.com/questions/481244/preseed-command-string-fail-with-newline-character-using-virt-install-initrd-inj
#    https://www.debian.org/releases/stable/i386/apbs01.html.en
#    https://github.com/jameswthorne/preseeds/blob/master/debian-7-wheezy-unattended.seed
#    syntax for --location https://www.queryxchange.com/q/1_908324/virt-install-preseed-not-working/
#    example preseed https://www.debian.org/releases/stable/example-preseed.txt
#    skip next dvd question https://unix.stackexchange.com/questions/409212/preseed-directive-to-skip-another-cd-dvd-scanning
#    grub problem caused by consolekit:amd64 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=915947#10
#    https://stackoverflow.com/questions/39861614/how-to-fully-automate-unattended-virt-install
#    https://www.debian.org/releases/stable/i386/apbs03.html.en
#    https://dev1galaxy.org/viewtopic.php?id=1853
#    https://www.cyberciti.biz/faq/howto-setup-serial-console-on-debian-linux/
#    https://github.com/virt-manager/virt-manager/blob/master/virtinst/install/urldetect.py
#    /mnt/public/Support/Platforms/devuan/fix-virt-manager.txt
#    https://dev1galaxy.org/viewtopic.php?id=3332
#    https://ubuntuforums.org/showthread.php?t=2387570
#    sudo debconf-get-selections -c /mnt/public/Support/Platforms/devuan/preseed/preseed.cfg
#    on d2-03a: sudo debconf-get-selections --installer
#    https://serverfault.com/questions/593388/unable-to-nfs-mount-in-debian-preseed-target/593389
#    https://preseed.debian.net/debian-preseed/sid/amd64-main-full.txt
# Improve:
#    discover how to send email, using postfix or sendmail. Don't care which, but exclude exim4.
#    echo "$( hostname ) has IP $( ip -4 -o a s eth0 | awk '{print $4}' | sed -r -e 's/\/.*$//' )" |

d-i debian-installer/country string US
d-i debian-installer/keymap select us
d-i debian-installer/language string en
d-i debian-installer/locale string en_US
d-i localechooser/supported-locales string en_US.UTF-8

d-i keyboard-configuration/layoutcode string us
d-i keyboard-configuration/variantcode string
d-i keyboard-configuration/xkb-keymap select us

d-i netcfg/disable_autoconfig boolean false
d-i netcfg/get_domain string ipa.internal.com
d-i netcfg/wireless_wep string
# disable asking for non-free firmware, because this is a vm and has none
d-i hw-detect/load_firmware boolean false

#d-i apt-setup/enable-source-repositories boolean false
# ORIGINAL d-i apt-setup/services-select multiselect security updates, release updates, backported software
d-i apt-setup/services-select multiselect release updates
d-i apt-setup/contrib boolean true
d-i apt-setup/disable-cdrom-entries boolean true
d-i apt-setup/non-free boolean true
d-i apt-setup/use_mirror boolean true
d-i mirror/country string manual
d-i mirror/http/directory string /merged
d-i mirror/http/hostname string deb.devuan.org
d-i mirror/http/proxy string
d-i mirror/protocol string http
d-i mirror/suite string testing

d-i apt-setup/cdrom/set-failed boolean false
d-i apt-setup/cdrom/set-first boolean false
d-i apt-setup/cdrom/set-next boolean false

## my repos and ceres
d-i apt-setup/local0/comment    string internaldeb
d-i apt-setup/local0/key        string http://www.example.com/internal/repo/deb/internaldeb.gpg
d-i apt-setup/local0/repository string http://www.example.com/internal/repo/deb/ /
d-i apt-setup/local1/comment    string devuan-deb
d-i apt-setup/local1/key        string http://www.example.com/internal/repo/deb/internaldeb.gpg
d-i apt-setup/local1/repository string http://www.example.com/internal/repo/devuan-deb/ /
d-i apt-setup/local2/comment    string ceres
d-i apt-setup/local2/key        string http://www.example.com/mirror/devuan/dists/ceres/Release.gpg
d-i apt-setup/local2/repository string http://www.example.com/mirror/devuan ceres main contrib non-free
#d-i apt-setup/local2/key        string http://pkgmaster.devuan.org/merged/dists/ceres/Release.gpg
#d-i apt-setup/local2/repository string http://pkgmaster.devuan.org/merged ceres main contrib non-free
d-i apt-setup/local3/comment    string obsmirror
d-i apt-setup/local3/key        string http://www.example.com/mirror/obs/Release.key
d-i apt-setup/local3/repository string http://www.example.com/mirror/obs/ /
# if for some reason I really need to turn off the gpg key check:
#d-i debian-installer/allow_unauthenticated boolean false

#tasksel tasksel/first multiselect standard, ssh-server
tasksel tasksel/first multiselect none

# adapted from /mnt/public/Support/Platforms/devuan/devuan.txt, main fluxbox desktop, but for a vm
# no xscreensaver, for a vm.
#d-i pkgsel/include string \
#   alsamixergui alttab apt-transport-https bgconf bgscripts bgscripts-core \
#   cifs-utils curl fluxbox freeipa-client git grub lightdm lightdm-gtk-greeter \
#   mlocate net-tools nfs-common ntpdate oddjob-mkhomedir=0.0.1-1 openssh-server \
#   p7zip palemoon palemoon-ublock-origin parted qemu-guest-agent rsync scite \
#   screen spice-vdagent strace sudo tcpdump vim vlc volumeicon-alsa waterfox \
#   xfce4-terminal xfe xserver-xorg-video-qxl fluxbox-themes-stackrpms
#d-i pkgsel/include string cifs-utils curl grub lightdm vim sudo vlc screen p7zip nfs-common
d-i pkgsel/include string openssh-server wget curl

d-i pkgsel/upgrade select none

popularity-contest popularity-contest/participate boolean true

d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string dns1.ipa.internal.com
d-i time/zone string America/New_York

# skip grub during main part, because we will do it in late_command
#d-i grub-installer/skip boolean true
#d-i grub-installer/skip-again boolean true
#d-i grub-installer/skip-confirm boolean true
#d-i grub-installer/confirm_skip boolean true
#d-i nobootloader/confirmation_common boolean true
d-i     choose-init/select_init select  sysvinit
d-i     choose-init/selected_sysvinit bool   true
grub-installer  grub-installer/choose_bootdev   select  /dev/vda

d-i lilo-installer/skip boolean true
#d-i grub-installer/with_other_os boolean true
d-i grub-installer/only_debian boolean true
d-i grub-installer/grub2_instead_of_grub_legacy boolean true
#d-i grub-installer/bootdev string /dev/vda
#d-i grub-installer/choose_bootdev select /dev/vda
#grub-installer grub-installer/force-efi-extra-removable boolean false

d-i passwd/root-password password plaintextexamplepw
d-i passwd/root-password-again password plaintextexamplepw

d-i partman-auto/choose_recipe select home
d-i partman-auto-crypto/erase_disks boolean false
d-i partman-auto/disk string /dev/vda
d-i partman-auto/init_automatically_partition select biggest_free
d-i partman-auto/method string lvm
d-i partman/choose_label string gpt
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm_write_new_label boolean true
d-i partman/default_label string gpt
#d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-md/confirm_nooverwrite boolean true
#d-i partman/mount_style select uuid
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman-auto-lvm/guided_size string 100%

# Uncomment this to add multiarch configuration for i386
#d-i apt-setup/multiarch string i386

d-i passwd/make-user boolean true
d-i passwd/user-fullname string bgstack15-local
d-i passwd/username string bgstack15-local
d-i passwd/user-password-crypted password $6$BxyYQfM7A1TEeS6X$S0SALxIk6.n6SU21s.ojeQ9F06AMcnnHS7vODHTufeWXLpNu6EmpsDN7eLVSyYXXU4moiXVgzIiTJYXatdGBz0/
d-i passwd/user-default-groups string audio cdrom video

d-i finish-install/reboot_in_progress note
d-i cdrom-detect/eject boolean true

# additional application stuff just in case it works and is useful
# LDAP server URI:
d-i shared/ldapns/ldap-server   string  ldapi:///ipa.internal.com

d-i openssh-server/password-authentication  boolean true
d-i openssh-server/permit-root-login    boolean false

d-i preseed/late_command string mkdir -p /target/etc/apt/sources.list.d /target/mnt/bgstack15 /target/mnt/public /target/etc/apt/sources.list.d /target/root/input ; touch /target/etc/apt/sources.list.d/empty ; cd /target/etc/apt ; \
   in-target apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" gpg grub-pc sudo ; \
   in-target curl --no-progress-meter --output /root/set-local-devuan-repo.sh http://www.example.com/internal/Support/Platforms/devuan/scripts/set-local-devuan-repo.sh ; in-target sh /root/set-local-devuan-repo.sh ; \
   in-target curl --no-progress-meter --output /root/input/52apt-file-stackrpms.conf http://www.example.com/internal/Support/Platforms/devuan/scripts/input/52apt-file-stackrpms.conf ; in-target curl --no-progress-meter --output /root/set-my-repos.sh http://www.example.com/internal/Support/Platforms/devuan/scripts/set-my-repos.sh ; in-target sh /root/set-my-repos.sh || : ; \
   in-target rm /etc/apt/trusted.gpg.d/ceres.gpg || : ; \
   in-target curl --no-progress-meter http://www.example.com/internal/certs/ca-ipa.internal.com.crt --output /usr/local/share/ca-certificates/ca-ipa.internal.com.crt && in-target update-ca-certificates || : ; \
   in-target apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" alsamixergui alttab bgconf bgscripts bgscripts-core ca-certificates cifs-utils curl desktop-base fluxbox fluxbox-themes-stackrpms freeipa-client freeipa-helper git grub-pc gtk3-nocsd gtk3-nooverlayscrollbar krb5-auth-dialog logout-manager man mlocate net-tools newmoon nfs-common ntpdate oddjob-mkhomedir=0.0.1-1 p7zip parted postfix qemu-guest-agent rsync scite screen spice-vdagent strace sudo tcpdump ublock-origin-combined vim vlc volumeicon-alsa xdgmenumaker xfce4-terminal xfe xserver-xorg-input-libinput xserver-xorg-video-qxl ; \
   in-target apt-mark hold oddjob-mkhomedir ; \
   rm -f /target/etc/apt/sources.list.d/empty || : ; \
   in-target sed -i -r -e '/^\s*linux/s/(\s*console=.{1,7}[0-9])*\s*$/ console=tty0 console=ttyS0/;' /boot/grub/grub.cfg || : ; \
   in-target sed -i -r -e '/^\s*kernel/s/(\s*console=.{1,7}[0-9])*\s*$/ console=tty0 console=ttyS0/;' /boot/grub/menu.lst || : ; \
   in-target sed -i -r -e '$aT0:23:respawn:/sbin/getty -L ttyS0 9600 vt100' /etc/inittab ; \
   in-target apt-get update ; \
   in-target apt-get purge -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" consolekit exim4\* lxqt\* udev ; \
   in-target curl --no-progress-meter --output /root/lightdm-elogind.sh http://www.example.com/internal/Support/Platforms/devuan/scripts/lightdm-elogind.sh ; in-target sh /root/lightdm-elogind.sh -y ; \
   in-target su bgstack15-local -c "sudo /usr/bin/bgconf.py -d 10 1>/home/bgstack15-local/clone.log 2>&1" ; \
   in-target wget -O /root/update-devuan.sh http://www.example.com/internal/Support/Platforms/devuan/scripts/update-devuan.sh ; in-target sh /root/update-devuan.sh preseed ; \
   in-target curl --no-progress-meter --output /root/send-mail-ip-address.sh http://www.example.com/internal/Support/Platforms/devuan/scripts/send-mail-ip-address.sh ; in-target sh /root/send-mail-ip-address.sh bgstack15@gmail.com ;

Explanations

Some of the choices here need explanation. New since March 2020 is "partman- auto-lvm/guided_size string 100%". I like to use lvm for my VMs because I sometimes need to extend filesystems (particularly when trying to build mozilla-based browsers). I use my own local mirror of Devuan but it is a truly flattened repository and not the complex amprolla two-layer (proxying back to usptream Debian files) ordeal that upstream Devuan uses. It makes it possible for me to understand that apt repo, as well as facilitates the speed of downloads when it's just across my LAN! I discovered that a good portion of my logic that used to be in my preseed late_command I have already replicated with various shell scripts. So I just download them and execute them. They are included here as appendices. I install grub-pc (which is grub2) instead of grub-legacy like I used to. I forget why and don't care. I'm more familiar with grub2 anyway. There's some busted ceres.gpg file that could be part of the alpha-release ISO but it's not important for some odd reason. I always enable popcon to contribute stats upstream. Vote early, and vote often! The big apt-get install list has multiple choices in it that are significant. I don't use the pkgsel include because it would always flake out and I got tired of troubleshooting it.

  • The bgconf, bgscripts, and stackrpm options are all my own packages for my own themes, files, configurations, etc. However, some logic in the scripts that this preseed run depend on bgscripts-core specifically.
  • newmoon and waterfox are just my preferred web browsers
  • oddjob-mkhomedir is a custom empty package to satisfy freeipa-common requirements. I describe it in article Devuan join freeipa domain
  • qemu-guest-agent and spice-vdagent. While a modern Devuan installer will recognize it's in qemu and install that package, it doesn't catch spice-vdagent, which is incredibly useful including for resizing the screen of the guest console
  • xserver-xorg-input-libinput and xserver-xorg-video-xql are the drivers to enable mouse and keyboard input and graphical (X11) output on the guest in spice-viewer. These are explicitly listed now but in the past they were not specifically named; I'm guessing they are no longer part of -all packages or similar.

One of my scripts, as you will see below, uses a glob of /etc/apt/sources.list.d/* and to stave off any errors I just made an empty file. The grub.cfg an dmenu.lst logic add a serial console to the VM which I've already covered a few times. I dislike exim and not just because of it's security vulnerabilities; it had some weird bugs a few years ago and also I just don't like it. So I use postfix xor sendmail like a graybeard.

Appendices

set-local-devuan-repo.sh

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
# Startdate: 2020-03-12
# Purpose: Replace original devuan repos with my local devuan mirror
# History:
#    2021-01-27 remove prebuilt file. Just use heredoc
# Documentation:
# Use the network file if available, otherwise, use this hardcoded heredoc.
tf=/etc/apt/sources.list
touch "${tf}"
{
   cat <<'EOF'
# file: /mnt/public/Support/Platforms/devuan/sources.list 
# date: 2019-12-25

# the 3 main ones: ascii main/security/updates
# uncomment all of them when needing winehq-staging for AoC.
# If using ascii, there are multiple lines: ascii ascii-security ascii-updates
deb http://www.example.com/mirror/devuan ceres main contrib non-free
deb-src http://pkgmaster.devuan.org/merged ceres main
EOF
} > "${tf}"

set-my-repos.sh

This script also uses file input/52apt-file-stackrpms.conf.

# File: /etc/apt/apt.preferences.d/52apt-file-stackrpms.conf
# Part of support devuan scripts
# This enables the flat apt repos in internal to be supported by apt-file
Acquire::IndexTargets {
    deb::Contents-stackrpms {
        MetaKey "Contents-$(ARCHITECTURE)";
        ShortDescription "Contents-$(ARCHITECTURE)";
        Description "$(RELEASE) $(ARCHITECTURE) Contents (deb)";

        flatMetaKey "Contents-$(ARCHITECTURE)";
        flatDescription "$(RELEASE) Contents (deb)";
        PDiffs "true";
        KeepCompressed "true";
        DefaultEnabled "false";
        Identifier "Contents-deb";
    };
};

And now, set-my-repos.sh

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/sh
# File: /mnt/public/Support/Platforms/devuan/set-my-repos.sh
# Location:
# Author: bgstack15
# Startdate: 2019-08-10 16:02
# Title: Script that Establishes the repos needed for Devuan
# Purpose: Set up the 3 repos I always need on devuan clients
# History:
#    2020-02-01 customize clients for devuan-archive
#    2020-10-23 add apt-file compatibility
#    2021-01-27 disable devuan-archive
# Usage:
#    sudo set-my-repos.sh
# Reference:
#    /mnt/public/Support/Platforms/devuan/devuan.txt
# Improve:
#    need to control the sources.list file itself to have the main, contrib, etc., for ceres.
# Documentation:

test -z "${ALLREPOSGLOB}" && ALLREPOSGLOB="/etc/apt/sources.list /etc/apt/sources.list.d/*"
test -z "${REPOSBASE}" && REPOSBASE="/etc/apt/sources.list.d"
test -z "${PREFSBASE}" && PREFSBASE="/etc/apt/preferences.d"
test -z "${ADDLCONFBASE}" && ADDLCONFBASE="/etc/apt/apt.conf.d"

# confirm key
confirm_key() {
   # call: confirm_key "${PRETTYNAME}" "${SEARCHPHRASE}" "${URL_OF_KEY}"
   ___ck_repo="${1}"
   ___ck_sp="${2}"
   ___ck_url="${3}"
   if apt-key list 2>/dev/null | grep -qe "${___ck_sp}" ;
   then
      :
   else
      # not found so please add it
      echo "Adding key for ${___ck_repo}" 1>&2
      #wget -O- "${___ck_url}" | sudo apt-key add -
      ___ck_keyfile="/etc/apt/trusted.gpg.d/$( echo "${___ck_repo}" | tr '[: ]' '_' ).gpg"
      wget -O- --quiet "${___ck_url}" | gpg --dearmor | sudo tee "${___ck_keyfile}" 1>/dev/null
   fi
}

# confirm repo
confirm_repo() {
   # call: confirm_repo "${PRETTYNAME}" "${SEARCHPHRASE}" "${SEARCHGLOB}" "${FULLSTRING}" "${PREFERRED_FILENAME}" "${OVERWRITE}"
   ___cr_repo="${1}"
   ___cr_sp="${2}"
   ___cr_sf="${3}"
   ___cr_full="${4}"
   ___cr_pref="${5}"
   ___cr_overwrite="${6}"
   if ! grep -E -qe "${___cr_sp}" ${___cr_sf} ;
   then
      # not found so please add it to preferred file
      echo "Adding repo ${___cr_repo}" 1>&2
      if test "${___cr_overwrite}" = "true" ;
      then
         # overwrite, instead of append
         echo "${___cr_full}" > "${REPOSBASE}/${___cr_pref:-99_misc.list}"
      else
         echo "${___cr_full}" >> "${REPOSBASE}/${___cr_pref:-99_misc.list}"
      fi
   fi
}

confirm_preferences() {
   # call: confirm_preferences "${PRETTYNAME}" "${FILENAME}" "{PACKAGE}" "${PIN_EXPRESSION}" "{PRIORITY}"
   ___cp_prettyname="${1}"
   ___cp_pref="${2}"
   ___cp_package="${3}"
   ___cp_pin_expression="${4}"
   ___cp_priority="${5}"

   ___cp_tempfile="$( mktemp )"
   {
      echo "Package: ${___cp_package}"
      echo "Pin: ${___cp_pin_expression}"
      echo "Pin-Priority: ${___cp_priority}"
   } > "${___cp_tempfile}"

   diff "${PREFSBASE}/${___cp_pref}" "${___cp_tempfile}" 1>/dev/null 2>&1 || {
      echo "Setting preferences for ${___cp_prettyname}"
      touch "${PREFSBASE}/${___cp_pref}" ; chmod 0644 "${PREFSBASE}/${___cp_pref}"
      cat "${___cp_tempfile}" > "${PREFSBASE}/${___cp_pref}"
   }

   rm -f "${___cp_tempfile:-NOTHINGTODEL}" 1>/dev/null 2>&1
}

# REPO 1: local internaldeb
confirm_key "internaldeb" "bgstack15.*www\.no-ip\.biz" "http://www.example.com/internal/repo/deb/internaldeb.gpg"
confirm_repo "internaldeb" "target.*internal\/repo\/deb" "${ALLREPOSGLOB}" "deb [target-=Contents-deb target+=Contents-stackrpms] http://www.example.com/internal/repo/deb/ /" "internaldeb.list" "true"

# REPO 2: local devuan-deb
confirm_key "devuan-deb" "bgstack15.*www\.no-ip\.biz" "http://www.example.com/internal/repo/deb/internaldeb.gpg"
confirm_repo "devuan-deb" "target.*internal\/repo\/devuan-deb" "${ALLREPOSGLOB}" "deb [target-=Contents-deb target+=Contents-stackrpms] http://www.example.com/internal/repo/devuan-deb/ /" "devuan-deb.list" "true"

# REPO 3: local obs
#confirm_key "OBS bgstack15" "bgstack15@build\.opensuse\.org" "https://download.opensuse.org/repositories/home:bgstack15/Debian_Unstable/Release.key"
#confirm_repo "OBS bgstack15" "repositories\/home:\/bgstack15\/Debian_Unstable" "${ALLREPOSGLOB}" "deb http://download.opensuse.org/repositories/home:/bgstack15/Debian_Unstable/ /" "home:bgstack15.list"
confirm_key "OBS bgstack15" "bgstack15@build\.opensuse\.org" "http://www.example.com/mirror/obs/Release.key"
confirm_repo "OBS bgstack15" "mirror\/obs" "${ALLREPOSGLOB}" "deb http://www.example.com/mirror/obs/ /" "home:bgstack15.list"

# REPO 4: local devuan-archive
#confirm_key "devuan-archive" "bgstack15.*www\.no-ip\.biz" "http://www.example.com/internal/repo/deb/internaldeb.gpg"
#confirm_repo "devuan-archive" "target.*server1((\.ipa)?\.internal\.com)?(:180)?.*internal\/repo\/devuan-archive" "${ALLREPOSGLOB}" "deb [target-=Contents-deb target+=Contents-stackrpms] http://server1.ipa.internal.com:180/internal/repo/devuan-archive/ /" "devuan-archive.list" "true"
#confirm_preferences "devuan-archive" "puddletag" "*" "origin server1.ipa.internal.com" "700"

# REPO 5: local obs-aftermozilla key for non-local aftermozilla repo
# just the key
confirm_key "OBS bgstack15 aftermozilla" "bgstack15@build\.opensuse\.org" "https://download.opensuse.org/repositories/home:bgstack15:aftermozilla/Debian_Unstable/Release.key"

# ADDITIONAL APT PREFS
# important for the [target] stuff to work on repos so apt-file can work
cp -p "$( dirname "$( readlink -f "${0}" )")/input/52apt-file-stackrpms.conf" "${ADDLCONFBASE}/"

This script just enforces the contents of /etc/apt/sources.list.d/.

lightdm-elogind.sh

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#!/bin/sh
# Reference: /posts/2019/09/01/devuan-with-lightdm-and-xfce-will-not-let-user-reboot-or-shutdown-from-user-session/
# Startdate: 2019-08-11
# History:
#    2020-04-30 updated
# only for devuan ceres
unset YESSTRING
echo " ${@} " | grep -qE -e " -y " && export YESSTRING="-y"

sudo apt-get install "${YESSTRING}" --no-install-recommends policykit-1 libpam-elogind lightdm lightdm-gtk-greeter
sudo sed -i -r -e '/session\s+optional\s+pam_systemd\.so/s/systemd/elogind/;' /etc/pam.d/lightdm-greeter

update-devuan.sh

This script is already covered in Unattended updates for Devuan Ceres, 2021 edition

send-mail-ip-address.sh

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
# File: send-mail-ip-address.sh
# Startdate: 2021-05-17 08:59
# 
# Purpose: send email message from newly build VM to myself with new hostname and IP address

# Usage:
#    send-mail-ip-address.sh 
# Dependencies:
#    bgscripts-core (>=1.5.0)

test -z "${ADDRESS}" && export ADDRESS="${1}" # use ADDRESS environment variable or else use first parameter
test -z "${ADDRESS}" && export ADDRESS=bgstack15@gmail.com

test -z "${SERVER}" && export SERVER="$( hostname --fqdn )"

# Ensure PATH contains /sbin and /usr/sbin for ip and sendmail (called by send)
echo "${PATH}" | grep -qE '^\/usr\/sbin|:\/usr\/sbin' || export PATH="${PATH}:/usr/sbin"
echo "${PATH}" | grep -qE '^\/sbin|:\/sbin'           || export PATH="${PATH}:/sbin"

# Modified and improved from bgscripts framework.sh 2021-02-16a
thisip="$( ip -4 -o a s | awk '$1 !~ /^lo$/ && $2 !~ /^lo$/ && ($1 ~ /^e/ || $2 ~/^e/) {print $3,$4}' | awk -F'/' '{print $1}' | tr -dc '[0-9\.]' )"

# Send message
{
   echo "${SERVER} has IP address ${thisip}."
   echo "system finished build at $( TZ=UTC date "+%FT%TZ" )"
# leave cat INFILE unquoted in case it is inaccessible
} | send -f "root@${SERVER}" -h -s "${SERVER} is ${thisip}" "${ADDRESS}"

Connect to arbitrary ssh port number with virt-manager

So I was away from my virtualization environment but I wanted to connect to it tunneled through ssh! I jumped through my bastion server and forwarded a port to the virtualization host.

ssh -L 5022:vm3.ipa.example.com:22 home

Where home is just an alias in ~/.ssh/config:

Match host home
   Hostname www.ipa.example.com
   Port 6022
   User bgstack15

And virt-manager doesn't have a way to let you configure port number in a custom connection string, but you can do it from the command line:

virt-manager -c 'qemu+ssh://myuser@localhost:5022/system?keyfile=id_rsa'

Upon first connection you have to accept the new/unknown ssh host key so you probably need package ssh-askpass-gnome.

References

Weblinks

  1. Ripped directly from https://fabianlee.org/2019/02/16/kvm-virt-manager-to-connect-to-a-remote-console-using-qemussh/

Search expressions

  1. libvirt qemu+ssh custom port

LibreWolf rpm for Fedora Linux

I am assisting the LibreWolf community with building rpms of the application for Fedora Linux. LibreWolf is a rebuild of Firefox with additional privacy settings. The initial release, version 88.0, is now ready on the AfterMozilla copr. Go install it now! The sources used to build it are in the LibreWolf namespace on gitlab: https://gitlab.com/librewolf-community/browser/fedora Because copr accepts a git repository as an input source for building packages, the above scripts produce the results that are stored in this repo: https://gitlab.com/bgstack15/librewolf-fedora-ff screenshot of LibreWolf
showing start.fedoraproject.org and also its about
page

My kickstart for Fedora 34 VMs

I still have a single production Fedora instance, and I test my processes on a VM before approving them for production. I've discussed how to use virt- install to fully automate the install for CentOS/Fedora with kickstart before, and now I'm showing you my latest version for Fedora 34. The biggest changes are really just the deprecated options are removed.

# File: /mnt/public/Support/Platforms/Fedora/fc34x-ks.cfg
# Locations:
#    /mnt/public/Support/Platforms/Fedora/fc34x-ks.cfg
# Author: bgstack15
# Startdate: 2017-08-16
# Title: Kickstart for Fedora 34 xfce for ipa.example.com
# Purpose: To provide an easy installation for VMs and other systems in the Mersey network
# History:
#    2017-06 I learned how to use kickstart files for the RHCSA EX-200 exam
#    2017-08-08 Added notifyemail to --extra-args
#    2017-11-01 major revision to use local mirror
#    2017-11-04 converted for building directly into an iso file
#    2017-11-15 fedora 27
#    2018-05-05 fedora 28
#    2018-07-08 adjusted to use --network type=bridge,source=br0 instead of type=direct,source=eno1
#    2018-12-01 fedora 29
#    2019-05-05 fedora 30
#    2020-02-20 fedora 31
#    2020-05-05 fedora 32
#    2020-12-02 fedora 33
#    2021-05-04 fedora 34
# Usage with virt-install:
#    vm=fc34x-01a ; time sudo virt-install -n "${vm}" --memory 2048 --vcpus=1 --os-variant=fedora29 --accelerate -v --disk path=/var/lib/libvirt/images/"${vm}".qcow2,size=30 -l /mnt/public/Support/SetupsBig/Linux/Fedora-Everything-netinst-x86_64-34-1.2.iso --initrd-inject=/mnt/public/Support/Platforms/Fedora/fc34x-ks.cfg --extra-args "inst.ks=file:/fc34x-ks.cfg SERVERNAME=${vm} NOTIFYEMAIL=bgstack15@gmail.com" --debug --network type=bridge,source=br0 --noautoconsole
#    vm=fc34x-01a; sudo virsh destroy "${vm}"; sudo virsh undefine --remove-all-storage "${vm}";
# Reference:
#    https://sysadmin.compxtreme.ro/automatically-set-the-hostname-during-kickstart-installation/
#    /mnt/public/Support/Platforms/CentOS7/install-vm.txt

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
#install
# Keyboard layouts
keyboard --vckeymap=us --xlayouts=''
# Root password
rootpw --plaintext notMyRootPw
# my user
user --groups=wheel --name=bgstack15-local --password=$6$.gh3u6vg2HDGPPX/$g3X1l.q75ft7i0ULUt7h89jDIo1BaHHj/1DGeUzzbMTb0pBh4of6iLYWyxvs/937qUjPgETiOsSGI5XNrkaVe. --iscrypted --gecos="bgstack15-local"

# System language
lang en_US.UTF-8
# Firewall configuration
firewall --enabled --ssh
# Reboot after installation
reboot
# Network information
#attempting to put it in the included ks file that accepts hostname from the virsh command.
#network  --bootproto=dhcp --device=eth0 --ipv6=auto --activate
%include /tmp/network.ks
# System timezone
timezone America/New_York --utc
# System authorization information
#auth  --useshadow  --passalgo=sha512
# Use network installation instead of CDROM installation media
url --url="http://www.example.com/mirror/fedora/linux/releases/34/Everything/x86_64/os/"

# Use text mode install
text
# SELinux configuration
selinux --enforcing
# Prepare X to run at boot
xconfig --startxonboot

# Use all local repositories
# Online repos
repo --name=examplerpm --baseurl=https://www.example.com/example/repo/rpm/
repo --name=fedora --baseurl=https://www.example.com/mirror/fedora/linux/releases/$releasever/Everything/$basearch/os/
# disabled updates 2020-02-20; maybe the repo was just having a bad day
#repo --name=updates --baseurl=https://www.example.com/mirror/fedora/linux/updates/$releasever/Everything/$basearch/
repo --name=rpmfusion-free --baseurl=https://www.example.com/mirror/rpmfusion/free/fedora/releases/$releasever/Everything/$basearch/os/
repo --name=rpmfusion-free-updates --baseurl=https://www.example.com/mirror/rpmfusion/free/fedora/updates/$releasever/$basearch/
repo --name=bgstack15-stackrpms --baseurl=https://copr-be.cloud.fedoraproject.org/results/bgstack15/stackrpms/fedora-$releasever-$basearch/

# Offline repos
#repo --name=examplerpm --baseurl=https://server1/example/repo/rpm/
#repo --name=fedora --baseurl=https://server1/mirror/fedora/linux/releases/$releasever/Everything/$basearch/os/
#repo --name=updates --baseurl=https://server1/mirror/fedora/linux/updates/$releasever/$basearch/
#repo --name=rpmfusion-free --baseurl=https://server1/mirror/rpmfusion/free/fedora/releases/$releasever/Everything/$basearch/os/
#repo --name=rpmfusion-free-updates --baseurl=https://server1/mirror/rpmfusion/free/fedora/updates/$releasever/$basearch/

firstboot --disabled

# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
autopart --type=lvm

%pre
echo "network  --bootproto=dhcp --device=eth0 --ipv6=auto --activate --hostname renameme.ipa.example.com" > /tmp/network.ks
for x in $( cat /proc/cmdline );
do
   case $x in
      SERVERNAME*)
         eval $x
         echo "network  --bootproto=dhcp --device=eth0 --ipv6=auto --activate --hostname ${SERVERNAME}.ipa.example.com" > /tmp/network.ks
         ;;
      NOTIFYEMAIL*)
         eval $x
         echo "${NOTIFYEMAIL}" > /mnt/sysroot/root/notifyemail.txt
     ;;
   esac
done
cp -p /run/install/repo/ca-ipa.example.com.crt /etc/pki/ca-trust/source/anchors/ 2>/dev/null || :
wget http://www.example.com/example/certs/ca-ipa.example.com.crt -O /etc/pki/ca-trust/source/anchors/ca-ipa.example-wget.com.crt || :
update-ca-trust || :
%end

%post
{
   set -x
   # Set temporary hostname
   #hostnamectl set-hostname renameme.ipa.example.com;

   # Get local mirror root ca certificate
   wget http://www.example.com/example/certs/ca-ipa.example.com.crt -O /etc/pki/ca-trust/source/anchors/ca-ipa.example.com.crt && update-ca-trust

   # Get local mirror repositories
   wget http://www.example.com/example/repo/rpm/examplerpm.repo -O /etc/yum.repos.d/examplerpm.repo
   wget http://www.example.com/example/repo/rpm/examplerpm.mirrorlist -O /etc/yum.repos.d/examplerpm.mirrorlist
   distro=fc34 ; sudo wget https://www.example.com/example/repo/mirror/example-bundle-${distro}.repo -O /etc/yum.repos.d/example-bundle-${distro}.repo && grep -oP "(?<=^\[).*(?=-example])" /etc/yum.repos.d/example-bundle-${distro}.repo | while read thisrepo; do sudo dnf config-manager --set-disabled "${thisrepo}"; done
   dnf -y remove dnfdragora ;
   dnf clean all ;
   dnf update -y ;

   # Remove graphical boot and add serial console
   sed -i -r -e '/^GRUB_CMDLINE_LINUX=/{s/(\s*)(rhgb|quiet)\s*/\1/g;};' -e '/^GRUB_CMDLINE_LINUX=/{s/(\s*)\"$/ console=ttyS0 console=tty1\"/;}' /etc/default/grub
   grub2-mkconfig > /boot/grub2/grub.cfg

   systemctl enable sendmail.service && systemctl start sendmail.service
   # Send IP address to myself
   thisip="$( ifconfig 2>/dev/null | awk '/Bcast|broadcast/{print $2}' | tr -cd '[^0-9\.\n]' | head -n1 )"
   {
      echo "${SERVER} has IP ${thisip}."
      echo "system finished kickstart at $( date "+%Y-%m-%d %T" )";
   } | /usr/share/bgscripts/send.sh -f "root@$( hostname --fqdn )" \
      -h -s "${SERVER} is ${thisip}" $( cat /root/notifyemail.txt 2>/dev/null )

   # Ensure boot to runlevel 5
   systemctl set-default graphical.target

   # fix the mkhomedir problem
   systemctl enable oddjobd.service && systemctl start oddjobd.service

   # Personal customizations
   mkdir -p /mnt/bgstack15 /mnt/public
   #su bgstack15-local -c "sudo /usr/share/bgconf/bgconf.py"
   tf=/etc/cron.d/01_init.cron
   touch "${tf}" ; chown root.root "${tf}" ; chmod 0600 "${tf}"
   cat <<-"EOFCRON" 1>"${tf}"
@reboot         root    su bgstack15-local -c "sudo /usr/bin/bgconf.py" 1>/root/clone.log 2>&1 ; rm -f /etc/cron.d/01_init.cron 1>/dev/null 2>&1 ; systemctl restart lightdm 1>/dev/null 2>&1 ;
EOFCRON

} 2>&1 | tee -a /root/install.log
%end

%packages
@core
@^xfce-desktop-environment
@xfce-apps
@xfce-media
#@basic-desktop
autossh
bc
bgconf
bgscripts
bgscripts-core
bind-utils
cifs-utils
cryptsetup
-dnfdragora
-dnfdragora-updater
dosfstools
expect
firefox
firewalld
freeipa-client
git
-hplip
iotop
lightdm-gtk
mailx
man
mlocate
net-tools
nfs-utils
numix-icon-theme-circle
p7zip
parted
python3-policycoreutils
qemu-guest-agent
rpm-build
rsync
scite
screen
sendmail
spice-vdagent
strace
sysstat
tcpdump
telnet
-thunderbird
vim
vlc
wget
xdg-themes-stackrpms
xfce4-whiskermenu-plugin
-gstreamer1-plugins-ugly*
%end