Skip to content

Commit 229d9c4

Browse files
authored
Add script folder for R2025a, R2024b, R2024a and R2023b releases
1 parent 6e1f3a0 commit 229d9c4

File tree

12 files changed

+688
-0
lines changed

12 files changed

+688
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
3+
WORKSPACE=/opt/mathworks
4+
5+
# $0 is the file name
6+
7+
storageAccountName="$1"
8+
dbConnectionString="$2"
9+
mpsEndpoint="$3"
10+
CIDRRange="$4"
11+
cloudPlatform="$5"
12+
osPlatform="$6"
13+
ikey="$7"
14+
resourceGroup="$8"
15+
subscriptionID="$9"
16+
userName="${10}"
17+
passWord="${11}"
18+
redisName="${12}"
19+
gatewayPrivateIP="${13}"
20+
offerType="${14}"
21+
22+
azEnvironment=$(sudo curl -s -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | jq -r '.compute.azEnvironment')
23+
24+
echo "$storageAccountName"
25+
echo "$dbConnectionString"
26+
echo "$mpsEndpoint"
27+
echo "$CIDRRange"
28+
echo "$cloudPlatform"
29+
echo "$osPlatform"
30+
echo "$ikey"
31+
echo "$resourceGroup"
32+
echo "$subscriptionID"
33+
echo "$userName"
34+
echo "$redisName"
35+
echo "$gatewayPrivateIP"
36+
echo "$offerType"
37+
echo "$azEnvironment"
38+
39+
JSONCMD='
40+
{
41+
"storageAccountName": "'"$storageAccountName"'",
42+
"dbConnectionString": "'"$dbConnectionString"'",
43+
"mpsEndPoint": "'"$mpsEndpoint"'",
44+
"CIDRRange": "'"$CIDRRange"'",
45+
"cloudPlatform": "'"$cloudPlatform"'",
46+
"osPlatform": "'"$osPlatform"'",
47+
"ikey": "'"$ikey"'",
48+
"resourceGroup": "'"$resourceGroup"'",
49+
"subscriptionID": "'"$subscriptionID"'",
50+
"redisCacheName": "'"$redisName"'",
51+
"gatewayPrivateIP": "'"$gatewayPrivateIP"'",
52+
"offerType": "'"$offerType"'",
53+
"azEnvironment": "'"$azEnvironment"'"
54+
}
55+
'
56+
57+
destination=$WORKSPACE/controller/dynamicOptions.json
58+
rm $destination
59+
60+
echo $JSONCMD >> $destination
61+
62+
echo "Written Config File successfully"
63+
64+
cd $WORKSPACE/cloud/main
65+
node $WORKSPACE/cloud/main/server/hash_pw.js "${userName}" "${passWord}" "${passWord}"
66+
67+
echo "Written sudo passwd successfully"
68+
69+
cp ./.shadow ./bin/.
70+
71+
echo "Copied shadow file"
72+
73+
systemctl restart refarchcontroller
74+
75+
echo "Restarted daemon successfully!"
76+
77+
78+
# chown to this user /opt/mathworks
79+
# Clear history
80+
history -c
81+
82+
echo "Cleared History!"
83+
# File Location
84+
#https://mwstorage24.blob.core.windows.net/azuretemplates/initVm.sh
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<#
2+
.SYNOPSIS
3+
This Script runs on MPS instances
4+
#>
5+
6+
# Param (
7+
# [Parameter(Mandatory=$False)][string]$SERVER_MODE
8+
# )
9+
10+
# disable automatic updates
11+
Echo "disabling automatic updates"
12+
$service = Get-WmiObject Win32_Service -Filter 'Name="wuauserv"'
13+
if ($service)
14+
{
15+
if ($service.StartMode -ne "Disabled")
16+
{
17+
$result = $service.ChangeStartMode("Disabled").ReturnValue
18+
if($result)
19+
{
20+
Echo "Failed to disable the 'wuauserv' service. The return value was $result."
21+
}
22+
else {Echo "Success to disable the 'wuauserv' service."}
23+
24+
if ($service.State -eq "Running")
25+
{
26+
$result = $service.StopService().ReturnValue
27+
if ($result)
28+
{
29+
Echo "Failed to stop the 'wuauserv' service. The return value was $result."
30+
}
31+
else {Echo "Success to stop the 'wuauserv' service."}
32+
}
33+
}
34+
else {Echo "The 'wuauserv' service is already disabled."}
35+
}
36+
else {Echo "Failed to retrieve the service 'wuauserv'."}
37+
38+
#Disable Automatic Windows Updates
39+
Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU -Name AUOptions -Value 1
40+
41+
# exclude .ctf file from windows defender scanning
42+
#Add-MpPreference -ExclusionExtension ".ctf"
43+
44+
#Get-ChildItem "C:\Program Files\MATLAB\MATLAB Runtime\" -Directory |
45+
# ForEach-Object {
46+
# Echo ($_.FullName + '\bin\win64\extractCTF.exe')
47+
# Add-MpPreference -ExclusionProcess ($_.FullName + '\bin\win64\extractCTF.exe')
48+
# }
49+
50+
Stop-Service -Name Spooler -Force
51+
52+
Set-Service -Name Spooler -StartupType Disabled
53+
54+
# Execute reboot required for domain join
55+
#Restart-Computer
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /bin/bash
2+
#Put your extra commands here
3+
ls
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/bin/bash
2+
3+
WORKSPACE=/opt/mathworks
4+
5+
LOG_DIR=/var/log/custom_script
6+
LOG_FILE=$LOG_DIR/custom_script.log
7+
8+
# Create log directory and file
9+
sudo mkdir -p $LOG_DIR
10+
sudo touch $LOG_FILE
11+
sudo chmod 666 $LOG_FILE
12+
13+
# $0 is the file name
14+
15+
storageAccountName="$1"
16+
dbConnectionString="$2"
17+
mpsEndpoint="$3"
18+
CIDRRange="$4"
19+
cloudPlatform="$5"
20+
osPlatform="$6"
21+
ikey="$7"
22+
resourceGroup="$8"
23+
subscriptionID="$9"
24+
userName="${10}"
25+
passWord="${11}"
26+
redisName="${12}"
27+
gatewayPrivateIP="${13}"
28+
offerType="${14}"
29+
30+
azEnvironment=$(sudo curl -s -H Metadata:true --noproxy "*" "http://169.254.169.254/metadata/instance?api-version=2021-02-01" | jq -r '.compute.azEnvironment')
31+
32+
echo "$storageAccountName"
33+
echo "$dbConnectionString"
34+
echo "$mpsEndpoint"
35+
echo "$CIDRRange"
36+
echo "$cloudPlatform"
37+
echo "$osPlatform"
38+
echo "$ikey"
39+
echo "$resourceGroup"
40+
echo "$subscriptionID"
41+
echo "$userName"
42+
echo "$redisName"
43+
echo "$gatewayPrivateIP"
44+
echo "$offerType"
45+
echo "$azEnvironment"
46+
47+
JSONCMD='
48+
{
49+
"storageAccountName": "'"$storageAccountName"'",
50+
"dbConnectionString": "'"$dbConnectionString"'",
51+
"mpsEndPoint": "'"$mpsEndpoint"'",
52+
"CIDRRange": "'"$CIDRRange"'",
53+
"cloudPlatform": "'"$cloudPlatform"'",
54+
"osPlatform": "'"$osPlatform"'",
55+
"ikey": "'"$ikey"'",
56+
"resourceGroup": "'"$resourceGroup"'",
57+
"subscriptionID": "'"$subscriptionID"'",
58+
"redisCacheName": "'"$redisName"'",
59+
"gatewayPrivateIP": "'"$gatewayPrivateIP"'",
60+
"offerType": "'"$offerType"'",
61+
"azEnvironment": "'"$azEnvironment"'"
62+
}
63+
'
64+
65+
destination=$WORKSPACE/controller/dynamicOptions.json
66+
rm $destination
67+
68+
echo $JSONCMD >> $destination
69+
70+
echo "Written Config File successfully"
71+
72+
cd $WORKSPACE/cloud/main
73+
node $WORKSPACE/cloud/main/server/hash_pw.js "${userName}" "${passWord}" "${passWord}"
74+
75+
echo "Written sudo passwd successfully"
76+
77+
cp ./.shadow ./bin/.
78+
79+
echo "Copied shadow file"
80+
81+
# Update package lists and log errors
82+
sudo apt-get update 2>> $LOG_FILE
83+
if [ $? -ne 0 ]; then
84+
echo "apt update failed. Check the log file at $LOG_FILE" | tee -a $LOG_FILE
85+
fi
86+
87+
# Install openssh-server and log errors
88+
sudo apt-get install -y openssh-server 2>> $LOG_FILE
89+
if [ $? -ne 0 ]; then
90+
echo "apt install failed. Check the log file at $LOG_FILE" | tee -a $LOG_FILE
91+
fi
92+
93+
systemctl restart refarchcontroller
94+
95+
echo "Restarted daemon successfully!"
96+
97+
98+
# chown to this user /opt/mathworks
99+
# Clear history
100+
history -c
101+
102+
echo "Cleared History!"
103+
# File Location
104+
#https://mwstorage24.blob.core.windows.net/azuretemplates/initVm.sh
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<#
2+
.SYNOPSIS
3+
This Script runs on MPS instances
4+
#>
5+
6+
# Param (
7+
# [Parameter(Mandatory=$False)][string]$SERVER_MODE
8+
# )
9+
10+
# disable automatic updates
11+
Echo "disabling automatic updates"
12+
$service = Get-WmiObject Win32_Service -Filter 'Name="wuauserv"'
13+
if ($service)
14+
{
15+
if ($service.StartMode -ne "Disabled")
16+
{
17+
$result = $service.ChangeStartMode("Disabled").ReturnValue
18+
if($result)
19+
{
20+
Echo "Failed to disable the 'wuauserv' service. The return value was $result."
21+
}
22+
else {Echo "Success to disable the 'wuauserv' service."}
23+
24+
if ($service.State -eq "Running")
25+
{
26+
$result = $service.StopService().ReturnValue
27+
if ($result)
28+
{
29+
Echo "Failed to stop the 'wuauserv' service. The return value was $result."
30+
}
31+
else {Echo "Success to stop the 'wuauserv' service."}
32+
}
33+
}
34+
else {Echo "The 'wuauserv' service is already disabled."}
35+
}
36+
else {Echo "Failed to retrieve the service 'wuauserv'."}
37+
38+
#Disable Automatic Windows Updates
39+
Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU -Name AUOptions -Value 1
40+
41+
# exclude .ctf file from windows defender scanning
42+
#Add-MpPreference -ExclusionExtension ".ctf"
43+
44+
#Get-ChildItem "C:\Program Files\MATLAB\MATLAB Runtime\" -Directory |
45+
# ForEach-Object {
46+
# Echo ($_.FullName + '\bin\win64\extractCTF.exe')
47+
# Add-MpPreference -ExclusionProcess ($_.FullName + '\bin\win64\extractCTF.exe')
48+
# }
49+
50+
Stop-Service -Name Spooler -Force
51+
52+
Set-Service -Name Spooler -StartupType Disabled
53+
54+
# Execute reboot required for domain join
55+
#Restart-Computer
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#! /bin/bash
2+
#Put your extra commands here
3+
LOG_DIR=/var/log/custom_script
4+
LOG_FILE=$LOG_DIR/custom_script.log
5+
6+
# Create log directory and file
7+
sudo mkdir -p $LOG_DIR
8+
sudo touch $LOG_FILE
9+
sudo chmod 666 $LOG_FILE
10+
11+
# Update package lists and log errors
12+
sudo apt-get update 2>> $LOG_FILE
13+
if [ $? -ne 0 ]; then
14+
echo "apt update failed. Check the log file at $LOG_FILE" | tee -a $LOG_FILE
15+
fi
16+
17+
# Install openssh-server and log errors
18+
sudo apt-get install -y openssh-server 2>> $LOG_FILE
19+
if [ $? -ne 0 ]; then
20+
echo "apt install failed. Check the log file at $LOG_FILE" | tee -a $LOG_FILE
21+
fi
22+
23+
ls

0 commit comments

Comments
 (0)