Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions releases/R2023b/scripts/initAdminVM.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/bash

WORKSPACE=/opt/mathworks

# $0 is the file name

storageAccountName="$1"
dbConnectionString="$2"
mpsEndpoint="$3"
CIDRRange="$4"
cloudPlatform="$5"
osPlatform="$6"
ikey="$7"
resourceGroup="$8"
subscriptionID="$9"
userName="${10}"
passWord="${11}"
redisName="${12}"
gatewayPrivateIP="${13}"
offerType="${14}"

azEnvironment=$(sudo curl -s -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | jq -r '.compute.azEnvironment')

echo "$storageAccountName"
echo "$dbConnectionString"
echo "$mpsEndpoint"
echo "$CIDRRange"
echo "$cloudPlatform"
echo "$osPlatform"
echo "$ikey"
echo "$resourceGroup"
echo "$subscriptionID"
echo "$userName"
echo "$redisName"
echo "$gatewayPrivateIP"
echo "$offerType"
echo "$azEnvironment"

JSONCMD='
{
"storageAccountName": "'"$storageAccountName"'",
"dbConnectionString": "'"$dbConnectionString"'",
"mpsEndPoint": "'"$mpsEndpoint"'",
"CIDRRange": "'"$CIDRRange"'",
"cloudPlatform": "'"$cloudPlatform"'",
"osPlatform": "'"$osPlatform"'",
"ikey": "'"$ikey"'",
"resourceGroup": "'"$resourceGroup"'",
"subscriptionID": "'"$subscriptionID"'",
"redisCacheName": "'"$redisName"'",
"gatewayPrivateIP": "'"$gatewayPrivateIP"'",
"offerType": "'"$offerType"'",
"azEnvironment": "'"$azEnvironment"'"
}
'

destination=$WORKSPACE/controller/dynamicOptions.json
rm $destination

echo $JSONCMD >> $destination

echo "Written Config File successfully"

cd $WORKSPACE/cloud/main
node $WORKSPACE/cloud/main/server/hash_pw.js "${userName}" "${passWord}" "${passWord}"

echo "Written sudo passwd successfully"

cp ./.shadow ./bin/.

echo "Copied shadow file"

systemctl restart refarchcontroller

echo "Restarted daemon successfully!"


# chown to this user /opt/mathworks
# Clear history
history -c

echo "Cleared History!"
# File Location
#https://mwstorage24.blob.core.windows.net/azuretemplates/initVm.sh
55 changes: 55 additions & 0 deletions releases/R2023b/scripts/scriptScaleSet.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<#
.SYNOPSIS
This Script runs on MPS instances
#>

# Param (
# [Parameter(Mandatory=$False)][string]$SERVER_MODE
# )

# disable automatic updates
Echo "disabling automatic updates"
$service = Get-WmiObject Win32_Service -Filter 'Name="wuauserv"'
if ($service)
{
if ($service.StartMode -ne "Disabled")
{
$result = $service.ChangeStartMode("Disabled").ReturnValue
if($result)
{
Echo "Failed to disable the 'wuauserv' service. The return value was $result."
}
else {Echo "Success to disable the 'wuauserv' service."}

if ($service.State -eq "Running")
{
$result = $service.StopService().ReturnValue
if ($result)
{
Echo "Failed to stop the 'wuauserv' service. The return value was $result."
}
else {Echo "Success to stop the 'wuauserv' service."}
}
}
else {Echo "The 'wuauserv' service is already disabled."}
}
else {Echo "Failed to retrieve the service 'wuauserv'."}

#Disable Automatic Windows Updates
Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU -Name AUOptions -Value 1

# exclude .ctf file from windows defender scanning
#Add-MpPreference -ExclusionExtension ".ctf"

#Get-ChildItem "C:\Program Files\MATLAB\MATLAB Runtime\" -Directory |
# ForEach-Object {
# Echo ($_.FullName + '\bin\win64\extractCTF.exe')
# Add-MpPreference -ExclusionProcess ($_.FullName + '\bin\win64\extractCTF.exe')
# }

Stop-Service -Name Spooler -Force

Set-Service -Name Spooler -StartupType Disabled

# Execute reboot required for domain join
#Restart-Computer
3 changes: 3 additions & 0 deletions releases/R2023b/scripts/scriptScaleSet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/bash
#Put your extra commands here
ls
104 changes: 104 additions & 0 deletions releases/R2024a/scripts/initAdminVM.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/bash

WORKSPACE=/opt/mathworks

LOG_DIR=/var/log/custom_script
LOG_FILE=$LOG_DIR/custom_script.log

# Create log directory and file
sudo mkdir -p $LOG_DIR
sudo touch $LOG_FILE
sudo chmod 666 $LOG_FILE

# $0 is the file name

storageAccountName="$1"
dbConnectionString="$2"
mpsEndpoint="$3"
CIDRRange="$4"
cloudPlatform="$5"
osPlatform="$6"
ikey="$7"
resourceGroup="$8"
subscriptionID="$9"
userName="${10}"
passWord="${11}"
redisName="${12}"
gatewayPrivateIP="${13}"
offerType="${14}"

