various fixed and updates as per PR#44

This commit is contained in:
Darrin Hodges 2018-03-07 09:51:00 +11:00
Родитель efbebcb8b9
Коммит 137ccd717c
9 изменённых файлов: 41 добавлений и 119 удалений

Просмотреть файл

@ -7,7 +7,7 @@
"metadata": {
"description": "The base URI where artifacts required by this template are located. When the template is deployed using the accompanying scripts, a private location in the subscription will be used and this value will be automatically generated."
},
"defaultValue": "https://raw.githubusercontent.com/CatalystAUInf/Moodle/master/"
"defaultValue": "https://raw.githubusercontent.com/Azure/Moodle/master/"
},
"_artifactsLocationSasToken": {
"type": "securestring",
@ -235,7 +235,7 @@
"S4",
"S5",
"S6",
"S7",
"S7",
"S9"
],
"defaultValue": "S1",
@ -245,7 +245,7 @@
"type": "string"
},
"msSizeMB": {
"msDbSize": {
"allowedValues": [
"100MB",
"250MB",
@ -266,7 +266,7 @@
"750GB",
"1024GB"
],
"defaultValue": "250MB",
"defaultValue": "250GB",
"metadata": {
"description": "MS SQL database size"
},
@ -597,7 +597,7 @@
},
"databaseDNS": {
"type": "string",
"value": "[variables('moodleCommon').dbDNS]"
"value": "[variables('moodleCommon').dbDNS]"
},
"databaseAdminUsername": {
"type": "string",
@ -753,7 +753,7 @@
"webServerSetupScriptFilename": "setup_webserver.sh",
"webServerType": "[parameters('webServerType')]",
"serviceObjective": "[parameters('serviceObjective')]",
"msSizeMB": "[parameters('msSizeMB')]",
"msDbSize": "[parameters('msDbSize')]",
"webServerType": "[parameters('webServerType')]"
},
"octets": "[split(parameters('vNetAddressSpace'), '.')]",

Просмотреть файл

@ -24,6 +24,6 @@
"vNetAddressSpace": { "value": "172.31.0.0" },
"sshPublicKey": { "value": "GEN-SSH-PUB-KEY" },
"serviceObjective": { "value": "S7" },
"msSizeMB": { "value": "250GB" }
"msDbSize": { "value": "250GB" }
}
}

Просмотреть файл

@ -1,58 +0,0 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"moodleCommon": {
"metadata": {
"description": "Common Moodle values"
},
"type": "object"
}
},
"resources": [
{
"kind": "BlobStorage",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').blobStorageAccountName]",
"apiVersion": "2017-06-01",
"sku": {
"name": "[parameters('moodleCommon').blobStorageAccountType]"
},
"properties": {
"accessTier": "Hot",
"encryption": {
"keySource": "Microsoft.Storage",
"services": {
"blob": {
"enabled": true
},
"file": {
"enabled": true
}
}
},
"networkAcls": {
"bypass": "AzureServices",
"defaultAction": "Allow",
"ipRules": [],
"virtualNetworkRules": []
},
"supportsHttpsTrafficOnly": true
},
"type": "Microsoft.Storage/storageAccounts"
}
],
"variables": {
"documentation1": "This sub-template creates a blob storage account. It expects certain values in the 'common' datastructure.",
"documentation2": " blobStorageAccountName - name of storage account",
"documentation3": " blobStorageAccountType - type of storage account",
"scriptUri": "[concat(parameters('moodleCommon').ScriptLocation,parameters('moodleCommon').moodleInstallScriptFilename)]",
"blobStorageAccountId": "[concat(resourceGroup().id,'/providers/Microsoft.Storage/storageAccounts/', parameters('moodleCommon').blobStorageAccountName)]"
},
"outputs": {
"blobStorageAccountKey": {
"value": "[listKeys(variables('blobStorageAccountId'), '2017-06-01').keys[0].value]",
"type": "string"
}
}
}

Просмотреть файл

