Skip to content

Commit b0e03ae

Browse files
authored
Merge pull request #39 from zeniar-au/main
New Updates! Install Instructions, Update Every time, Endpoints & Button Colours
2 parents 576e3d7 + f8df7e1 commit b0e03ae

File tree

3 files changed

+296
-78
lines changed

3 files changed

+296
-78
lines changed

README.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,180 @@
11
# CubeCoders AMP WHMCS Module
22

33
This WHMCS module provides provisioning integration with CubeCoders AMP with WHMCS.
4+
5+
<h2>Installing the AMP WHMCS module</h2>
6+
7+
1. Download the .Zip file from this GitHub
8+
2. Upload the package content into your MAIN WHMCS DIRECTORY. 
(We recommend using an FTP Client)
9+
3. Login to WHMCS Admin Area
10+
4. Navigate to **System Settings -> Product & Services -> Servers**
11+
5. Click on **Add New Server**
12+
13+
- For the Module type, select **AMP**
14+
- Enter the hostname for your AMP server followed by a Username and Password
15+
16+
- Note: You should create a seperate AMP user for WHMCS with the Super Admin Role and ensure MFA is disabled for this user.
17+
18+
6. Click **Test Connection**
19+
20+
- If the connection was successful you will see a green banner confirming the connection at the top
21+
22+
- Enter a Name for this AMP server that will be displayed in WHMCS
23+
24+
7. Click **Save Changes**
25+
8. From the Servers overview page click on **Create New Group**
26+
27+
- Enter a Name for your AMP Server Group
28+
- Select your AMP Server(s) from the list and Add to Selected Servers
29+
30+
9. Click **Save Changes**
31+
32+
<h2>Creating the AMP Welcome & Password Reset Email Template</h2>
33+
34+
10. Navigate to **System Settings -> System -> Email Templates**
35+
11. Click on **Create New Email Template**
36+
37+
- For Email Type, click the dropdown and select **Product/Service**
38+
- Enter the name “AMP Welcome Email” for this template.
39+
40+
⚠️ Its important you use this exact template title name otherwise the email will not be sent once AMP has provisioned the Instance. This name will not be visible to your customers
41+
42+
- Enter an Email Subject that your customers will see such as “Important Account Information”
43+
- Copy and paste the below template into the text area of the email template
44+
45+
Congratulations {$client_name},
46+
47+
Your order has now been activated and you are minuets away from starting an epic journey with your friends in {$service_product_name}
48+
49+
50+
51+
Username: {$service_username}
52+
53+
Generated Password: {$service_password}
54+
55+
Console Login: https://{$service_server_hostname}/?instance={$service_instance_id}
56+
57+
58+
59+
Lets get started!
60+
61+
Now that you are a {$service_product_name} Server owner, you'll need to login to the above link and accept the {$service_product_name} EULA and then Start your server.
62+
63+
Please raise a ticket on our website if you require assistance. 
64+
65+
66+
{$signature}
67+
68+
12. Click **Save Changes**
69+
13. Next, we'll setup the AMP Password Reset email.
70+
14. Navigate to **System Settings -> System -> Email Templates**
71+
15. Click on **Create New Email Template**
72+
73+
- For Email Type, click the dropdown and select **Product/Service**
74+
- Enter the name “AMP Password Reset” for this template.
75+
76+
⚠️ Its important you use this exact template title name otherwise the email will not be sent once AMP has provisioned the Instance. This name will not be visible to your customers
77+
78+
- Enter an Email Subject that your customers will see such as “Password Reset Information”
79+
- Copy and paste the below template into the text area of the email template
80+
81+
Hello {$client_name},
82+
83+
We've reset your password to your Control Panel. Please find your new login details below:
84+
85+
86+
Username: {$service_username}
87+
88+
Generated Password: {$service_password}
89+
90+
Console Login: https://{$service_server_hostname}/?instance={$service_instance_id}
91+
92+
93+
94+
If you did not request this password change, please reply to this email.
95+
96+
{$signature}
97+
98+
16: Click **Save Changes**
99+
100+
<h2>Set the callback function between AMP & WHMCS</h2>
101+
102+
17. Login to your AMP Control Panel
103+
18. Navigate to **Configuration -> Instance Deployment**
104+
19. Set the Template deployment callback URL as follows :
105+
106+
https://WHMCS_URL/index.php?ampCallback=1
107+
eg. https://example.com/index.php?ampCallback=1
108+
109+
⚠️ Ensure to change WHMCS_URL to your own domain where WHMCS is installed as this will allow AMP to tell WHMCS once the product is created and the status of the instance.
110+
111+
112+
<h2>Setting up a Server Group & Product within WHMCS</h2>
113+
114+
20. Navigate to **System Settings -> Products & Services -> Products/Services**
115+
21. Create New Product Group ( or use existing one )
116+
117+
- Select **Create New Product**
118+
- For the Product Type, select **[Other]**
119+
- From the Product Group dropdown, select the Product Group you created earlier
120+
- Enter a product name (For Example, Minecraft Java)
121+
- Click on the drop down menu for Module and select **AMP**
122+
123+
22. Click on **Continue**
124+
125+
- Click on the **Module Settings** tab
126+
- Ensure that Module Name is set to **AMP**
127+
- Click on the Server Group drop down menu and select the Server Group you created earlier
128+
129+
- You will now see new fields appear that are specific to this product
130+
- The **Provisioning Template** allows you to select your deployment template within AMP for specific server you want to deploy
131+
- Then select the **Post Create Action** from the below list depending on your desired outcome
132+
133+
Do Nothing = Creates instance and doesnt start the instance or application
134+
Start Instance = Creates and starts the instance but doesnt start the application automatcially
135+
Start instance & update application = Creates & Starts the instance and performs an application update.
136+
Full Instance & application startup = Creates & Starts the instance and starts & updates the application and starts the application everytime the instance starts. (Providing no additional setup is required on the customers behalf such as EULA acknowledgement or Steam sign in)
137+
138+
- Set the **Required Tags** field as per below
139+
- If you are running AMP in **Standalone** or Hybrid mode, enter the value ‘Local’
140+
- If you are running AMP in **Controller/Target** mode, enter the Tag value that you have set on a Target within the AMP panel
141+
- Extra Provision Setting field allows you to set a static setting that will apply to all Instances created for this product. If you wish to sell customisable parameters such as RAM & CPU allocations, please see the Configurable Options section further down.
142+
- The **Update Every Tim**e option tells AMP if the application should be updated everytime the instance is started in teh future
143+
- The **Mode** selection allows you to specify how teh Endpoints are displayed in the Client section of WHMCS. For example:
144+
145+
Standalone URL will be displayed as https://yourdomain.com:25565
146+
Target/Node IP Address will be displayed as 0.0.0.0:25565
147+
148+
- Now select your preference for the Automatic Setup
149+
150+
23. Click **Save Changes**
151+
152+
⚠️ Don’t forget to set the other configurations in the other tabs for this product such as pricing.
153+
154+
You’re ready to go! Module is ready to use. After activation of ordered product, module will wait for callback - then Application URL will be show in client area.
155+
156+
<h2>Configurable Options</h2>
157+
158+
You can set custom configuration options within WHMCS for settings such as RAM Allocation & CPU Allocation.
159+
160+
1. Navigate to **System Settings -> Products & Services -> Configurable Options**
161+
2. Click on **Create a New Group** and give it a name such as ‘AMP Product Options’
162+
3. From the Assigned Products select the products that these configurable options applies to
163+
4. Click on **Add New Configurable Option**
164+
5. Enter the configrable option that you would like to set from the list below and click **Save Changes**
165+
166+
<h3> Example Configurable Options</h3>
167+
168+
+$$ContainerCPUs|Server CPU Allocation
169+
2|2 CPU Cores
170+
4|4 CPU Cores
171+
+$$ContainerMemoryMB|RAM Allowance
172+
1024|1 GB
173+
2048|2 GB
174+
4096|4 GB
175+
176+
<h2>FAQ’s</h2>
177+
178+
Q: Do I need to set a Product Welcome Email in each product?
179+
180+
A: No, the AMP WHMCS Module will always send out the email Template called “AMP Welcome Email”. You can however send an additional welcome email by selecting another email template in the Welcome Email drop down box within each product.

