oliver@91: #!/bin/bash oliver@91: oliver@91: # ------------------------------------------------------------ oliver@240: # download_initial_image.sh oliver@240: # oliver@91: # download initial VM for oliver@91: # oliver@240: # Copyright 2013-2014 X-Net and AIT Austrian Institute of Technology oliver@240: # oliver@240: # oliver@240: # X-Net Services GmbH oliver@240: # Elisabethstrasse 1 oliver@240: # 4020 Linz oliver@240: # AUSTRIA oliver@240: # https://www.x-net.at oliver@240: # oliver@240: # AIT Austrian Institute of Technology oliver@240: # Donau City Strasse 1 oliver@240: # 1220 Wien oliver@240: # AUSTRIA oliver@240: # http://www.ait.ac.at oliver@240: # oliver@240: # oliver@240: # Licensed under the Apache License, Version 2.0 (the "License"); oliver@240: # you may not use this file except in compliance with the License. oliver@240: # You may obtain a copy of the License at oliver@240: # oliver@240: # http://www.apache.org/licenses/LICENSE-2.0 oliver@240: # oliver@240: # Unless required by applicable law or agreed to in writing, software oliver@240: # distributed under the License is distributed on an "AS IS" BASIS, oliver@240: # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. oliver@240: # See the License for the specific language governing permissions and oliver@240: # limitations under the License. oliver@91: # ------------------------------------------------------------ oliver@91: oliver@240: oliver@91: # ------------------------------------------------------------ oliver@91: # code oliver@91: oliver@91: oliver@91: # download the ionitial OsecVM.ova from the X-Net servers oliver@91: # and place the file in the folder specified by ${1} oliver@91: oliver@91: oliver@91: # ------------------------------ oliver@91: # main ... oliver@91: # oliver@91: oliver@91: # check if we do have elevated rights oliver@91: # that is "Run as Administrator" invocation oliver@91: id -G | grep 544 &> /dev/null oliver@91: if [ "${?}" != 0 ]; then oliver@133: echo "Insufficient privileges. Is this script executed with 'Run As Administrator'?" oliver@133: echo "I'll try anyway..." oliver@91: fi oliver@91: oliver@91: TARGET_FOLDER="${1}" oliver@91: echo "fetching OpenSecurity initial VM at " $(date) oliver@91: echo "target folder: ${TARGET_FOLDER}" oliver@91: oliver@91: # sanity check oliver@91: mkdir -p "${TARGET_FOLDER}" oliver@91: if [ ! -d "${TARGET_FOLDER}" ]; then oliver@91: echo "failed to access target folder." oliver@91: exit 1 oliver@91: fi oliver@91: oliver@91: # start download oliver@250: URL=$(cat /proc/registry64/HKEY_LOCAL_MACHINE/SOFTWARE/OpenSecurity/ImageUrl) oliver@250: if [ $? != "0" ]; then oliver@250: echo "no URL given at HKEY_LOCAL_MACHINE/SOFTWARE/OpenSecurity/ImageUrl" oliver@250: echo "don't know where to look" oliver@250: exit 1 oliver@250: fi oliver@91: wget --progress=dot:mega ${URL} -O "${TARGET_FOLDER}"/OsecVM.ova oliver@91: oliver@91: