-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add support to specify backup directories - Fixes incorrect lambda packing - Add MineCloud Configuration Package support
- Loading branch information
Showing
34 changed files
with
296 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Please download and unzip MineCloud Configuration Package to this folder. | ||
The folders hierarchy should look like this: | ||
``` | ||
- /MineCloud_root_folder | ||
- /minecloud_configs | ||
- MineCloud-Configs.ts | ||
- /server | ||
- ... | ||
- /advanced_configs | ||
- ... | ||
- /bin | ||
- /lambda | ||
- /lib | ||
- /server_init_assets | ||
- ... | ||
``` | ||
The pairing MineCloud version of the Configuration Package can be found in `MineCloud-Configs.ts`. | ||
|
||
An out-of-the-box Minecraft server example, `minecraft_example_config_pack.zip`, can also be found in this folder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/opt/minecloud/server |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# MineCloud: Minecraft Configuration Package | ||
|
||
// To-do |
32 changes: 32 additions & 0 deletions
32
minecloud_configuration_packages/Minecraft/dev/vanilla_configs/MineCloud-Configs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// MineCloud Version: 1.2.2 | ||
|
||
// ---------------- Required -------------------- // | ||
export const AWS_ACCOUNT_ID = ''; | ||
export const AWS_REGION = ''; | ||
|
||
export const DISCORD_APP_ID = ''; | ||
export const DISCORD_PUBLIC_KEY = ''; | ||
export const DISCORD_BOT_TOKEN = ''; | ||
export const DISCORD_CHANNEL_WEB_HOOK = ''; | ||
|
||
// ------------- CloudFormation ------------- // | ||
export const STACK_NAME = 'Minecraft'; | ||
|
||
// -------------- Server Executable ------------- // | ||
// If set to true, /minecloud_configs/server/server.zip will be deployed | ||
export const DEPLOY_LOCAL_SERVER_EXECUTABLE = false; | ||
|
||
// ----------------EC2 Machine Settings-------------------- // | ||
// EC2 max price per hours, in dollars | ||
export const MAX_PRICE = 0.1; | ||
// EC2 instance type, refer to https://aws.amazon.com/ec2/instance-types/ for more info | ||
export const EC2_INSTANCE_TYPE = 't2.large'; | ||
// Disk size, in GB | ||
export const EC2_VOLUME = 16; | ||
// Init time out, in minutes | ||
export const EC2_INIT_TIMEOUT = 15; | ||
|
||
// --------------- Backup Settings------------------ // | ||
// At most how many backups | ||
export const MAX_BACKUP_COUNT = 3; | ||
export const BACKUP_INTERVAL_IN_SECONDS = 10800; |
1 change: 1 addition & 0 deletions
1
..._configuration_packages/Minecraft/dev/vanilla_configs/advanced_configs/backup-folders.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/opt/minecloud/server |
32 changes: 32 additions & 0 deletions
32
...iguration_packages/Minecraft/dev/vanilla_configs/advanced_configs/custom-instance-init.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
InitCommand, | ||
InitConfig, | ||
InitFile, | ||
InitPackage | ||
} from 'aws-cdk-lib/aws-ec2'; | ||
import { MINECLOUD_SERVER_DIR } from '../../lib/const/minecloud-dir'; | ||
import { DEPLOY_LOCAL_SERVER_EXECUTABLE } from '../MineCloud-Configs'; | ||
import { MINECRAFT_SERVER_DOWNLOAD_URL } from './minecraft-server-download-url'; | ||
|
||
export const CUSTOM_INIT_CONFIG: InitConfig = getCustomInitConfig(); | ||
|
||
function getCustomInitConfig(): InitConfig { | ||
let configs: (InitPackage | InitCommand | InitFile)[] = [ | ||
// Install an Amazon Java package using yum | ||
InitPackage.yum('java-17-amazon-corretto-headless'), | ||
InitCommand.shellCommand("echo 'eula=true' > eula.txt", { | ||
cwd: MINECLOUD_SERVER_DIR | ||
}) | ||
]; | ||
|
||
if (!DEPLOY_LOCAL_SERVER_EXECUTABLE) { | ||
configs.push( | ||
InitFile.fromUrl( | ||
`${MINECLOUD_SERVER_DIR}/server.jar`, | ||
MINECRAFT_SERVER_DOWNLOAD_URL | ||
) | ||
); | ||
} | ||
|
||
return new InitConfig(configs); | ||
} |
5 changes: 5 additions & 0 deletions
5
...iguration_packages/Minecraft/dev/vanilla_configs/advanced_configs/get_connection_count.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function get_current_connection_count() | ||
{ | ||
local mcCons=$(netstat -anp | grep :25565 | grep ESTABLISHED | wc -l) | ||
echo "$mcCons" | ||
} |
10 changes: 10 additions & 0 deletions
10
...kages/Minecraft/dev/vanilla_configs/advanced_configs/get_connection_count_udp_template.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
function get_current_connection_count() | ||
{ | ||
local mcCons=$(sudo timeout 300 tcpdump -c 1 udp port 25565 2>/dev/null) | ||
|
||
if [[ -z $mcCons ]]; then | ||
echo 0 | ||
else | ||
echo 1 | ||
fi | ||
} |
2 changes: 2 additions & 0 deletions
2
..._packages/Minecraft/dev/vanilla_configs/advanced_configs/minecraft-server-download-url.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const MINECRAFT_SERVER_DOWNLOAD_URL = | ||
'https://piston-data.mojang.com/v1/objects/8f3112a1049751cc472ec13e397eade5336ca7ae/server.jar'; |
2 changes: 2 additions & 0 deletions
2
...ud_configuration_packages/Minecraft/dev/vanilla_configs/advanced_configs/other-configs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Set to true so to avoid roll back when EC2 init fail, mainly used for debugging. | ||
export const IGNORE_FAILURE_ON_INSTANCE_INIT = false; |
9 changes: 9 additions & 0 deletions
9
...oud_configuration_packages/Minecraft/dev/vanilla_configs/advanced_configs/port-configs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Peer, Port } from 'aws-cdk-lib/aws-ec2'; | ||
|
||
export const PORT_CONFIGS = [ | ||
{ | ||
peer: Peer.anyIpv4(), | ||
port: Port.tcp(25565), | ||
description: 'Allows Minecraft connection' | ||
} | ||
]; |
Binary file added
BIN
+240 Bytes
minecloud_configuration_packages/Minecraft/dev/vanilla_configs/server/server.zip
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
minecloud_configuration_packages/Minecraft/dev/vanilla_configs/server/start_server.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
|
||
echo "Starting Minecraft server" | ||
# You can adjust your server start up command here | ||
/usr/bin/env java -Xmx6144M -Xms1024M -jar server.jar nogui | ||
echo "Minecraft server stop" |
9 changes: 9 additions & 0 deletions
9
minecloud_configuration_packages/Minecraft/dev/vanilla_configs/server/stop_server.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
/usr/bin/screen -S mc_server -X stuff 'say Server shutting down (closing by the system service)^M' | ||
/usr/bin/screen -S mc_server -X stuff 'save-all^M' | ||
/bin/sleep 10 | ||
/usr/bin/screen -S mc_server -X stuff 'stop^M' | ||
/opt/minecloud/send_discord_message_to_webhook.sh "Shutting Minecraft server down..." | ||
/bin/sleep 10 | ||
/opt/minecloud/send_discord_message_to_webhook.sh "(Minecraft server shut down)" |
Binary file added
BIN
+4.42 KB
minecloud_configuration_packages/Minecraft/releases/minecraft_vanilla_1.19.4.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# MineCloud: Terraria Configuration Package | ||
|
||
// To-do |
32 changes: 32 additions & 0 deletions
32
minecloud_configuration_packages/Terraria/dev/vanilla_configs/MineCloud-Configs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// MineCloud Version: 1.2.2 | ||
|
||
// ---------------- Required -------------------- // | ||
export const AWS_ACCOUNT_ID = ''; | ||
export const AWS_REGION = ''; | ||
|
||
export const DISCORD_APP_ID = ''; | ||
export const DISCORD_PUBLIC_KEY = ''; | ||
export const DISCORD_BOT_TOKEN = ''; | ||
export const DISCORD_CHANNEL_WEB_HOOK = ''; | ||
|
||
// ------------- CloudFormation ------------- // | ||
export const STACK_NAME = 'Terraria'; | ||
|
||
// -------------- Server Executable ------------- // | ||
// If set to true, /minecloud_configs/server/server.zip will be deployed | ||
export const DEPLOY_LOCAL_SERVER_EXECUTABLE = false; | ||
|
||
// ----------------EC2 Machine Settings-------------------- // | ||
// EC2 max price per hours, in dollars | ||
export const MAX_PRICE = 0.1; | ||
// EC2 instance type, refer to https://aws.amazon.com/ec2/instance-types/ for more info | ||
export const EC2_INSTANCE_TYPE = 't2.large'; | ||
// Disk size, in GB | ||
export const EC2_VOLUME = 16; | ||
// Init time out, in minutes | ||
export const EC2_INIT_TIMEOUT = 15; | ||
|
||
// --------------- Backup Settings------------------ // | ||
// At most how many backups | ||
export const MAX_BACKUP_COUNT = 3; | ||
export const BACKUP_INTERVAL_IN_SECONDS = 10800; |
2 changes: 2 additions & 0 deletions
2
...d_configuration_packages/Terraria/dev/vanilla_configs/advanced_configs/backup-folders.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/opt/minecloud/server | ||
/opt/minecloud/TerrariaSaves |
48 changes: 48 additions & 0 deletions
48
...figuration_packages/Terraria/dev/vanilla_configs/advanced_configs/custom-instance-init.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { | ||
InitCommand, | ||
InitConfig, | ||
InitFile, | ||
InitPackage | ||
} from 'aws-cdk-lib/aws-ec2'; | ||
import { MINECLOUD_SERVER_DIR } from '../../lib/const/minecloud-dir'; | ||
import { DEPLOY_LOCAL_SERVER_EXECUTABLE } from '../MineCloud-Configs'; | ||
|
||
const TERRARIA_SERVER_DOWNLOAD_URL = | ||
'https://terraria.org/api/download/pc-dedicated-server/terraria-server-1449.zip'; | ||
|
||
export const CUSTOM_INIT_CONFIG: InitConfig = getCustomInitConfig(); | ||
|
||
function getCustomInitConfig(): InitConfig { | ||
|
||
if (!DEPLOY_LOCAL_SERVER_EXECUTABLE) { | ||
// Download and setup Terraria server | ||
return new InitConfig([ | ||
InitFile.fromUrl( | ||
`${MINECLOUD_SERVER_DIR}/terraria-server-1449.zip`, | ||
TERRARIA_SERVER_DOWNLOAD_URL | ||
), | ||
InitCommand.shellCommand(`sudo unzip terraria-server-1449.zip`, { | ||
cwd: MINECLOUD_SERVER_DIR | ||
}), | ||
InitCommand.shellCommand(`sudo rm -f terraria-server-1449.zip`, { | ||
cwd: MINECLOUD_SERVER_DIR | ||
}), | ||
InitCommand.shellCommand(`sudo mv 1449/Linux/* .`, { | ||
cwd: MINECLOUD_SERVER_DIR | ||
}), | ||
InitCommand.shellCommand(`sudo rm -rf 1449`, { | ||
cwd: MINECLOUD_SERVER_DIR | ||
}), | ||
InitCommand.shellCommand(`sudo chmod +x TerrariaServer.bin.x86*`, { | ||
cwd: MINECLOUD_SERVER_DIR | ||
}), | ||
InitFile.fromFileInline(`${MINECLOUD_SERVER_DIR}/serverconfig.txt`,'minecloud_configs/advanced_configs/serverconfig.txt') | ||
]); | ||
} else { | ||
return new InitConfig([ | ||
InitCommand.shellCommand(`sudo chmod +x TerrariaServer.bin.x86*`, { | ||
cwd: MINECLOUD_SERVER_DIR | ||
}) | ||
]); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...figuration_packages/Terraria/dev/vanilla_configs/advanced_configs/get_connection_count.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function get_current_connection_count() | ||
{ | ||
# Check how many TCP connections on port 7777 | ||
local mcCons=$(netstat -anp | grep :7777 | grep ESTABLISHED | wc -l) | ||
echo "$mcCons" | ||
} |
2 changes: 2 additions & 0 deletions
2
...oud_configuration_packages/Terraria/dev/vanilla_configs/advanced_configs/other-configs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Set to true so to avoid roll back when EC2 init fail, mainly used for debugging. | ||
export const IGNORE_FAILURE_ON_INSTANCE_INIT = false; |
Oops, something went wrong.