modules/servers/AMP/AMP.php

Lines changed: 51 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -166,38 +166,48 @@ function ($table) {
166166
} catch(e) {}
167167
168168
</script>';
169-
$fields = [
170-
'Provisioning Template' => array(
171-
'Type' => 'dropdown',
172-
'Options' => $options,
173-
'Description' => 'Choose one',
174-
),
175-
'Post Create Action' => array(
176-
'Type' => 'dropdown',
177-
'Options' =>
178-
[
179-
0 => 'Do nothing',
180-
10 => 'Start instance only',
181-
20 => 'Start instance and update application',
182-
30 => 'Full application startup',
183-
],
184-
'Description' => 'Choose one'.$script,
185-
),
186-
'Required Tags' => array(
187-
'Type' => 'text',
188-
'Size' => '25',
189-
'Default' => '',
190-
'Description' => 'comma separated',
191-
),
192-
'Extra Provision Settings' => array(
193-
'Type' => 'text',
194-
'Size' => '25',
195-
'Default' => '',
196-
'Description' => $scriptExtraProvisionSettings,
197-
),
198-
199-
];
200-
return $fields;
169+
$fields = [
170+
'Provisioning Template' => array(
171+
'Type' => 'dropdown',
172+
'Options' => $options,
173+
'Description' => 'Choose a deployment template from AMP',
174+
),
175+
'Post Create Action' => array(
176+
'Type' => 'dropdown',
177+
'Options' =>
178+
[
179+
0 => 'Do nothing',
180+
1 => 'Start instance only',
181+
2 => 'Start instance & update application',
182+
3 => 'Full instance & application startup',
183+
],
184+
'Description' => '<br><br>Choose what happens after AMP has created the instance'.$script,
185+
),
186+
'Required Tags' => array(
187+
'Type' => 'text',
188+
'Size' => '25',
189+
'Default' => '',
190+
'Description' => '<br><br>Seperate the tags by using a comma. For more info, see module install guide',
191+
),
192+
'Extra Provision Settings' => array(
193+
'Type' => 'text',
194+
'Size' => '25',
195+
'Default' => '',
196+
'Description' => $scriptExtraProvisionSettings.'<br>',
197+
),
198+
'Update Every Time' => array(
199+
'Type' => 'yesno',
200+
'Description' => 'Tick this box to update the application every time the instance starts in the future',
201+
),
202+
"Mode" => array(
203+
'Type' => 'dropdown',
204+
'Options' => 'Standalone URL,Target/Node IP Address',
205+
'Default' => 'Target/Node IP Address',
206+
'Description' => '<br><br>Select how the Endpoints should be displayed on the Client section within WHMCS',
207+
)
208+
];
209+
return $fields;
210+
201211

