-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions
46 lines (40 loc) · 1003 Bytes
/
functions
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
# shared functions
function _getinfo {
id=`awk -F= '/DISTRIB_ID/ {print $2}' "$fsys/etc/lsb-release"`
release=`cut -d' ' -f2 $iso/.disk/info`
codename=`awk -F= '/DISTRIB_CODENAME/ {print $2}' "$fsys/etc/lsb-release"`
arch=`sed 's/.*Release \(.*\) (.*/\1/' $iso/.disk/info`
codefname=`cut -d'"' -f2 $iso/.disk/info`
}
function argpass {
if [ $# -gt 1 ]; then
echo $@ | cut -d' ' -f1 --complement;
fi
}
function _crop {
len=${#str}
ptr=$(($len-40))
if [ $ptr -gt 0 ]; then
echo -e "...${str:ptr:len}"
else
echo -e $str
fi
}
function _unmountISO { # error control for abnormal termination
for i in `sed -n 's/.*loop0 \(.*\) iso.*/\1/p' /proc/mounts`; do
if [ $i = $mnt ]; then
echo -en "${h2}Unmount ISO from${cdef} "; str=$i; _crop
umount -lf "$i"
if [ $? != 0 ]; then
echo -e "${error}Unable to unmount $i. Try it manually${cdef}"
exit
fi
rmdir $mnt
fi
done
}
function _clean {
_unmountISO
echo -e "${h2}cleaning up${cdef}"
rm -rf "$wd/custom"
}