3 # Copyright 2013-2014 Intel Corporation
4 # Author: Artem Bityutskiy
10 srcdir="$(readlink -ev -- ${0%/*})"
11 PATH="/usr/share/setup-ivi:$srcdir:$PATH"
13 if [ -f "$srcdir/setup-ivi-sh-functions" ]; then
14 . "$srcdir/setup-ivi-sh-functions"
15 . "$srcdir/installerfw-sh-functions"
17 . /usr/share/setup-ivi/setup-ivi-sh-functions
18 . /usr/share/setup-ivi/installerfw-sh-functions
21 # This is a small trick which I use to make sure my scripts are portable -
22 # check if 'dash' is present, and if yes - use it.
23 if can_switch_to_dash; then
24 exec dash -euf -- "$srcdir/$PROG" "$@"
31 Usage: $PROG [options]
33 Create the default Tizen IVI /etc/fstab file.
36 -f, --force re-write /etc/fstab if it exists
37 -v, --verbose be verbose
38 --version show the program version and exit
39 -h, --help show this text and exit
45 IFS= printf "%s\n\n" "$PROG: error: $*" >&2
51 tmp=`getopt -n $PROG -o f,v,h --long force,verbose,version,help -- "$@"` ||
52 show_usage_fail "cannot parse command-line options"
75 *) show_usage_fail "unrecognized option \"$1\""
81 if ! installerfw_available; then
82 installerfw_restore_env
85 fstab="$(installerfw_mnt_prefix "/etc/fstab")"
87 if [ -s "$fstab" ] && [ -z "$force" ]; then
88 fatal "\"$fstab\" already exists, use -f to re-write it"
91 installerfw_verify_defined "INSTALLERFW_PART_COUNT"
93 contents="# Generated by $PROG
94 devpts /dev/pts devpts gid=5,mode=620 0 0
95 tmpfs /dev/shm tmpfs defaults 0 0
96 proc /proc proc defaults 0 0
97 sysfs /sys sysfs defaults 0 0"
100 while [ "$pnum" -lt "$INSTALLERFW_PART_COUNT" ]; do
101 installerfw_verify_defined "INSTALLERFW_PART${pnum}_UUID"
102 installerfw_verify_defined "INSTALLERFW_PART${pnum}_MOUNTPOINT"
103 installerfw_verify_defined "INSTALLERFW_PART${pnum}_FSTYPE"
105 eval uuid="\${INSTALLERFW_PART${pnum}_UUID:-}"
106 eval mountpoint="\${INSTALLERFW_PART${pnum}_MOUNTPOINT:-}"
107 eval fsopts="\${INSTALLERFW_PART${pnum}_FSOPTS:-defaults}"
108 eval fstype="\${INSTALLERFW_PART${pnum}_FSTYPE:-}"
110 if [ "$fstype" = "vfat" ]; then
111 # FAT FS's short UUID has to be uppercase
112 uuid="$(printf "%s" "$uuid" | tr "[:lower:]" "[:upper:]")"
114 # Normal UUID has to be lowercase
115 uuid="$(printf "%s" "$uuid" | tr "[:upper:]" "[:lower:]")"
118 contents="${contents}${br}UUID=$uuid $mountpoint $fstype $fsopts 0 0"
123 verbose "writing the followint to \"$fstab\": $contents"
125 printf "%s" "$contents" > "$fstab"