@ -25,7 +25,7 @@
]
},
"protectedSettings":{
"commandToExecute": "[concat('bash ', parameters('moodleCommon').moodleInstallScriptFilename, ' ', parameters('moodleCommon').moodleVersion, ' ', concat(parameters('moodleCommon').gfsNameRoot, '0'), ' ', 'data', ' ', parameters('moodleCommon').siteURL, ' ', parameters('moodleCommon').dbDNS, ' ', parameters('moodleCommon').moodleDbName, ' ', parameters('moodleCommon').moodleDbUser, ' ', parameters('moodleCommon').moodleDbPass, ' ', parameters('moodleCommon').moodleAdminPass, ' ', concat(parameters('moodleCommon').dbLogin, '@', parameters('moodleCommon').dbServerType, '-', parameters('moodleCommon').resourcesPrefix), ' ', parameters('moodleCommon').dbLoginPassword, ' ', parameters('moodleCommon').storageAccountName, ' ', listKeys(variables('storageAccountId'), '2017-06-01').keys[0].value, ' ', parameters('moodleCommon').moodleDbUserAzure, ' None None ', parameters('moodleCommon').elasticVm1IP, ' ', parameters('moodleCommon').installO365pluginsSwitch, ' ', parameters('moodleCommon').installElasticSearchSwitch, ' ', parameters('moodleCommon').dbServerType, ' ', parameters('moodleCommon').fileServerType, ' ', parameters('moodleCommon').serviceObjective, ' ', parameters('moodleCommon').skuTier, ' ', parameters('moodleCommon').msSizeMB )]",
"commandToExecute": "[concat('bash ', parameters('moodleCommon').moodleInstallScriptFilename, ' ', parameters('moodleCommon').moodleVersion, ' ', concat(parameters('moodleCommon').gfsNameRoot, '0'), ' ', 'data', ' ', parameters('moodleCommon').siteURL, ' ', parameters('moodleCommon').dbDNS, ' ', parameters('moodleCommon').moodleDbName, ' ', parameters('moodleCommon').moodleDbUser, ' ', parameters('moodleCommon').moodleDbPass, ' ', parameters('moodleCommon').moodleAdminPass, ' ', concat(parameters('moodleCommon').dbLogin, '@', parameters('moodleCommon').dbServerType, '-', parameters('moodleCommon').resourcesPrefix), ' ', parameters('moodleCommon').dbLoginPassword, ' ', parameters('moodleCommon').storageAccountName, ' ', listKeys(variables('storageAccountId'), '2017-06-01').keys[0].value, ' ', parameters('moodleCommon').moodleDbUserAzure, ' None None ', parameters('moodleCommon').elasticVm1IP, ' ', parameters('moodleCommon').installO365pluginsSwitch, ' ', parameters('moodleCommon').installElasticSearchSwitch, ' ', parameters('moodleCommon').dbServerType, ' ', parameters('moodleCommon').fileServerType, ' ', parameters('moodleCommon').serviceObjective, ' ', parameters('moodleCommon').skuTier, ' ', parameters('moodleCommon').msDbSize )]",
},
"type": "CustomScript",
"typeHandlerVersion": "2.0"
@ -50,7 +50,7 @@
"documentation12": " moodleAdminPass - password for moodle admin user",
"documentation13": " serviceObjective - MS SQL porformance tier.",
"documentation14": " skuTier - MS SQL edition tier",
"documentation15": " msSizeMB - MS SQL database size",
"documentation15": " msDbSize - MS SQL database size",
"scriptUri": "[concat(parameters('moodleCommon').scriptLocation,parameters('moodleCommon').moodleInstallScriptFilename,parameters('moodleCommon').artifactsSasToken)]",
"storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', parameters('moodleCommon').storageAccountName)]"

Просмотреть файл

