From 675389f11ffaab590e9dedabc821e33745e3eb5c Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 14 Oct 2010 15:06:41 -0400 Subject: Reorganize the systemd bits as we'll have scripts to put in /lib/systemd. --- systemd/halt.service | 19 ------------------- systemd/killall.service | 19 ------------------- systemd/poweroff.service | 19 ------------------- systemd/prefdm.service | 22 ---------------------- systemd/rc-local.service | 16 ---------------- systemd/reboot.service | 19 ------------------- systemd/single.service | 29 ----------------------------- systemd/sysinit.service | 19 ------------------- systemd/system/halt.service | 19 +++++++++++++++++++ systemd/system/killall.service | 19 +++++++++++++++++++ systemd/system/poweroff.service | 19 +++++++++++++++++++ systemd/system/prefdm.service | 22 ++++++++++++++++++++++ systemd/system/rc-local.service | 16 ++++++++++++++++ systemd/system/reboot.service | 19 +++++++++++++++++++ systemd/system/single.service | 29 +++++++++++++++++++++++++++++ systemd/system/sysinit.service | 19 +++++++++++++++++++ 16 files changed, 162 insertions(+), 162 deletions(-) delete mode 100644 systemd/halt.service delete mode 100644 systemd/killall.service delete mode 100644 systemd/poweroff.service delete mode 100644 systemd/prefdm.service delete mode 100644 systemd/rc-local.service delete mode 100644 systemd/reboot.service delete mode 100644 systemd/single.service delete mode 100644 systemd/sysinit.service create mode 100644 systemd/system/halt.service create mode 100644 systemd/system/killall.service create mode 100644 systemd/system/poweroff.service create mode 100644 systemd/system/prefdm.service create mode 100644 systemd/system/rc-local.service create mode 100644 systemd/system/reboot.service create mode 100644 systemd/system/single.service create mode 100644 systemd/system/sysinit.service (limited to 'systemd') diff --git a/systemd/halt.service b/systemd/halt.service deleted file mode 100644 index a1c0e84f..00000000 --- a/systemd/halt.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=Halt the system -DefaultDependencies=no -Requires=umount.target killall.service -After=umount.target killall.service - -[Service] -Type=oneshot -RemainAfterExit=yes -Environment=INIT_HALT=HALT RUNLEVEL=0 -ExecStart=/etc/init.d/halt start -StandardOutput=tty diff --git a/systemd/killall.service b/systemd/killall.service deleted file mode 100644 index 953dc19d..00000000 --- a/systemd/killall.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=Kill all processes -DefaultDependencies=no -Requires=shutdown.target -After=shutdown.target -RefuseManualStart=yes - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=-/etc/init.d/killall start -StandardOutput=tty diff --git a/systemd/poweroff.service b/systemd/poweroff.service deleted file mode 100644 index 28b4a5f4..00000000 --- a/systemd/poweroff.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=Power down the system -DefaultDependencies=no -Requires=umount.target killall.service -After=umount.target killall.service - -[Service] -Type=oneshot -RemainAfterExit=yes -Environment=RUNLEVEL=0 -ExecStart=/etc/init.d/halt start -StandardOutput=tty diff --git a/systemd/prefdm.service b/systemd/prefdm.service deleted file mode 100644 index 60a5ed05..00000000 --- a/systemd/prefdm.service +++ /dev/null @@ -1,22 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=Display Manager -After=syslog.target livesys-late.service rc-local.service - -# On Fedora gdm/X11 is on tty1. We explicitly cancel the getty here to -# avoid any races around that. -Conflicts=getty@tty1.service plymouth-quit.service - -[Service] -ExecStart=/etc/X11/prefdm -nodaemon -Restart=restart-always -RestartSec=0 - -[Install] -Alias=display-manager.service diff --git a/systemd/rc-local.service b/systemd/rc-local.service deleted file mode 100644 index 21ecfb23..00000000 --- a/systemd/rc-local.service +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=Local customization - -[Service] -ExecStart=/etc/rc.local start -TimeoutSec=0 -StandardOutput=tty -RemainAfterExit=yes -SysVStartPriority=99 diff --git a/systemd/reboot.service b/systemd/reboot.service deleted file mode 100644 index 622beb58..00000000 --- a/systemd/reboot.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=Reboot the system -DefaultDependencies=no -Requires=umount.target killall.service -After=umount.target killall.service - -[Service] -Type=oneshot -RemainAfterExit=yes -Environment=RUNLEVEL=6 -ExecStart=/etc/init.d/reboot start -StandardOutput=tty diff --git a/systemd/single.service b/systemd/single.service deleted file mode 100644 index d91166b3..00000000 --- a/systemd/single.service +++ /dev/null @@ -1,29 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# See systemd.special(7) for details - -[Unit] -Description=Rescue Shell -DefaultDependencies=no -Conflicts=multi-user.target shutdown.target -After=sysinit.target -Before=multi-user.target - -[Service] -Type=simple -EnvironmentFile=/etc/sysconfig/init -Environment=HOME=/root -ExecStartPre=-/bin/plymouth --hide-splash -ExecStart=-/bin/bash -c "exec $SINGLE" -ExecStopPost=/bin/systemctl default -StandardInput=tty-force -KillMode=process-group - -# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash -# terminates cleanly. -KillSignal=SIGHUP diff --git a/systemd/sysinit.service b/systemd/sysinit.service deleted file mode 100644 index 860d3a34..00000000 --- a/systemd/sysinit.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=System Initialization -DefaultDependencies=no -Conflicts=shutdown.target -Before=shutdown.target emergency.service emergency.target - -[Service] -ExecStart=/etc/rc.d/rc.sysinit -Type=forking -TimeoutSec=0 -StandardInput=tty -RemainAfterExit=yes diff --git a/systemd/system/halt.service b/systemd/system/halt.service new file mode 100644 index 00000000..a1c0e84f --- /dev/null +++ b/systemd/system/halt.service @@ -0,0 +1,19 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Halt the system +DefaultDependencies=no +Requires=umount.target killall.service +After=umount.target killall.service + +[Service] +Type=oneshot +RemainAfterExit=yes +Environment=INIT_HALT=HALT RUNLEVEL=0 +ExecStart=/etc/init.d/halt start +StandardOutput=tty diff --git a/systemd/system/killall.service b/systemd/system/killall.service new file mode 100644 index 00000000..953dc19d --- /dev/null +++ b/systemd/system/killall.service @@ -0,0 +1,19 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Kill all processes +DefaultDependencies=no +Requires=shutdown.target +After=shutdown.target +RefuseManualStart=yes + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=-/etc/init.d/killall start +StandardOutput=tty diff --git a/systemd/system/poweroff.service b/systemd/system/poweroff.service new file mode 100644 index 00000000..28b4a5f4 --- /dev/null +++ b/systemd/system/poweroff.service @@ -0,0 +1,19 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Power down the system +DefaultDependencies=no +Requires=umount.target killall.service +After=umount.target killall.service + +[Service] +Type=oneshot +RemainAfterExit=yes +Environment=RUNLEVEL=0 +ExecStart=/etc/init.d/halt start +StandardOutput=tty diff --git a/systemd/system/prefdm.service b/systemd/system/prefdm.service new file mode 100644 index 00000000..60a5ed05 --- /dev/null +++ b/systemd/system/prefdm.service @@ -0,0 +1,22 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Display Manager +After=syslog.target livesys-late.service rc-local.service + +# On Fedora gdm/X11 is on tty1. We explicitly cancel the getty here to +# avoid any races around that. +Conflicts=getty@tty1.service plymouth-quit.service + +[Service] +ExecStart=/etc/X11/prefdm -nodaemon +Restart=restart-always +RestartSec=0 + +[Install] +Alias=display-manager.service diff --git a/systemd/system/rc-local.service b/systemd/system/rc-local.service new file mode 100644 index 00000000..21ecfb23 --- /dev/null +++ b/systemd/system/rc-local.service @@ -0,0 +1,16 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Local customization + +[Service] +ExecStart=/etc/rc.local start +TimeoutSec=0 +StandardOutput=tty +RemainAfterExit=yes +SysVStartPriority=99 diff --git a/systemd/system/reboot.service b/systemd/system/reboot.service new file mode 100644 index 00000000..622beb58 --- /dev/null +++ b/systemd/system/reboot.service @@ -0,0 +1,19 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=Reboot the system +DefaultDependencies=no +Requires=umount.target killall.service +After=umount.target killall.service + +[Service] +Type=oneshot +RemainAfterExit=yes +Environment=RUNLEVEL=6 +ExecStart=/etc/init.d/reboot start +StandardOutput=tty diff --git a/systemd/system/single.service b/systemd/system/single.service new file mode 100644 index 00000000..d91166b3 --- /dev/null +++ b/systemd/system/single.service @@ -0,0 +1,29 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +# See systemd.special(7) for details + +[Unit] +Description=Rescue Shell +DefaultDependencies=no +Conflicts=multi-user.target shutdown.target +After=sysinit.target +Before=multi-user.target + +[Service] +Type=simple +EnvironmentFile=/etc/sysconfig/init +Environment=HOME=/root +ExecStartPre=-/bin/plymouth --hide-splash +ExecStart=-/bin/bash -c "exec $SINGLE" +ExecStopPost=/bin/systemctl default +StandardInput=tty-force +KillMode=process-group + +# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash +# terminates cleanly. +KillSignal=SIGHUP diff --git a/systemd/system/sysinit.service b/systemd/system/sysinit.service new file mode 100644 index 00000000..860d3a34 --- /dev/null +++ b/systemd/system/sysinit.service @@ -0,0 +1,19 @@ +# This file is part of systemd. +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. + +[Unit] +Description=System Initialization +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target + +[Service] +ExecStart=/etc/rc.d/rc.sysinit +Type=forking +TimeoutSec=0 +StandardInput=tty +RemainAfterExit=yes -- cgit v1.2.1 From 59b2f505ea603ef65823615711b5adfa87795f41 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 15 Oct 2010 16:25:31 -0400 Subject: Add split-out bits of rc.sysinit and associated service files. Remove sysinit.service. Based on work by Harald Hoyer () sysinit-hack/unhack will be removed once the net hotplug stuff is fixed to not require this. --- systemd/fedora-cleanup | 58 +++++++ systemd/fedora-configure | 25 +++ systemd/fedora-init-crypto | 5 + systemd/fedora-loadmodules | 11 ++ systemd/fedora-mountall | 243 +++++++++++++++++++++++++++ systemd/fedora-readonly | 167 ++++++++++++++++++ systemd/fedora-storage-init | 42 +++++ systemd/fedora-swapon | 20 +++ systemd/system/fedora-cleanup.service | 13 ++ systemd/system/fedora-configure.service | 13 ++ systemd/system/fedora-init-crypto-1.service | 14 ++ systemd/system/fedora-init-crypto-2.service | 14 ++ systemd/system/fedora-init-crypto-3.service | 14 ++ systemd/system/fedora-loadmodules.service | 15 ++ systemd/system/fedora-mountall.service | 14 ++ systemd/system/fedora-readonly.service | 14 ++ systemd/system/fedora-storage-init.service | 13 ++ systemd/system/fedora-swapon.service | 13 ++ systemd/system/fedora-sysinit-hack.service | 10 ++ systemd/system/fedora-sysinit-unhack.service | 10 ++ systemd/system/fedora-wait-storage.service | 15 ++ systemd/system/single.service | 2 +- systemd/system/sysinit.service | 19 --- 23 files changed, 744 insertions(+), 20 deletions(-) create mode 100755 systemd/fedora-cleanup create mode 100755 systemd/fedora-configure create mode 100755 systemd/fedora-init-crypto create mode 100755 systemd/fedora-loadmodules create mode 100755 systemd/fedora-mountall create mode 100755 systemd/fedora-readonly create mode 100755 systemd/fedora-storage-init create mode 100755 systemd/fedora-swapon create mode 100644 systemd/system/fedora-cleanup.service create mode 100644 systemd/system/fedora-configure.service create mode 100644 systemd/system/fedora-init-crypto-1.service create mode 100644 systemd/system/fedora-init-crypto-2.service create mode 100644 systemd/system/fedora-init-crypto-3.service create mode 100644 systemd/system/fedora-loadmodules.service create mode 100644 systemd/system/fedora-mountall.service create mode 100644 systemd/system/fedora-readonly.service create mode 100644 systemd/system/fedora-storage-init.service create mode 100644 systemd/system/fedora-swapon.service create mode 100644 systemd/system/fedora-sysinit-hack.service create mode 100644 systemd/system/fedora-sysinit-unhack.service create mode 100644 systemd/system/fedora-wait-storage.service delete mode 100644 systemd/system/sysinit.service (limited to 'systemd') diff --git a/systemd/fedora-cleanup b/systemd/fedora-cleanup new file mode 100755 index 00000000..4f6b8c0d --- /dev/null +++ b/systemd/fedora-cleanup @@ -0,0 +1,58 @@ +#!/bin/bash +# +# Clean out various old state. +# + +SELINUX_STATE= +if [ -e "/selinux/enforce" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then + if [ -r "/selinux/enforce" ] ; then + SELINUX_STATE=$(cat "/selinux/enforce") + else + # assume enforcing if you can't read it + SELINUX_STATE=1 + fi +fi + +# Clean out /. +rm -f /fastboot /fsckoptions /forcefsck /.autofsck /forcequotacheck /halt \ + /poweroff /.suspended &> /dev/null + +# Do we need (w|u)tmpx files? We don't set them up, but the sysadmin might... +_NEED_XFILES= +[ -f /var/run/utmpx ] || [ -f /var/log/wtmpx ] && _NEED_XFILES=1 + +# Clean up /var. +rm -rf /var/lock/cvs/* /var/run/screen/* +find /var/lock /var/run ! -type d -exec rm -f {} \; +rm -f /var/lib/rpm/__db* &> /dev/null +rm -f /var/gdm/.gdmfifo &> /dev/null + +# Clean up utmp/wtmp +> /var/run/utmp +touch /var/log/wtmp /var/log/btmp +chgrp utmp /var/run/utmp /var/log/wtmp /var/log/btmp +chmod 0664 /var/run/utmp /var/log/wtmp +chmod 0600 /var/log/btmp +if [ -n "$_NEED_XFILES" ]; then + > /var/run/utmpx + touch /var/log/wtmpx + chgrp utmp /var/run/utmpx /var/log/wtmpx + chmod 0664 /var/run/utmpx /var/log/wtmpx +fi +[ -n "$SELINUX_STATE" ] && restorecon /var/run/utmp* /var/log/wtmp* >/dev/null 2>&1 + +# Clean up various /tmp bits +[ -n "$SELINUX_STATE" ] && restorecon /tmp +rm -f /tmp/.X*-lock /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.* +rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \ + /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \ + /tmp/scrollkeeper-* /tmp/ssh-* \ + /dev/.in_sysinit + +# Make ICE directory +mkdir -m 1777 -p /tmp/.ICE-unix >/dev/null 2>&1 +chown root:root /tmp/.ICE-unix +[ -n "$SELINUX_STATE" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1 + +# create the crash indicator flag to warn on crashes, offer fsck with timeout +touch /.autofsck &> /dev/null diff --git a/systemd/fedora-configure b/systemd/fedora-configure new file mode 100755 index 00000000..3a8c6dc4 --- /dev/null +++ b/systemd/fedora-configure @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Configure machine if necessary. + +. /etc/init.d/functions + +if [ -f /.unconfigured ]; then + if [ -x /usr/bin/rhgb-client ] && /usr/bin/rhgb-client --ping ; then + /usr/bin/rhgb-client --quit + fi + + if [ -x /usr/sbin/firstboot ]; then + /usr/sbin/firstboot + fi + + # Reread in network configuration data. + if [ -f /etc/sysconfig/network ]; then + . /etc/sysconfig/network + + # Reset the hostname. + action $"Resetting hostname ${HOSTNAME}: " hostname ${HOSTNAME} + fi + + rm -f /.unconfigured +fi diff --git a/systemd/fedora-init-crypto b/systemd/fedora-init-crypto new file mode 100755 index 00000000..9134d93f --- /dev/null +++ b/systemd/fedora-init-crypto @@ -0,0 +1,5 @@ +#!/bin/sh + +. /etc/init.d/functions + +[ -f /etc/crypttab ] && init_crypto $1 diff --git a/systemd/fedora-loadmodules b/systemd/fedora-loadmodules new file mode 100755 index 00000000..4fd167c4 --- /dev/null +++ b/systemd/fedora-loadmodules @@ -0,0 +1,11 @@ +#!/bin/bash + +# Load other user-defined modules +for file in /etc/sysconfig/modules/*.modules ; do + [ -x $file ] && $file +done + +# Load modules (for backward compatibility with VARs) +if [ -f /etc/rc.modules ]; then + /etc/rc.modules +fi diff --git a/systemd/fedora-mountall b/systemd/fedora-mountall new file mode 100755 index 00000000..e66c0b2b --- /dev/null +++ b/systemd/fedora-mountall @@ -0,0 +1,243 @@ +#!/bin/bash +# +# fsck, mount, set quotas, and relabel filesystems. +# + +. /etc/init.d/functions + +PLYMOUTH= +[ -x /usr/bin/plymouth ] && PLYMOUTH=yes + +# Check SELinux status +SELINUX_STATE= +if [ -e "/selinux/enforce" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then + if [ -r "/selinux/enforce" ] ; then + SELINUX_STATE=$(cat "/selinux/enforce") + else + # assume enforcing if you can't read it + SELINUX_STATE=1 + fi +fi + +disable_selinux() { + echo $"*** Warning -- SELinux is active" + echo $"*** Disabling security enforcement for system recovery." + echo $"*** Run 'setenforce 1' to reenable." + echo "0" > "/selinux/enforce" +} + +relabel_selinux() { + # if /sbin/init is not labeled correctly this process is running in the + # wrong context, so a reboot will be required after relabel + AUTORELABEL= + . /etc/selinux/config + echo "0" > /selinux/enforce + [ -n "$PLYMOUTH" ] && plymouth --hide-splash + + if [ "$AUTORELABEL" = "0" ]; then + echo + echo $"*** Warning -- SELinux ${SELINUXTYPE} policy relabel is required. " + echo $"*** /etc/selinux/config indicates you want to manually fix labeling" + echo $"*** problems. Dropping you to a shell; the system will reboot" + echo $"*** when you leave the shell." + sulogin + + else + echo + echo $"*** Warning -- SELinux ${SELINUXTYPE} policy relabel is required." + echo $"*** Relabeling could take a very long time, depending on file" + echo $"*** system size and speed of hard drives." + + /sbin/fixfiles -F restore > /dev/null 2>&1 + fi + rm -f /.autorelabel + echo $"Unmounting file systems" + umount -a + mount -n -o remount,ro / + echo $"Automatic reboot in progress." + reboot -f +} + +[ -z "${cmdline}" ] && cmdline=$(cat /proc/cmdline) + +if [ -f /fastboot ] || strstr "$cmdline" fastboot ; then + fastboot=yes +fi + +if [ -f /fsckoptions ]; then + fsckoptions=$(cat /fsckoptions) +fi + +if [ -f /forcefsck ] || strstr "$cmdline" forcefsck ; then + fsckoptions="-f $fsckoptions" +elif [ -f /.autofsck ]; then + [ -f /etc/sysconfig/autofsck ] && . /etc/sysconfig/autofsck + if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then + AUTOFSCK_OPT="$AUTOFSCK_OPT -f" + fi + if [ -n "$AUTOFSCK_SINGLEUSER" ]; then + [ -n "$PLYMOUTH" ] && plymouth --hide-splash + echo + echo $"*** Warning -- the system did not shut down cleanly. " + echo $"*** Dropping you to a shell; the system will continue" + echo $"*** when you leave the shell." + [ -n "$SELINUX_STATE" ] && echo "0" > /selinux/enforce + sulogin + [ -n "$SELINUX_STATE" ] && echo "1" > /selinux/enforce + [ -n "$PLYMOUTH" ] && plymouth --show-splash + fi + fsckoptions="$AUTOFSCK_OPT $fsckoptions" +fi + +if [ "$BOOTUP" = "color" ]; then + fsckoptions="-C $fsckoptions" +else + fsckoptions="-V $fsckoptions" +fi + +READONLY= +if [ -f /etc/sysconfig/readonly-root ]; then + . /etc/sysconfig/readonly-root +fi +if strstr "$cmdline" readonlyroot ; then + READONLY=yes + [ -z "$RW_MOUNT" ] && RW_MOUNT=/var/lib/stateless/writable + [ -z "$STATE_MOUNT" ] && STATE_MOUNT=/var/lib/stateless/state +fi +if strstr "$cmdline" noreadonlyroot ; then + READONLY=no +fi + +if [[ " $fsckoptions" != *" -y"* ]]; then + fsckoptions="-a $fsckoptions" +fi + +_RUN_QUOTACHECK=0 +if strstr "$cmdline" forcequotacheck || [ -f /forcequotacheck ] ; then + _RUN_QUOTACHECK=1 +fi +if [ -z "$fastboot" -a "$READONLY" != "yes" ]; then + + STRING=$"Checking filesystems" + echo $STRING + fsck -T -t noopts=_netdev -A $fsckoptions + rc=$? + + if [ "$rc" -eq "0" ]; then + success "$STRING" + echo + elif [ "$rc" -eq "1" ]; then + passed "$STRING" + echo + elif [ "$rc" -eq "2" -o "$rc" -eq "3" ]; then + echo $"Unmounting file systems" + umount -a + mount -n -o remount,ro / + echo $"Automatic reboot in progress." + reboot -f + fi + + # A return of 4 or higher means there were serious problems. + if [ $rc -gt 1 ]; then + [ -n "$PLYMOUTH" ] && plymouth --hide-splash + + failure "$STRING" + echo + echo + echo $"*** An error occurred during the file system check." + echo $"*** Dropping you to a shell; the system will reboot" + echo $"*** when you leave the shell." + + str=$"(Repair filesystem)" + PS1="$str \# # "; export PS1 + [ "$SELINUX_STATE" = "1" ] && disable_selinux + sulogin + + echo $"Unmounting file systems" + umount -a + mount -n -o remount,ro / + echo $"Automatic reboot in progress." + reboot -f + elif [ "$rc" -eq "1" ]; then + _RUN_QUOTACHECK=1 + fi +fi + +remount_needed() { + local state oldifs + [ "$READONLY" = "yes" ] && return 1 + state=$(LC_ALL=C awk '/ \/ / && ($3 !~ /rootfs/) { print $4 }' /proc/mounts) + oldifs=$IFS + IFS="," + for opt in $state ; do + if [ "$opt" = "rw" ]; then + IFS=$oldifs + return 1 + fi + done + IFS=$oldifs + return 0 +} + +# Remount the root filesystem read-write. +update_boot_stage RCmountfs +if remount_needed ; then + action $"Remounting root filesystem in read-write mode: " mount -n -o remount,rw / +fi + +# Clean up SELinux labels +if [ -n "$SELINUX_STATE" ]; then + restorecon /etc/mtab /etc/ld.so.cache /etc/blkid/blkid.tab /etc/resolv.conf >/dev/null 2>&1 +fi + +# If relabeling, relabel mount points. +if [ -n "$SELINUX_STATE" -a "$READONLY" != "yes" ]; then + if strstr "$cmdline" autorelabel || [ -f /.autorelabel ] ; then + restorecon $(awk '!/^#/ && $4 !~ /noauto/ && $2 ~ /^\// { print $2 }' /etc/fstab) >/dev/null 2>&1 + fi +fi + +if [ "$READONLY" != "yes" ] ; then + # Clear mtab + (> /etc/mtab) &> /dev/null + + # Remove stale backups + rm -f /etc/mtab~ /etc/mtab~~ + + # Enter mounted filesystems into /etc/mtab + mount -f / + mount -f /proc >/dev/null 2>&1 + mount -f /sys >/dev/null 2>&1 + mount -f /dev/pts >/dev/null 2>&1 + mount -f /dev/shm >/dev/null 2>&1 + mount -f /proc/bus/usb >/dev/null 2>&1 +fi + +# Mount all other filesystems (except for NFS and /proc, which is already +# mounted). Contrary to standard usage, +# filesystems are NOT unmounted in single user mode. +if [ "$READONLY" != "yes" ] ; then + action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev +else + action $"Mounting local filesystems: " mount -a -n -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev +fi + +# Update quotas if necessary +if [ X"$_RUN_QUOTACHECK" = X1 ] && [ -x /sbin/quotacheck ]; then + action $"Checking local filesystem quotas: " /sbin/quotacheck -anug +fi + +if [ -x /sbin/quotaon ]; then + action $"Enabling local filesystem quotas: " /sbin/quotaon -aug +fi + +# Check to see if a full relabel is needed +if [ -n "$SELINUX_STATE" -a "$READONLY" != "yes" ]; then + if strstr "$cmdline" autorelabel || [ -f /.autorelabel ] ; then + relabel_selinux + fi +else + if [ "$READONLY" != "yes" ] && [ -d /etc/selinux ]; then + [ -f /.autorelabel ] || touch /.autorelabel + fi +fi diff --git a/systemd/fedora-readonly b/systemd/fedora-readonly new file mode 100755 index 00000000..70e57a62 --- /dev/null +++ b/systemd/fedora-readonly @@ -0,0 +1,167 @@ +#!/bin/bash +# +# Set up readonly-root support. +# + +. /etc/init.d/functions + +# Check SELinux status +SELINUX_STATE= +if [ -e "/selinux/enforce" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then + if [ -r "/selinux/enforce" ] ; then + SELINUX_STATE=$(cat "/selinux/enforce") + else + # assume enforcing if you can't read it + SELINUX_STATE=1 + fi +fi + +# Only read this once. +[ -z "${cmdline}" ] && cmdline=$(cat /proc/cmdline) + +READONLY= +if [ -f /etc/sysconfig/readonly-root ]; then + . /etc/sysconfig/readonly-root +fi +if strstr "$cmdline" readonlyroot ; then + READONLY=yes + [ -z "$RW_MOUNT" ] && RW_MOUNT=/var/lib/stateless/writable + [ -z "$STATE_MOUNT" ] && STATE_MOUNT=/var/lib/stateless/state +fi +if strstr "$cmdline" noreadonlyroot ; then + READONLY=no +fi + +if [ "$READONLY" = "yes" -o "$TEMPORARY_STATE" = "yes" ]; then + + mount_empty() { + if [ -e "$1" ]; then + echo "$1" | cpio -p -vd "$RW_MOUNT" &>/dev/null + mount -n --bind "$RW_MOUNT$1" "$1" + fi + } + + mount_dirs() { + if [ -e "$1" ]; then + mkdir -p "$RW_MOUNT$1" + find "$1" -type d -print0 | cpio -p -0vd "$RW_MOUNT" &>/dev/null + mount -n --bind "$RW_MOUNT$1" "$1" + fi + } + + mount_files() { + if [ -e "$1" ]; then + cp -a --parents "$1" "$RW_MOUNT" + mount -n --bind "$RW_MOUNT$1" "$1" + fi + } + + # Common mount options for scratch space regardless of + # type of backing store + mountopts= + + # Scan partitions for local scratch storage + rw_mount_dev=$(blkid -t LABEL="$RW_LABEL" -l -o device) + + # First try to mount scratch storage from /etc/fstab, then any + # partition with the proper label. If either succeeds, be sure + # to wipe the scratch storage clean. If both fail, then mount + # scratch storage via tmpfs. + if mount $mountopts "$RW_MOUNT" > /dev/null 2>&1 ; then + rm -rf "$RW_MOUNT" > /dev/null 2>&1 + elif [ x$rw_mount_dev != x ] && mount $rw_mount_dev $mountopts "$RW_MOUNT" > /dev/null 2>&1; then + rm -rf "$RW_MOUNT" > /dev/null 2>&1 + else + mount -n -t tmpfs $RW_OPTIONS $mountopts none "$RW_MOUNT" + fi + + for file in /etc/rwtab /etc/rwtab.d/* /dev/.initramfs/rwtab ; do + is_ignored_file "$file" && continue + [ -f $file ] && cat $file | while read type path ; do + case "$type" in + empty) + mount_empty $path + ;; + files) + mount_files $path + ;; + dirs) + mount_dirs $path + ;; + *) + ;; + esac + [ -n "$SELINUX_STATE" ] && [ -e "$path" ] && restorecon -R "$path" + done + done + + # Use any state passed by initramfs + [ -d /dev/.initramfs/state ] && cp -a /dev/.initramfs/state/* $RW_MOUNT + + # In theory there should be no more than one network interface active + # this early in the boot process -- the one we're booting from. + # Use the network address to set the hostname of the client. This + # must be done even if we have local storage. + ipaddr= + if [ "$HOSTNAME" = "localhost" -o "$HOSTNAME" = "localhost.localdomain" ]; then + ipaddr=$(ip addr show to 0.0.0.0/0 scope global | awk '/[[:space:]]inet / { print gensub("/.*","","g",$2) }') + for ip in $ipaddr ; do + HOSTNAME= + eval $(ipcalc -h $ipaddr 2>/dev/null) + [ -n "$HOSTNAME" ] && { hostname ${HOSTNAME} ; break; } + done + fi + + # Clients with read-only root filesystems may be provided with a + # place where they can place minimal amounts of persistent + # state. SSH keys or puppet certificates for example. + # + # Ideally we'll use puppet to manage the state directory and to + # create the bind mounts. However, until that's all ready this + # is sufficient to build a working system. + + # First try to mount persistent data from /etc/fstab, then any + # partition with the proper label, then fallback to NFS + state_mount_dev=$(blkid -t LABEL="$STATE_LABEL" -l -o device) + if mount $mountopts $STATE_OPTIONS "$STATE_MOUNT" > /dev/null 2>&1 ; then + /bin/true + elif [ x$state_mount_dev != x ] && mount $state_mount_dev $mountopts "$STATE_MOUNT" > /dev/null 2>&1; then + /bin/true + elif [ ! -z "$CLIENTSTATE" ]; then + # No local storage was found. Make a final attempt to find + # state on an NFS server. + + mount -t nfs $CLIENTSTATE/$HOSTNAME $STATE_MOUNT -o rw,nolock + fi + + if [ -w "$STATE_MOUNT" ]; then + + mount_state() { + if [ -e "$1" ]; then + [ ! -e "$STATE_MOUNT$1" ] && cp -a --parents "$1" "$STATE_MOUNT" + mount -n --bind "$STATE_MOUNT$1" "$1" + fi + } + + for file in /etc/statetab /etc/statetab.d/* ; do + is_ignored_file "$file" && continue + [ ! -f "$file" ] && continue + + if [ -f "$STATE_MOUNT/$file" ] ; then + mount -n --bind "$STATE_MOUNT/$file" "$file" + fi + + for path in $(grep -v "^#" "$file" 2>/dev/null); do + mount_state "$path" + [ -n "$SELINUX_STATE" ] && [ -e "$path" ] && restorecon -R "$path" + done + done + + if [ -f "$STATE_MOUNT/files" ] ; then + for path in $(grep -v "^#" "$STATE_MOUNT/files" 2>/dev/null); do + mount_state "$path" + [ -n "$SELINUX_STATE" ] && [ -e "$path" ] && restorecon -R "$path" + done + fi + fi +fi diff --git a/systemd/fedora-storage-init b/systemd/fedora-storage-init new file mode 100755 index 00000000..a9c12769 --- /dev/null +++ b/systemd/fedora-storage-init @@ -0,0 +1,42 @@ +#!/bin/bash +# +# Storage initialization + +. /etc/init.d/functions + +[ -z "${cmdline}" ] && cmdline=$(cat /proc/cmdline) + +[ -f /etc/crypttab ] && init_crypto 0 + +if ! strstr "$cmdline" nompath && [ -f /etc/multipath.conf ] && \ + [ -x /sbin/multipath ]; then + modprobe dm-multipath > /dev/null 2>&1 + /sbin/multipath -v 0 + if [ -x /sbin/kpartx ]; then + /sbin/dmsetup ls --target multipath --exec "/sbin/kpartx -a -p p" >/dev/null + fi +fi + +if ! strstr "$cmdline" nodmraid && [ -x /sbin/dmraid ]; then + modprobe dm-mirror >/dev/null 2>&1 + dmraidsets=$(LC_ALL=C /sbin/dmraid -s -c -i) + if [ "$?" = "0" ]; then + for dmname in $dmraidsets; do + if [[ "$dmname" == isw_* ]] && \ + ! strstr "$cmdline" noiswmd; then + continue + fi + /sbin/dmraid -ay -i --rm_partitions -p "$dmname" >/dev/null 2>&1 + /sbin/kpartx -a -p p "/dev/mapper/$dmname" + done + fi +fi + +# Start any MD RAID arrays that haven't been started yet +[ -r /proc/mdstat -a -r /dev/md/md-device-map ] && /sbin/mdadm -IRs + +if [ -x /sbin/lvm ]; then + action $"Setting up Logical Volume Management:" /sbin/lvm vgchange -a y --sysinit +fi + +[ -f /etc/crypttab ] && init_crypto 0 diff --git a/systemd/fedora-swapon b/systemd/fedora-swapon new file mode 100755 index 00000000..98c5b273 --- /dev/null +++ b/systemd/fedora-swapon @@ -0,0 +1,20 @@ +#!/bin/bash +# +# Start up swap (partitions and files) +# + +. /etc/init.d/functions + +update_boot_stage RCswap +action $"Enabling /etc/fstab swaps: " swapon -a -e +if [ "$AUTOSWAP" = "yes" ]; then + curswap=$(awk '/^\/dev/ { print $1 }' /proc/swaps | while read x; do get_numeric_dev dec $x ; echo -n " "; done) + swappartitions=$(blkid -t TYPE=swap -o device) + if [ x"$swappartitions" != x ]; then + for partition in $swappartitions ; do + [ ! -e $partition ] && continue + majmin=$(get_numeric_dev dec $partition) + echo $curswap | grep -qw "$majmin" || action $"Enabling local swap partitions: " swapon $partition + done + fi +fi diff --git a/systemd/system/fedora-cleanup.service b/systemd/system/fedora-cleanup.service new file mode 100644 index 00000000..127fab64 --- /dev/null +++ b/systemd/system/fedora-cleanup.service @@ -0,0 +1,13 @@ +[Unit] +Description=Clean out assorted temporary files +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target +After=fedora-mountall.service fedora-readonly.service +Requires=fedora-mountall.service + +[Service] +ExecStart=/lib/systemd/fedora-cleanup +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes diff --git a/systemd/system/fedora-configure.service b/systemd/system/fedora-configure.service new file mode 100644 index 00000000..032e94ae --- /dev/null +++ b/systemd/system/fedora-configure.service @@ -0,0 +1,13 @@ +[Unit] +Description=Reconfigure the system on administrator request +DefaultDependencies=no +Conflicts=multi-user.target shutdown.target +Before=multi-user.target shutdown.target +After=local-fs.target + +[Service] +ExecStart=/lib/systemd/fedora-configure +Type=oneshot +TimeoutSec=0 +StandardInput=tty +RemainAfterExit=yes diff --git a/systemd/system/fedora-init-crypto-1.service b/systemd/system/fedora-init-crypto-1.service new file mode 100644 index 00000000..fee6bcce --- /dev/null +++ b/systemd/system/fedora-init-crypto-1.service @@ -0,0 +1,14 @@ +[Unit] +Description=Initialize encrypted storage +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target +After=fedora-wait-storage.service +Requires=fedora-wait-storage.service + +[Service] +ExecStart=/lib/systemd/fedora-init-crypto 0 +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes +StandardInput=tty diff --git a/systemd/system/fedora-init-crypto-2.service b/systemd/system/fedora-init-crypto-2.service new file mode 100644 index 00000000..2fc128eb --- /dev/null +++ b/systemd/system/fedora-init-crypto-2.service @@ -0,0 +1,14 @@ +[Unit] +Description=Initialize encrypted filesystems on top of other storage +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target +After=fedora-storage-init.service +Requires=fedora-storage-init.service + +[Service] +ExecStart=/lib/systemd/fedora-init-crypto 0 +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes +StandardInput=tty diff --git a/systemd/system/fedora-init-crypto-3.service b/systemd/system/fedora-init-crypto-3.service new file mode 100644 index 00000000..08d3bf96 --- /dev/null +++ b/systemd/system/fedora-init-crypto-3.service @@ -0,0 +1,14 @@ +[Unit] +Description=Initialize encrypted filesystems on top of other storage +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target +After=systemd-random-seed-load.service +Requires=systemd-random-seed-load.service + +[Service] +ExecStart=/lib/systemd/fedora-init-crypto 1 +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes +StandardInput=tty diff --git a/systemd/system/fedora-loadmodules.service b/systemd/system/fedora-loadmodules.service new file mode 100644 index 00000000..aac773b8 --- /dev/null +++ b/systemd/system/fedora-loadmodules.service @@ -0,0 +1,15 @@ +[Unit] +Description=Load legacy module configuration +DefaultDependencies=no +Conflicts=shutdown.target +Before=basic.target shutdown.target emergency.service emergency.target +#Conflicts=sysinit.service +After=udev.service +Requires=udev.service + +[Service] +ExecStart=/lib/systemd/fedora-loadmodules +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes + diff --git a/systemd/system/fedora-mountall.service b/systemd/system/fedora-mountall.service new file mode 100644 index 00000000..af5cf79b --- /dev/null +++ b/systemd/system/fedora-mountall.service @@ -0,0 +1,14 @@ +[Unit] +Description=Check, mount, and relabel all filesystems +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target remount-rootfs.service +After=fedora-storage-init.service fedora-init-crypto-2.service +Requires=fedora-storage-init.service fedora-init-crypto-2.service + +[Service] +ExecStart=/lib/systemd/fedora-mountall +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes +StandardInput=tty diff --git a/systemd/system/fedora-readonly.service b/systemd/system/fedora-readonly.service new file mode 100644 index 00000000..c1e42367 --- /dev/null +++ b/systemd/system/fedora-readonly.service @@ -0,0 +1,14 @@ +[Unit] +Description=Configure read-only root support +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target fedora-cleanup.service +After=fedora-mountall.service +Requires=fedora-mountall.service + +[Service] +ExecStart=/lib/systemd/fedora-readonly +Type=oneshot +TimeoutSec=0 +StandardInput=tty +RemainAfterExit=yes diff --git a/systemd/system/fedora-storage-init.service b/systemd/system/fedora-storage-init.service new file mode 100644 index 00000000..2806c2dd --- /dev/null +++ b/systemd/system/fedora-storage-init.service @@ -0,0 +1,13 @@ +[Unit] +Description=Initialize storage subsystems (RAID, LVM, etc.) +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target local-fs.target emergency.service emergency.target +After=fedora-wait-storage.service fedora-init-crypto-1.service +Requires=fedora-wait-storage.service fedora-init-crypto-1.service + +[Service] +ExecStart=/lib/systemd/fedora-storage-init +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes diff --git a/systemd/system/fedora-swapon.service b/systemd/system/fedora-swapon.service new file mode 100644 index 00000000..4b945026 --- /dev/null +++ b/systemd/system/fedora-swapon.service @@ -0,0 +1,13 @@ +[Unit] +Description=Configure the system if the administrator requested it +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target +After=fedora-mountall.service fedora-init-crypto-3.service +Requires=fedora-mountall.service fedora-init-crypto-3.service + +[Service] +ExecStart=/lib/systemd/fedora-swapon +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes diff --git a/systemd/system/fedora-sysinit-hack.service b/systemd/system/fedora-sysinit-hack.service new file mode 100644 index 00000000..dd78da80 --- /dev/null +++ b/systemd/system/fedora-sysinit-hack.service @@ -0,0 +1,10 @@ +[Unit] +Description=Bootup hack +DefaultDependencies=no +Conflicts=shutdown.target +Before=basic.target shutdown.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/touch /dev/.in_sysinit diff --git a/systemd/system/fedora-sysinit-unhack.service b/systemd/system/fedora-sysinit-unhack.service new file mode 100644 index 00000000..86e20cd6 --- /dev/null +++ b/systemd/system/fedora-sysinit-unhack.service @@ -0,0 +1,10 @@ +[Unit] +Description=Bootup hack +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=-/bin/rm -f /dev/.in_sysinit diff --git a/systemd/system/fedora-wait-storage.service b/systemd/system/fedora-wait-storage.service new file mode 100644 index 00000000..63744b63 --- /dev/null +++ b/systemd/system/fedora-wait-storage.service @@ -0,0 +1,15 @@ +[Unit] +Description=Wait for storage scan +DefaultDependencies=no +Conflicts=shutdown.target +Before=local-fs.target shutdown.target emergency.service emergency.target +After=udev-settle.service +Requires=udev.service udev-settle.service + +[Service] +ExecStart=-/sbin/rmmod scsi_wait_scan +ExecStart=-/sbin/modprobe scsi_wait_scan +ExecStart=-/sbin/rmmod scsi_wait_scan +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes diff --git a/systemd/system/single.service b/systemd/system/single.service index d91166b3..4264cd56 100644 --- a/systemd/system/single.service +++ b/systemd/system/single.service @@ -11,7 +11,7 @@ Description=Rescue Shell DefaultDependencies=no Conflicts=multi-user.target shutdown.target -After=sysinit.target +After=basic.target Before=multi-user.target [Service] diff --git a/systemd/system/sysinit.service b/systemd/system/sysinit.service deleted file mode 100644 index 860d3a34..00000000 --- a/systemd/system/sysinit.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=System Initialization -DefaultDependencies=no -Conflicts=shutdown.target -Before=shutdown.target emergency.service emergency.target - -[Service] -ExecStart=/etc/rc.d/rc.sysinit -Type=forking -TimeoutSec=0 -StandardInput=tty -RemainAfterExit=yes -- cgit v1.2.1 From cc08cf0ffe30d0564c7517ffcee2401121f17917 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 15 Oct 2010 17:07:51 -0400 Subject: Add a basic sysint service that is After: local-fs so that sockets still work. This is a workaround for https://bugs.freedesktop.org/show_bug.cgi?id=30913 --- systemd/system/sysinit.service | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 systemd/system/sysinit.service (limited to 'systemd') diff --git a/systemd/system/sysinit.service b/systemd/system/sysinit.service new file mode 100644 index 00000000..9b0ccf77 --- /dev/null +++ b/systemd/system/sysinit.service @@ -0,0 +1,13 @@ + +[Unit] +Description=System Initialization +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target +After=local-fs.target + +[Service] +ExecStart=/bin/true +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes -- cgit v1.2.1 From 2811a2c7d76aca4ef10c8d5e9fcee18204e6ede8 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 15 Oct 2010 22:47:56 -0400 Subject: Adjust for current syntax. --- systemd/system/prefdm.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'systemd') diff --git a/systemd/system/prefdm.service b/systemd/system/prefdm.service index 60a5ed05..2e2396d7 100644 --- a/systemd/system/prefdm.service +++ b/systemd/system/prefdm.service @@ -15,7 +15,7 @@ Conflicts=getty@tty1.service plymouth-quit.service [Service] ExecStart=/etc/X11/prefdm -nodaemon -Restart=restart-always +Restart=always RestartSec=0 [Install] -- cgit v1.2.1 From 2d238bd89255740f308f51a50b4cfae2c713293f Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 15 Oct 2010 23:09:56 -0400 Subject: Don't have sysinit be after local-fs, that way lie loops. Assume https://bugs.freedesktop.org/show_bug.cgi?id=30913 will be fixed in systemd. --- systemd/system/fedora-cleanup.service | 2 +- systemd/system/sysinit.service | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'systemd') diff --git a/systemd/system/fedora-cleanup.service b/systemd/system/fedora-cleanup.service index 127fab64..3bbb12df 100644 --- a/systemd/system/fedora-cleanup.service +++ b/systemd/system/fedora-cleanup.service @@ -2,7 +2,7 @@ Description=Clean out assorted temporary files DefaultDependencies=no Conflicts=shutdown.target -Before=shutdown.target emergency.service emergency.target +Before=shutdown.target emergency.service emergency.target local-fs.target After=fedora-mountall.service fedora-readonly.service Requires=fedora-mountall.service diff --git a/systemd/system/sysinit.service b/systemd/system/sysinit.service index 9b0ccf77..54e9ffac 100644 --- a/systemd/system/sysinit.service +++ b/systemd/system/sysinit.service @@ -1,13 +1,10 @@ - [Unit] -Description=System Initialization +Description=System initialization placeholder DefaultDependencies=no Conflicts=shutdown.target Before=shutdown.target emergency.service emergency.target -After=local-fs.target [Service] ExecStart=/bin/true Type=oneshot -TimeoutSec=0 RemainAfterExit=yes -- cgit v1.2.1 From 588fadded55c6d808b5a2b076da87d32a7b885e6 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 15 Oct 2010 23:20:15 -0400 Subject: Use systemd's support for normal swapon; only handle autoswap here. --- systemd/fedora-autoswap | 18 ++++++++++++++++++ systemd/fedora-swapon | 20 -------------------- systemd/system/fedora-autoswap.service | 13 +++++++++++++ systemd/system/fedora-swapon.service | 13 ------------- 4 files changed, 31 insertions(+), 33 deletions(-) create mode 100755 systemd/fedora-autoswap delete mode 100755 systemd/fedora-swapon create mode 100644 systemd/system/fedora-autoswap.service delete mode 100644 systemd/system/fedora-swapon.service (limited to 'systemd') diff --git a/systemd/fedora-autoswap b/systemd/fedora-autoswap new file mode 100755 index 00000000..ea392909 --- /dev/null +++ b/systemd/fedora-autoswap @@ -0,0 +1,18 @@ +#!/bin/bash +# +# Support automatic swapon. +# + +. /etc/init.d/functions + +if [ "$AUTOSWAP" = "yes" ]; then + curswap=$(awk '/^\/dev/ { print $1 }' /proc/swaps | while read x; do get_numeric_dev dec $x ; echo -n " "; done) + swappartitions=$(blkid -t TYPE=swap -o device) + if [ x"$swappartitions" != x ]; then + for partition in $swappartitions ; do + [ ! -e $partition ] && continue + majmin=$(get_numeric_dev dec $partition) + echo $curswap | grep -qw "$majmin" || action $"Enabling local swap partitions: " swapon $partition + done + fi +fi diff --git a/systemd/fedora-swapon b/systemd/fedora-swapon deleted file mode 100755 index 98c5b273..00000000 --- a/systemd/fedora-swapon +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Start up swap (partitions and files) -# - -. /etc/init.d/functions - -update_boot_stage RCswap -action $"Enabling /etc/fstab swaps: " swapon -a -e -if [ "$AUTOSWAP" = "yes" ]; then - curswap=$(awk '/^\/dev/ { print $1 }' /proc/swaps | while read x; do get_numeric_dev dec $x ; echo -n " "; done) - swappartitions=$(blkid -t TYPE=swap -o device) - if [ x"$swappartitions" != x ]; then - for partition in $swappartitions ; do - [ ! -e $partition ] && continue - majmin=$(get_numeric_dev dec $partition) - echo $curswap | grep -qw "$majmin" || action $"Enabling local swap partitions: " swapon $partition - done - fi -fi diff --git a/systemd/system/fedora-autoswap.service b/systemd/system/fedora-autoswap.service new file mode 100644 index 00000000..c5087967 --- /dev/null +++ b/systemd/system/fedora-autoswap.service @@ -0,0 +1,13 @@ +[Unit] +Description=Enable all detected swap partitions +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target +After=fedora-mountall.service fedora-init-crypto-3.service +Requires=fedora-mountall.service fedora-init-crypto-3.service + +[Service] +ExecStart=/lib/systemd/fedora-autoswap +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes diff --git a/systemd/system/fedora-swapon.service b/systemd/system/fedora-swapon.service deleted file mode 100644 index 4b945026..00000000 --- a/systemd/system/fedora-swapon.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Configure the system if the administrator requested it -DefaultDependencies=no -Conflicts=shutdown.target -Before=shutdown.target emergency.service emergency.target -After=fedora-mountall.service fedora-init-crypto-3.service -Requires=fedora-mountall.service fedora-init-crypto-3.service - -[Service] -ExecStart=/lib/systemd/fedora-swapon -Type=oneshot -TimeoutSec=0 -RemainAfterExit=yes -- cgit v1.2.1 From 0ca2d13cc3ea75ffcabd5124d250fa1754d111bb Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 22 Oct 2010 13:20:53 -0400 Subject: Always succeed if /etc/crypttab isn't there. --- systemd/fedora-init-crypto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'systemd') diff --git a/systemd/fedora-init-crypto b/systemd/fedora-init-crypto index 9134d93f..1f707aec 100755 --- a/systemd/fedora-init-crypto +++ b/systemd/fedora-init-crypto @@ -2,4 +2,4 @@ . /etc/init.d/functions -[ -f /etc/crypttab ] && init_crypto $1 +[ -f /etc/crypttab ] && init_crypto $1 || : -- cgit v1.2.1 From 7577c483e62806140a278d2eb9147ce835893f7c Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 26 Oct 2010 15:21:05 -0400 Subject: Drop fedora-mountall, fedora-cleanup. Adjust other services accordingly. systemd can do mount & fsck & quota, etc. now. --- systemd/fedora-cleanup | 58 -------- systemd/fedora-mountall | 243 --------------------------------- systemd/system/fedora-autoswap.service | 4 +- systemd/system/fedora-cleanup.service | 13 -- systemd/system/fedora-mountall.service | 14 -- systemd/system/fedora-readonly.service | 5 +- 6 files changed, 4 insertions(+), 333 deletions(-) delete mode 100755 systemd/fedora-cleanup delete mode 100755 systemd/fedora-mountall delete mode 100644 systemd/system/fedora-cleanup.service delete mode 100644 systemd/system/fedora-mountall.service (limited to 'systemd') diff --git a/systemd/fedora-cleanup b/systemd/fedora-cleanup deleted file mode 100755 index 4f6b8c0d..00000000 --- a/systemd/fedora-cleanup +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# -# Clean out various old state. -# - -SELINUX_STATE= -if [ -e "/selinux/enforce" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then - if [ -r "/selinux/enforce" ] ; then - SELINUX_STATE=$(cat "/selinux/enforce") - else - # assume enforcing if you can't read it - SELINUX_STATE=1 - fi -fi - -# Clean out /. -rm -f /fastboot /fsckoptions /forcefsck /.autofsck /forcequotacheck /halt \ - /poweroff /.suspended &> /dev/null - -# Do we need (w|u)tmpx files? We don't set them up, but the sysadmin might... -_NEED_XFILES= -[ -f /var/run/utmpx ] || [ -f /var/log/wtmpx ] && _NEED_XFILES=1 - -# Clean up /var. -rm -rf /var/lock/cvs/* /var/run/screen/* -find /var/lock /var/run ! -type d -exec rm -f {} \; -rm -f /var/lib/rpm/__db* &> /dev/null -rm -f /var/gdm/.gdmfifo &> /dev/null - -# Clean up utmp/wtmp -> /var/run/utmp -touch /var/log/wtmp /var/log/btmp -chgrp utmp /var/run/utmp /var/log/wtmp /var/log/btmp -chmod 0664 /var/run/utmp /var/log/wtmp -chmod 0600 /var/log/btmp -if [ -n "$_NEED_XFILES" ]; then - > /var/run/utmpx - touch /var/log/wtmpx - chgrp utmp /var/run/utmpx /var/log/wtmpx - chmod 0664 /var/run/utmpx /var/log/wtmpx -fi -[ -n "$SELINUX_STATE" ] && restorecon /var/run/utmp* /var/log/wtmp* >/dev/null 2>&1 - -# Clean up various /tmp bits -[ -n "$SELINUX_STATE" ] && restorecon /tmp -rm -f /tmp/.X*-lock /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.* -rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \ - /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \ - /tmp/scrollkeeper-* /tmp/ssh-* \ - /dev/.in_sysinit - -# Make ICE directory -mkdir -m 1777 -p /tmp/.ICE-unix >/dev/null 2>&1 -chown root:root /tmp/.ICE-unix -[ -n "$SELINUX_STATE" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1 - -# create the crash indicator flag to warn on crashes, offer fsck with timeout -touch /.autofsck &> /dev/null diff --git a/systemd/fedora-mountall b/systemd/fedora-mountall deleted file mode 100755 index e66c0b2b..00000000 --- a/systemd/fedora-mountall +++ /dev/null @@ -1,243 +0,0 @@ -#!/bin/bash -# -# fsck, mount, set quotas, and relabel filesystems. -# - -. /etc/init.d/functions - -PLYMOUTH= -[ -x /usr/bin/plymouth ] && PLYMOUTH=yes - -# Check SELinux status -SELINUX_STATE= -if [ -e "/selinux/enforce" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then - if [ -r "/selinux/enforce" ] ; then - SELINUX_STATE=$(cat "/selinux/enforce") - else - # assume enforcing if you can't read it - SELINUX_STATE=1 - fi -fi - -disable_selinux() { - echo $"*** Warning -- SELinux is active" - echo $"*** Disabling security enforcement for system recovery." - echo $"*** Run 'setenforce 1' to reenable." - echo "0" > "/selinux/enforce" -} - -relabel_selinux() { - # if /sbin/init is not labeled correctly this process is running in the - # wrong context, so a reboot will be required after relabel - AUTORELABEL= - . /etc/selinux/config - echo "0" > /selinux/enforce - [ -n "$PLYMOUTH" ] && plymouth --hide-splash - - if [ "$AUTORELABEL" = "0" ]; then - echo - echo $"*** Warning -- SELinux ${SELINUXTYPE} policy relabel is required. " - echo $"*** /etc/selinux/config indicates you want to manually fix labeling" - echo $"*** problems. Dropping you to a shell; the system will reboot" - echo $"*** when you leave the shell." - sulogin - - else - echo - echo $"*** Warning -- SELinux ${SELINUXTYPE} policy relabel is required." - echo $"*** Relabeling could take a very long time, depending on file" - echo $"*** system size and speed of hard drives." - - /sbin/fixfiles -F restore > /dev/null 2>&1 - fi - rm -f /.autorelabel - echo $"Unmounting file systems" - umount -a - mount -n -o remount,ro / - echo $"Automatic reboot in progress." - reboot -f -} - -[ -z "${cmdline}" ] && cmdline=$(cat /proc/cmdline) - -if [ -f /fastboot ] || strstr "$cmdline" fastboot ; then - fastboot=yes -fi - -if [ -f /fsckoptions ]; then - fsckoptions=$(cat /fsckoptions) -fi - -if [ -f /forcefsck ] || strstr "$cmdline" forcefsck ; then - fsckoptions="-f $fsckoptions" -elif [ -f /.autofsck ]; then - [ -f /etc/sysconfig/autofsck ] && . /etc/sysconfig/autofsck - if [ "$AUTOFSCK_DEF_CHECK" = "yes" ]; then - AUTOFSCK_OPT="$AUTOFSCK_OPT -f" - fi - if [ -n "$AUTOFSCK_SINGLEUSER" ]; then - [ -n "$PLYMOUTH" ] && plymouth --hide-splash - echo - echo $"*** Warning -- the system did not shut down cleanly. " - echo $"*** Dropping you to a shell; the system will continue" - echo $"*** when you leave the shell." - [ -n "$SELINUX_STATE" ] && echo "0" > /selinux/enforce - sulogin - [ -n "$SELINUX_STATE" ] && echo "1" > /selinux/enforce - [ -n "$PLYMOUTH" ] && plymouth --show-splash - fi - fsckoptions="$AUTOFSCK_OPT $fsckoptions" -fi - -if [ "$BOOTUP" = "color" ]; then - fsckoptions="-C $fsckoptions" -else - fsckoptions="-V $fsckoptions" -fi - -READONLY= -if [ -f /etc/sysconfig/readonly-root ]; then - . /etc/sysconfig/readonly-root -fi -if strstr "$cmdline" readonlyroot ; then - READONLY=yes - [ -z "$RW_MOUNT" ] && RW_MOUNT=/var/lib/stateless/writable - [ -z "$STATE_MOUNT" ] && STATE_MOUNT=/var/lib/stateless/state -fi -if strstr "$cmdline" noreadonlyroot ; then - READONLY=no -fi - -if [[ " $fsckoptions" != *" -y"* ]]; then - fsckoptions="-a $fsckoptions" -fi - -_RUN_QUOTACHECK=0 -if strstr "$cmdline" forcequotacheck || [ -f /forcequotacheck ] ; then - _RUN_QUOTACHECK=1 -fi -if [ -z "$fastboot" -a "$READONLY" != "yes" ]; then - - STRING=$"Checking filesystems" - echo $STRING - fsck -T -t noopts=_netdev -A $fsckoptions - rc=$? - - if [ "$rc" -eq "0" ]; then - success "$STRING" - echo - elif [ "$rc" -eq "1" ]; then - passed "$STRING" - echo - elif [ "$rc" -eq "2" -o "$rc" -eq "3" ]; then - echo $"Unmounting file systems" - umount -a - mount -n -o remount,ro / - echo $"Automatic reboot in progress." - reboot -f - fi - - # A return of 4 or higher means there were serious problems. - if [ $rc -gt 1 ]; then - [ -n "$PLYMOUTH" ] && plymouth --hide-splash - - failure "$STRING" - echo - echo - echo $"*** An error occurred during the file system check." - echo $"*** Dropping you to a shell; the system will reboot" - echo $"*** when you leave the shell." - - str=$"(Repair filesystem)" - PS1="$str \# # "; export PS1 - [ "$SELINUX_STATE" = "1" ] && disable_selinux - sulogin - - echo $"Unmounting file systems" - umount -a - mount -n -o remount,ro / - echo $"Automatic reboot in progress." - reboot -f - elif [ "$rc" -eq "1" ]; then - _RUN_QUOTACHECK=1 - fi -fi - -remount_needed() { - local state oldifs - [ "$READONLY" = "yes" ] && return 1 - state=$(LC_ALL=C awk '/ \/ / && ($3 !~ /rootfs/) { print $4 }' /proc/mounts) - oldifs=$IFS - IFS="," - for opt in $state ; do - if [ "$opt" = "rw" ]; then - IFS=$oldifs - return 1 - fi - done - IFS=$oldifs - return 0 -} - -# Remount the root filesystem read-write. -update_boot_stage RCmountfs -if remount_needed ; then - action $"Remounting root filesystem in read-write mode: " mount -n -o remount,rw / -fi - -# Clean up SELinux labels -if [ -n "$SELINUX_STATE" ]; then - restorecon /etc/mtab /etc/ld.so.cache /etc/blkid/blkid.tab /etc/resolv.conf >/dev/null 2>&1 -fi - -# If relabeling, relabel mount points. -if [ -n "$SELINUX_STATE" -a "$READONLY" != "yes" ]; then - if strstr "$cmdline" autorelabel || [ -f /.autorelabel ] ; then - restorecon $(awk '!/^#/ && $4 !~ /noauto/ && $2 ~ /^\// { print $2 }' /etc/fstab) >/dev/null 2>&1 - fi -fi - -if [ "$READONLY" != "yes" ] ; then - # Clear mtab - (> /etc/mtab) &> /dev/null - - # Remove stale backups - rm -f /etc/mtab~ /etc/mtab~~ - - # Enter mounted filesystems into /etc/mtab - mount -f / - mount -f /proc >/dev/null 2>&1 - mount -f /sys >/dev/null 2>&1 - mount -f /dev/pts >/dev/null 2>&1 - mount -f /dev/shm >/dev/null 2>&1 - mount -f /proc/bus/usb >/dev/null 2>&1 -fi - -# Mount all other filesystems (except for NFS and /proc, which is already -# mounted). Contrary to standard usage, -# filesystems are NOT unmounted in single user mode. -if [ "$READONLY" != "yes" ] ; then - action $"Mounting local filesystems: " mount -a -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev -else - action $"Mounting local filesystems: " mount -a -n -t nonfs,nfs4,smbfs,ncpfs,cifs,gfs,gfs2 -O no_netdev -fi - -# Update quotas if necessary -if [ X"$_RUN_QUOTACHECK" = X1 ] && [ -x /sbin/quotacheck ]; then - action $"Checking local filesystem quotas: " /sbin/quotacheck -anug -fi - -if [ -x /sbin/quotaon ]; then - action $"Enabling local filesystem quotas: " /sbin/quotaon -aug -fi - -# Check to see if a full relabel is needed -if [ -n "$SELINUX_STATE" -a "$READONLY" != "yes" ]; then - if strstr "$cmdline" autorelabel || [ -f /.autorelabel ] ; then - relabel_selinux - fi -else - if [ "$READONLY" != "yes" ] && [ -d /etc/selinux ]; then - [ -f /.autorelabel ] || touch /.autorelabel - fi -fi diff --git a/systemd/system/fedora-autoswap.service b/systemd/system/fedora-autoswap.service index c5087967..8cd881d9 100644 --- a/systemd/system/fedora-autoswap.service +++ b/systemd/system/fedora-autoswap.service @@ -3,8 +3,8 @@ Description=Enable all detected swap partitions DefaultDependencies=no Conflicts=shutdown.target Before=shutdown.target emergency.service emergency.target -After=fedora-mountall.service fedora-init-crypto-3.service -Requires=fedora-mountall.service fedora-init-crypto-3.service +After=local-fs.target fedora-init-crypto-3.service +Requires=local-fs.target fedora-init-crypto-3.service [Service] ExecStart=/lib/systemd/fedora-autoswap diff --git a/systemd/system/fedora-cleanup.service b/systemd/system/fedora-cleanup.service deleted file mode 100644 index 3bbb12df..00000000 --- a/systemd/system/fedora-cleanup.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Clean out assorted temporary files -DefaultDependencies=no -Conflicts=shutdown.target -Before=shutdown.target emergency.service emergency.target local-fs.target -After=fedora-mountall.service fedora-readonly.service -Requires=fedora-mountall.service - -[Service] -ExecStart=/lib/systemd/fedora-cleanup -Type=oneshot -TimeoutSec=0 -RemainAfterExit=yes diff --git a/systemd/system/fedora-mountall.service b/systemd/system/fedora-mountall.service deleted file mode 100644 index af5cf79b..00000000 --- a/systemd/system/fedora-mountall.service +++ /dev/null @@ -1,14 +0,0 @@ -[Unit] -Description=Check, mount, and relabel all filesystems -DefaultDependencies=no -Conflicts=shutdown.target -Before=shutdown.target emergency.service emergency.target remount-rootfs.service -After=fedora-storage-init.service fedora-init-crypto-2.service -Requires=fedora-storage-init.service fedora-init-crypto-2.service - -[Service] -ExecStart=/lib/systemd/fedora-mountall -Type=oneshot -TimeoutSec=0 -RemainAfterExit=yes -StandardInput=tty diff --git a/systemd/system/fedora-readonly.service b/systemd/system/fedora-readonly.service index c1e42367..eca197f0 100644 --- a/systemd/system/fedora-readonly.service +++ b/systemd/system/fedora-readonly.service @@ -2,9 +2,8 @@ Description=Configure read-only root support DefaultDependencies=no Conflicts=shutdown.target -Before=shutdown.target emergency.service emergency.target fedora-cleanup.service -After=fedora-mountall.service -Requires=fedora-mountall.service +Before=shutdown.target emergency.service emergency.target systemd-tmpfiles-setup.service +After=remount-rootfs.service [Service] ExecStart=/lib/systemd/fedora-readonly -- cgit v1.2.1 From 57abe2bcd4b228416f54bda6aa7912a711a21edb Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 26 Oct 2010 15:43:30 -0400 Subject: Add autorelabel service. --- systemd/fedora-autorelabel | 84 +++++++++++++++++++++++++++++++ systemd/system/fedora-autorelabel.service | 14 ++++++ 2 files changed, 98 insertions(+) create mode 100755 systemd/fedora-autorelabel create mode 100644 systemd/system/fedora-autorelabel.service (limited to 'systemd') diff --git a/systemd/fedora-autorelabel b/systemd/fedora-autorelabel new file mode 100755 index 00000000..9144d59e --- /dev/null +++ b/systemd/fedora-autorelabel @@ -0,0 +1,84 @@ +#!/bin/bash +# +# fsck, mount, set quotas, and relabel filesystems. +# + +. /etc/init.d/functions + +PLYMOUTH= +[ -x /usr/bin/plymouth ] && PLYMOUTH=yes + +# Check SELinux status +SELINUX_STATE= +if [ -e "/selinux/enforce" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then + if [ -r "/selinux/enforce" ] ; then + SELINUX_STATE=$(cat "/selinux/enforce") + else + # assume enforcing if you can't read it + SELINUX_STATE=1 + fi +fi + +disable_selinux() { + echo $"*** Warning -- SELinux is active" + echo $"*** Disabling security enforcement for system recovery." + echo $"*** Run 'setenforce 1' to reenable." + echo "0" > "/selinux/enforce" +} + +relabel_selinux() { + # if /sbin/init is not labeled correctly this process is running in the + # wrong context, so a reboot will be required after relabel + AUTORELABEL= + . /etc/selinux/config + echo "0" > /selinux/enforce + [ -n "$PLYMOUTH" ] && plymouth --hide-splash + + if [ "$AUTORELABEL" = "0" ]; then + echo + echo $"*** Warning -- SELinux ${SELINUXTYPE} policy relabel is required. " + echo $"*** /etc/selinux/config indicates you want to manually fix labeling" + echo $"*** problems. Dropping you to a shell; the system will reboot" + echo $"*** when you leave the shell." + sulogin + + else + echo + echo $"*** Warning -- SELinux ${SELINUXTYPE} policy relabel is required." + echo $"*** Relabeling could take a very long time, depending on file" + echo $"*** system size and speed of hard drives." + + /sbin/fixfiles -F restore > /dev/null 2>&1 + fi + rm -f /.autorelabel + echo $"Unmounting file systems" + umount -a + mount -n -o remount,ro / + echo $"Automatic reboot in progress." + reboot -f +} + +[ -z "${cmdline}" ] && cmdline=$(cat /proc/cmdline) + +# Clean up SELinux labels +if [ -n "$SELINUX_STATE" ]; then + restorecon /etc/mtab /etc/ld.so.cache /etc/blkid/blkid.tab /etc/resolv.conf >/dev/null 2>&1 +fi + +# If relabeling, relabel mount points. +if [ -n "$SELINUX_STATE" -a "$READONLY" != "yes" ]; then + if strstr "$cmdline" autorelabel || [ -f /.autorelabel ] ; then + restorecon $(awk '!/^#/ && $4 !~ /noauto/ && $2 ~ /^\// { print $2 }' /etc/fstab) >/dev/null 2>&1 + fi +fi + +# Check to see if a full relabel is needed +if [ -n "$SELINUX_STATE" -a "$READONLY" != "yes" ]; then + if strstr "$cmdline" autorelabel || [ -f /.autorelabel ] ; then + relabel_selinux + fi +else + if [ "$READONLY" != "yes" ] && [ -d /etc/selinux ]; then + [ -f /.autorelabel ] || touch /.autorelabel + fi +fi diff --git a/systemd/system/fedora-autorelabel.service b/systemd/system/fedora-autorelabel.service new file mode 100644 index 00000000..bca3f956 --- /dev/null +++ b/systemd/system/fedora-autorelabel.service @@ -0,0 +1,14 @@ +[Unit] +Description=Relabel all filesystems, if necessary +DefaultDependencies=no +Conflicts=shutdown.target +Before=shutdown.target emergency.service emergency.target +After=local-fs.target +Requires=remount-rootfs.service local-fs.target + +[Service] +ExecStart=/lib/systemd/fedora-autorelabel +Type=oneshot +TimeoutSec=0 +RemainAfterExit=yes +StandardInput=tty -- cgit v1.2.1 From 10e5e60f3efa4e5495771694acf5f534eee80e13 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Tue, 26 Oct 2010 17:16:44 -0400 Subject: Don't ship our own halt service; systemd handles this natively. We will need to add a halt.local service. --- systemd/system/halt.service | 19 ------------------- systemd/system/poweroff.service | 19 ------------------- systemd/system/reboot.service | 19 ------------------- 3 files changed, 57 deletions(-) delete mode 100644 systemd/system/halt.service delete mode 100644 systemd/system/poweroff.service delete mode 100644 systemd/system/reboot.service (limited to 'systemd') diff --git a/systemd/system/halt.service b/systemd/system/halt.service deleted file mode 100644 index a1c0e84f..00000000 --- a/systemd/system/halt.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=Halt the system -DefaultDependencies=no -Requires=umount.target killall.service -After=umount.target killall.service - -[Service] -Type=oneshot -RemainAfterExit=yes -Environment=INIT_HALT=HALT RUNLEVEL=0 -ExecStart=/etc/init.d/halt start -StandardOutput=tty diff --git a/systemd/system/poweroff.service b/systemd/system/poweroff.service deleted file mode 100644 index 28b4a5f4..00000000 --- a/systemd/system/poweroff.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=Power down the system -DefaultDependencies=no -Requires=umount.target killall.service -After=umount.target killall.service - -[Service] -Type=oneshot -RemainAfterExit=yes -Environment=RUNLEVEL=0 -ExecStart=/etc/init.d/halt start -StandardOutput=tty diff --git a/systemd/system/reboot.service b/systemd/system/reboot.service deleted file mode 100644 index 622beb58..00000000 --- a/systemd/system/reboot.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=Reboot the system -DefaultDependencies=no -Requires=umount.target killall.service -After=umount.target killall.service - -[Service] -Type=oneshot -RemainAfterExit=yes -Environment=RUNLEVEL=6 -ExecStart=/etc/init.d/reboot start -StandardOutput=tty -- cgit v1.2.1 From 3e24e424d59a7c9bad0c99cbb702cdc6f2f6e23f Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 28 Oct 2010 10:42:28 -0400 Subject: Fix comment. --- systemd/fedora-autorelabel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'systemd') diff --git a/systemd/fedora-autorelabel b/systemd/fedora-autorelabel index 9144d59e..f5e4db29 100755 --- a/systemd/fedora-autorelabel +++ b/systemd/fedora-autorelabel @@ -1,6 +1,6 @@ #!/bin/bash # -# fsck, mount, set quotas, and relabel filesystems. +# Do automatic relabelling # . /etc/init.d/functions -- cgit v1.2.1 From 96bf02f67020374327528b6e0ec742499b516aba Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 28 Oct 2010 10:43:13 -0400 Subject: Remove init_crypto 0, this is in a separate service. --- systemd/fedora-storage-init | 2 -- 1 file changed, 2 deletions(-) (limited to 'systemd') diff --git a/systemd/fedora-storage-init b/systemd/fedora-storage-init index a9c12769..0e3a417e 100755 --- a/systemd/fedora-storage-init +++ b/systemd/fedora-storage-init @@ -6,8 +6,6 @@ [ -z "${cmdline}" ] && cmdline=$(cat /proc/cmdline) -[ -f /etc/crypttab ] && init_crypto 0 - if ! strstr "$cmdline" nompath && [ -f /etc/multipath.conf ] && \ [ -x /sbin/multipath ]; then modprobe dm-multipath > /dev/null 2>&1 -- cgit v1.2.1 From 12cabd751919122551b6eb73850b35fbe565c679 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 28 Oct 2010 10:44:00 -0400 Subject: Simplify some things with ConditionPathExists. --- systemd/fedora-configure | 26 +++++++++++--------------- systemd/fedora-init-crypto | 2 +- systemd/system/fedora-configure.service | 2 ++ systemd/system/fedora-init-crypto-1.service | 1 + systemd/system/fedora-init-crypto-2.service | 1 + systemd/system/fedora-init-crypto-3.service | 1 + 6 files changed, 17 insertions(+), 16 deletions(-) (limited to 'systemd') diff --git a/systemd/fedora-configure b/systemd/fedora-configure index 3a8c6dc4..63e6e4c7 100755 --- a/systemd/fedora-configure +++ b/systemd/fedora-configure @@ -4,22 +4,18 @@ . /etc/init.d/functions -if [ -f /.unconfigured ]; then - if [ -x /usr/bin/rhgb-client ] && /usr/bin/rhgb-client --ping ; then - /usr/bin/rhgb-client --quit - fi +if [ -x /usr/bin/rhgb-client ] && /usr/bin/rhgb-client --ping ; then + /usr/bin/rhgb-client --quit +fi - if [ -x /usr/sbin/firstboot ]; then - /usr/sbin/firstboot - fi - - # Reread in network configuration data. - if [ -f /etc/sysconfig/network ]; then - . /etc/sysconfig/network +if [ -x /usr/sbin/firstboot ]; then + /usr/sbin/firstboot +fi - # Reset the hostname. - action $"Resetting hostname ${HOSTNAME}: " hostname ${HOSTNAME} - fi +# Reread in network configuration data. +if [ -f /etc/sysconfig/network ]; then + . /etc/sysconfig/network - rm -f /.unconfigured + # Reset the hostname. + action $"Resetting hostname ${HOSTNAME}: " hostname ${HOSTNAME} fi diff --git a/systemd/fedora-init-crypto b/systemd/fedora-init-crypto index 1f707aec..79d18beb 100755 --- a/systemd/fedora-init-crypto +++ b/systemd/fedora-init-crypto @@ -2,4 +2,4 @@ . /etc/init.d/functions -[ -f /etc/crypttab ] && init_crypto $1 || : +init_crypto $1 || : diff --git a/systemd/system/fedora-configure.service b/systemd/system/fedora-configure.service index 032e94ae..fcaa5348 100644 --- a/systemd/system/fedora-configure.service +++ b/systemd/system/fedora-configure.service @@ -4,9 +4,11 @@ DefaultDependencies=no Conflicts=multi-user.target shutdown.target Before=multi-user.target shutdown.target After=local-fs.target +ConditionPathExists=/.unconfigured [Service] ExecStart=/lib/systemd/fedora-configure +ExecStopPost=rm -f /.unconfigured Type=oneshot TimeoutSec=0 StandardInput=tty diff --git a/systemd/system/fedora-init-crypto-1.service b/systemd/system/fedora-init-crypto-1.service index fee6bcce..6d6b732f 100644 --- a/systemd/system/fedora-init-crypto-1.service +++ b/systemd/system/fedora-init-crypto-1.service @@ -5,6 +5,7 @@ Conflicts=shutdown.target Before=shutdown.target emergency.service emergency.target After=fedora-wait-storage.service Requires=fedora-wait-storage.service +ConditionPathExists=/etc/crypttab [Service] ExecStart=/lib/systemd/fedora-init-crypto 0 diff --git a/systemd/system/fedora-init-crypto-2.service b/systemd/system/fedora-init-crypto-2.service index 2fc128eb..c01bbd1b 100644 --- a/systemd/system/fedora-init-crypto-2.service +++ b/systemd/system/fedora-init-crypto-2.service @@ -5,6 +5,7 @@ Conflicts=shutdown.target Before=shutdown.target emergency.service emergency.target After=fedora-storage-init.service Requires=fedora-storage-init.service +ConditionPathExists=/etc/crypttab [Service] ExecStart=/lib/systemd/fedora-init-crypto 0 diff --git a/systemd/system/fedora-init-crypto-3.service b/systemd/system/fedora-init-crypto-3.service index 08d3bf96..84b11fd5 100644 --- a/systemd/system/fedora-init-crypto-3.service +++ b/systemd/system/fedora-init-crypto-3.service @@ -5,6 +5,7 @@ Conflicts=shutdown.target Before=shutdown.target emergency.service emergency.target After=systemd-random-seed-load.service Requires=systemd-random-seed-load.service +ConditionPathExists=/etc/crypttab [Service] ExecStart=/lib/systemd/fedora-init-crypto 1 -- cgit v1.2.1 From 2f51ac69b5a56444344af3248e80dff2a51d5661 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Thu, 28 Oct 2010 12:57:42 -0400 Subject: Use systemd versions of these services. --- systemd/system/killall.service | 19 ------------------- systemd/system/prefdm.service | 22 ---------------------- systemd/system/rc-local.service | 16 ---------------- systemd/system/single.service | 29 ----------------------------- 4 files changed, 86 deletions(-) delete mode 100644 systemd/system/killall.service delete mode 100644 systemd/system/prefdm.service delete mode 100644 systemd/system/rc-local.service delete mode 100644 systemd/system/single.service (limited to 'systemd') diff --git a/systemd/system/killall.service b/systemd/system/killall.service deleted file mode 100644 index 953dc19d..00000000 --- a/systemd/system/killall.service +++ /dev/null @@ -1,19 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=Kill all processes -DefaultDependencies=no -Requires=shutdown.target -After=shutdown.target -RefuseManualStart=yes - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=-/etc/init.d/killall start -StandardOutput=tty diff --git a/systemd/system/prefdm.service b/systemd/system/prefdm.service deleted file mode 100644 index 2e2396d7..00000000 --- a/systemd/system/prefdm.service +++ /dev/null @@ -1,22 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=Display Manager -After=syslog.target livesys-late.service rc-local.service - -# On Fedora gdm/X11 is on tty1. We explicitly cancel the getty here to -# avoid any races around that. -Conflicts=getty@tty1.service plymouth-quit.service - -[Service] -ExecStart=/etc/X11/prefdm -nodaemon -Restart=always -RestartSec=0 - -[Install] -Alias=display-manager.service diff --git a/systemd/system/rc-local.service b/systemd/system/rc-local.service deleted file mode 100644 index 21ecfb23..00000000 --- a/systemd/system/rc-local.service +++ /dev/null @@ -1,16 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -[Unit] -Description=Local customization - -[Service] -ExecStart=/etc/rc.local start -TimeoutSec=0 -StandardOutput=tty -RemainAfterExit=yes -SysVStartPriority=99 diff --git a/systemd/system/single.service b/systemd/system/single.service deleted file mode 100644 index 4264cd56..00000000 --- a/systemd/system/single.service +++ /dev/null @@ -1,29 +0,0 @@ -# This file is part of systemd. -# -# systemd is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# See systemd.special(7) for details - -[Unit] -Description=Rescue Shell -DefaultDependencies=no -Conflicts=multi-user.target shutdown.target -After=basic.target -Before=multi-user.target - -[Service] -Type=simple -EnvironmentFile=/etc/sysconfig/init -Environment=HOME=/root -ExecStartPre=-/bin/plymouth --hide-splash -ExecStart=-/bin/bash -c "exec $SINGLE" -ExecStopPost=/bin/systemctl default -StandardInput=tty-force -KillMode=process-group - -# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash -# terminates cleanly. -KillSignal=SIGHUP -- cgit v1.2.1 From 4e23bccc52a2a03c7d14cf89d96d6c1b197b6bda Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Fri, 29 Oct 2010 11:56:32 -0400 Subject: Don't conflict with multi-user.target. --- systemd/system/fedora-configure.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'systemd') diff --git a/systemd/system/fedora-configure.service b/systemd/system/fedora-configure.service index fcaa5348..f463c98b 100644 --- a/systemd/system/fedora-configure.service +++ b/systemd/system/fedora-configure.service @@ -1,7 +1,7 @@ [Unit] Description=Reconfigure the system on administrator request DefaultDependencies=no -Conflicts=multi-user.target shutdown.target +Conflicts=shutdown.target Before=multi-user.target shutdown.target After=local-fs.target ConditionPathExists=/.unconfigured -- cgit v1.2.1 From 4249af37f490c5ab40b8609929e29ff5509cab9c Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Wed, 3 Nov 2010 11:30:18 -0400 Subject: Don't use rhgb-client; it's long since deprecated. --- systemd/fedora-configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'systemd') diff --git a/systemd/fedora-configure b/systemd/fedora-configure index 63e6e4c7..e6779fed 100755 --- a/systemd/fedora-configure +++ b/systemd/fedora-configure @@ -4,8 +4,8 @@ . /etc/init.d/functions -if [ -x /usr/bin/rhgb-client ] && /usr/bin/rhgb-client --ping ; then - /usr/bin/rhgb-client --quit +if [ -x /usr/bin/plymouth ]; then + /usr/bin/plymouth quit fi if [ -x /usr/sbin/firstboot ]; then -- cgit v1.2.1