OpenSecurity/bin/download_initial_image.sh
author Oliver Maurhart <oliver.maurhart@ait.ac.at>
Fri, 28 Nov 2014 15:52:36 +0100
changeset 250 7310daa5a362
parent 240 d7ef04254e9c
permissions -rwxr-xr-x
fix for downloading ImageUrl
     1 #!/bin/bash
     2 
     3 # ------------------------------------------------------------
     4 # download_initial_image.sh
     5 #
     6 # download initial VM for
     7 #
     8 # Copyright 2013-2014 X-Net and AIT Austrian Institute of Technology
     9 # 
    10 # 
    11 #     X-Net Services GmbH
    12 #     Elisabethstrasse 1
    13 #     4020 Linz
    14 #     AUSTRIA
    15 #     https://www.x-net.at
    16 # 
    17 #     AIT Austrian Institute of Technology
    18 #     Donau City Strasse 1
    19 #     1220 Wien
    20 #     AUSTRIA
    21 #     http://www.ait.ac.at
    22 # 
    23 # 
    24 # Licensed under the Apache License, Version 2.0 (the "License");
    25 # you may not use this file except in compliance with the License.
    26 # You may obtain a copy of the License at
    27 # 
    28 #    http://www.apache.org/licenses/LICENSE-2.0
    29 # 
    30 # Unless required by applicable law or agreed to in writing, software
    31 # distributed under the License is distributed on an "AS IS" BASIS,
    32 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    33 # See the License for the specific language governing permissions and
    34 # limitations under the License.
    35 # ------------------------------------------------------------
    36 
    37 
    38 # ------------------------------------------------------------
    39 # code
    40 
    41 
    42 # download the ionitial OsecVM.ova from the X-Net servers
    43 # and place the file in the folder specified by ${1}
    44 
    45 
    46 # ------------------------------
    47 # main ...
    48 #
    49 
    50 # check if we do have elevated rights
    51 # that is "Run as Administrator" invocation
    52 id -G | grep 544 &> /dev/null
    53 if [ "${?}" != 0 ]; then
    54     echo "Insufficient privileges. Is this script executed with 'Run As Administrator'?"
    55     echo "I'll try anyway..."
    56 fi
    57 
    58 TARGET_FOLDER="${1}"
    59 echo "fetching OpenSecurity initial VM at " $(date)
    60 echo "target folder: ${TARGET_FOLDER}"
    61 
    62 # sanity check
    63 mkdir -p "${TARGET_FOLDER}" 
    64 if [ ! -d "${TARGET_FOLDER}" ]; then
    65     echo "failed to access target folder."
    66     exit 1
    67 fi
    68 
    69 # start download
    70 URL=$(cat /proc/registry64/HKEY_LOCAL_MACHINE/SOFTWARE/OpenSecurity/ImageUrl)
    71 if [ $? != "0" ]; then
    72     echo "no URL given at HKEY_LOCAL_MACHINE/SOFTWARE/OpenSecurity/ImageUrl"
    73     echo "don't know where to look"
    74     exit 1
    75 fi
    76 wget --progress=dot:mega ${URL} -O "${TARGET_FOLDER}"/OsecVM.ova
    77 
    78