summaryrefslogtreecommitdiffstats
path: root/rescue
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2013-12-01 22:29:20 +0000
committerColin Guthrie <colin@mageia.org>2013-12-07 18:32:06 +0000
commitc4634f60b5c6d67eedfedc02166499884e4d6625 (patch)
tree844fb25572edbf617eaeccc7633d0031e7df1ec6 /rescue
parent645e6932216fddd154865a9bebb0fd0e3beed301 (diff)
downloaddrakx-c4634f60b5c6d67eedfedc02166499884e4d6625.tar
drakx-c4634f60b5c6d67eedfedc02166499884e4d6625.tar.gz
drakx-c4634f60b5c6d67eedfedc02166499884e4d6625.tar.bz2
drakx-c4634f60b5c6d67eedfedc02166499884e4d6625.tar.xz
drakx-c4634f60b5c6d67eedfedc02166499884e4d6625.zip
rescue: Use systemd as initsystem.
This commit converts the rescue system to systemd rather than the legacy sysvinit. Besides being faster, one primary advantage of running systemd here is that we can "boot" the system we're inspecting via systemd-nspawn to properly test it. Note: Bits that don't work: * nspawn * old dracut initqueue udev rules in /etc/ are not cleaned out (drop in support error?) * the gui may loop differently now
Diffstat (limited to 'rescue')
-rw-r--r--rescue/NEWS2
-rw-r--r--rescue/aliases2
-rw-r--r--rescue/dirs9
-rw-r--r--rescue/list.xml92
-rwxr-xr-xrescue/make_rescue_img13
-rw-r--r--rescue/tree/etc/hostname1
-rw-r--r--rescue/tree/etc/inittab16
-rw-r--r--rescue/tree/etc/passwd2
-rwxr-xr-xrescue/tree/etc/rc.reboot8
-rwxr-xr-xrescue/tree/etc/rc.sysinit87
-rwxr-xr-xrescue/tree/usr/bin/mageia-rescue35
-rw-r--r--rescue/tree/usr/lib/CVS.0
-rw-r--r--rescue/tree/usr/lib/modules-load.d/mageia-rescue.conf17
-rw-r--r--rescue/tree/usr/lib/systemd/system/rescue.service20
-rw-r--r--rescue/tree/usr/lib/systemd/system/systemd-udevd.service.d/dracut-rules.conf1
-rwxr-xr-xrescue/tree/usr/sbin/fakeshutdown39
-rw-r--r--rescue/tree/usr/share/symlinks4
17 files changed, 178 insertions, 170 deletions
diff --git a/rescue/NEWS b/rescue/NEWS
index bb85b4dbd..7f84b4b3e 100644
--- a/rescue/NEWS
+++ b/rescue/NEWS
@@ -1,3 +1,5 @@
+- use systemd as init in the rescue system
+
Version 1.46 - 20 October 2013 by Colin Guthrie
- adapt to a dracut based stage1
diff --git a/rescue/aliases b/rescue/aliases
index 59c96a124..ebb5a462e 100644
--- a/rescue/aliases
+++ b/rescue/aliases
@@ -1,2 +1,4 @@
/bin/vi vim-minimal
/lib/modules /modules
+/usr/sbin/init /usr/lib/systemd/systemd
+/usr/lib/systemd/system/default.target rescue.target
diff --git a/rescue/dirs b/rescue/dirs
index 6b6d88a6f..256a7f0f7 100644
--- a/rescue/dirs
+++ b/rescue/dirs
@@ -1,4 +1,9 @@
-/lib
+/dev
+/proc
+/run
+/sys
+/usr/bin
+/usr/sbin
+/usr/lib
/tmp
/modules
-/proc
diff --git a/rescue/list.xml b/rescue/list.xml
index fb73f4df4..fd5a829a2 100644
--- a/rescue/list.xml
+++ b/rescue/list.xml
@@ -150,12 +150,6 @@
</if>
</from>
-<from dir="/usr/LIB/drakx-installer-sysvinit/" expand="glob">
- <to dir="/sbin">
- init
- </to>
-</from>
-
<from>
/usr/lib/kbd/keymaps/include
<if ARCH="i.86|x86_64">
@@ -272,10 +266,94 @@
</from>
<from dir="/usr/lib/systemd">
+ systemd
+ systemd-cgroups-agent
+ systemd-shutdown
+ systemd-reply-password
+ systemd-fsck
systemd-udevd
+ systemd-journald
+ systemd-sysctl
+ systemd-modules-load
+ systemd-vconsole-setup
+ system-generators/systemd-fstab-generator
+</from>
+
+<from dir="/usr/lib/systemd/system">
+ cryptsetup.target
+ emergency.target
+ sysinit.target
+ basic.target
+ halt.target
+ kexec.target
+ local-fs.target
+ local-fs-pre.target
+ remote-fs.target
+ remote-fs-pre.target
+ network.target
+ nss-lookup.target
+ nss-user-lookup.target
+ poweroff.target
+ reboot.target
+ rescue.target
+ rpcbind.target
+ shutdown.target
+ final.target
+ sigpwr.target
+ sockets.target
+ swap.target
+ timers.target
+ paths.target
+ umount.target
+ kmod-static-nodes.service
+ systemd-tmpfiles-setup-dev.service
+ systemd-ask-password-console.path
+ systemd-udevd-control.socket
+ systemd-udevd-kernel.socket
+ systemd-ask-password-plymouth.path
+ systemd-journald.socket
+ systemd-ask-password-console.service
+ systemd-modules-load.service
+ systemd-halt.service
+ systemd-poweroff.service
+ systemd-reboot.service
+ systemd-kexec.service
+ systemd-fsck@.service
+ systemd-udevd.service
+ systemd-udev-trigger.service
+ systemd-udev-settle.service
+ systemd-ask-password-plymouth.service
+ systemd-journald.service
+ systemd-vconsole-setup.service
+
+ sysinit.target.wants/systemd-modules-load.service
+ sysinit.target.wants/systemd-ask-password-console.path
+ sysinit.target.wants/systemd-journald.service
+ sockets.target.wants/systemd-udevd-control.socket
+ sockets.target.wants/systemd-udevd-kernel.socket
+ sockets.target.wants/systemd-journald.socket
+ sysinit.target.wants/systemd-udevd.service
+ sysinit.target.wants/systemd-udev-trigger.service
+ sysinit.target.wants/kmod-static-nodes.service
+ sysinit.target.wants/systemd-tmpfiles-setup-dev.service
+
+ ctrl-alt-del.target
+ syslog.socket
+
+ slices.target
+ system.slice
+</from>
+
+<from expand="binary">
+ journalctl systemctl echo swapoff systemd-cgls systemd-tmpfiles systemd-nspawn
+</from>
+
+<from dir="/usr/lib/udev">
+ ata_id
+ scsi_id
</from>
-<from dir="/lib/udev/rules.d">
+<from dir="/usr/lib/udev/rules.d">
10-dm.rules
11-dm-lvm.rules
13-dm-disk.rules
diff --git a/rescue/make_rescue_img b/rescue/make_rescue_img
index 432a6cf94..50083d0b0 100755
--- a/rescue/make_rescue_img
+++ b/rescue/make_rescue_img
@@ -17,7 +17,7 @@ sub _ { __ @_; $? and die }
my $arch = arch() =~ /i.86/ ? $MDK::Common::System::compat_arch{arch()} : arch();
_ "rm -rf $tmp" if -e $tmp;
-_ "mkdir -p $tmp/usr/{bin,sbin,lib}";
+_ "mkdir -p $tmp";
_ "ln -s usr/bin $tmp/bin";
_ "ln -s usr/sbin $tmp/sbin";
_ "ln -s usr/lib $tmp/lib";
@@ -25,13 +25,16 @@ if ($arch eq "x86_64") {
_ "mkdir $tmp/usr/lib64";
_ "ln -s usr/lib64 $tmp/lib64";
}
-_ 'find . -name "*~" | xargs rm -f';
-mkdir_p($tmp . chomp_($_)) foreach cat_("dirs");
_ "cp -a tree/* $tmp";
+_ "find $tmp -name '*~' -delete";
+mkdir_p($tmp . chomp_($_)) foreach cat_("dirs");
substInFile { s/DISTRIB_DESCR/$ENV{DISTRIB_DESCR}/ } "$tmp/etc/issue";
_ "../tools/install-xml-file-list list.xml $tmp";
+_ "sed 's/Mageia \\([0-9]*\\)/Mageia Rescue \\1/' /etc/os-release >$tmp/etc/os-release";
+_ "ls -1 $tmp/etc | sed 's,\\(.*\\),/etc/\\1,' >>$tmp/usr/share/symlinks";
+
my %keytable_conflicts;
my @less_important_keytables = qw(am_old am_phonetic no-dvorak de-latin1);
foreach (keyboard::loadkeys_files(sub { warn @_ })) {
@@ -56,11 +59,11 @@ foreach (cat_("aliases")) {
if (my ($LANGUAGE) = map { if_(/LANGUAGE_(.*)/, $1) } keys %ENV) {
substInFile {
$_ = "export LANGUAGE=$LANGUAGE\n" . "export LC_ALL=$LANGUAGE\n" if /^#LANGUAGE/;
- } "$tmp/etc/rc.sysinit";
+ } "$tmp/usr/bin/mageia-rescue";
}
exit 0 if $ARGV[0];
_ "mksquashfs $tmp $rescue -all-root -noappend >/dev/null";
_ "chmod 755 $rescue";
-_ "rm -rf $tmp";
+#_ "rm -rf $tmp";
diff --git a/rescue/tree/etc/hostname b/rescue/tree/etc/hostname
new file mode 100644
index 000000000..344f71bc8
--- /dev/null
+++ b/rescue/tree/etc/hostname
@@ -0,0 +1 @@
+rescue
diff --git a/rescue/tree/etc/inittab b/rescue/tree/etc/inittab
deleted file mode 100644
index 6a30c0360..000000000
--- a/rescue/tree/etc/inittab
+++ /dev/null
@@ -1,16 +0,0 @@
-#Inittab for Mageia Rescue Disk
-#Author: Daouda Lo
-id:3:initdefault:
-
-si::sysinit:/etc/rc.sysinit
-re:6:wait:/etc/rc.reboot
-ca:12345:ctrlaltdel:/sbin/fakeshutdown
-
-1:12345:respawn:/sbin/mingetty --autologin root tty1
-2:23:respawn:/sbin/mingetty --autologin root tty2
-3:23:respawn:/sbin/mingetty --autologin root tty3
-4:23:respawn:/sbin/mingetty --autologin root tty4
-5:23:respawn:/sbin/mingetty --autologin root tty5
-6:23:respawn:/sbin/mingetty --autologin root tty6
-s0:2345:respawn:/sbin/agetty -h -t 60 ttyS0 9600 ansi
-#s1:2345:respawn:/sbin/agetty -h -t 60 ttyS1 115200,9600 linux
diff --git a/rescue/tree/etc/passwd b/rescue/tree/etc/passwd
index 3a1254f77..06677c9bf 100644
--- a/rescue/tree/etc/passwd
+++ b/rescue/tree/etc/passwd
@@ -1,3 +1 @@
root::0:0::/root:/bin/bash
-shutdown:*:6:0:shutdown:/sbin:/sbin/shutdown
-halt:*:7:0:halt:/sbin:/sbin/halt
diff --git a/rescue/tree/etc/rc.reboot b/rescue/tree/etc/rc.reboot
deleted file mode 100755
index 0b67416f1..000000000
--- a/rescue/tree/etc/rc.reboot
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-sleep 1
-/sbin/killall5 -9
-
-umount -a -f -t noproc
-
-reboot -i -d
diff --git a/rescue/tree/etc/rc.sysinit b/rescue/tree/etc/rc.sysinit
deleted file mode 100755
index 551a4bc76..000000000
--- a/rescue/tree/etc/rc.sysinit
+++ /dev/null
@@ -1,87 +0,0 @@
-#!/bin/sh
-
-action() { echo $1; shift; $*; }
-DATE=`date +%Y%m%d-%Hh%M`
-
-export PATH=/bin:/sbin:/usr/bin:/usr/sbin
-
-echo -e "\t\t\tWelcome to \\033[1;36mMageia\\033[0;39m Linux"
-
-action "Remounting root filesystem in read-write mode" mount -n -o remount,rw /
-
-echo "Starting udev"
-mkdir /run
-mount -t tmpfs -o mode=0755,nosuid,nodev tmpfs /run
-mkdir -p /run/udev/rules.d
-export UDEVRULESD=/run/udev/rules.d
-
-/usr/lib/systemd/systemd-udevd --daemon --resolve-names=never
-udevadm trigger --type=subsystems --action=add
-udevadm trigger --type=devices --action=add
-
-ln -s /tmp/stage2/etc/* /etc 2>/dev/null
-# make passwd changable
-rm -f /etc/passwd
-cp /tmp/stage2/etc/passwd /etc/
-
-mkdir -p /mnt /var/log
-
->/etc/mtab
-mount -f /
-mount -f /proc
-
-# Set the hostname.
-action "Setting hostname rescue" hostname rescue
-echo rescue > /etc/HOSTNAME
-
-# Loads common modules ( no kerneld :( )
-echo "Loading additional modules..."
-load() { modprobe $* 2>/dev/null; }
-load ide-gd_mod
-load ide-cd_mod
-load floppy
-load af_packet
-load isofs
-load vfat
-load ext3
-load ext4
-load reiserfs
-load nilfs2
-load btrfs
-load xfs
-load jfs
-load loop
-load fuse
-load sd_mod
-load sr_mod
-
-action "Bringing up local loop interface" ifconfig lo up
-
-# disable the weird echoprt in cooked mode for user interaction:
-stty sane
-
-#LANGUAGE (filled by make_rescue_img)
-
-grep -q noauto /proc/cmdline || drvinst SERIAL_USB
-
-partimage_default_dir=/data/box
-partimage_dir=`perl -lne 'print $1 if /BOX=(\S+)/' /proc/cmdline`
-[ -z "$partimage_dir" ] && partimage_dir=$partimage_default_dir
-partimage_server=`perl -lne 'print $1 if /\bpserver=(\S+)/' /proc/cmdline`
-
-if grep -q save_all /proc/cmdline; then
- partimage_whole_disk -s $partimage_server save_all $partimage_default_dir
-elif grep -q rest_all /proc/cmdline; then
- if [ -d /tmp/image$partimage_dir ]; then
- partimage_whole_disk rest_all /tmp/image$partimage_dir
- else
- partimage_whole_disk -s $partimage_server rest_all $partimage_dir
- fi
-elif grep -q oem /proc/cmdline; then
- /tmp/image/oem-rescue.sh
-elif grep -q restore /proc/cmdline; then
- /usr/sbin/restore-image.sh
-elif ! grep -q expert /proc/cmdline; then
- echo "starting GUI"
- rescue-gui
-fi
diff --git a/rescue/tree/usr/bin/mageia-rescue b/rescue/tree/usr/bin/mageia-rescue
new file mode 100755
index 000000000..c9dd35661
--- /dev/null
+++ b/rescue/tree/usr/bin/mageia-rescue
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# disable the weird echoprt in cooked mode for user interaction:
+stty sane
+
+#LANGUAGE (filled by make_rescue_img)
+
+grep -q noauto /proc/cmdline || drvinst SERIAL_USB
+
+partimage_default_dir=/data/box
+partimage_dir=`perl -lne 'print $1 if /BOX=(\S+)/' /proc/cmdline`
+[ -z "$partimage_dir" ] && partimage_dir=$partimage_default_dir
+partimage_server=`perl -lne 'print $1 if /\bpserver=(\S+)/' /proc/cmdline`
+
+LOOP=""
+if grep -q save_all /proc/cmdline; then
+ partimage_whole_disk -s $partimage_server save_all $partimage_default_dir
+elif grep -q rest_all /proc/cmdline; then
+ if [ -d /tmp/image$partimage_dir ]; then
+ partimage_whole_disk rest_all /tmp/image$partimage_dir
+ else
+ partimage_whole_disk -s $partimage_server rest_all $partimage_dir
+ fi
+elif grep -q oem /proc/cmdline; then
+ /tmp/image/oem-rescue.sh
+elif grep -q restore /proc/cmdline; then
+ /usr/sbin/restore-image.sh
+elif ! grep -q expert /proc/cmdline; then
+ rescue-gui && LOOP=y
+fi
+
+while [ "$LOOP" ]; do
+ bash --login
+ rescue-gui
+done
diff --git a/rescue/tree/usr/lib/CVS. b/rescue/tree/usr/lib/CVS.
deleted file mode 100644
index e69de29bb..000000000
--- a/rescue/tree/usr/lib/CVS.
+++ /dev/null
diff --git a/rescue/tree/usr/lib/modules-load.d/mageia-rescue.conf b/rescue/tree/usr/lib/modules-load.d/mageia-rescue.conf
new file mode 100644
index 000000000..4111c0484
--- /dev/null
+++ b/rescue/tree/usr/lib/modules-load.d/mageia-rescue.conf
@@ -0,0 +1,17 @@
+ide-gd_mod
+ide-cd_mod
+floppy
+af_packet
+isofs
+vfat
+ext3
+ext4
+reiserfs
+nilfs2
+btrfs
+xfs
+jfs
+loop
+fuse
+sd_mod
+sr_mod
diff --git a/rescue/tree/usr/lib/systemd/system/rescue.service b/rescue/tree/usr/lib/systemd/system/rescue.service
new file mode 100644
index 000000000..336e06c22
--- /dev/null
+++ b/rescue/tree/usr/lib/systemd/system/rescue.service
@@ -0,0 +1,20 @@
+[Unit]
+Description=Mageia Rescue
+DefaultDependencies=no
+Conflicts=shutdown.target
+After=sysinit.target plymouth-start.service
+Before=shutdown.target
+
+[Service]
+Environment=HOME=/
+WorkingDirectory=/
+ExecStartPre=-/bin/plymouth quit
+ExecStart=/usr/bin/mageia-rescue
+ExecStopPost=-/usr/bin/systemctl --fail --no-block reboot
+Type=idle
+StandardInput=tty-force
+StandardOutput=inherit
+StandardError=inherit
+KillMode=process
+IgnoreSIGPIPE=no
+SendSIGHUP=yes
diff --git a/rescue/tree/usr/lib/systemd/system/systemd-udevd.service.d/dracut-rules.conf b/rescue/tree/usr/lib/systemd/system/systemd-udevd.service.d/dracut-rules.conf
new file mode 100644
index 000000000..b75df2e4e
--- /dev/null
+++ b/rescue/tree/usr/lib/systemd/system/systemd-udevd.service.d/dracut-rules.conf
@@ -0,0 +1 @@
+ExecStartPre=-/usr/bin/rm -f /etc/udev/rules.d/10-console.rules
diff --git a/rescue/tree/usr/sbin/fakeshutdown b/rescue/tree/usr/sbin/fakeshutdown
deleted file mode 100755
index 309f26c6c..000000000
--- a/rescue/tree/usr/sbin/fakeshutdown
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/perl
-
-#
-# Guillaume Cottenceau (gc)
-#
-# Copyright 2001 Mandrakesoft
-#
-# This software may be freely redistributed under the terms of the GNU
-# public license.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-
-# From MDK::Common:
-sub cat_ { open(my $F, '<', $_[0]) or die "cat of file $_[0] failed: $!\n"; my @l = <$F>; wantarray() ? @l : join '', @l }
-print "\n";
-
-
-#- try to umount as much as possible; uses Pixel's ultra optimized algo (let you guess how it works..)
-print "Umounting:\n";
-my @mounts = cat_('/proc/mounts');
-my $something_moved;
-do {
- $something_moved = 0;
- foreach (@mounts) {
- my $where = (split)[1];
- next if $where eq '/'; #- ouch! umounting the ramdisk on / always succeeds, and makes it becoming ro :-(
- if (!system("umount $where 2>/dev/null")) {
- print "\t$where\n";
- $something_moved++;
- }
- }
-} while $something_moved;
-
-
-#- shutdown with init
-exec '/sbin/init', 6;
diff --git a/rescue/tree/usr/share/symlinks b/rescue/tree/usr/share/symlinks
deleted file mode 100644
index 091153872..000000000
--- a/rescue/tree/usr/share/symlinks
+++ /dev/null
@@ -1,4 +0,0 @@
-/boot
-/etc/fstab
-/etc/inittab
-/etc/rc.sysinit