From 3185a204b43ae4a383f40a1fd97b734e7b24f037 Mon Sep 17 00:00:00 2001 From: kev Date: Mon, 21 Oct 2019 16:21:10 +0800 Subject: [PATCH] update phpvirtualbox --- phpvirtualbox/Dockerfile | 23 ++--- phpvirtualbox/arm/Dockerfile | 25 ++--- phpvirtualbox/arm/{ => data}/config.php | 116 +++++++++++------------- phpvirtualbox/arm/docker-compose.yml | 10 +- phpvirtualbox/arm/servers-from-env.php | 65 ------------- phpvirtualbox/{ => data}/config.php | 116 +++++++++++------------- phpvirtualbox/docker-compose.yml | 10 +- phpvirtualbox/servers-from-env.php | 65 ------------- 8 files changed, 137 insertions(+), 293 deletions(-) rename phpvirtualbox/arm/{ => data}/config.php (69%) delete mode 100644 phpvirtualbox/arm/servers-from-env.php rename phpvirtualbox/{ => data}/config.php (69%) delete mode 100644 phpvirtualbox/servers-from-env.php diff --git a/phpvirtualbox/Dockerfile b/phpvirtualbox/Dockerfile index e84ea54..bc3e60c 100644 --- a/phpvirtualbox/Dockerfile +++ b/phpvirtualbox/Dockerfile @@ -3,28 +3,23 @@ # FROM alpine -MAINTAINER kev +MAINTAINER EasyPi Software Foundation + +ENV PHPVBOX_VERSION=5.2-1 +ENV PHPVBOX_URL=https://github.com/phpvirtualbox/phpvirtualbox/archive/${PHPVBOX_VERSION}.tar.gz + +WORKDIR /var/www RUN set -xe \ && apk add --no-cache bash nginx php5-fpm php5-cli php5-json php5-soap \ - && apk add --no-cache --virtual build-dependencies wget unzip \ + && apk add --no-cache --virtual build-dependencies curl tar \ && touch /etc/php5/fpm.d/empty.conf \ - && wget --no-check-certificate https://sourceforge.net/projects/phpvirtualbox/files/latest/download -O phpvirtualbox.zip \ - && unzip phpvirtualbox.zip -d phpvirtualbox \ - && mkdir -p /var/www \ - && mv -v phpvirtualbox/*/* /var/www/ \ - && rm phpvirtualbox.zip \ - && rm phpvirtualbox/ -R \ + && curl -sSL ${PHPVBOX_URL} | tar xz --strip 1 \ && apk del build-dependencies \ - && rm -rf /var/cache/apk/* \ - && echo "" > /var/www/config-servers.php \ - && echo "" > /var/www/config-override.php \ && chown nobody:nobody -R /var/www -COPY config.php /var/www/config.php COPY nginx.conf /etc/nginx/nginx.conf -COPY servers-from-env.php /servers-from-env.php EXPOSE 80 -CMD php /servers-from-env.php && php-fpm && nginx +CMD php-fpm && nginx diff --git a/phpvirtualbox/arm/Dockerfile b/phpvirtualbox/arm/Dockerfile index 593b1da..3c13996 100644 --- a/phpvirtualbox/arm/Dockerfile +++ b/phpvirtualbox/arm/Dockerfile @@ -2,29 +2,24 @@ # Dockerfile for phpvirtualbox-arm # -FROM easypi/alpine-arm -MAINTAINER kev +FROM arm32v7/alpine:3 +MAINTAINER EasyPi Software Foundation + +ENV PHPVBOX_VERSION=5.2-1 +ENV PHPVBOX_URL=https://github.com/phpvirtualbox/phpvirtualbox/archive/${PHPVBOX_VERSION}.tar.gz + +WORKDIR /var/www RUN set -xe \ && apk add --no-cache bash nginx php5-fpm php5-cli php5-json php5-soap \ - && apk add --no-cache --virtual build-dependencies wget unzip \ + && apk add --no-cache --virtual build-dependencies curl tar \ && touch /etc/php5/fpm.d/empty.conf \ - && wget --no-check-certificate https://sourceforge.net/projects/phpvirtualbox/files/latest/download -O phpvirtualbox.zip \ - && unzip phpvirtualbox.zip -d phpvirtualbox \ - && mkdir -p /var/www \ - && mv -v phpvirtualbox/*/* /var/www/ \ - && rm phpvirtualbox.zip \ - && rm phpvirtualbox/ -R \ + && curl -sSL ${PHPVBOX_URL} | tar xz --strip 1 \ && apk del build-dependencies \ - && rm -rf /var/cache/apk/* \ - && echo "" > /var/www/config-servers.php \ - && echo "" > /var/www/config-override.php \ && chown nobody:nobody -R /var/www -COPY config.php /var/www/config.php COPY nginx.conf /etc/nginx/nginx.conf -COPY servers-from-env.php /servers-from-env.php EXPOSE 80 -CMD php /servers-from-env.php && php-fpm && nginx +CMD php-fpm && nginx diff --git a/phpvirtualbox/arm/config.php b/phpvirtualbox/arm/data/config.php similarity index 69% rename from phpvirtualbox/arm/config.php rename to phpvirtualbox/arm/data/config.php index fa19014..57e94b9 100644 --- a/phpvirtualbox/arm/config.php +++ b/phpvirtualbox/arm/data/config.php @@ -1,29 +1,19 @@ servers = require __DIR__ . '/config-servers.php'; - // getting override settings - $overrides = require __DIR__.'/config-override.php'; - foreach ($overrides as $key => $value) { - $this->$key = $value; - } - } - /* Username / Password for system user that runs VirtualBox */ - var $username = ''; - var $password = ''; + var $username = 'vbox'; + var $password = 'pass'; /* SOAP URL of vboxwebsrv (not phpVirtualBox's URL) */ - var $location = 'http://127.0.0.1:18083/'; + var $location = 'http://vboxwebsrv:18083/'; /* Default language. See languages folder for more language options. * Can also be changed in File -> Preferences -> Language in @@ -33,6 +23,8 @@ class phpVBoxConfig { /* Set the standard VRDE Port Number / Range, e.g. 1010-1020 or 1027 */ var $vrdeports = '9000-9100'; + /* Set the default VRDE address, e.g. 192.168.1.1 */ + #var $vrdeaddress = '192.168.1.1'; /* * @@ -43,27 +35,26 @@ class phpVBoxConfig { // Multiple servers example config. Uncomment (remove /* and */) to use. // Add ALL the servers you want to use. Even if you have the server set // above. The default server will be the first one in the list. - /* - var $servers = array( - array( - 'name' => 'London', - 'username' => 'user', - 'password' => 'pass', - 'location' => 'http://192.168.1.1:18083/', - 'authMaster' => true // Use this server for authentication - ), - array( - 'name' => '', - 'username' => 'user2', - 'password' => 'pass2', - 'location' => 'http://192.168.1.2:18083/' - ), - ); - */ + var $servers = array( + array( + 'name' => 'London', + 'username' => 'user', + 'password' => 'pass', + 'location' => 'http://192.168.1.1:18083/', + 'authMaster' => true // Use this server for authentication + ), + array( + 'name' => 'New York', + 'username' => 'user2', + 'password' => 'pass2', + 'location' => 'http://192.168.1.2:18083/' + ), + ); + */ // Disable authentication - var $noAuth = true; + #var $noAuth = true; // Host / ip to use for console connections #var $consoleHost = '192.168.1.40'; @@ -80,7 +71,7 @@ class phpVBoxConfig { // Max number of progress operations to keep in list var $maxProgressList = 5; - // Change default preview aspect ratio to 1. + // Change default preview aspect ratio to 1. // http://www.wikipedia.org/wiki/Aspect_ratio_%28image%29#Previous_and_presently_used_aspect_ratios #var $previewAspectRatio = 1.6; @@ -88,24 +79,24 @@ class phpVBoxConfig { #var $enableCustomIcons = true; /* - Exclusively use phpVirtualBox's groups configuration rather than VirtualBox groups. - This has the following effects: + Exclusively use phpVirtualBox's groups configuration rather than VirtualBox groups. + This has the following effects: - *) Group changes made in phpVirtualBox will not be reflected in VirtualBox programs such as - VirtualBox and VBoxManage - *) Group changes will not affect which folder a VM is placed in - *) You can rename groups that contain running VMs and move / copy running VMs to groups - */ - #var $phpVboxGroups = true; + *) Group changes made in phpVirtualBox will not be reflected in VirtualBox programs such as + VirtualBox and VBoxManage + *) Group changes will not affect which folder a VM is placed in + *) You can rename groups that contain running VMs and move / copy running VMs to groups + */ + #var $phpVboxGroups = true; /* - Allow to prompt deletion hard disk files on removal from Virtual Media Manager. - If this is not set, files are always kept. If this is set, you will be PROMPTED - to decide whether or not you would like to delete the hard disk file(s) when you - remove a hard disk from virtual media manager. You may still choose not to delete - the file when prompted. - */ + Allow to prompt deletion hard disk files on removal from Virtual Media Manager. + If this is not set, files are always kept. If this is set, you will be PROMPTED + to decide whether or not you would like to delete the hard disk file(s) when you + remove a hard disk from virtual media manager. You may still choose not to delete + the file when prompted. + */ var $deleteOnRemove = true; /* @@ -116,7 +107,7 @@ class phpVBoxConfig { var $browserRestrictFiles = array('.iso','.vdi','.vmdk','.img','.bin','.vhd','.hdd','.ovf','.ova','.xml','.vbox','.cdr','.dmg','.ima','.dsk','.vfd'); // Restrict locations / folders - var $browserRestrictFolders = array('/'); // Or something like array('/home/vbox','/var/ISOs') + #var $browserRestrictFolders = array('D:\\','C:\\Users\\Ian'); // Or something like array('/home/vbox','/var/ISOs') // Force use of local, web server based file browser instead of going through vboxwebsrv #var $browserLocal = true; @@ -146,7 +137,7 @@ class phpVBoxConfig { /* * VM Memory warnings. - * + * * If $vmMemoryStartLimitWarn is enabled, each time a VM is started through * phpVirtualBox, it will check that the available host memory is greater than * the base and video memory of the VM + 50MB (a little bit of overhead). If it @@ -158,8 +149,8 @@ class phpVBoxConfig { * performed by $vmMemoryStartLimitWarn logic. For instance it may be a good * idea to always have VM memory requirements + 100MB free. 100 is the default. */ - #var $vmMemoryStartLimitWarn = true; - #var $vmMemoryOffset = 100; + #var $vmMemoryStartLimitWarn = true; + #var $vmMemoryOffset = 100; /* @@ -181,7 +172,7 @@ class phpVBoxConfig { var $nicMax = 4; /* Enable advanced configuration items (normally hidden in the VirtualBox GUI) - * Note that some of these items may not be translated to languages other than English. + * Note that some of these items may not be translated to languages other than English. */ #var $enableAdvancedConfig = true; @@ -192,7 +183,7 @@ class phpVBoxConfig { #var $startStopConfig = true; // Authentication library. - var $authLib = 'Builtin'; + // var $authLib = 'Builtin'; // VM ownership #var $enforceVMOwnership = true; @@ -204,26 +195,29 @@ class phpVBoxConfig { // Allow VDE network configuration. This must be supported by the underlying VirtualBox installation! // If you do not know what VDE networking is - you do not need it, it is probably not supported by your // VirtualBox installation and will cause errors if enabled. - #var $enableVDE = true; + #var $enableVDE = true; // Disable setting SATA controllers port count to the max port number found when saving VMs. #var $disableSataPortCount = true; /* Enable Parallel Port configuration - EXPERIMENTAL - LPT support may or may not work for you. - !!! VirtualBox LPT support only works in Linux. !!! - */ + LPT support may or may not work for you. + !!! VirtualBox LPT support only works in Linux. !!! + */ #var $enableLPTConfig = true; /* Enable HardDisk IgnoreFlush configuration. This controls the "ExtraData" setting * in "VBoxInternal/Devices/[controller type]/0/LUN#[x]/Config/IgnoreFlush". See * Responding to guest IDE/SATA flush requests at: * http://www.virtualbox.org/manual/ch12.html#idp12757424 - */ + */ #var $enableHDFlushConfig = true; + /* + * Event listener timeout in seconds. This is an advanced option that most people will + * probably not need to change. + */ + #var $eventListenerTimeout = 20; /* END SETTINGS */ - - } diff --git a/phpvirtualbox/arm/docker-compose.yml b/phpvirtualbox/arm/docker-compose.yml index 5ad45c7..9b33a2d 100644 --- a/phpvirtualbox/arm/docker-compose.yml +++ b/phpvirtualbox/arm/docker-compose.yml @@ -2,10 +2,8 @@ phpvirtualbox: image: easypi/phpvirtualbox-arm ports: - "8888:80" - environment: - - ID_PORT_18083_TCP=remote-server:18083 - - ID_NAME=Vbox - - ID_USER=username - - ID_PW=password - - CONF_browserRestrictFolders=/data, + volumes: + - ./data/config.php:/var/www/config.php:ro + extra_hosts: + - vboxwebsrv:x.x.x.x restart: always diff --git a/phpvirtualbox/arm/servers-from-env.php b/phpvirtualbox/arm/servers-from-env.php deleted file mode 100644 index 8089a45..0000000 --- a/phpvirtualbox/arm/servers-from-env.php +++ /dev/null @@ -1,65 +0,0 @@ - $value) { - preg_match('/(.*?)(?:_ENV_|_)?CONF_(.+)/', $key, $matches); - if ($matches) { - $value= (strpos($value, ',')) ? split(',',$value) : $value; - $config_overrides[$matches[1]] = array($matches[2] => $value); - } -} - -echo 'Exposing the following linked server instances:' . PHP_EOL; - -// getting servers from linked vboxwebsrv containers or environment variables -foreach ($_SERVER as $key => $value) { - if (substr($key, -15) === '_PORT_18083_TCP') { - $prefix = substr($key, 0, -15); - - $name = getenv($prefix . '_NAME'); - $pos = strrpos($name, '/'); - if ($pos !== false) { - $name = substr($name, $pos + 1); - } - - if (!$name) { - $name = strtolower($prefix); - } - $name = ucfirst($name); - - $location = 'http://' . str_replace('tcp://', '', $value) . '/'; - - echo '- ' . $name . ' (' . $location .')' . PHP_EOL; - - $username = getenv($prefix.'_USER'); - $password = getenv($prefix.'_PW'); - - if ($username == "") $username = 'username'; - if ($password == "") $password = 'username'; - - $servers []= array_merge(array( - 'name' => $name, - 'username' => $username, - 'password' => $password, - 'authMaster' => true, - 'location' => $location), - (array_key_exists($prefix, $config_overrides)) ? $config_overrides[$prefix] : array()); - } -} -// check if there are any servers -if (!$servers) { - echo 'Error: No vboxwebsrv instance linked? Use "--link containername:myname"' . PHP_EOL; - echo 'Use environment variables if no vboxwebsrv containers are used!'; - exit(1); -} - -// put servers array to file -file_put_contents('/var/www/config-servers.php', 'servers = require __DIR__ . '/config-servers.php'; - // getting override settings - $overrides = require __DIR__.'/config-override.php'; - foreach ($overrides as $key => $value) { - $this->$key = $value; - } - } - /* Username / Password for system user that runs VirtualBox */ - var $username = ''; - var $password = ''; + var $username = 'vbox'; + var $password = 'pass'; /* SOAP URL of vboxwebsrv (not phpVirtualBox's URL) */ - var $location = 'http://127.0.0.1:18083/'; + var $location = 'http://vboxwebsrv:18083/'; /* Default language. See languages folder for more language options. * Can also be changed in File -> Preferences -> Language in @@ -33,6 +23,8 @@ class phpVBoxConfig { /* Set the standard VRDE Port Number / Range, e.g. 1010-1020 or 1027 */ var $vrdeports = '9000-9100'; + /* Set the default VRDE address, e.g. 192.168.1.1 */ + #var $vrdeaddress = '192.168.1.1'; /* * @@ -43,27 +35,26 @@ class phpVBoxConfig { // Multiple servers example config. Uncomment (remove /* and */) to use. // Add ALL the servers you want to use. Even if you have the server set // above. The default server will be the first one in the list. - /* - var $servers = array( - array( - 'name' => 'London', - 'username' => 'user', - 'password' => 'pass', - 'location' => 'http://192.168.1.1:18083/', - 'authMaster' => true // Use this server for authentication - ), - array( - 'name' => '', - 'username' => 'user2', - 'password' => 'pass2', - 'location' => 'http://192.168.1.2:18083/' - ), - ); - */ + var $servers = array( + array( + 'name' => 'London', + 'username' => 'user', + 'password' => 'pass', + 'location' => 'http://192.168.1.1:18083/', + 'authMaster' => true // Use this server for authentication + ), + array( + 'name' => 'New York', + 'username' => 'user2', + 'password' => 'pass2', + 'location' => 'http://192.168.1.2:18083/' + ), + ); + */ // Disable authentication - var $noAuth = true; + #var $noAuth = true; // Host / ip to use for console connections #var $consoleHost = '192.168.1.40'; @@ -80,7 +71,7 @@ class phpVBoxConfig { // Max number of progress operations to keep in list var $maxProgressList = 5; - // Change default preview aspect ratio to 1. + // Change default preview aspect ratio to 1. // http://www.wikipedia.org/wiki/Aspect_ratio_%28image%29#Previous_and_presently_used_aspect_ratios #var $previewAspectRatio = 1.6; @@ -88,24 +79,24 @@ class phpVBoxConfig { #var $enableCustomIcons = true; /* - Exclusively use phpVirtualBox's groups configuration rather than VirtualBox groups. - This has the following effects: + Exclusively use phpVirtualBox's groups configuration rather than VirtualBox groups. + This has the following effects: - *) Group changes made in phpVirtualBox will not be reflected in VirtualBox programs such as - VirtualBox and VBoxManage - *) Group changes will not affect which folder a VM is placed in - *) You can rename groups that contain running VMs and move / copy running VMs to groups - */ - #var $phpVboxGroups = true; + *) Group changes made in phpVirtualBox will not be reflected in VirtualBox programs such as + VirtualBox and VBoxManage + *) Group changes will not affect which folder a VM is placed in + *) You can rename groups that contain running VMs and move / copy running VMs to groups + */ + #var $phpVboxGroups = true; /* - Allow to prompt deletion hard disk files on removal from Virtual Media Manager. - If this is not set, files are always kept. If this is set, you will be PROMPTED - to decide whether or not you would like to delete the hard disk file(s) when you - remove a hard disk from virtual media manager. You may still choose not to delete - the file when prompted. - */ + Allow to prompt deletion hard disk files on removal from Virtual Media Manager. + If this is not set, files are always kept. If this is set, you will be PROMPTED + to decide whether or not you would like to delete the hard disk file(s) when you + remove a hard disk from virtual media manager. You may still choose not to delete + the file when prompted. + */ var $deleteOnRemove = true; /* @@ -116,7 +107,7 @@ class phpVBoxConfig { var $browserRestrictFiles = array('.iso','.vdi','.vmdk','.img','.bin','.vhd','.hdd','.ovf','.ova','.xml','.vbox','.cdr','.dmg','.ima','.dsk','.vfd'); // Restrict locations / folders - var $browserRestrictFolders = array('/'); // Or something like array('/home/vbox','/var/ISOs') + #var $browserRestrictFolders = array('D:\\','C:\\Users\\Ian'); // Or something like array('/home/vbox','/var/ISOs') // Force use of local, web server based file browser instead of going through vboxwebsrv #var $browserLocal = true; @@ -146,7 +137,7 @@ class phpVBoxConfig { /* * VM Memory warnings. - * + * * If $vmMemoryStartLimitWarn is enabled, each time a VM is started through * phpVirtualBox, it will check that the available host memory is greater than * the base and video memory of the VM + 50MB (a little bit of overhead). If it @@ -158,8 +149,8 @@ class phpVBoxConfig { * performed by $vmMemoryStartLimitWarn logic. For instance it may be a good * idea to always have VM memory requirements + 100MB free. 100 is the default. */ - #var $vmMemoryStartLimitWarn = true; - #var $vmMemoryOffset = 100; + #var $vmMemoryStartLimitWarn = true; + #var $vmMemoryOffset = 100; /* @@ -181,7 +172,7 @@ class phpVBoxConfig { var $nicMax = 4; /* Enable advanced configuration items (normally hidden in the VirtualBox GUI) - * Note that some of these items may not be translated to languages other than English. + * Note that some of these items may not be translated to languages other than English. */ #var $enableAdvancedConfig = true; @@ -192,7 +183,7 @@ class phpVBoxConfig { #var $startStopConfig = true; // Authentication library. - var $authLib = 'Builtin'; + // var $authLib = 'Builtin'; // VM ownership #var $enforceVMOwnership = true; @@ -204,26 +195,29 @@ class phpVBoxConfig { // Allow VDE network configuration. This must be supported by the underlying VirtualBox installation! // If you do not know what VDE networking is - you do not need it, it is probably not supported by your // VirtualBox installation and will cause errors if enabled. - #var $enableVDE = true; + #var $enableVDE = true; // Disable setting SATA controllers port count to the max port number found when saving VMs. #var $disableSataPortCount = true; /* Enable Parallel Port configuration - EXPERIMENTAL - LPT support may or may not work for you. - !!! VirtualBox LPT support only works in Linux. !!! - */ + LPT support may or may not work for you. + !!! VirtualBox LPT support only works in Linux. !!! + */ #var $enableLPTConfig = true; /* Enable HardDisk IgnoreFlush configuration. This controls the "ExtraData" setting * in "VBoxInternal/Devices/[controller type]/0/LUN#[x]/Config/IgnoreFlush". See * Responding to guest IDE/SATA flush requests at: * http://www.virtualbox.org/manual/ch12.html#idp12757424 - */ + */ #var $enableHDFlushConfig = true; + /* + * Event listener timeout in seconds. This is an advanced option that most people will + * probably not need to change. + */ + #var $eventListenerTimeout = 20; /* END SETTINGS */ - - } diff --git a/phpvirtualbox/docker-compose.yml b/phpvirtualbox/docker-compose.yml index 5870709..17b868d 100644 --- a/phpvirtualbox/docker-compose.yml +++ b/phpvirtualbox/docker-compose.yml @@ -2,10 +2,8 @@ phpvirtualbox: image: vimagick/phpvirtualbox ports: - "8888:80" - environment: - - ID_PORT_18083_TCP=remote-server:18083 - - ID_NAME=Vbox - - ID_USER=username - - ID_PW=password - - CONF_browserRestrictFolders=/data, + volumes: + - ./data/config.php:/var/www/config.php:ro + extra_hosts: + - vboxwebsrv:x.x.x.x restart: always diff --git a/phpvirtualbox/servers-from-env.php b/phpvirtualbox/servers-from-env.php deleted file mode 100644 index 8089a45..0000000 --- a/phpvirtualbox/servers-from-env.php +++ /dev/null @@ -1,65 +0,0 @@ - $value) { - preg_match('/(.*?)(?:_ENV_|_)?CONF_(.+)/', $key, $matches); - if ($matches) { - $value= (strpos($value, ',')) ? split(',',$value) : $value; - $config_overrides[$matches[1]] = array($matches[2] => $value); - } -} - -echo 'Exposing the following linked server instances:' . PHP_EOL; - -// getting servers from linked vboxwebsrv containers or environment variables -foreach ($_SERVER as $key => $value) { - if (substr($key, -15) === '_PORT_18083_TCP') { - $prefix = substr($key, 0, -15); - - $name = getenv($prefix . '_NAME'); - $pos = strrpos($name, '/'); - if ($pos !== false) { - $name = substr($name, $pos + 1); - } - - if (!$name) { - $name = strtolower($prefix); - } - $name = ucfirst($name); - - $location = 'http://' . str_replace('tcp://', '', $value) . '/'; - - echo '- ' . $name . ' (' . $location .')' . PHP_EOL; - - $username = getenv($prefix.'_USER'); - $password = getenv($prefix.'_PW'); - - if ($username == "") $username = 'username'; - if ($password == "") $password = 'username'; - - $servers []= array_merge(array( - 'name' => $name, - 'username' => $username, - 'password' => $password, - 'authMaster' => true, - 'location' => $location), - (array_key_exists($prefix, $config_overrides)) ? $config_overrides[$prefix] : array()); - } -} -// check if there are any servers -if (!$servers) { - echo 'Error: No vboxwebsrv instance linked? Use "--link containername:myname"' . PHP_EOL; - echo 'Use environment variables if no vboxwebsrv containers are used!'; - exit(1); -} - -// put servers array to file -file_put_contents('/var/www/config-servers.php', '