Skip to content
Newer
Older
100755 42 lines (34 sloc) 896 Bytes
255867a Initial commit
Dave Reisner authored
1 #!/bin/bash
2
97342fc @falconindy Pull in /etc/rc.conf to allow color
authored
3 . /etc/rc.conf
255867a Initial commit
Dave Reisner authored
4 . /etc/rc.d/functions
5 SQUASH_ROOT=/squashed
6
9b345b4 resquash: Add list of space taken by each squashed dir's rw aufs
Dave Reisner authored
7 if [[ -z $1 ]] || [[ ! -d ${SQUASH_ROOT}/$1 ]]; then
8 echo "Invalid target or none specified. Valid targets are: "
255867a Initial commit
Dave Reisner authored
9 squashes=($(ls $SQUASH_ROOT))
9b345b4 resquash: Add list of space taken by each squashed dir's rw aufs
Dave Reisner authored
10 echo -e "\n Used\tDir\n ---------------"
11 for dir in ${squashes[*]}; do
12 echo -e " $(du -sh ${SQUASH_ROOT}/${dir}/rw 2> /dev/null | cut -d\/ -f1)${dir}"
13 done
14 echo
255867a Initial commit
Dave Reisner authored
15 exit 1
16 fi
17
18 if [[ $UID -ne 0 ]]; then
19 sudo $0 $*
20 exit
21 fi
22
23 stat_busy "Squashing /${1}"
341a766 cleanup
Dave Reisner authored
24 mksquashfs /$1 ${SQUASH_ROOT}/${1}/${1}_tmp.sfs -b 65536 || exit 1
255867a Initial commit
Dave Reisner authored
25 stat_done
26
27 stat_busy "Unmounting old UnionFS"
341a766 cleanup
Dave Reisner authored
28 umount -l /${1}
a16b237 Use -d flag in unmounting loop device to free it
Dave Reisner authored
29 umount -l -d ${SQUASH_ROOT}/${1}/ro
255867a Initial commit
Dave Reisner authored
30 stat_done
31
32 stat_busy "Replacing with new SquashFS"
341a766 cleanup
Dave Reisner authored
33 rm ${SQUASH_ROOT}/${1}/${1}.sfs
34 mv ${SQUASH_ROOT}/${1}/${1}{_tmp,}.sfs
35 rm -rf ${SQUASH_ROOT}/${1}/rw/*
255867a Initial commit
Dave Reisner authored
36 stat_done
37
38 stat_busy "Mounting new /${1}"
341a766 cleanup
Dave Reisner authored
39 mount ${SQUASH_ROOT}/${1}/ro
40 mount /${1}
255867a Initial commit
Dave Reisner authored
41 stat_done
Something went wrong with that request. Please try again.