diff options
author | Bill Nottingham <notting@redhat.com> | 2010-10-15 16:25:31 -0400 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2010-10-15 16:25:31 -0400 |
commit | 59b2f505ea603ef65823615711b5adfa87795f41 (patch) | |
tree | d5b42a97c7c6e964d920c51f39d890313b997b09 /systemd/fedora-cleanup | |
parent | 675389f11ffaab590e9dedabc821e33745e3eb5c (diff) | |
download | initscripts-59b2f505ea603ef65823615711b5adfa87795f41.tar initscripts-59b2f505ea603ef65823615711b5adfa87795f41.tar.gz initscripts-59b2f505ea603ef65823615711b5adfa87795f41.tar.bz2 initscripts-59b2f505ea603ef65823615711b5adfa87795f41.tar.xz initscripts-59b2f505ea603ef65823615711b5adfa87795f41.zip |
Add split-out bits of rc.sysinit and associated service files. Remove sysinit.service. Based on work by Harald Hoyer (<harald@redhat.com>)
sysinit-hack/unhack will be removed once the net hotplug stuff is fixed to not require this.
Diffstat (limited to 'systemd/fedora-cleanup')
-rwxr-xr-x | systemd/fedora-cleanup | 58 |
1 files changed, 58 insertions, 0 deletions
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 |