-
Notifications
You must be signed in to change notification settings - Fork 2
/
resquash
executable file
·41 lines (34 loc) · 896 Bytes
/
resquash
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
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
SQUASH_ROOT=/squashed
if [[ -z $1 ]] || [[ ! -d ${SQUASH_ROOT}/$1 ]]; then
echo "Invalid target or none specified. Valid targets are: "
squashes=($(ls $SQUASH_ROOT))
echo -e "\n Used\tDir\n ---------------"
for dir in ${squashes[*]}; do
echo -e " $(du -sh ${SQUASH_ROOT}/${dir}/rw 2> /dev/null | cut -d\/ -f1)${dir}"
done
echo
exit 1
fi
if [[ $UID -ne 0 ]]; then
sudo $0 $*
exit
fi
stat_busy "Squashing /${1}"
mksquashfs /$1 ${SQUASH_ROOT}/${1}/${1}_tmp.sfs -b 65536 || exit 1
stat_done
stat_busy "Unmounting old UnionFS"
umount -l /${1}
umount -l -d ${SQUASH_ROOT}/${1}/ro
stat_done
stat_busy "Replacing with new SquashFS"
rm ${SQUASH_ROOT}/${1}/${1}.sfs
mv ${SQUASH_ROOT}/${1}/${1}{_tmp,}.sfs
rm -rf ${SQUASH_ROOT}/${1}/rw/*
stat_done
stat_busy "Mounting new /${1}"
mount ${SQUASH_ROOT}/${1}/ro
mount /${1}
stat_done