Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 412134 Details for
Bug 560008
sys-apps/openrc-0.17 localmount service incorrectly handles stop phase for aufs without mounts (directories in /sys/fs/aufs/)
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
cleandie: old cleanup script from Slax rewritten
cleandie (text/plain), 5.18 KB, created by
Andrea Zuccherelli
on 2015-09-17 20:10:33 UTC
(
hide
)
Description:
cleandie: old cleanup script from Slax rewritten
Filename:
MIME Type:
Creator:
Andrea Zuccherelli
Created:
2015-09-17 20:10:33 UTC
Size:
5.18 KB
patch
obsolete
>#!/bin/ash ># This script must be executed with parameter "--start" at the end of distro shutdown ># What it does is it executes as init (process 1) and unmounts all filesystems ># including union and the USB device (if any), so it can be cleanly removed ># ># Simply add the following as the last command executed by init on your distro ># instead of the actual poweroff or shutdown command: ># ># exec /mnt/live/lib/cleanup --start poweroff ># or ># exec /mnt/live/lib/cleanup --start shutdown ># ># on Slackware, add this to rc.0: ># exec /mnt/live/lib/cleanup --start /sbin/$command ># ># It may be needed to call this script also with --killall5 from your shutdown scripts ># instead of calling regular killall5, to prevent fuse filesystems from being killed ># ># Author: Tomas M <http://www.linux-live.org/> ># > >if [ "$1" = "--killall5" ]; then > # kill all unneeded processes, which have smaller ID then the ID of > # current shell's parent process. We can't use killall5, as it would kill some > # processes which may be currently needed, for example fuse filesystems (ntfs-3g). > for pid in $(/mnt/live/bin/ps | grep -v "PID" | grep -E -v "\[.*\]" | grep -E -v "mount|posixovl|fuse" | sed -r "s/^ +//" | cut -d " " -f 1); do > if [ $pid -lt $PPID ]; then > LIST="$LIST $pid" > fi > done > > kill -15 $LIST 2>/dev/null # SIGTERM > sleep 2 # give processes some time to end properly > kill -9 $LIST 2>/dev/null # SIGKILL >fi > > >if [ "$1" = "--start" ]; then > # This is the part which is to be called from shutdown script. > # We will assume init is running as process 1 and re-executes itself after 'telinit u' > # So we're going to force init to stop and start this script instead as PID 1 > # If your init works differently, you may need to slightly modify few lines below > # - without this, init would be blocking union and it couldn't be unmounted later. > cd /mnt/live > mkdir dev bin sbin lib memory/union proc sys > mount -t devtmpfs udev dev > initrd/bin/cpld /sbin/init lib >/dev/null > cp /sbin/init sbin/telinit > cp initrd/bin/sh bin > cp initrd/bin/findsubmnt bin > > BBOX=../initrd/bin/busybox > ln -s $BBOX sbin/chroot > ln -s $BBOX sbin/ls > ln -s $BBOX sbin/unmount > ln -s $BBOX sbin/mount > ln -s $BBOX sbin/losetup > ln -s $BBOX bin/eject > ln -s $BBOX bin/ash > ln -s $BBOX bin/kill > ln -s $BBOX bin/sleep > ln -s $BBOX bin/tac > ln -s $BBOX bin/awk > ln -s $BBOX bin/sed > ln -s $BBOX bin/grep > ln -s $BBOX bin/xargs > ln -s $BBOX bin/cut > > cp "$0" sbin/init > echo "Cleandie: before pivot_root" > mount|grep aufs > sleep 30 > pivot_root . memory/union > echo "$2 -f" > /lib/command > /sbin/telinit u >fi > > >if [ "$1" = "--init" ]; then > # now we're called from init to replace the process nr 1. > # We know that init binary reexecutes itself with --init parameter > # All other processes are already killed > # so our goal now is just to unmount everything and reboot/shutdown > > # First, mount proc and sys again since it will be needed and it was already unmounted > mount -n -t proc proc /proc >/dev/console 2>&1 > mount -n -t sysfs sysfs /sys >/dev/console 2>&1 > > echo "Cleandie: these are my mounts" >/dev/console > cat /proc/mounts >/dev/console > sleep 60 > # Detach loop devices which are no longer used > losetup -a | cut -d : -f 1 | xargs -n 1 losetup -d > > # next, unmount everything from union, backwards > tac /proc/mounts | grep union | cut -d " " -f 2 | while read LINE; do > umount $LINE >/dev/console 2>&1 > done > > # then free up loop mounts, backwards > tac /proc/mounts | grep loop | cut -d " " -f 2 | while read LINE; do > umount $LINE >/dev/console 2>&1 > done > > # Detach loop devices which are no longer used > losetup -a | cut -d : -f 1 | xargs -n 1 losetup -d > > # remember from which device we are started, do it now before we lose it > DEVICE="$(cat /proc/mounts | grep /memory/data | grep /dev/ | cut -d " " -f 1)" > > echo "Cleandie: after unmounting these are my mounts" >/dev/console > cat /proc/mounts >/dev/console > echo "Cleandie: start device: $DEVICE" >/dev/console > > # free up memory mounts, backwards > MMOUNT="$(findsubmnt /memory)" > for m in ${MMOUNT} > do > if [ $m != "/memory" ]; then > echo "Cleandie: unmounting $m" >/dev/console > umount $m >/dev/console 2>&1 > fi > done > echo "Cleandie: unmounting /memory" >/dev/console > umount /memory >/dev/console 2>&1 > > echo "Cleandie: checking unmount" >/dev/console > for m in ${MMOUNT} > do > if (cat /proc/mounts|grep $m) ; then > echo "Cleandie failed: stopping" >/dev/console > while true; do sleep 20; done > fi > done > > # eject cdrom device if we were running from it > for i in $(cat /proc/sys/dev/cdrom/info | grep name); do > if [ "$DEVICE" = "/dev/$i" ]; then > echo "Cleandie: attemptiong to eject /dev/$i..." >/dev/console > eject /dev/$i > echo "Cleandie: CD/DVD tray will close in 6 seconds..." >/dev/console > sleep 6 > eject -t /dev/$i > fi > done > > cat /lib/command >/dev/console > sleep 60 > $(cat /lib/command 2>/dev/null) > echo "Cleandie failed: cannot be here" >/dev/console > while true; do sleep 20; done > reboot -f >fi
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 560008
:
411386
|
412064
|
412082
|
412096
|
412098
|
412126
| 412134 |
412136
|
412138
|
412140