202212
} catch (\Exception $ex) {
203213
if (App::getFromRequest('action') != 'save') {
@@ -268,7 +278,11 @@ function AMP_CreateAccount(array $params)
268278
AMP_commercialCheck($params);
269279
$client = new Client($params);
270280
$provisioningTemplateId = $params['configoption1'];
271-
$postCreate = !empty($params['configoption2']) ? $params['configoption2'] : 10;
281+
$postCreate = !empty($params['configoption2']) ? $params['configoption2'] : 0;
282+
// Check if the 'Every Time' box is ticked and if so, add 16 to the PostCreate value
283+
if (!empty($params['configoption5'])) {
284+
$postCreate += 16;
285+
}
272286
$templates = $client->call('ADSModule/GetDeploymentTemplates');
273287

274288
$options = [];
@@ -552,6 +566,9 @@ function AMP_ClientArea(array $params)
552566
}
553567
die;
554568
}
569+
570+
$vars['mode'] = isset($params['configoption6']) ? $params['configoption6'] : 'Standalone URL';
571+
555572

556573
if(!empty($service->instanceId))
557574
{
@@ -733,4 +750,4 @@ function AMP_ClearInstanceFromWHMCS(array $params)
733750
} catch (\Exception $e) {
734751
return $e->getMessage();
735752
}
736-
}
753+
}

0 commit comments

Comments
 (0)