Subversion Repositories livecd

Rev

Rev 168 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 168 Rev 206
Line 5... Line 5...
5
#               unmounts file systems and then either halts or reboots.
5
#               unmounts file systems and then either halts or reboots.
6
#
6
#
7
# Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
7
# Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
8
#               Modified for RHS Linux by Damien Neil
8
#               Modified for RHS Linux by Damien Neil
9
#
9
#
-
 
10
# modified for LiveCD, Urs Beyerle
10
 
11
 
11
NOLOCALE=1
12
NOLOCALE=1
12
. /etc/init.d/functions
13
. /etc/init.d/functions
13
 
14
 
-
 
15
UMOUNT="umount"
-
 
16
[ ! -w /etc ] && UMOUNT="umount -n"
-
 
17
 
14
action() {
18
action() {
15
   echo -n "$1 "
19
   echo -n "$1 "
16
   shift
20
   shift
17
   if [ "$BOOTUP" = "color" ]; then
21
   if [ "$BOOTUP" = "color" ]; then
18
      "$@" && echo_success || echo_failure
22
      "$@" && echo_success || echo_failure
Line 129... Line 133...
129
[ -x /sbin/hwclock ] && action $"Syncing hardware clock to system time" /sbin/hwclock $CLOCKFLAGS
133
[ -x /sbin/hwclock ] && action $"Syncing hardware clock to system time" /sbin/hwclock $CLOCKFLAGS
130
 
134
 
131
# Try to unmount tmpfs filesystems to avoid swapping them in.  Ignore failures.
135
# Try to unmount tmpfs filesystems to avoid swapping them in.  Ignore failures.
132
tmpfs=$(awk '$2 ~ /^\/($|proc|dev)/ { next; }
136
tmpfs=$(awk '$2 ~ /^\/($|proc|dev)/ { next; }
133
	     $3 == "tmpfs" { print $2; }' /proc/mounts | sort -r)
137
	     $3 == "tmpfs" { print $2; }' /proc/mounts | sort -r)
134
[ -n "$tmpfs" ] && fstab-decode umount $tmpfs 2>/dev/null
138
[ -n "$tmpfs" ] && fstab-decode $UMOUNT $tmpfs 2>/dev/null
135
 
139
 
136
# Turn off swap, then unmount file systems.
140
# Turn off swap, then unmount file systems.
137
[ -f /proc/swaps ] && SWAPS=`awk '! /^Filename/ { print $1 }' /proc/swaps`
141
[ -f /proc/swaps ] && SWAPS=`awk '! /^Filename/ { print $1 }' /proc/swaps`
138
if [ -n "$SWAPS" ]; then
142
if [ -n "$SWAPS" ]; then
139
    action $"Turning off swap: " swapoff $SWAPS
143
    action $"Turning off swap: " swapoff $SWAPS
Line 141... Line 145...
141
	if [[ "$dst" =~ "^/dev/mapper" ]] \
145
	if [[ "$dst" =~ "^/dev/mapper" ]] \
142
	    && [ "$(dmsetup status "$dst" | cut -d ' ' -f 3)" = crypt ]; then
146
	    && [ "$(dmsetup status "$dst" | cut -d ' ' -f 3)" = crypt ]; then
143
	    backdev=$(/sbin/cryptsetup status "$dst" \
147
	    backdev=$(/sbin/cryptsetup status "$dst" \
144
		| awk '$1 == "device:" { print $2 }')
148
		| awk '$1 == "device:" { print $2 }')
145
	    /sbin/cryptsetup remove "$dst"
149
	    /sbin/cryptsetup remove "$dst"
146
	    # Leave partition with a blank plain-text swap
-
 
147
	    mkswap "$backdev" > /dev/null
-
 
148
	fi
150
	fi
149
    done
151
    done
150
fi
152
fi
151
 
153
 
152
[ -x /sbin/quotaoff ] && action $"Turning off quotas: " /sbin/quotaoff -aug
154
[ -x /sbin/quotaoff ] && action $"Turning off quotas: " /sbin/quotaoff -aug
153
 
155
 
154
# Unmount file systems, killing processes if we have to.
156
# Unmount file systems, killing processes if we have to.
155
# Unmount loopback stuff first
157
# Unmount loopback stuff first
156
# __umount_loopback_loop
158
#__umount_loopback_loop
157
 
159
 
158
# Unmount RPC pipe file systems
160
# Unmount RPC pipe file systems
159
# __umount_loop '$3 ~ /^rpc_pipefs$/ || $3 ~ /^rpc_svc_gss_pipefs$/ {print $2}' \
161
#__umount_loop '$3 ~ /^rpc_pipefs$/ || $3 ~ /^rpc_svc_gss_pipefs$/ {print $2}' \
160
#    /proc/mounts \
162
#    /proc/mounts \
161
#    $"Unmounting pipe file systems: " \
163
#    $"Unmounting pipe file systems: " \
162
#    $"Unmounting pipe file systems (retry): " \
164
#    $"Unmounting pipe file systems (retry): " \
163
#    -f
165
#    -f
164
 
166
 
165
# LANG=C __umount_loop '$2 ~ /^\/$|^\/proc|^\/dev/{next}
167
#LANG=C __umount_loop '$2 ~ /^\/$|^\/proc|^\/dev/{next}
166
#	$3 == "tmpfs" || $3 == "proc" {print $2 ; next}
168
#	$3 == "tmpfs" || $3 == "proc" {print $2 ; next}
167
#	/(loopfs|autofs|nfs|cifs|smbfs|ncpfs|sysfs|^none|^\/dev\/ram|^\/dev\/root$)/ {next}
169
#	/(loopfs|autofs|nfs|cifs|smbfs|ncpfs|sysfs|^none|^\/dev\/ram|^\/dev\/root$)/ {next}
168
#	{print $2}' /proc/mounts \
170
#	{print $2}' /proc/mounts \
169
#	$"Unmounting file systems: " \
171
#	$"Unmounting file systems: " \
170
#	$"Unmounting file systems (retry): " \
172
#	$"Unmounting file systems (retry): " \
171
#	-f
173
#	-f
172
 
174
 
173
[ -f /proc/bus/usb/devices ] && umount /proc/bus/usb
175
[ -f /proc/bus/usb/devices ] && $UMOUNT /proc/bus/usb
174
 
176
 
175
[ -f /etc/crypttab ] && \
177
[ -f /etc/crypttab ] && \
176
    LANG=C action $"Stopping disk encryption: " halt_crypto
178
    LANG=C action $"Stopping disk encryption: " halt_crypto
177
 
179
 
178
# remove the crash indicator flag
180
# remove the crash indicator flag
Line 181... Line 183...
181
# Try all file systems other than root, essential filesystems and RAM disks,
183
# Try all file systems other than root, essential filesystems and RAM disks,
182
# one last time.
184
# one last time.
183
awk '$2 !~ /\/(|dev|proc|selinux)$/ && $1 !~ /^\/dev\/ram/ { print $2 }' \
185
awk '$2 !~ /\/(|dev|proc|selinux)$/ && $1 !~ /^\/dev\/ram/ { print $2 }' \
184
    /proc/mounts | grep -v "/livecd/" | sort -r | \
186
    /proc/mounts | grep -v "/livecd/" | sort -r | \
185
  while read line; do
187
  while read line; do
186
    fstab-decode umount -f $line
188
    fstab-decode $UMOUNT -f $line
187
done
189
done
188
 
190
 
189
if [ -x /sbin/halt.local ]; then
191
if [ -x /sbin/halt.local ]; then
190
   /sbin/halt.local
192
   /sbin/halt.local
191
fi
193
fi