xref: /OK3568_Linux_fs/external/rkscript/resize-helper (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/sh
2### BEGIN INIT INFO
3# Provides:       resize-all
4# Default-Start:  S
5# Default-Stop:
6# Description:    Resize all internal mounted partitions
7### END INIT INFO
8
9# Don't exit on error status
10set +e
11
12# Uncomment below to see more logs
13# set -x
14
15. $(dirname $0)/disk-helper
16
17LOGFILE=/tmp/resize-all.log
18
19do_part()
20{
21	DEV=$1
22	MOUNT_POINT=$2
23	FSTYPE=$3
24	OPTS=$4
25
26	# Check /etc/fstab
27	if ! sed "s/#.*//" /etc/fstab | xargs -n 6 | cut -d' ' -f2 | \
28		grep -q "^$MOUNT_POINT/*$"; then
29		if [ "$MOUNT_POINT" != "/" ]; then
30			return 0
31		fi
32	fi
33
34	echo "Handling $DEV $MOUNT_POINT $FSTYPE $OPTS"
35
36	# Setup check/mount tools and do some prepare
37	prepare_part || return
38
39	# Store ro/rw
40	MOUNTED_RO_RW=$(touch $MOUNT_POINT &>/dev/null && echo rw || echo ro)
41
42	# Resize partition if needed
43	resize_part
44
45	# Restore ro/rw
46	remount_part $MOUNTED_RO_RW
47}
48
49resize_all()
50{
51	echo "Will now resize all mounted partitions in /etc/fstab or root"
52
53	while read LINE;do
54		do_part $LINE
55	done < /proc/mounts
56}
57
58case "$1" in
59	start|"")
60		resize_all 2>&1 | tee $LOGFILE
61		echo "Log saved to $LOGFILE"
62		;;
63	*)
64		echo "Usage: resize-helper start" >&2
65		exit 3
66		;;
67esac
68
69:
70