@ -25,7 +25,7 @@
]
},
"protectedSettings":{
"commandToExecute": "[concat('bash ', parameters('moodleCommon').moodleInstallScriptFilename, ' ', parameters('moodleCommon').moodleVersion, ' ', concat(parameters('moodleCommon').gfsNameRoot, '0'), ' ', 'data', ' ', parameters('moodleCommon').siteURL, ' ', parameters('moodleCommon').dbDNS, ' ', parameters('moodleCommon').moodleDbName, ' ', parameters('moodleCommon').moodleDbUser, ' ', parameters('moodleCommon').moodleDbPass, ' ', parameters('moodleCommon').moodleAdminPass, ' ', concat(parameters('moodleCommon').dbLogin, '@', parameters('moodleCommon').dbServerType, '-', parameters('moodleCommon').resourcesPrefix), ' ', parameters('moodleCommon').dbLoginPassword, ' ', parameters('moodleCommon').storageAccountName, ' ', listKeys(variables('storageAccountId'), '2017-06-01').keys[0].value, ' ', parameters('moodleCommon').moodleDbUserAzure, ' ', parameters('moodleCommon').redisDns, ' ', listKeys(variables('redisResourceId'), '2016-04-01').primaryKey, ' ', parameters('moodleCommon').elasticVm1IP, ' ', parameters('moodleCommon').installO365pluginsSwitch, ' ', parameters('moodleCommon').installElasticSearchSwitch, ' ', parameters('moodleCommon').dbServerType, ' ', parameters('moodleCommon').fileServerType , ' ', parameters('moodleCommon').serviceObjective, ' ', parameters('moodleCommon').skuTier, ' ', parameters('moodleCommon').msSizeMB )]",
"commandToExecute": "[concat('bash ', parameters('moodleCommon').moodleInstallScriptFilename, ' ', parameters('moodleCommon').moodleVersion, ' ', concat(parameters('moodleCommon').gfsNameRoot, '0'), ' ', 'data', ' ', parameters('moodleCommon').siteURL, ' ', parameters('moodleCommon').dbDNS, ' ', parameters('moodleCommon').moodleDbName, ' ', parameters('moodleCommon').moodleDbUser, ' ', parameters('moodleCommon').moodleDbPass, ' ', parameters('moodleCommon').moodleAdminPass, ' ', concat(parameters('moodleCommon').dbLogin, '@', parameters('moodleCommon').dbServerType, '-', parameters('moodleCommon').resourcesPrefix), ' ', parameters('moodleCommon').dbLoginPassword, ' ', parameters('moodleCommon').storageAccountName, ' ', listKeys(variables('storageAccountId'), '2017-06-01').keys[0].value, ' ', parameters('moodleCommon').moodleDbUserAzure, ' ', parameters('moodleCommon').redisDns, ' ', listKeys(variables('redisResourceId'), '2016-04-01').primaryKey, ' ', parameters('moodleCommon').elasticVm1IP, ' ', parameters('moodleCommon').installO365pluginsSwitch, ' ', parameters('moodleCommon').installElasticSearchSwitch, ' ', parameters('moodleCommon').dbServerType, ' ', parameters('moodleCommon').fileServerType , ' ', parameters('moodleCommon').serviceObjective, ' ', parameters('moodleCommon').skuTier, ' ', parameters('moodleCommon').msDbSize )]",
},
"type": "CustomScript",
"typeHandlerVersion": "2.0"
@ -50,7 +50,7 @@
"documentation12": " moodleAdminPass - password for moodle admin user",
"documentation13": " serviceObjective - MS SQL porformance tier.",
"documentation14": " skuTier - MS SQL edition tier",
"documentation15": " msSizeMB - MS SQL database size",
"documentation15": " msDbSize - MS SQL database size",
"scriptUri": "[concat(parameters('moodleCommon').scriptLocation,parameters('moodleCommon').moodleInstallScriptFilename,parameters('moodleCommon').artifactsSasToken)]",
"storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', parameters('moodleCommon').storageAccountName)]",

Просмотреть файл

