update domain names with the cli (yet another topic)
-
@potemkin_ai while there is no cli subcommand as such, as @fbartels correctly mentioned, there is a REST api, which the Cloudron dashboard also uses.
I have documented it now at https://docs.cloudron.io/api.html#tag/Cloudron/paths/~1cloudron~1renew_certs/post -
@nebulon oh, that's wonderful!
May I ask you for some help in here, please?
I did the call 'curl -k -X POST -H 'Content-Type: application/json' --data '{"domain": "sub.domain.name"}' https://mydomain.name//api/v1/cloudron/renew_certs
and it failed with the following error:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Error</title> </head> <body> <pre>Cannot POST //api/v1/cloudron/renew_certs</pre> </body> </html>
What am I missing here?
-
@potemkin_ai were you using the dashboard domain. As in my.example.com ?
-
@nebulon nop; but I changed it to be my.sub-domain.domain.name, which is exactly a cloudron address, and get the very same error there.
As I wrote I realized that I used double slash after the domain name - that broke out things, which I didn't expected...
Got the new error - could you please, assist me - how to get the token?
{ "status": "Unauthorized", "message": "Token required" }
-
@potemkin_ai you need to provide an access token for verification as mentioned on the top of https://docs.cloudron.io/api.html
Such api tokens can be created in the profile page in your Cloudron dashboard.
-
@nebulon Thank you.
For the future guys like me - that's in profile page.I've added the token, but it still generate an error:
curl -k -X POST -H 'Content-Type: application/json' -H 'Bearer: $TOKEN' --data '{"domain": "my.sub.domain.com"}' https://my.sub.domain.com/api/v1/cloudron/renew_certs
Generates the same error:
{ "status": "Unauthorized", "message": "Token required"
Request via ?access_token=<token> works, though.
Is there something I'm missing with passing token as a header? Tried both "Bearer: $token" and "Bearer $token" - same result.
-
@potemkin_ai said in update domain names with the cli (yet another topic):
Is there something I'm missing with passing token as a header?
It needs to be
-H "authorization: Bearer $TOKEN"
. -
For the future me, here is a two minutes guide I wish I had when I started:
- Go to the profile page on your Cloudron, generate the token there.
- Create the script you want to be executed and here is the part of it, in charge of the API calls:
dns_host_name='my.your_instance.name' token='token_you_just_generated' set +e set +x #do your voodoo here; in my case - it's firewall rules altering curl -k -X POST -H 'Content-Type: application/json' -H "authorization: Bearer $token" --data '{"domain": "'$dns_host_name'"}' https://$dns_host_name/api/v1/cloudron/renew_certs echo "You can check the status of the task at https://$dns_host_name/logs.html?taskId=$task_id_from_above" sleep 180 #do your next voodoo here - in my case, altering firewall rules back
-
@nebulon indeed, thank you!
For the sake of future users, I guess it could make sense to add information about where to take token and full command line for cURL into the documentation, but it's not directly related to the case.