Files
new_install/operation/mount_partition.sh
lizhi-rocky 220e6bfe40 add Qin Bo's operating shell scripts in
rename directory 'python' to 'interface', for I think it is a better name for its included python scripts function.
2010-09-03 15:59:49 +08:00

97 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
#
# DESCRIPTION: mounting all partitions which from stdin
#
# SCRIPT NAME: mount_partition.sh
#
# Usage: echo "/dev/sda1 / ext3" |./mount_partition.sh
#
# Notice: don't expect mount swap partition : )
#
# Input: stdin
# 1. partition
# 2. mountpoint
# 3. filesystem type
# below input is optional, if not set, we mount default configure,
# 4. fs_mntops: set mount options
# Output:
# 1 argument error
# 2 lack input (reserve)
# 3 device node doesn't exist
# 32 mount failure
#
# AUTHOR: Qin Bo
#
# EMAIL: bqin@linx-info.com
#
# DATE: 2010-08-06
#
# HISTORY:
# REVISOR DATE MODIFICATION
# Qin Bo 2010-08-06 create
#
#
#
source ./functions
mount_partition ()
{
local devname="$1"
local mountpoint="$2"
local fs_type="$3"
local fs_mntops="$4"
if [ ! -e "$devname" ];then
err "$devname node doesn't exist !"
return 3
fi
if [ "$mountpoint" == "/" ];then
mount_pos="$TARGET"
else
mount_pos="$TARGET$mountpoint"
fi
# mount filesystem for default option
# after install will set acl, so we use acl option mount here
# this configure according old Rocky installer
case $fs_type in
ext2|ext3|reiserfs)
[ -z "$fs_mntops" ] && fs_mntops="acl" ;;
*)
[ -z "$fs_mntops" ] && fs_mntops="defaults" ;;
esac
if [ ! -d "$mount_pos" ];then
info "create directory $mount_pos ..."
mkdir -p "$mount_pos"
fi
# mountpoint has already mounted, umount it
if mountpoint -q $mount_pos;then
# may be have mountpoint under the mountpoint directory
reumount $mount_pos
fi
info "mount $devname on $mount_pos with $fs_type filesystem"
mount -t "$fs_type" -o $fs_mntops "$devname" "$mount_pos" 1>"$dev_LOG" 2>&1
}
main()
{
while read line; do
echo $line
done|sort -k 2 -u|
while read line; do
if [ -n "$line" ];then
mount_partition $line
erv
fi
done
}
main "$@"