@ -11,14 +11,13 @@
},
"resources": [
{
"apiVersion": "2015-05-01-preview",
"apiVersion": "2014-04-01",
"kind": "",
"location": "[resourceGroup().location]",
"name": "[parameters('moodleCommon').serverName]",
"properties": {
"administratorLogin": "[parameters('moodleCommon').dbLogin]",
"administratorLoginPassword": "[parameters('moodleCommon').dbLoginPassword]",
"sslEnforcement": "[parameters('moodleCommon').sslEnforcement]",
"storageMB": "[parameters('moodleCommon').skuSizeMB]",
"version": "[parameters('moodleCommon').mssqlVersion]"
},
@ -34,7 +33,7 @@
"startIpAddress": "0.0.0.0",
"endIpAddress": "255.255.255.255"
},
"type": "firewallrules"
"type": "firewallRules"
}
],
"sku": {

Просмотреть файл

@ -2,6 +2,31 @@
# Common functions definitions
function install_php_sql_driver
{
# Download and build php/mssql driver
/usr/bin/curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
/usr/bin/curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql mssql-tools unixodbc-dev -y
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
#Build mssql driver
/usr/bin/pear config-set php_ini `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` system
/usr/bin/pecl install sqlsrv
/usr/bin/pecl install pdo_sqlsrv
PHPVER=`/usr/bin/php -r "echo PHP_VERSION;" | /usr/bin/cut -c 1,2,3`
echo "extension=sqlsrv.so" >> /etc/php/$PHPVER/fpm/php.ini
echo "extension=pdo_sqlsrv.so" >> /etc/php/$PHPVER/fpm/php.ini
echo "extension=sqlsrv.so" >> /etc/php/$PHPVER/apache2/php.ini
echo "extension=pdo_sqlsrv.so" >> /etc/php/$PHPVER/apache2/php.ini
echo "extension=sqlsrv.so" >> /etc/php/$PHPVER/cli/php.ini
echo "extension=pdo_sqlsrv.so" >> /etc/php/$PHPVER/cli/php.ini
}
function check_fileServerType_param
{
local fileServerType=$1
@ -1128,4 +1153,4 @@ function create_redis_configuration_in_moodledata_muc_config_php
),
);
EOF
}
}

Просмотреть файл

