~tormodvolden/lupin/locale

« back to all changes in this revision

Viewing changes to debian/lupin-support.mounthost.init

  • Committer: Agostino Russo
  • Date: 2008-03-11 22:50:57 UTC
  • Revision ID: agostino.russo@gmail.com-20080311225057-2kq30onjg2p4wsqe
* Do not use awk in mounthost (LP: #198007)

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
# NOTE: should /host be in fstab
6
6
#
7
7
### BEGIN INIT INFO
8
 
# Provides:             mounthost
9
 
# Required-Start:       mountdevsubfs
 
8
# Provides:        mounthost
 
9
# Required-Start:    mountdevsubfs
10
10
# Required-Stop:
11
 
# Default-Start:        S
 
11
# Default-Start:    S
12
12
# Default-Stop:
13
 
# Short-Description:    Remount /host folder read write.
 
13
# Short-Description:    Remount /host folder read write.
14
14
### END INIT INFO
15
15
 
16
16
PATH=/sbin:/bin
19
19
. /lib/lsb/init-functions
20
20
 
21
21
do_start() {
22
 
        [ "$VERBOSE" = no ] || log_action_begin_msg "Mounting host filesystem read-write"
23
 
        
 
22
    [ "$VERBOSE" = no ] || log_action_begin_msg "Mounting host filesystem read-write"
 
23
 
24
24
    hosttype=none
25
 
        hostopts=defaults
26
 
        hostmode=rw
27
 
        hostcheck=no
28
 
        
29
 
    
 
25
    hostopts=defaults
 
26
    hostmode=rw
 
27
    hostcheck=no
 
28
 
30
29
    ES=$?
31
 
        loop_file=$(awk '$2=="/" && $4~"loop" {print $1}' /etc/fstab)
32
 
    host_device=$(awk '"'${loop_file}'"~"^"$2 && $2!="/" {print $1}' /proc/mounts)
 
30
    loopfile_fstab_line=$(sed -n '\:^/[^ ]*[ ]*[ ]/[ ][ ]*[^ ]*[ ].*loop.*[ ]:p' /etc/fstab)
 
31
    host_mountpoint=${loopfile_fstab_line%% *}
 
32
    while [ -z "$host_device" ] && [ -n "$host_mountpoint" ] && [ ! "$host_mountpoint" = "/" ]; do
 
33
        host_mountpoint="${host_mountpoint%/*}"
 
34
        host_device=$(sed -n "\:^/[^ ]*[ ]*[ ]$host_mountpoint :p" /proc/mounts)
 
35
        host_device=${host_device%% *}
 
36
    done
33
37
    if [ -n "$host_device" ]; then
34
38
        if [ "$hostcheck" = yes ]; then
35
39
            if \
36
 
                ! mount    -n -o remount,ro              $host_device /host             \
37
 
                && ! mount -n -o remount,ro -t dummytype $host_device /host 2>/dev/null \
38
 
                && ! mount -n -o remount,ro            $host_device  /host 2>/dev/null
 
40
                ! mount    -n -o remount,ro              "$host_device" /host             \
 
41
                && ! mount -n -o remount,ro -t dummytype "$host_device" /host 2>/dev/null \
 
42
                && ! mount -n -o remount,ro            "$host_device"  /host 2>/dev/null
39
43
            then
40
44
                log_failure_msg "Cannot check host file system because it is not mounted read-only."
41
45
                rootcheck=no
43
47
            #TBD add fs checking
44
48
            #skipping since not supported by ntfs-3g
45
49
        fi
46
 
        mount -n -o remount,$hostopts,$hostmode $host_device /host
 
50
        mount -n -o remount,$hostopts,$hostmode "$host_device" /host
47
51
        ES=$?
48
52
    fi
49
 
 
50
 
        [ "$VERBOSE" = no ] || log_action_end_msg $ES
 
53
    [ "$VERBOSE" = no ] || log_action_end_msg "$ES"
51
54
}
52
55
 
53
56
case "$1" in
54
57
  start)
55
 
        do_start
56
 
        ;;
 
58
    do_start
 
59
    ;;
57
60
  restart|reload|force-reload)
58
 
        echo "Error: argument '$1' not supported" >&2
59
 
        exit 3
60
 
        ;;
 
61
    echo "Error: argument '$1' not supported" >&2
 
62
    exit 3
 
63
    ;;
61
64
  stop)
62
 
        # No-op
63
 
        ;;
 
65
    # No-op
 
66
    ;;
64
67
  *)
65
 
        echo "Usage: $0 start|stop" >&2
66
 
        exit 3
67
 
        ;;
 
68
    echo "Usage: $0 start|stop" >&2
 
69
    exit 3
 
70
    ;;
68
71
esac
69
72
 
70
73
: