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