about summary refs log blame commit diff stats
path: root/core/scripts/setup-iso.sh
blob: 11a38bc009fb3423dcfc4cb9153da9720ff272e2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13

         










                                                            


















                                                      
               
 
                       





                                             
                                                      






                                               
                                                          

      
                                                



                                 

      



                                         
 






                                        
#!/bin/sh

ISO_DIR=$1
CHROOT="/mnt"

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="${ISO_DIR}/crux-3.3.iso"
MD5_FILE="${ISO_DIR}/crux-3.3.md5"



# 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 ..."
}

prepare_iso() {

    mkdir -p ${ISO_DIR}

    if [ -f $ISO_FILE ];
    then
        echo "File $ISO_FILE exists."
    else
        echo "File $ISO_FILE does not exist."
        cd $ISO_DIR && { 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 ${ISO_DIR} && { curl -k -O ${MD5_URL} ; cd -; }
    fi

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

    modprobe isofs
    modprobe loop
    mount -o loop $ISO_FILE $CHROOT/media
}

echo "1.1.1 Paths to iso and md5 files:"
echo "dir: ${ISO_DIR}"
echo "iso url: ${ISO_URL}"
echo "md5 url: ${MD5_URL}"

ConfirmOrExit
prepare_iso