Automatically translate date formats in po files.
[live-boot-grml.git] / initramfs-tools / scripts / live-bottom / 12fstab
1 #!/bin/sh
2
3 #set -e
4
5 # initramfs-tools header
6
7 PREREQ=""
8 FSTAB=/root/etc/fstab
9
10 prereqs()
11 {
12         echo "${PREREQ}"
13 }
14
15 case "${1}" in
16         prereqs)
17                 prereqs
18                 exit 0
19                 ;;
20 esac
21
22 # live-boot header
23
24 . /scripts/live-functions
25
26 if [ -n "${NOFSTAB}" ]
27 then
28         exit 0
29 fi
30
31 log_begin_msg "Configuring fstab"
32
33 # live-boot script
34
35 if ! grep -qs  "^${UNIONTYPE}" "${FSTAB}"
36 then
37         echo "${UNIONTYPE} / ${UNIONTYPE} rw 0 0" >> "${FSTAB}"
38 fi
39
40 if ! grep -qs "^tmpfs /tmp" "${FSTAB}"
41 then
42         echo "tmpfs /tmp tmpfs nosuid,nodev 0 0" >> "${FSTAB}"
43 fi
44
45 if [ -n "${SWAPON}" ]
46 then
47         devices=""
48
49         for device in /dev/[hs]d[a-z][0-9]*
50         do
51                 if ! [ -b "${device}" ]
52                 then
53                         continue
54                 fi
55
56                 /sbin/blkid -o udev -p ${device%%[0-9]*} | grep -q "^ID_FS_USAGE=raid" && continue
57
58                 magic=$(/bin/dd if="${device}" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue
59
60                 if [ "${magic}" = "SWAPSPACE2" -o "${magic}" = "SWAP-SPACE" ]
61                 then
62                         #log "Found ${device}"
63                         devices="${devices} ${device}"
64                 fi
65         done
66
67         # Remove all auto swap entries
68         if grep -qs  "swap swap" "${FSTAB}"
69         then
70                 grep -v "swap swap" "${FSTAB}" > "${FSTAB}".tmp
71                 mv "${FSTAB}".tmp "${FSTAB}"
72         fi
73
74         # Add new swap entries
75         for device in ${devices}
76         do
77                 echo "${device} swap swap defaults 0 0" >> "${FSTAB}"
78         done
79 fi
80
81 # disabled for now
82 #rm -f /root/etc/rcS.d/S*checkroot.sh
83
84 if [ "${NOFASTBOOT}" != "Yes" ]
85 then
86         touch root/fastboot
87 fi
88
89 log_end_msg