&1`;
} elseif ($_POST['action'] == "off") {
$out = `aws ec2 stop-instances --region=$REGION --instance-id $INSTANCE_ID`;
} elseif ($_POST['action'] == "status") {
$out = `aws ec2 describe-instance-status --region=$REGION --include-all-instances --instance-id $INSTANCE_ID`;
}
if ($out) {
$json = json_decode($out, true);
if ($_POST['action'] == "on") {
echo "Go back
Result: ";
}
if ($json['StartingInstances']) {
exit($json['StartingInstances'][0]['CurrentState']['Name']);
} elseif ($json['StoppingInstances']) {
exit($json['StoppingInstances'][0]['CurrentState']['Name']);
} elseif ($json['InstanceStatuses']) {
exit($json['InstanceStatuses'][0]['InstanceState']['Name']);
}
}
?>
Press this button to turn on the server. It'll take a couple minutes to fully turn on, and it'll turn off automatically after about 30 minutes of inactivity.
Current status: &1`; $json = json_decode($status, true); echo $json['InstanceStatuses'][0]['InstanceState']['Name']; if ($json['InstanceStatuses'][0]['InstanceState']['Name'] == "running") { $players = `python3 /var/minecraft/minestatus.py 2>&1`; $json = json_decode($players, true); if ($json['players'] !== null) { echo " with ".$json['players']." players"; } else { echo " but not reachable yet."; } } ?>