@ -666,27 +666,7 @@ EOF
if [ $dbServerType = "mysql" ]; then
sudo apt-get install -y --force-yes php-mysql
elif [ $dbServerType = "mssql" ]; then
# Download and build php/mssql driver
/usr/bin/curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
/usr/bin/curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql mssql-tools unixodbc-dev -y
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
#Build mssql driver
/usr/bin/pear config-set php_ini `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` system
/usr/bin/pecl install sqlsrv
/usr/bin/pecl install pdo_sqlsrv
PHPVER=`/usr/bin/php -r "echo PHP_VERSION;" | /usr/bin/cut -c 1,2,3`
echo "extension=sqlsrv.so" >> /etc/php/$PHPVER/fpm/php.ini
echo "extension=pdo_sqlsrv.so" >> /etc/php/$PHPVER/fpm/php.ini
echo "extension=sqlsrv.so" >> /etc/php/$PHPVER/apache2/php.ini
echo "extension=pdo_sqlsrv.so" >> /etc/php/$PHPVER/apache2/php.ini
echo "extension=sqlsrv.so" >> /etc/php/$PHPVER/cli/php.ini
echo "extension=pdo_sqlsrv.so" >> /etc/php/$PHPVER/cli/php.ini
install_php_sql_driver
else
sudo apt-get install -y --force-yes php-pgsql
fi
@ -1195,10 +1175,6 @@ EOF
/opt/mssql-tools/bin/sqlcmd -S $mssqlIP -U $mssqladminlogin -P ${mssqladminpass} -d ${moodledbname} -Q "CREATE USER ${moodledbuser} FROM LOGIN ${moodledbuser}"
/opt/mssql-tools/bin/sqlcmd -S $mssqlIP -U $mssqladminlogin -P ${mssqladminpass} -d ${moodledbname} -Q "exec sp_addrolemember 'db_owner','${moodledbuser}'"
echo "/opt/mssql-tools/bin/sqlcmd -S $mssqlIP -U $mssqladminlogin -P ${mssqladminpass} -Q \"CREATE DATABASE ${moodledbname} ( MAXSIZE = $serviceSize, EDITION = '$serviceTier', SERVICE_OBJECTIVE = '$serviceObjective' )\"" > /tmp/debug
echo "/opt/mssql-tools/bin/sqlcmd -S $mssqlIP -U $mssqladminlogin -P ${mssqladminpass} -Q \"CREATE LOGIN ${moodledbuser} with password = '${moodledbpass}'\"" >> /tmp/debug
echo "/opt/mssql-tools/bin/sqlcmd -S $mssqlIP -U $mssqladminlogin -P ${mssqladminpass} -d ${moodledbname} -Q \"CREATE USER ${moodledbuser} FROM LOGIN ${moodledbuser}\"" >> /tmp/debug
echo "/opt/mssql-tools/bin/sqlcmd -S $mssqlIP -U $mssqladminlogin -P ${mssqladminpass} -d ${moodledbname} -Q \"exec sp_addrolemember 'db_owner','${moodledbuser}'\"" >> /tmp/debug
else
# Create postgres db
echo "${postgresIP}:5432:postgres:${pgadminlogin}:${pgadminpass}" > /root/.pgpass
@ -1234,7 +1210,6 @@ EOF
mysql -h $mysqlIP -u $mysqladminlogin -p${mysqladminpass} ${moodledbname} -e "INSERT INTO mdl_config_plugins (plugin, name, value) VALUES ('tool_objectfs', 'azure_container', 'objectfs');"
mysql -h $mysqlIP -u $mysqladminlogin -p${mysqladminpass} ${moodledbname} -e "INSERT INTO mdl_config_plugins (plugin, name, value) VALUES ('tool_objectfs', 'azure_sastoken', '${sas}');"
elif [ $dbServerType = "mssql" ]; then
echo -e "cd /tmp; sudo -u www-data /usr/bin/php /moodle/html/moodle/admin/cli/install.php --chmod=770 --lang=en_us --wwwroot=https://"$siteFQDN" --dataroot=/moodle/moodledata --dbhost="$mssqlIP" --dbname="$moodledbname" --dbuser="$azuremoodledbuser" --dbpass="$moodledbpass" --dbtype=sqlsrv --fullname='Moodle LMS' --shortname='Moodle' --adminuser=admin --adminpass="$adminpass" --adminemail=admin@"$siteFQDN" --non-interactive --agree-license --allow-unstable || true "
cd /tmp; sudo -u www-data /usr/bin/php /moodle/html/moodle/admin/cli/install.php --chmod=770 --lang=en_us --wwwroot=https://$siteFQDN --dataroot=/moodle/moodledata --dbhost=$mssqlIP --dbname=$moodledbname --dbuser=$azuremoodledbuser --dbpass=$moodledbpass --dbtype=sqlsrv --fullname='Moodle LMS' --shortname='Moodle' --adminuser=admin --adminpass=$adminpass --adminemail=admin@$siteFQDN --non-interactive --agree-license --allow-unstable || true
/opt/mssql-tools/bin/sqlcmd -S $mssqlIP -U $mssqladminlogin -P ${mssqladminpass} -d ${moodledbname} -Q "INSERT INTO mdl_config_plugins (plugin, name, value) VALUES ('tool_objectfs', 'enabletasks', 1)"

Просмотреть файл

@ -77,26 +77,7 @@ check_fileServerType_param $fileServerType
# Moodle requirements
sudo apt-get install -y graphviz aspell php-soap php-json php-redis php-bcmath php-gd php-pgsql php-mysql php-xmlrpc php-intl php-xml php-bz2
# Download and build php/mssql driver
/usr/bin/curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
/usr/bin/curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql mssql-tools unixodbc-dev -y
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
#Build mssql driver
/usr/bin/pear config-set php_ini `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` system
/usr/bin/pecl install sqlsrv
/usr/bin/pecl install pdo_sqlsrv
PHPVER=`/usr/bin/php -r "echo PHP_VERSION;" | /usr/bin/cut -c 1,2,3`
echo "extension=sqlsrv.so" >> /etc/php/$PHPVER/fpm/php.ini
echo "extension=pdo_sqlsrv.so" >> /etc/php/$PHPVER/fpm/php.ini
echo "extension=sqlsrv.so" >> /etc/php/$PHPVER/apache2/php.ini
echo "extension=pdo_sqlsrv.so" >> /etc/php/$PHPVER/apache2/php.ini
echo "extension=sqlsrv.so" >> /etc/php/$PHPVER/cli/php.ini
echo "extension=pdo_sqlsrv.so" >> /etc/php/$PHPVER/cli/php.ini
install_php_sql_driver
if [ $fileServerType = "gluster" ]; then
# Mount gluster fs for /moodle