xref: /OK3568_Linux_fs/debian/overlay/usr/bin/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	echo "Handling $DEV $MOUNT_POINT $FSTYPE $OPTS"
27
28	# Setup check/mount tools and do some prepare
29	prepare_part || return
30
31	# Store ro/rw
32	MOUNTED_RO_RW=$(touch $MOUNT_POINT &>/dev/null && echo rw || echo ro)
33
34	# Resize partition if needed
35	resize_part
36
37	# Restore ro/rw
38	remount_part $MOUNTED_RO_RW
39}
40
41resize_all()
42{
43	echo "Will now resize all partitions in /proc/mounts"
44
45	while read LINE;do
46		do_part $LINE
47	done < /proc/mounts
48}
49
50case "$1" in
51	start|"")
52		resize_all 2>&1 | tee $LOGFILE
53		echo "Log saved to $LOGFILE"
54		;;
55	*)
56		echo "Usage: resize-helper start" >&2
57		exit 3
58		;;
59esac
60
61:
62