1.1 --- a/OpenSecurity.iss Wed Feb 19 12:59:29 2014 +0100
1.2 +++ b/OpenSecurity.iss Thu Feb 20 15:40:48 2014 +0100
1.3 @@ -3,6 +3,7 @@
1.4 ; Inno Setup Compiler (http://www.jrsoftware.org/isinfo.php)
1.5
1.6 [Setup]
1.7 +; Basic installation stuff and config
1.8 AppName=OpenSecurity
1.9 AppContact=AIT Austrian Institute of Technology
1.10 AppPublisher=AIT Austrian Institute of Technology
1.11 @@ -10,6 +11,7 @@
1.12 AppVersion=0.1
1.13 ArchitecturesInstallIn64BitMode=x64
1.14 DefaultDirName={pf}\OpenSecurity
1.15 +DefaultGroupName=OpenSecurity
1.16 OutputDir="."
1.17 OutputBaseFilename="OpenSecurity Setup V0.1"
1.18 OutputManifestFile=OpenSecurity-Setup-Manifest.txt
1.19 @@ -18,11 +20,25 @@
1.20 UninstallDisplayIcon={app}\gfx\OpenSecurity.ico
1.21
1.22 [Files]
1.23 +; Files to copy
1.24 Source: "OpenSecurity\bin\*"; Excludes: "*.pyc"; DestDir: "{app}\bin"; Flags: recursesubdirs;
1.25 Source: "OpenSecurity\cygwin64\*"; DestDir: "{app}\cygwin64"; Flags: recursesubdirs;
1.26 Source: "OpenSecurity\gfx\*"; DestDir: "{app}\gfx"; Flags: recursesubdirs;
1.27 Source: "OpenSecurity\install\*"; DestDir: "{app}\install"; Flags: recursesubdirs;
1.28 Source: "OpenSecurity\python27\*"; DestDir: "{app}\python27"; Flags: recursesubdirs;
1.29
1.30 +[Registry]
1.31 +; Registry entries to set
1.32 +Root: HKLM; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueName: "OpenSecurity Daemon"; ValueType: string; ValueData: "{app}\python27\pythonw.exe ""{app}\bin\opensecurityd.pyw"""; Flags: uninsdeletevalue
1.33 +Root: HKCU; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueName: "OpenSecurity Tray Icon"; ValueType: string; ValueData: "{app}\python27\pythonw.exe ""{app}\bin\opensecurity_tray.pyw"""; Flags: uninsdeletevalue
1.34 +
1.35 +[Icons]
1.36 +; Program Icons in start menu
1.37 +Name: "{group}\OpenSecurity Tray Icon"; Filename: "{app}\python27\pythonw.exe"; Parameters: """{app}\bin\opensecurity_tray.pyw"""; WorkingDir: "{userappdata}"; Comment: "The OpenSecurity Tray Icon"; IconFilename: "{app}\gfx\OpenSecurity.ico"
1.38 +Name: "{group}\OpenSecurity Server"; Filename: "{app}\python27\pythonw.exe"; Parameters: """{app}\bin\opensecurityd.pyw"""; WorkingDir: "{userappdata}"; Comment: "The OpenSecurity VM System Orchestrating Server"; IconFilename: "{app}\gfx\OpenSecurity.ico"
1.39 +Name: "{group}\Uninstall OpenSecurity"; Filename: "{uninstallexe}"
1.40 +
1.41 [Run]
1.42 +; Run after installment
1.43 Filename: "{app}\install\initial_vm.bat"; Description: "Loading initial VM"; WorkingDir: "{app}\install"; StatusMsg: "Setting up initial VM..."; Flags: runasoriginaluser
1.44 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/OpenSecurity/install/initial_vm.sh Thu Feb 20 15:40:48 2014 +0100
2.3 @@ -0,0 +1,193 @@
2.4 +#!/bin/bash
2.5 +
2.6 +# ------------------------------------------------------------
2.7 +# download and install the initial VM for
2.8 +#
2.9 +# OpenSecurity V0.1
2.10 +#
2.11 +# This has been originally a Windows only BAT file.
2.12 +#
2.13 +# ... but coding this makes your head hurt and
2.14 +# supporting this "technology" any further by adding
2.15 +# software to the world relying on CMD.exe is an act
2.16 +# against humanity and should be punished by jail.
2.17 +#
2.18 +# To be called with the OpenSecurity installation folder
2.19 +# like C:\Program Files\OpenSecurity
2.20 +#
2.21 +# (C)opyright 2014, AIT Austrian Instiitute of Technology
2.22 +# ------------------------------------------------------------
2.23 +
2.24 +
2.25 +# ------------------------------------------------------------
2.26 +# vars
2.27 +
2.28 +OPENSECURITY_DIR="${1}"
2.29 +OPENSECURITY_PORT=8080
2.30 +OVA_TEMPLATE_URL="http://service.x-net.at/opensecurity/OsecVM_latest.ova"
2.31 +
2.32 +# we try to call VBox commans several times
2.33 +#
2.34 +# rational: on windows VirtualBox relies on the
2.35 +# VBoxSVC.exe DCOM service
2.36 +# which to interact with the VirtualBox
2.37 +# images.
2.38 +#
2.39 +# Sadly, this pretty buggy ...
2.40 +#
2.41 +# number of tries we do when interacting with vbox
2.42 +VBOX_RETRY_COUNT="5"
2.43 +
2.44 +
2.45 +# ------------------------------------------------------------
2.46 +# code
2.47 +
2.48 +
2.49 +# ------------------------------
2.50 +# read a value from the windows regsitry
2.51 +#
2.52 +# $1 ... full registry key
2.53 +# $2 ... value name
2.54 +# stdout the value found
2.55 +#
2.56 +function reg_read() {
2.57 +
2.58 + test -z "${1}" && return
2.59 +
2.60 + if [ -z "${2}" ]; then
2.61 + reg.exe query "${1}"
2.62 + else
2.63 + reg.exe query "${1}" /v "${2}" | grep "${2}" | sed 's/^.*REG_[A-Z]* *//'
2.64 + fi
2.65 +}
2.66 +
2.67 +
2.68 +# ------------------------------
2.69 +# turns a windows path into a cygwin path
2.70 +#
2.71 +# $1 ... windows path
2.72 +# stdout the value found
2.73 +#
2.74 +function sanitize_path() {
2.75 + test -z "${1}" && return
2.76 + echo $(cygpath -u "${1}")
2.77 +}
2.78 +
2.79 +
2.80 +# ------------------------------
2.81 +# vbox command hammer
2.82 +#
2.83 +# retry the vbox command some times
2.84 +# until sucess ... or death
2.85 +#
2.86 +# $1 ... full command to execute
2.87 +# stdout the result
2.88 +#
2.89 +function vbox_command() {
2.90 +
2.91 + echo "command failed ... :("
2.92 + exit 1
2.93 +}
2.94 +
2.95 +
2.96 +# ------------------------------
2.97 +# main ...
2.98 +#
2.99 +
2.100 +# check opensecurity folder
2.101 +#
2.102 +OPENSECURITY_DIR=$(sanitize_path "${OPENSECURITY_DIR}")
2.103 +if [ ! -d "${OPENSECURITY_DIR}" ]; then
2.104 + echo "please specify a valid path to the OpenSecurity"
2.105 + echo "installation folder --> not a valid directory"
2.106 + exit 1
2.107 +fi
2.108 +
2.109 +# look up VirtulBox installation
2.110 +#
2.111 +VBOX_MANAGER="$(reg_read 'HKLM\Software\Oracle\VirtualBox' 'InstallDir')VBoxManage.exe"
2.112 +VBOX_MANAGER=$(sanitize_path "${VBOX_MANAGER}")
2.113 +if [ ! -x "${VBOX_MANAGER}" ]; then
2.114 + echo "can't execute VBoxManage.exe - is VirtualBox installed?"
2.115 + echo "looked at: "$(cygpath -w ${VBOX_MANAGER})""
2.116 + exit 1
2.117 +fi
2.118 +
2.119 +# enforce VirtualBox to "feel good" by calling some functions
2.120 +#
2.121 +VBOX_VERSION=$("${VBOX_MANAGER}" -version)
2.122 +"${VBOX_MANAGER}" list vms &> /dev/null
2.123 +
2.124 +# download OSec.VM
2.125 +#
2.126 +OSECVM_IMAGE="${OPENSECURITY_DIR}/install/OsecVM.ova"
2.127 +if [ ! -e "${OSECVM_IMAGE}" ]; then
2.128 + echo "downloading OSecVM.ova image"
2.129 + wget -O "${OSECVM_IMAGE}" "${OVA_TEMPLATE_URL}"
2.130 + if [ "${?}" != "0" ]; then
2.131 + echo "failed to download OsecVM.ova"
2.132 + exit 1
2.133 + fi
2.134 +fi
2.135 +
2.136 +# import VM
2.137 +#
2.138 +for (( i=1; i<=${VBOX_RETRY_COUNT}; i++ )); do
2.139 +
2.140 + "${VBOX_MANAGER}" import "$(cygpath -w "${OSECVM_IMAGE}")" --vsys 0 --vmname SecurityDVM --unit 12 --disk "SecurityDVM\SecurityDVM.vmdk"
2.141 + test "${?}" -eq "0" && return
2.142 + echo "next try ..."
2.143 + sleep 1
2.144 +done
2.145 +
2.146 +# detach disk image
2.147 +#
2.148 +for (( i=1; i<=${VBOX_RETRY_COUNT}; i++ )); do
2.149 +
2.150 + "${VBOX_MANAGER}" storageattach SecurityDVM --storagectl SATA --port 0 --medium none
2.151 + test "${?}" -eq "0" && break
2.152 + echo "next try ..."
2.153 + sleep 1
2.154 +done
2.155 +
2.156 +# turn disk image into writethrough
2.157 +#
2.158 +for (( i=1; i<=${VBOX_RETRY_COUNT}; i++ )); do
2.159 +
2.160 + "${VBOX_MANAGER}" storageattach SecurityDVM --storagectl SATA --port 0 --device 0 --type hdd --mtype writethrough --medium 'SecurityDVM\SecurityDVM.vmdk'
2.161 + test "${?}" -eq "0" && break
2.162 + echo "next try ..."
2.163 + sleep 1
2.164 +done
2.165 +
2.166 +# attach disk again
2.167 +#
2.168 +for (( i=1; i<=${VBOX_RETRY_COUNT}; i++ )); do
2.169 +
2.170 + "${VBOX_MANAGER}" storageattach SecurityDVM --storagectl SATA --port 0 --device 0 --type hdd --mtype immutable --medium 'SecurityDVM\SecurityDVM.vmdk'
2.171 + test "${?}" -eq "0" && break
2.172 + echo "next try ..."
2.173 + sleep 1
2.174 +done
2.175 +
2.176 +
2.177 +
2.178 +
2.179 +#echo turning template image immutable
2.180 +#echo step 1: detach image
2.181 +#"${VBOX_MANAGER}" storageattach SecurityDVM --storagectl SATA --port 0 --medium none
2.182 +#echo step 2: writethrough image
2.183 +#echo.
2.184 +#"${VBOX_MANAGER}" storageattach SecurityDVM --storagectl SATA --port 0 --device 0 --type hdd --mtype writethrough --medium SecurityDVM\SecurityDVM.vmdk
2.185 +#echo step 3: detach image
2.186 +#echo.
2.187 +#"${VBOX_MANAGER}" storageattach SecurityDVM --storagectl SATA --port 0 --medium none
2.188 +#echo step 4: imuteable
2.189 +#echo.
2.190 +#"${VBOX_MANAGER}" storageattach SecurityDVM --storagectl SATA --port 0 --device 0 --type hdd --mtype immutable --medium SecurityDVM\SecurityDVM.vmdk
2.191 +#echo OpenSecurity VM Image ready.
2.192 +#echo.
2.193 +
2.194 +
2.195 +
2.196 +