source: make-mini-image/functions @ 4293

Last change on this file since 4293 was 1751, checked in by mabarracus, 4 years ago

Add Initial Release

File size: 712 bytes
Line 
1source CONFIG
2
3ensure(){
4    while [ "$#" -gt 0 ]; do
5        if [ -z "${!1}" ]; then
6            echo "Need ${1} defined in CONFIG, exitting.."
7            exit 1
8        fi
9        shift
10    done
11}
12
13exists(){
14    local ret=0
15    while [ "$#" -gt 0 ]; do
16        if [ -z "${!1}" ]; then
17            ret=1
18        fi
19        shift
20    done
21    return ${ret}
22}
23
24exitting(){
25
26if [ "x${CLEAN_BASE}" = "x0" ]; then
27    exit 0
28fi
29
30ensure BASE
31
32if [ ! -d ./${BASE} ]; then
33    popd &> /dev/null
34fi
35if [ -d ./${BASE} ]; then
36    if [ "${IN_RAM}" = "1" ]; then
37        umount -l ./${BASE} &> /dev/null
38        rmdir ./${BASE} &> /dev/null
39    else
40        rm -rf ./${BASE} &> /dev/null
41    fi
42    if [ -z "${1}" ]; then
43        exit 1
44    else
45        echo ${1}
46        exit 0
47    fi
48fi
49}
50
51trap exitting QUIT KILL TERM INT
Note: See TracBrowser for help on using the repository browser.