Коммит
18ff5c2c9d
|
@ -0,0 +1,51 @@
|
|||
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=windows,visualstudiocode
|
||||
|
||||
### VisualStudioCode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
### VisualStudioCode Patch ###
|
||||
# Ignore all local history of files
|
||||
.history
|
||||
.ionide
|
||||
|
||||
### Windows ###
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/windows,visualstudiocode
|
||||
|
||||
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)
|
||||
.ssh/*
|
|
@ -0,0 +1,37 @@
|
|||
# Airsonic deployment
|
||||
Ubuntu/Tomcat/Java/mySQL environment for Azure airsonic app deployment
|
||||
|
||||
|
||||
Ported from https://github.com/selvasingh/tomcat-on-virtual-machine
|
||||
|
||||
Fully automated deployment via arm templates and custom scripts
|
||||
|
||||
### Port Notes:
|
||||
|
||||
* Does not install Tomcat as a service
|
||||
* Does not configure transcoding, i.e. sudo snap install ffmpeg
|
||||
* Binding of airsonic app to mysql fisrt requires the app be started to create a .properties file, stopped, then the .properties needs to be updated with jndi binding. At the end of the airsonic install, the app is started then stopped to create this file using a 30 second wait period between operations. The properties file is updated with binding during the mysql binding setup.
|
||||
* When this repo is cloned the base path to repo where the vm install scripts needs to be updated in azuredeploy.parameters.json to the **raw** path of new repo as show below.
|
||||
```
|
||||
"_artifactsLocation": {
|
||||
"value": "https://raw.githubusercontent.com/Lantern-Cloud-Services/AzureMigrateJava/main/scripts/vm/"
|
||||
}
|
||||
```
|
||||
|
||||
## Deployment
|
||||
|
||||
git clone https://github.com/Lantern-Cloud-Services/AzureMigrateJava.git
|
||||
cd AzureMigrateJava
|
||||
chmod +x scripts/deploy.sh
|
||||
./scripts/deploy.sh '<REGION NAME>' '<RESOURCE GROUP>'
|
||||
|
||||
Total depoyment will take ~5 minutes. When complete navigate to the resource group in the azure portal. Find the created vm named TomcatServer click on its name.
|
||||
|
||||
![Tomcat VM.](https://raw.githubusercontent.com/microsoft/MTC_APPContainerization/main/media/server.jpg)
|
||||
|
||||
Identify the public IP address provisioned for the VM.
|
||||
|
||||
![Public IP.](https://raw.githubusercontent.com/microsoft/MTC_APPContainerization/main/media/ip.jpg)
|
||||
|
||||
Use the IP address to access the Airsonic app at http://{ip}/airsonic
|
||||
![Airsonic App.](https://raw.githubusercontent.com/microsoft/MTC_APPContainerization/main/media/app.jpg)
|
|
@ -0,0 +1,476 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"javaPackageName": {
|
||||
"type": "string",
|
||||
"defaultValue": "openjdk-11-jdk",
|
||||
"allowedValues": [
|
||||
"openjdk-11-jdk",
|
||||
"openjdk-12-jdk",
|
||||
"openjdk-13-jdk"
|
||||
],
|
||||
"metadata": {
|
||||
"description": "java Package Name"
|
||||
}
|
||||
},
|
||||
"tomcatPackageName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "tomcat Package Name"
|
||||
}
|
||||
},
|
||||
"airsonicPackageName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "location of airsonic app package"
|
||||
}
|
||||
},
|
||||
"tomcatContext": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "tomcat context for airsonic app"
|
||||
}
|
||||
},
|
||||
"mysqlDriverName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "mysql java driver"
|
||||
}
|
||||
},
|
||||
"adminUsername": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "User name for the Virtual Machine."
|
||||
}
|
||||
},
|
||||
"vmSize": {
|
||||
"type": "string",
|
||||
"defaultValue": "Standard_D2s_v3",
|
||||
"metadata": {
|
||||
"description": "The size of the virtual machines used when provisioning"
|
||||
}
|
||||
},
|
||||
"ubuntuOSVersion": {
|
||||
"type": "string",
|
||||
"defaultValue": "18.04-LTS",
|
||||
"allowedValues": [
|
||||
"18.04-LTS",
|
||||
"16.04-LTS",
|
||||
"14.04.5-LTS"
|
||||
],
|
||||
"metadata": {
|
||||
"description": "The Ubuntu version for the VM. This will pick a fully patched image of this given Ubuntu version."
|
||||
}
|
||||
},
|
||||
"location": {
|
||||
"type": "string",
|
||||
"defaultValue": "[resourceGroup().location]",
|
||||
"metadata": {
|
||||
"description": "Location for all resources."
|
||||
}
|
||||
},
|
||||
"authenticationType": {
|
||||
"type": "securestring",
|
||||
"defaultValue": "password",
|
||||
"allowedValues": [
|
||||
"sshPublicKey",
|
||||
"password"
|
||||
],
|
||||
"metadata": {
|
||||
"description": "Type of authentication to use on the Virtual Machine. SSH key is recommended."
|
||||
}
|
||||
},
|
||||
"adminPasswordOrKey": {
|
||||
"type": "securestring",
|
||||
"metadata": {
|
||||
"description": "SSH Key or password for the Virtual Machine. SSH key is recommended."
|
||||
}
|
||||
},
|
||||
"mysqlServername": {
|
||||
"type": "string",
|
||||
"defaultValue": "[concat('airsonic-mysql-server-', utcNow('MMddyyHmmss'))]",
|
||||
"metadata": {
|
||||
"description": "MySQL Server name for the demo db"
|
||||
}
|
||||
},
|
||||
"mysqlDBName": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "MySQL Server name for the demo db"
|
||||
}
|
||||
},
|
||||
"mysqlAdminName": {
|
||||
"type": "securestring",
|
||||
"metadata": {
|
||||
"description": "MySQL server admin name for the demo db"
|
||||
}
|
||||
},
|
||||
"mysqlAdminPass": {
|
||||
"type": "securestring",
|
||||
"metadata": {
|
||||
"description": "MySQL server pass for the demo db"
|
||||
}
|
||||
},
|
||||
"mysqlClientPackage": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "MySQL client package"
|
||||
}
|
||||
},
|
||||
"_artifactsLocation": {
|
||||
"type": "string",
|
||||
"metadata": {
|
||||
"description": "The base URI where artifacts required by this template are located."
|
||||
}
|
||||
},
|
||||
"_artifactsLocationSasToken": {
|
||||
"type": "securestring",
|
||||
"metadata": {
|
||||
"description": "The sasToken required to access _artifactsLocation. When the template is deployed using the accompanying scripts, a sasToken will be automatically generated."
|
||||
},
|
||||
"defaultValue": ""
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"imagePublisher": "Canonical",
|
||||
"imageOffer": "UbuntuServer",
|
||||
"nicName": "myVMNic",
|
||||
"nsgName": "myNSG",
|
||||
"vmName": "TomcatServer",
|
||||
"addressPrefix": "10.0.0.0/16",
|
||||
"subnetName": "Subnet",
|
||||
"subnetPrefix": "10.0.0.0/24",
|
||||
"publicIPAddressName": "myPublicIP",
|
||||
"virtualNetworkName": "MyVNET",
|
||||
"linuxConfiguration": {
|
||||
"disablePasswordAuthentication": false
|
||||
// "disablePasswordAuthentication": true,
|
||||
// "ssh": {
|
||||
// "publicKeys": [
|
||||
// {
|
||||
// "path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]",
|
||||
// "keyData": "[parameters('adminPasswordOrKey')]"
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
},
|
||||
"networkSecurityGroupName": "default-NSG"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"apiVersion": "2019-06-01",
|
||||
"type": "Microsoft.Network/publicIPAddresses",
|
||||
"name": "[variables('publicIPAddressName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"sku": {
|
||||
"name": "Basic"
|
||||
},
|
||||
"properties": {
|
||||
"publicIPAllocationMethod": "Dynamic"
|
||||
}
|
||||
},
|
||||
{
|
||||
"comments": "Default Network Security Group for template",
|
||||
"type": "Microsoft.Network/networkSecurityGroups",
|
||||
"apiVersion": "2019-08-01",
|
||||
"name": "[variables('networkSecurityGroupName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"securityRules": [
|
||||
{
|
||||
"name": "default-allow-22",
|
||||
"properties": {
|
||||
"priority": 1000,
|
||||
"access": "Allow",
|
||||
"direction": "Inbound",
|
||||
"destinationPortRange": "22",
|
||||
"protocol": "Tcp",
|
||||
"sourceAddressPrefix": "*",
|
||||
"sourcePortRange": "*",
|
||||
"destinationAddressPrefix": "*"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "default-allow-8080",
|
||||
"properties": {
|
||||
"priority": 1010,
|
||||
"access": "Allow",
|
||||
"direction": "Inbound",
|
||||
"destinationPortRange": "8080",
|
||||
"protocol": "Tcp",
|
||||
"sourceAddressPrefix": "*",
|
||||
"sourcePortRange": "*",
|
||||
"destinationAddressPrefix": "*"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2019-06-01",
|
||||
"type": "Microsoft.Network/virtualNetworks",
|
||||
"name": "[variables('virtualNetworkName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"addressSpace": {
|
||||
"addressPrefixes": [
|
||||
"[variables('addressPrefix')]"
|
||||
]
|
||||
},
|
||||
"subnets": [
|
||||
{
|
||||
"name": "[variables('subnetName')]",
|
||||
"properties": {
|
||||
"addressPrefix": "[variables('subnetPrefix')]",
|
||||
"networkSecurityGroup": {
|
||||
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2019-06-01",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[variables('nicName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]",
|
||||
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
|
||||
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Dynamic",
|
||||
"publicIPAddress": {
|
||||
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
|
||||
},
|
||||
"subnet": {
|
||||
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"networkSecurityGroup": {
|
||||
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Network/networkSecurityGroups",
|
||||
"apiVersion": "2019-06-01",
|
||||
"name": "[variables('nsgName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"properties": {
|
||||
"securityRules": [
|
||||
{
|
||||
"name": "SSH",
|
||||
"properties": {
|
||||
"description": "Allow SSH",
|
||||
"protocol": "Tcp",
|
||||
"sourcePortRange": "*",
|
||||
"destinationPortRange": "22",
|
||||
"sourceAddressPrefix": "Internet",
|
||||
"destinationAddressPrefix": "*",
|
||||
"access": "Allow",
|
||||
"priority": 100,
|
||||
"direction": "Inbound"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Web",
|
||||
"properties": {
|
||||
"description": "Allow Web",
|
||||
"protocol": "Tcp",
|
||||
"sourcePortRange": "*",
|
||||
"destinationPortRange": "8080",
|
||||
"sourceAddressPrefix": "Internet",
|
||||
"destinationAddressPrefix": "*",
|
||||
"access": "Allow",
|
||||
"priority": 112,
|
||||
"direction": "Inbound"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2019-07-01",
|
||||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[variables('vmName')]",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
|
||||
],
|
||||
"properties": {
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[parameters('vmSize')]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computerName": "[variables('vmName')]",
|
||||
"adminUsername": "[parameters('adminUsername')]",
|
||||
"adminPassword": "[parameters('adminPasswordOrKey')]",
|
||||
"linuxConfiguration": "[if(equals(parameters('authenticationType'), 'password'), json('null'), variables('linuxConfiguration'))]"
|
||||
},
|
||||
"storageProfile": {
|
||||
"imageReference": {
|
||||
"publisher": "[variables('imagePublisher')]",
|
||||
"offer": "[variables('imageOffer')]",
|
||||
"sku": "[parameters('ubuntuOSVersion')]",
|
||||
"version": "latest"
|
||||
},
|
||||
"osDisk": {
|
||||
"osType": "Linux",
|
||||
"name": "[concat(variables('vmName'),'_OSDisk')]",
|
||||
"caching": "ReadWrite",
|
||||
"createOption": "FromImage",
|
||||
"managedDisk": {
|
||||
"storageAccountType": "StandardSSD_LRS"
|
||||
}
|
||||
},
|
||||
"dataDisks": [
|
||||
{
|
||||
"lun": 0,
|
||||
"name": "[concat(variables('vmName'),'_DataDisk_0')]",
|
||||
"createOption": "Empty",
|
||||
"caching": "None",
|
||||
"writeAcceleratorEnabled": false,
|
||||
"managedDisk": {
|
||||
"storageAccountType": "Premium_LRS"
|
||||
},
|
||||
"diskSizeGB": 32,
|
||||
"toBeDetached": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.DBforMySQL/servers",
|
||||
"apiVersion": "2017-12-01-preview",
|
||||
"name": "[parameters('mySqlServername')]",
|
||||
"location": "[parameters('location')]",
|
||||
"sku": {
|
||||
"name": "GP_Gen5_2",
|
||||
"tier": "GeneralPurpose",
|
||||
"family": "Gen5",
|
||||
"size": "5120",
|
||||
"capacity": 2
|
||||
},
|
||||
"properties": {
|
||||
"createMode": "Default",
|
||||
"version": "5.7",
|
||||
"administratorLogin": "[parameters('mySqlAdminName')]",
|
||||
"administratorLoginPassword": "[parameters('mySqlAdminPass')]",
|
||||
"sslEnforcement": "Disabled"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.DBforMySQL/servers/databases",
|
||||
"apiversion": "2017-12-01",
|
||||
"name": "[concat(parameters('mySqlServername'), '/', parameters('mysqlDBName'))]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DBforMySQL/servers', parameters('mySqlServername'))]"
|
||||
],
|
||||
"properties": {
|
||||
"charset": "utf8",
|
||||
"collation": "utf8_general_ci"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
/*
|
||||
{
|
||||
"type": "Microsoft.DBforMySQL/servers/configurations",
|
||||
"apiVersion": "2017-12-01",
|
||||
"name": "[concat(parameters('mySqlServername'), '/timezone')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DBforMySQL/servers', parameters('mySqlServername'))]"
|
||||
],
|
||||
"properties": {
|
||||
"value": "US/Pacific",
|
||||
"source": "time_zone"
|
||||
}
|
||||
},
|
||||
*/
|
||||
{
|
||||
"type": "Microsoft.DBforMySQL/servers/firewallRules",
|
||||
"apiVersion": "2017-12-01-preview",
|
||||
"name": "[concat(parameters('mySqlServername'), '/AllowAllWindowsAzureIps')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DBforMySQL/servers', parameters('mySqlServername'))]"
|
||||
],
|
||||
"properties": {
|
||||
"startIpAddress": "0.0.0.0",
|
||||
"endIpAddress": "0.0.0.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.DBforMySQL/servers/firewallRules",
|
||||
"apiVersion": "2017-12-01-preview",
|
||||
"name": "[concat(parameters('mySqlServername'), '/AllowAllWindowsDevIps')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.DBforMySQL/servers', parameters('mySqlServername'))]"
|
||||
],
|
||||
"properties": {
|
||||
"startIpAddress": "0.0.0.0",
|
||||
"endIpAddress": "255.255.255.255"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Microsoft.Compute/virtualMachines/extensions",
|
||||
"name": "[concat(variables('vmName'),'/installscript')]",
|
||||
"apiVersion": "2019-07-01",
|
||||
"location": "[parameters('location')]",
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Compute/virtualMachines', variables('vmName'))]",
|
||||
"[resourceId('Microsoft.DBforMySQL/servers', parameters('mySqlServername'))]"
|
||||
],
|
||||
"properties": {
|
||||
"publisher": "Microsoft.Azure.Extensions",
|
||||
"type": "CustomScript",
|
||||
"typeHandlerVersion": "2.0",
|
||||
"autoUpgradeMinorVersion": true,
|
||||
"protectedSettings": {
|
||||
"commandToExecute": "[
|
||||
concat('sh setup-vm.sh',' ',
|
||||
parameters('adminUsername'), ' ',
|
||||
parameters('javaPackageName'),' ',
|
||||
parameters('tomcatPackageName'), ' ',
|
||||
parameters('airsonicPackageName'), ' ',
|
||||
parameters('tomcatContext'), ' ',
|
||||
parameters('mysqlDriverName'), ' ',
|
||||
parameters('mysqlClientPackage'), ' ',
|
||||
concat(parameters('mysqlAdminName'), '@', parameters('mySqlServername')), ' ',
|
||||
concat('''', parameters('mysqlAdminPass'), ''''), ' ',
|
||||
concat(parameters('mySqlServername'), '.mysql.database.azure.com'), ' ',
|
||||
parameters('mysqlDBName')
|
||||
)
|
||||
]",
|
||||
"fileUris": [
|
||||
"[uri(parameters('_artifactsLocation'), concat('setup-vm.sh', parameters('_artifactsLocationSasToken')))]",
|
||||
"[uri(parameters('_artifactsLocation'), concat('java-tomcat-install.sh', parameters('_artifactsLocationSasToken')))]",
|
||||
"[uri(parameters('_artifactsLocation'), concat('airsonic-install.sh', parameters('_artifactsLocationSasToken')))]",
|
||||
"[uri(parameters('_artifactsLocation'), concat('mysql-install.sh', parameters('_artifactsLocationSasToken')))]",
|
||||
"[uri(parameters('_artifactsLocation'), concat('mysql-bind.sh', parameters('_artifactsLocationSasToken')))]"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
|
||||
"contentVersion": "1.0.0.0",
|
||||
"parameters": {
|
||||
"javaPackageName": {
|
||||
"value": "openjdk-11-jdk"
|
||||
},
|
||||
"tomcatPackageName": {
|
||||
"value":"https://downloads.apache.org/tomcat/tomcat-9/v9.0.50/bin/apache-tomcat-9.0.50.tar.gz"
|
||||
},
|
||||
"airsonicPackageName": {
|
||||
"value":"https://github.com/airsonic/airsonic/releases/download/v10.6.2/airsonic.war"
|
||||
},
|
||||
"tomcatContext": {
|
||||
"value":"https://raw.githubusercontent.com/Lantern-Cloud-Services/AzureMigrateJava/main/resource/tomcat/context.xml "
|
||||
},
|
||||
"mysqlDriverName": {
|
||||
"value":"https://downloads.mysql.com/archives/get/p/3/file/mysql-connector-java-5.1.48.tar.gz"
|
||||
},
|
||||
"adminUsername": {
|
||||
"value": "adminuser"
|
||||
},
|
||||
"mysqlAdminName": {
|
||||
"value": "mysqladmin"
|
||||
},
|
||||
"mysqlAdminPass": {
|
||||
"value": "$uperS3kretPa$$w0rd"
|
||||
},
|
||||
"mysqlDBName": {
|
||||
"value": "airsonic"
|
||||
},
|
||||
"mysqlClientPackage": {
|
||||
"value": "mysql-client-core-5.7"
|
||||
},
|
||||
"adminPasswordOrKey": {
|
||||
"value": "Super$ekr3tPa$sw0rd!"
|
||||
},
|
||||
"_artifactsLocation": {
|
||||
"value": "https://raw.githubusercontent.com/Lantern-Cloud-Services/AzureMigrateJava/main/scripts/vm/"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<Context>
|
||||
<Resource name="jdbc/airsonicDB" auth="Container"
|
||||
type="javax.sql.DataSource"
|
||||
maxActive="20"
|
||||
maxIdle="30"
|
||||
maxWait="10000"
|
||||
username="${MYSQL_SERVER_ADMIN_LOGIN_NAME}"
|
||||
password="${MYSQL_SERVER_ADMIN_PASSWORD}"
|
||||
driverClassName="com.mysql.jdbc.Driver"
|
||||
url="jdbc:mysql://${MYSQL_SERVER_FULL_NAME}:3306/${MYSQL_DATABASE_NAME}?useSSL=false&sessionVariables=sql_mode=ANSI_QUOTES"/>
|
||||
</Context>
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
REGION=$1
|
||||
RG_NAME=$2
|
||||
|
||||
az group create --name $RG_NAME --location $REGION
|
||||
az group deployment create --name "azuredeploy" --resource-group $RG_NAME --template-file "./azuredeploy.json" --parameters "./azuredeploy.parameters.json" --verbose
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh
|
||||
|
||||
AIRSONIC_PACKAGE=$1
|
||||
|
||||
echo "installing airsonic app"
|
||||
### install airsonic app ###
|
||||
cd /tmp
|
||||
mkdir airsonic
|
||||
cd airsonic
|
||||
|
||||
# Download airsonic WAR package
|
||||
wget $AIRSONIC_PACKAGE
|
||||
|
||||
# Move the downloaded WAR file in the $TOMCAT_HOME/webapps
|
||||
# folder and assign ownership to the Tomcat system user:
|
||||
mkdir /opt/tomcat9/webapps/airsonic
|
||||
|
||||
jar -xvf airsonic.war
|
||||
rm -rf airsonic.war
|
||||
mv * /opt/tomcat9/webapps/airsonic
|
||||
|
||||
mkdir -p /datadrive/airsonic/
|
||||
|
||||
# create music, media, podcasts and playlists folders
|
||||
cd /datadrive/airsonic/
|
||||
mkdir music
|
||||
mkdir media
|
||||
mkdir podcasts
|
||||
mkdir playlists
|
||||
|
||||
chown -R tomcat9:tomcat9 /datadrive/airsonic/
|
||||
chmod 777 /datadrive/airsonic/music
|
||||
|
||||
# setup env vars
|
||||
echo "Setting env vars"
|
||||
echo "CATALINA_OPTS='-Xms512M -Xmx1024M -server -XX:+UseParallelGC'" >> /opt/tomcat9/bin/setenv.sh
|
||||
echo "JAVA_OPTS='-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dairsonic.home=/datadrive/airsonic'" >> /opt/tomcat9/bin/setenv.sh
|
||||
echo "Setting env vars complete"
|
||||
|
||||
# Start/Stop tomcat to generate airsonic properties file
|
||||
echo "Starting tomcat"
|
||||
/opt/tomcat9/bin/startup.sh
|
||||
sleep 30
|
||||
echo "Stopping tomcat"
|
||||
/opt/tomcat9/bin/shutdown.sh
|
||||
sleep 30
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/sh
|
||||
|
||||
JAVA_PACKAGE=$1
|
||||
TOMCAT_PACKAGE=$2
|
||||
|
||||
|
||||
echo "Intalling Java"
|
||||
### Install Java ###
|
||||
####################
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y upgrade
|
||||
sudo apt-get install -y $JAVA_PACKAGE
|
||||
sudo apt-get -y update --fix-missing
|
||||
sudo apt-get install -y $JAVA_PACKAGE
|
||||
echo "Intalling Java complete"
|
||||
echo ""
|
||||
echo ""
|
||||
|
||||
echo "Intalling Tomcat"
|
||||
### Install Tomcat 9 ###
|
||||
########################
|
||||
# Create a tomcat9 group
|
||||
sudo groupadd tomcat9
|
||||
|
||||
# Create a new tomcat9 user
|
||||
sudo useradd -s /bin/false -g tomcat9 -d /opt/tomcat9 tomcat9
|
||||
|
||||
# Download Apache Tomcat
|
||||
cd /tmp
|
||||
curl -O $TOMCAT_PACKAGE
|
||||
|
||||
# Install tomcat in /opt/tomcat9 directory
|
||||
sudo mkdir /opt/tomcat9
|
||||
sudo tar xzvf apache-tomcat-*tar.gz -C /opt/tomcat9 --strip-components=1
|
||||
|
||||
# Update permissions for tomcat9 directory
|
||||
cd /opt/tomcat9
|
||||
sudo chgrp -R tomcat9 /opt/tomcat9
|
||||
|
||||
# Give tomcat9 group read access
|
||||
sudo chmod -R g+r conf
|
||||
sudo chmod g+x conf
|
||||
|
||||
# Make the tomcat user the owner of the Web apps, work, temp, and logs directories:
|
||||
sudo chown -R tomcat9 webapps/ work/ temp/ logs/ bin/
|
||||
echo "Installing Tomcat complete"
|
||||
echo ""
|
||||
echo ""
|
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
|
||||
TOMCAT_CONTEXT=$1
|
||||
MYSQL_DRIVER=$2
|
||||
MYSQL_ADMIN_USER=$3
|
||||
MYSQL_ADMIN_PASS=$4
|
||||
MYSQL_DBNAME=$5
|
||||
MYSQL_HOSTNAME=$6
|
||||
|
||||
# Download airsonic app contxt.xml
|
||||
cd /tmp
|
||||
wget $TOMCAT_CONTEXT
|
||||
mv context.xml /opt/tomcat9/webapps/airsonic/META-INF/context.xml
|
||||
|
||||
# Download MySQL Driver
|
||||
wget $MYSQL_DRIVER
|
||||
tar xvzf mysql-connector-java-*tar.gz
|
||||
|
||||
# copy to Tomcat9/lib folder
|
||||
cp mysql-connector-java-*/mysql-connector-java-*.jar /opt/tomcat9/lib
|
||||
|
||||
echo 'DatabaseConfigType=jndi' >> /datadrive/airsonic/airsonic.properties
|
||||
echo 'DatabaseConfigJNDIName=jdbc/airsonicDB' >> /datadrive/airsonic/airsonic.properties
|
||||
|
||||
# replace setenv
|
||||
rm -rf /opt/tomcat9/bin/setenv.sh
|
||||
echo "MYSQL_SERVER_ADMIN_LOGIN_NAME='$MYSQL_ADMIN_USER'" >> /opt/tomcat9/bin/setenv.sh
|
||||
echo "MYSQL_SERVER_ADMIN_PASSWORD='$MYSQL_ADMIN_PASS'" >> /opt/tomcat9/bin/setenv.sh
|
||||
echo "MYSQL_DATABASE_NAME='$MYSQL_DBNAME'" >> /opt/tomcat9/bin/setenv.sh
|
||||
echo "MYSQL_SERVER_FULL_NAME='$MYSQL_HOSTNAME'" >> /opt/tomcat9/bin/setenv.sh
|
||||
echo "CATALINA_OPTS='-Xms8192M -Xmx8192M -server -XX:+UseParallelGC'" >> /opt/tomcat9/bin/setenv.sh
|
||||
echo "JAVA_OPTS='-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom -Dairsonic.home=/datadrive/airsonic -DMYSQL_SERVER_FULL_NAME=\$MYSQL_SERVER_FULL_NAME -DMYSQL_DATABASE_NAME=\$MYSQL_DATABASE_NAME -DMYSQL_SERVER_ADMIN_LOGIN_NAME=\$MYSQL_SERVER_ADMIN_LOGIN_NAME -DMYSQL_SERVER_ADMIN_PASSWORD=\$MYSQL_SERVER_ADMIN_PASSWORD'" >> /opt/tomcat9/bin/setenv.sh
|
||||
|
||||
|
||||
# Move to db creation
|
||||
# Increase connection timeout
|
||||
#az mysql server configuration set --name wait_timeout \
|
||||
# --resource-group ${RESOURCE_GROUP} \
|
||||
# --server ${MYSQL_SERVER_NAME} --value 2147483
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
|
||||
MYSQL_CLIENT_PACKAGE=$1
|
||||
MYSQL_ADMIN_USER=$2
|
||||
MYSQL_SERVER_HOST=$3
|
||||
MYSQL_ADMIN_PASS=$4
|
||||
|
||||
echo "pack: $MYSQL_CLIENT_PACKAGE"
|
||||
echo "user: $MYSQL_ADMIN_USER"
|
||||
echo "host: $MYSQL_SERVER_HOST"
|
||||
echo "pass: $MYSQL_ADMIN_PASS"
|
||||
|
||||
|
||||
### Install MySQL client ###
|
||||
############################
|
||||
echo "Installing $MYSQL_CLIENT_PACKAGE"
|
||||
sudo apt-get -y update
|
||||
sudo apt-get -y upgrade
|
||||
sudo apt-get install -y $MYSQL_CLIENT_PACKAGE
|
||||
sudo apt-get -y update --fix-missing
|
||||
sudo apt-get install -y $MYSQL_CLIENT_PACKAGE
|
||||
echo "Installing $MYSQL_CLIENT_PACKAGE complete"
|
||||
echo ""
|
||||
|
||||
|
||||
### Create root user ###
|
||||
########################
|
||||
echo "Creating root user on host $MYSQL_SERVER_HOST"
|
||||
mysql -u $MYSQL_ADMIN_USER -h $MYSQL_SERVER_HOST -P 3306 -p$MYSQL_ADMIN_PASS -e "\
|
||||
CREATE USER 'root' IDENTIFIED BY 'airsonic';
|
||||
GRANT ALL PRIVILEGES ON airsonic.* TO 'root';
|
||||
CALL mysql.az_load_timezone();"
|
||||
echo "Creating root user complete"
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
|
||||
LOG_HOME=/home/$1/vm-setup-logs
|
||||
|
||||
JAVA_PACKAGE=$2
|
||||
TOMCAT_PACKAGE=$3
|
||||
|
||||
AIRSONIC_PACKAGE=$4
|
||||
TOMCAT_CONTEXT=$5
|
||||
MYSQL_DRIVER=$6
|
||||
|
||||
MYSQL_CLIENT_PACKAGE=$7
|
||||
MYSQL_ADMIN_USER=$8
|
||||
MYSQL_ADMIN_PASS=$9
|
||||
MYSQL_SERVER_HOST=$10
|
||||
MYSQL_DBNAME=$11
|
||||
|
||||
mkdir $LOG_HOME
|
||||
|
||||
sh java-tomcat-install.sh $JAVA_PACKAGE $TOMCAT_PACKAGE >> $LOG_HOME/java-tomcat-install.log
|
||||
sh airsonic-install.sh $AIRSONIC_PACKAGE >> $LOG_HOME/airsonic-install.log
|
||||
sh mysql-install.sh $MYSQL_CLIENT_PACKAGE $MYSQL_ADMIN_USER $MYSQL_SERVER_HOST $MYSQL_ADMIN_PASS >> $LOG_HOME/mysql-install.log
|
||||
sh mysql-bind.sh $TOMCAT_CONTEXT $MYSQL_DRIVER $MYSQL_ADMIN_USER $MYSQL_ADMIN_PASS $MYSQL_DBNAME $MYSQL_SERVER_HOST >> $LOG_HOME/mysql-bind.log
|
||||
|
||||
echo "Starting tomcat"
|
||||
/opt/tomcat9/bin/startup.sh
|
||||
sleep 30
|
Загрузка…
Ссылка в новой задаче