rename directory 'python' to 'interface', for I think it is a better name for its included python scripts function.
114 lines
2.5 KiB
Bash
Executable File
114 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# DESCRIPTION: configure fstab
|
|
# this script will modify $TARGT/etc/fstab,
|
|
# append the mountpoint to $TARGET/etc/fstab.
|
|
#
|
|
# SCRIPT NAME: configure_fstab.sh
|
|
#
|
|
# Usage: echo "/dev/hda2 /home ext3"|./configure_fstab.sh
|
|
#
|
|
# Input: stdin
|
|
# 1. partition
|
|
# 2. mountpoint
|
|
# 3. filesystem type
|
|
# below input is optional, if not set, we configure default,
|
|
# more about these argument read man fstab.
|
|
# 4. fs_mntops
|
|
# 5. fs_freq
|
|
# 6. fs_passno
|
|
#
|
|
# Output:
|
|
# 1 fstab doesn't exist
|
|
# 2 lack input (reserve)
|
|
# 3 device node doesn't exist
|
|
#
|
|
# AUTHOR: Qin Bo
|
|
#
|
|
# EMAIL: bqin@linx-info.com
|
|
#
|
|
# DATE: 2010-08-12
|
|
#
|
|
# HISTORY:
|
|
# REVISOR DATE MODIFICATION
|
|
# Qin Bo 2010-08-12 create
|
|
#
|
|
#
|
|
#
|
|
|
|
source ./functions
|
|
|
|
#
|
|
# if you redirect to /etc/fstab, don't print redundant to stdout in this function
|
|
#
|
|
configure_fstab ()
|
|
{
|
|
local devname="$1"
|
|
local mountpoint="$2"
|
|
local fs_type="$3"
|
|
|
|
local fs_mntops="$4"
|
|
local fs_freq="$5"
|
|
local fs_passno="$6"
|
|
|
|
if [ ! -e "$devname" ];then
|
|
err "$devname node doesn't exist !"
|
|
return 3
|
|
fi
|
|
|
|
# if partition is not swap, md, /, we use uuid instead device node
|
|
# / and swap partition use device node is decide by mkinitrd, this
|
|
# fstab will use by mkinitrd first ,if use UUID in fstab, mkinitrd will dead loop.
|
|
if [ "$mountpoint" != "/" -a "$(echo $devname | grep md)" = "" -a "$fs_type" != "swap" ];then
|
|
DEV_UUID=$(vol_id "$devname" | grep "ID_FS_UUID=" | cut -d "=" -f2)
|
|
devname="UUID=$DEV_UUID"
|
|
else
|
|
devname="$devname"
|
|
fi
|
|
|
|
# configure fstab options here
|
|
# fs_mntops, fs_freq, fs_passno has given, we use function argument,
|
|
# or we set default configuration, this default configuration according
|
|
# to old Rocky installer.
|
|
case $fs_type in
|
|
ext2|ext3|reiserfs)
|
|
[ -z "$fs_mntops" ] && fs_mntops="acl"
|
|
[ -z "$fs_freq" ] && fs_freq=1
|
|
[ -z "$fs_passno" ] && fs_passno=1 ;;
|
|
swap)
|
|
[ -z "$fs_mntops" ] && fs_mntops="defaults"
|
|
[ -z "$fs_freq" ] && fs_freq=0
|
|
[ -z "$fs_passno" ] && fs_passno=0 ;;
|
|
*)
|
|
[ -z "$fs_mntops" ] && fs_mntops="defaults"
|
|
[ -z "$fs_freq" ] && fs_freq=1
|
|
[ -z "$fs_passno" ] && fs_passno=1 ;;
|
|
esac
|
|
|
|
printf "%-60s %-10s %-10s %-25s %-1s %-1s\n" $devname $mountpoint $fs_type $fs_mntops $fs_freq $fs_passno
|
|
|
|
}
|
|
|
|
|
|
main ()
|
|
{
|
|
if [ -e "$TARGET/etc/fstab" ];then
|
|
sed -i '/^#devpts/ s/#//
|
|
/^#sysfs/ s/#//
|
|
/^#shm/ s/#shm /tmpfs/ ' "$TARGET/etc/fstab"
|
|
|
|
while read line;do
|
|
if [ -n "$line" ];then
|
|
configure_fstab $line >> "$TARGET/etc/fstab"
|
|
erv
|
|
fi
|
|
done
|
|
else
|
|
err "$TARGET/etc/fstab doesn't exist"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
main $@
|
|
|