azEnvironment=$(sudo curl -s -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | jq -r '.compute.azEnvironment')

echo "$storageAccountName"
echo "$dbConnectionString"
echo "$mpsEndpoint"
echo "$CIDRRange"
echo "$cloudPlatform"
echo "$osPlatform"
echo "$ikey"
echo "$resourceGroup"
echo "$subscriptionID"
echo "$userName"
echo "$redisName"
echo "$gatewayPrivateIP"
echo "$offerType"
echo "$azEnvironment"

JSONCMD='
{
"storageAccountName": "'"$storageAccountName"'",
"dbConnectionString": "'"$dbConnectionString"'",
"mpsEndPoint": "'"$mpsEndpoint"'",
"CIDRRange": "'"$CIDRRange"'",
"cloudPlatform": "'"$cloudPlatform"'",
"osPlatform": "'"$osPlatform"'",
"ikey": "'"$ikey"'",
"resourceGroup": "'"$resourceGroup"'",
"subscriptionID": "'"$subscriptionID"'",
"redisCacheName": "'"$redisName"'",
"gatewayPrivateIP": "'"$gatewayPrivateIP"'",
"offerType": "'"$offerType"'",
"azEnvironment": "'"$azEnvironment"'"
}
'

destination=$WORKSPACE/controller/dynamicOptions.json
rm $destination

echo $JSONCMD >> $destination

echo "Written Config File successfully"

cd $WORKSPACE/cloud/main
node $WORKSPACE/cloud/main/server/hash_pw.js "${userName}" "${passWord}" "${passWord}"

echo "Written sudo passwd successfully"

cp ./.shadow ./bin/.

echo "Copied shadow file"

# Update package lists and log errors
sudo apt-get update 2>> $LOG_FILE
if [ $? -ne 0 ]; then
echo "apt update failed. Check the log file at $LOG_FILE" | tee -a $LOG_FILE
fi

# Install openssh-server and log errors
sudo apt-get install -y openssh-server 2>> $LOG_FILE
if [ $? -ne 0 ]; then
echo "apt install failed. Check the log file at $LOG_FILE" | tee -a $LOG_FILE
fi

systemctl restart refarchcontroller

echo "Restarted daemon successfully!"


# chown to this user /opt/mathworks
# Clear history
history -c

echo "Cleared History!"
# File Location
#https://mwstorage24.blob.core.windows.net/azuretemplates/initVm.sh
55 changes: 55 additions & 0 deletions releases/R2024a/scripts/scriptScaleSet.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<#
.SYNOPSIS
This Script runs on MPS instances
#>

# Param (
# [Parameter(Mandatory=$False)][string]$SERVER_MODE
# )

# disable automatic updates
Echo "disabling automatic updates"
$service = Get-WmiObject Win32_Service -Filter 'Name="wuauserv"'
if ($service)
{
if ($service.StartMode -ne "Disabled")
{
$result = $service.ChangeStartMode("Disabled").ReturnValue
if($result)
{
Echo "Failed to disable the 'wuauserv' service. The return value was $result."
}
else {Echo "Success to disable the 'wuauserv' service."}

if ($service.State -eq "Running")
{
$result = $service.StopService().ReturnValue
if ($result)
{
Echo "Failed to stop the 'wuauserv' service. The return value was $result."
}
else {Echo "Success to stop the 'wuauserv' service."}
}
}
else {Echo "The 'wuauserv' service is already disabled."}
}
else {Echo "Failed to retrieve the service 'wuauserv'."}

#Disable Automatic Windows Updates
Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU -Name AUOptions -Value 1

# exclude .ctf file from windows defender scanning
#Add-MpPreference -ExclusionExtension ".ctf"

#Get-ChildItem "C:\Program Files\MATLAB\MATLAB Runtime\" -Directory |
# ForEach-Object {
# Echo ($_.FullName + '\bin\win64\extractCTF.exe')
# Add-MpPreference -ExclusionProcess ($_.FullName + '\bin\win64\extractCTF.exe')
# }

Stop-Service -Name Spooler -Force

Set-Service -Name Spooler -StartupType Disabled

# Execute reboot required for domain join
#Restart-Computer
23 changes: 23 additions & 0 deletions releases/R2024a/scripts/scriptScaleSet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#! /bin/bash
#Put your extra commands here
LOG_DIR=/var/log/custom_script
LOG_FILE=$LOG_DIR/custom_script.log

# Create log directory and file
sudo mkdir -p $LOG_DIR
sudo touch $LOG_FILE
sudo chmod 666 $LOG_FILE

# Update package lists and log errors
sudo apt-get update 2>> $LOG_FILE
if [ $? -ne 0 ]; then
echo "apt update failed. Check the log file at $LOG_FILE" | tee -a $LOG_FILE
fi

# Install openssh-server and log errors
sudo apt-get install -y openssh-server 2>> $LOG_FILE
if [ $? -ne 0 ]; then
echo "apt install failed. Check the log file at $LOG_FILE" | tee -a $LOG_FILE
fi

ls
Loading
Loading