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