install systemd services as compat package
This commit is contained in:
parent
dcd051f795
commit
199edd5716
103
install.sh
103
install.sh
|
@ -57,6 +57,7 @@ set -eu
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
shopt -s dotglob
|
shopt -s dotglob
|
||||||
|
umask 022
|
||||||
|
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
export LANG=C
|
export LANG=C
|
||||||
|
@ -83,6 +84,70 @@ mask_to_prefix() {
|
||||||
echo ${prefix}
|
echo ${prefix}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_compat_package() {
|
||||||
|
|
||||||
|
local workdir=$(mktemp -d)
|
||||||
|
local unitdir=${workdir}/usr/lib/systemd/system
|
||||||
|
local kexeccmd
|
||||||
|
|
||||||
|
set -- /sbin/kexec \
|
||||||
|
/boot/vmlinuz-${kernel_package} \
|
||||||
|
--initrd=/boot/initramfs-${kernel_package}.img \
|
||||||
|
--reuse-cmdline \
|
||||||
|
--command-line=archkernel
|
||||||
|
kexeccmd="$*"
|
||||||
|
|
||||||
|
cat > ${workdir}/.PKGINFO <<-'EOF'
|
||||||
|
pkgname = digitalocean-debian-compat
|
||||||
|
pkgver = 1.0-1
|
||||||
|
pkgdesc = Compatibility files to run Arch Linux as a Debian distro on DigitalOcean
|
||||||
|
url = https://github.com/gh2o/digitalocean-debian-to-arch
|
||||||
|
arch = any
|
||||||
|
license = GPL
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mkdir -p ${unitdir}/sysinit.target.wants/
|
||||||
|
ln -s ../arch-kernel.service ${unitdir}/sysinit.target.wants/
|
||||||
|
cat > ${unitdir}/arch-kernel.service <<-EOF
|
||||||
|
[Unit]
|
||||||
|
Description=Reboots into Arch kernel
|
||||||
|
ConditionKernelCommandLine=!archkernel
|
||||||
|
DefaultDependencies=no
|
||||||
|
Before=local-fs-pre.target systemd-remount-fs.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=${kexeccmd}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mkdir -p ${unitdir}/multi-user.target.wants/
|
||||||
|
ln -s ../debian-interfaces.service ${unitdir}/multi-user.target.wants/
|
||||||
|
cat > ${unitdir}/debian-interfaces.service <<-EOF
|
||||||
|
[Unit]
|
||||||
|
Description=Parses /etc/network/interfaces into .network files for systemd-networkd
|
||||||
|
DefaultDependencies=no
|
||||||
|
Before=systemd-networkd.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/sbin/parse-debian-interfaces
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mkdir -p ${workdir}/usr/bin/
|
||||||
|
cat > ${workdir}/usr/bin/parse-debian-interfaces <<-EOF
|
||||||
|
#!/bin/bash
|
||||||
|
set -eu
|
||||||
|
set -o pipefail
|
||||||
|
echo ENIENIENIENI > /dev/kmsg
|
||||||
|
EOF
|
||||||
|
chmod 0755 ${workdir}/usr/bin/parse-debian-interfaces
|
||||||
|
|
||||||
|
( cd ${workdir} && bsdtar -cf compat.pkg.tar * )
|
||||||
|
pacman -U --noconfirm ${workdir}/compat.pkg.tar
|
||||||
|
rm -rf ${workdir}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
parse_debian_interfaces() {
|
parse_debian_interfaces() {
|
||||||
local filename="${1}" # path to interfaces file
|
local filename="${1}" # path to interfaces file
|
||||||
local interface="${2}" # interface name
|
local interface="${2}" # interface name
|
||||||
|
@ -431,29 +496,15 @@ postbootstrap_configuration() {
|
||||||
local unitdir=/archroot/etc/systemd/system
|
local unitdir=/archroot/etc/systemd/system
|
||||||
|
|
||||||
mkdir -p ${unitdir}/basic.target.wants
|
mkdir -p ${unitdir}/basic.target.wants
|
||||||
ln -s ../installer-cleanup.service ${unitdir}/basic.target.wants/
|
ln -s ../installer-finalize.service ${unitdir}/basic.target.wants/
|
||||||
cat > ${unitdir}/installer-cleanup.service <<EOF
|
cat > ${unitdir}/installer-finalize.service <<EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Post-install cleanup
|
Description=Post-install finalization
|
||||||
ConditionPathExists=/installer/script.sh
|
ConditionPathExists=/installer/script.sh
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/installer/script.sh
|
ExecStart=/installer/script.sh
|
||||||
EOF
|
|
||||||
|
|
||||||
mkdir -p ${unitdir}/sysinit.target.wants
|
|
||||||
ln -s ../arch-kernel.service ${unitdir}/sysinit.target.wants
|
|
||||||
cat > ${unitdir}/arch-kernel.service <<EOF
|
|
||||||
[Unit]
|
|
||||||
Description=Reboots into arch kernel
|
|
||||||
ConditionKernelCommandLine=!archkernel
|
|
||||||
DefaultDependencies=no
|
|
||||||
Before=local-fs-pre.target systemd-remount-fs.service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
Type=oneshot
|
|
||||||
ExecStart=/sbin/kexec /boot/vmlinuz-${kernel_package} --initrd=/boot/initramfs-${kernel_package}.img --reuse-cmdline --command-line=archkernel
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -579,12 +630,16 @@ transitory_main() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
postinstall_main() {
|
finalize_main() {
|
||||||
|
|
||||||
# remove cleanup service
|
# install compatibility package
|
||||||
|
install_compat_package
|
||||||
|
|
||||||
|
# remove finalization service
|
||||||
local unitdir=/etc/systemd/system
|
local unitdir=/etc/systemd/system
|
||||||
rm -f ${unitdir}/installer-cleanup.service
|
rm -f ${unitdir}/installer-finalize.service
|
||||||
rm -f ${unitdir}/basic.target.wants/installer-cleanup.service
|
rm -f ${unitdir}/basic.target.wants/installer-finalize.service
|
||||||
|
rmdir ${unitdir}/basic.target.wants || true
|
||||||
|
|
||||||
# cleanup filesystem
|
# cleanup filesystem
|
||||||
rm -f /var/cache/pacman/pkg
|
rm -f /var/cache/pacman/pkg
|
||||||
|
@ -593,6 +648,10 @@ postinstall_main() {
|
||||||
rm -rf /archroot
|
rm -rf /archroot
|
||||||
rm -rf /installer
|
rm -rf /installer
|
||||||
|
|
||||||
|
# restart into new kernel
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl start arch-kernel.service
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
canonicalize_path() {
|
canonicalize_path() {
|
||||||
|
@ -610,7 +669,7 @@ if [ $$ -eq 1 ]; then
|
||||||
elif [ "${script_path}" = "/sbin/init" ]; then
|
elif [ "${script_path}" = "/sbin/init" ]; then
|
||||||
exec /sbin/init.original "$@"
|
exec /sbin/init.original "$@"
|
||||||
elif [ "${script_path}" = "/installer/script.sh" ]; then
|
elif [ "${script_path}" = "/installer/script.sh" ]; then
|
||||||
postinstall_main "$@"
|
finalize_main "$@"
|
||||||
else
|
else
|
||||||
installer_main "$@"
|
installer_main "$@"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue