Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [Solved] Building Artix as a vagrant box dinit issue 'systemd timer replacement' (Read 401 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

[Solved] Building Artix as a vagrant box dinit issue 'systemd timer replacement'

I'm trying to use Artix for the first time by building a vagrant box for it, 
so I can use it as an OS install box, the OS installed will be of course yet another 
custom-made OS, with server apps pre-installed, 
so I have my RPi server OSes fully installed  at a press of a button. 

I used to use Manjaro for the vagrant box, but Manjaro discontinued minimal x64 support,  
so I can't make any minimal VM-boxes in them anymore, which seemed like an excellent  
opportunity to switch to Artix Linux.  

I plan my custom made to be still in Manjaro until I figure out how their manjaro-arm-installer script works, 
and then make an Artix-based arm-installer script as well. 

That's my plan. 



I'm using vagrant packer to build the box, but I'm running into two issues:

First of all, I'm used to systemd and so I don't know how to deal with
services that were previously categorized into service types, namely service, socket and timer.

For example, for Manjaro I would use reflector.timer like so: 

Code: [Select]
/usr/bin/manjaro-chroot ${ROOT_DIR} /usr/bin/systemctl enable reflector.timer

Which I try to replicate like so: 

Code: [Select]
/usr/bin/artix-chroot ${ROOT_DIR} /usr/bin/dinitctl enable rankmirrors.timer

Which leads to two issues. 

A) I've already noticed that dinitctl doesn't work enabling services when I write
dinitctl enable x.service, it needs to be dinitctl enable x, so I'm uncertain how I would get the same 
result for dinitctl as I did using systemctl.   

B)

I'm getting this error:

Code: [Select]
dinit-client: connecting to socket /run/dinitctl: No such file or directory

Looking at stack exchange, the advise is to reboot, 
but since this is a script install, a reboot will lead to the liveVM grub menu, 
which doesn't  seem to have a countdown timeout. 

Editing grub in my script, 
means it would permanently alter my liveVM, 
meaning everytime I rerun the packer build, 
the boot command would either
be set for the altered liveVM or the unaltered version
and that's not what I want. 

Re: Building Artix as a vagrant box dinit issues.

Reply #1
I can't help you with your vagrant setup, but you can't use systemd "features" with any other init. For timers, there's crond. The error you're getting with dinitctl is because dinit isn't PID1, i.e. your vagrant packer probably uses systemd.

Re: Building Artix as a vagrant box dinit issues.

Reply #2
Thank you for your help. 
Especially the crond advice. 

I don't think vagrant packer uses systemd. 
Vagrant packer starts a VM, loads an inserted ISO
and then uses scripts to install the box. 

This is my list of scripts:
 -  liveVM.sh
 -   tables.sh
 -   partitions.sh
 -   base.sh
 -   mirrors.sh
 -   bootloader.sh
 -   pacman.sh
 -   setup.sh

I switched from using a Manjaro ISO to an Artix ISO and it's able to get past the liveVM script. 
As you can see in the first script, it has no issue calling, because I get stuck on mirrors.sh (crontab)
and setup.sh where dinitctl is required for starting sshd. 
Without it vagrant packer won't finish the installed box. 

liveVM.sh
Code: [Select]
#!/usr/bin/bash

. /tmp/files/vars.sh

NAME_SH=liveVM.sh
GRUB=/etc/default/grub

# stop on errors
set -eu

echo ">>>> ${NAME_SH}: Lock root password.."
/usr/bin/passwd -l root >/dev/null

echo ">>>> ${NAME_SH}: Update the system clock.."
/usr/bin/dinitctl start ntpd >/dev/null

echo ">>>> ${NAME_SH}: Modifying local settings.."
/usr/bin/ln -sf /usr/share/zoneinfo/Europe/Brussels /etc/localtime
echo -s ${HOSTNAME_LIVEVM} | tee /etc/hostname >/dev/null

echo ">>>> ${NAME_SH}: Installing packages for commands used in provisioner scripts.."
/usr/bin/pacman --noconfirm -Sy gptfdisk pacman-contrib >/dev/null

echo ">>>> ${NAME_SH}: Reranking pacman mirrorslist.."
/usr/bin/cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist-backup  
/usr/bin/rankmirrors /etc/pacman.d/mirrorlist-backup | tee /etc/pacman.d/mirrorlist >/dev/null
/usr/bin/rm -rf /etc/pacman.d/mirrorlist-backup

I'm now stuck on the crontab issue and the dinitctl issue. 

Here's what I have so far:

mirrors.sh
Code: [Select]
#!/usr/bin/env bash

. /tmp/files/vars.sh

NAME_SH=mirrors.sh

# stop on errors
set -eu

echo ">>>> ${NAME_SH}: Reranking pacman mirrorlist.."
/usr/bin/artix-chroot ${ROOT_DIR} pacman -S --noconfirm pacman-contrib >/dev/null
/usr/bin/artix-chroot ${ROOT_DIR} cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist-backup  
/usr/bin/artix-chroot ${ROOT_DIR} /usr/bin/rankmirrors /etc/pacman.d/mirrorlist-backup | tee /etc/pacman.d/mirrorlist >/dev/null 
/usr/bin/artix-chroot ${ROOT_DIR} rm -rf /etc/pacman.d/mirrorlist-backup

echo ">>>> ${NAME_SH}: Crontab rankmirrors every week.."
sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | /usr/bin/artix-chroot ${ROOT_DIR} sudo crontab -e
"Monthly update of Artix mirrorlist"
0 0 1 * * rankmirrors &>dev/null
EOF

echo ">>>> ${NAME_SH}: Debugging part.."
/usr/bin/ls -lha /run/dinitctl
/usr/bin/dinitctl list
/usr/bin/artix-chroot ${ROOT_DIR} /usr/bin/ls -lha /run/dinitctl
/usr/bin/artix-chroot ${ROOT_DIR} /usr/bin/dinitctl list

And this is the current result:

Code: [Select]
==> bastille-installer.qemu.artix: no crontab for root - using an empty one
    bastille-installer.qemu.artix: [Using open mode]
==> bastille-installer.qemu.artix: crontab: no changes made to crontab
    bastille-installer.qemu.artix:
    bastille-installer.qemu.artix: Open and visual must be used interactively
    bastille-installer.qemu.artix: At end-of-file
    bastille-installer.qemu.artix: Nonzero address required on this command
...
==> bastille-installer.qemu.artix: /usr/bin/ls: cannot access '/run/dinitctl': No such file or directory
==> bastille-installer.qemu.artix: Provisioning step had errors: Running the cleanup provisioner, if present...
==> bastille-installer.qemu.artix: Deleting output directory...
Build 'bastille-installer.qemu.artix' errored after 6 minutes 12 seconds: Script exited with non-zero exit status: 2. Allowed exit codes are: [0]

[edit]

I think I've got the crontab figured out.
You know what, I'll mark this as solved and open a seperate post.

Code: [Select]
/usr/bin/artix-chroot ${ROOT_DIR} crontab -l &>/dev/null | { cat; echo "0 0 1 * * rankmirrors" >/dev/null; } | crontab -