about summary refs log tree commit diff stats
path: root/core/scripts/setup-iso.sh
blob: e20837836b6f3b3b4885eda36a2125646f3ed60d (plain) (blame)
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
62
63
64
65
66
67
68
69
#!/bin/sh

# First we define the function
ConfirmOrExit ()
{
    while true
    do
        echo -n "Please confirm (y or n) :"
        read CONFIRM
        case $CONFIRM in
            y|Y|YES|yes|Yes) break ;;
            n|N|no|NO|No)
                echo "Aborting - you entered $CONFIRM"
                exit
                ;;
            *) echo "Please enter only y or n"
        esac
    done
    echo "You entered $CONFIRM. Continuing ..."
}

# Absolute path to this script, e.g. /home/user/bin/foo.sh
SCRIPT=$(readlink -f "$0")
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=$(dirname "$SCRIPT")

DIR=$(dirname "$SCRIPTPATH");
DIR_LOCAL="$(dirname $(dirname ${DIR}))/local";

ISO_URL="https://serverop.de/crux/crux-3.3/iso/crux-3.3.iso"
MD5_URL="https://serverop.de/crux/crux-3.3/iso/crux-3.3.md5"

ISO_FILE="${DIR_LOCAL}/crux-3.3.iso"
MD5_FILE="${DIR_LOCAL}/crux-3.3.md5"

echo "1.1.1 Paths to iso and md5 files:"
echo "dir: ${DIR_LOCAL}"
echo "iso url: ${ISO_URL}"
echo "md5 url: ${MD5_URL}"
ConfirmOrExit
mkdir -p ${DIR_LOCAL}

#prepare_iso() {

    if [ -f $ISO_FILE ];
    then
        echo "File $ISO_FILE exists."
    else
        echo "File $ISO_FILE does not exist."
        cd $DIR_LOCAL && { curl -k -O $ISO_URL ; cd -; }
    fi

    if [ -f $MD5_FILE ];
    then
        echo "File ${MD5_FILE} exists."
    else
        echo "File ${MD5_FILE} does not exist."
        cd ${DIR_LOCAL} && { curl -k -O ${MD5_URL} ; cd -; }
    fi

    if  cd ${DIR_LOCAL} && md5sum -c ${MD5_FILE} ;
    then
        echo "Valid iso md5sum"
    else
        echo "Invalid iso md5sum"
    fi

#}