moulinette/README.md

165 lines
5.9 KiB
Markdown
Raw Normal View History

2012-10-14 21:38:36 +02:00
YunoHost CLI
============
2012-10-06 16:22:15 +02:00
2012-10-14 21:38:36 +02:00
Specifications
--------------
2012-10-06 16:22:15 +02:00
2012-10-14 22:05:15 +02:00
2012-10-06 16:22:15 +02:00
### User
2012-10-14 21:14:36 +02:00
yunohost user list [-h] [--fields FIELDS [FIELDS ...]] [-o OFFSET]
[-f FILTER] [-l LIMIT]
2012-10-14 21:38:36 +02:00
yunohost user create [-h] [-u USERNAME] [-l LASTNAME] [-f FIRSTNAME]
[-p PASSWORD] [-m MAIL]
2012-10-29 16:42:47 +01:00
yunohost user delete [-h] [--purge] users [users ...]
2012-10-29 15:57:23 +01:00
yunohost user update [-h] [-f FIRSTNAME]
[--add-mailalias MAIL [MAIL ...]] [-m MAIL]
[-l LASTNAME]
2012-10-14 21:38:36 +02:00
[--remove-mailforward MAIL [MAIL ...]]
2012-10-29 15:57:23 +01:00
[--remove-mailalias MAIL [MAIL ...]]
2012-10-14 21:38:36 +02:00
[--add-mailforward MAIL [MAIL ...]]
2012-10-29 15:57:23 +01:00
[-p PASSWORD]
2012-10-14 21:38:36 +02:00
user
2012-10-29 15:58:13 +01:00
yunohost user info [-h] [-u USER] [-m MAIL]
2012-10-06 16:22:15 +02:00
### Domain
2012-10-14 21:38:36 +02:00
yunohost domain list [-h] [-l LIMIT] [-o OFFSET] [-f FILTER]
2012-10-29 17:59:07 +01:00
yunohost domain add [-h] [domain [domain ...]]
yunohost domain remove [-h] [domain [domain ...]]
2012-10-14 21:38:36 +02:00
yunohost domain info [-h] domain
yunohost domain renewcert [-h] domain
### App
2012-11-16 13:16:37 +01:00
yunohost app updatelist [-h] [-u URL]
2012-10-14 21:38:36 +02:00
yunohost app list [-h] [--fields FIELDS [FIELDS ...]] [-o OFFSET]
[-f FILTER] [-l LIMIT]
yunohost app install [-h] [-d DOMAIN] [--public] [-l LABEL] [-p PATH]
[--protected]
2012-11-16 13:16:37 +01:00
app
2012-10-14 21:38:36 +02:00
yunohost app remove [-h] app [app ...]
yunohost app upgrade [-h] [app [app ...]]
yunohost app info [-h] app
yunohost app addaccess [-h] [-u USER [USER ...]] app [app ...]
yunohost app removeaccess [-h] [-u USER [USER ...]] app [app ...]
2012-11-16 13:16:37 +01:00
2012-10-06 16:22:15 +02:00
### Firewall
2012-10-14 21:38:36 +02:00
yunohost firewall list [-h]
yunohost firewall allow [-h] {UDP,TCP,Both} port name
yunohost firewall disallow [-h] name
2012-10-06 16:22:15 +02:00
### Monitoring
2012-11-01 13:01:31 +01:00
yunohost monitor info [-h] [-u] [-d] [-p] [-c] [-m] [-i]
yunohost monitor process [-h] [-e PROCESS] [-d PROCESS]
[--stop PROCESS] [-c PORT] [-i]
[--start PROCESS]
2012-10-14 21:38:36 +02:00
### Tools
2012-10-29 18:02:08 +01:00
yunohost tools postinstall [-h] [-d DOMAIN] [-p PASSWORD]
yunohost tools maindomain [-h] [-o OLD_DOMAIN] [-n NEW_DOMAIN]
yunohost tools adminpw [-h] [-o OLD_PASSWORD] [-n NEW_PASSWORD]
2012-10-29 18:04:22 +01:00
yunohost tools ldapinit [-h] [-d DOMAIN]
2012-10-14 22:05:15 +02:00
2012-10-22 21:25:55 +02:00
How to use "as is" ?
--------------------
2013-06-15 14:37:27 +02:00
The executable file is yunohost, for example:
2012-10-22 21:25:55 +02:00
2013-06-15 14:37:27 +02:00
./yunohost user create
2012-10-22 21:25:55 +02:00
2012-10-14 22:05:15 +02:00
2012-10-26 12:08:38 +02:00
Contribute / FAQ
----------------
*What a lovely idea !* :)
### Dafuq is dat moulinette ?
We decided to regroup all YunoHost related operations into a single program called "moulinette". This will allow us to entirely manipulate our YunoHost instances through a wonderful CLI. Additionally the web interface will just have to call the same "moulinette" functions. Magic power inside :p
### Important files
2013-06-15 14:37:27 +02:00
* `` yunohost `` File executed on function calling - i.e `` ./yunohost user create ``.
2012-10-26 12:08:38 +02:00
* `` action_map.yml `` Defines all CLI actions and links arguments.
2012-11-16 13:16:37 +01:00
* `` yunohost.py `` Contains all YunoHost functions likely to be shared between moulinette files. Also contains service connections classes (erk).
2012-10-26 12:08:38 +02:00
* `` yunohost_*.py `` Files containing action functions. `` * `` is the category: user, domain, firewall, etc.
### How to add a function ?
1. Check if the action is already in the `` action_map.yml `` file. If not, follow the file documentation to add it.
2. Also check if the file `` yunohost_category.py `` is created in the working tree. If not, just create it (you may take example of `` yunohost_user.py `` file).
3. Add your function `` category_action() `` in this file - i.e `` user_create() ``
2012-11-16 13:16:37 +01:00
**Note:** `` category_action() `` takes one parameter,`` args `` which contains the arguments passed to the command. Refers to `` action_map.yml `` documentation for more informations.
2012-10-26 12:08:38 +02:00
### Error handling
Moulinette has a unified way to handle errors. First, you need to import the ``YunoHostError`` exception:
`` from yunohost import YunoHostError ``
Then you need to raise errors like this:
`` raise YunoHostError(<ERROR CODE>, <MESSAGE>) ``
For example:
`` raise YunoHostError(125, _("Interrupted, user not created")) ``
**Note:** Standard error codes can be found in the ``YunoHostError`` class in `` yunohost.py `` file.
### Print results
Moulinette also have a unified way to print results. In fact we don't only print result for the CLI, but we also have to export the result in a JSON way.
Results are automatically printed OR exported, you don't have to print it yourself in the action's functions. Your function just need is to return results as a dictionary, for example:
`` return { 'Fullname' : 'Homer Simpson', 'Mail' : 'homer@simpson.org', 'Username' : 'hsimpson' } ``
### i18n
We will have to translate YunoHost, and we have already initialized i18n module in the moulinette. As a result, do not forget to put potentially translated strings into `` _() `` function. For example:
`` raise YunoHostError(125, _("Interrupted, user not created")) ``
### Git is pissing me off !
OK, this is the workflow !
**For gitlab:**
Development is handle with git branches and you have your own (i.e dev_beudbeud).
```
git clone git@dev.yunohost.org:moulinette.git
git checkout -b dev_beudbeud ``
git rebase origin/dev
2012-10-26 12:08:38 +02:00
```
2012-10-26 12:08:38 +02:00
Do your modifications, then :
```
git commit -am 'My commit message'
git pull origin dev (merge manually if conflicts)
git push origin dev_beudbeud
2012-10-26 12:08:38 +02:00
```
Then you could ask for a 'merge request' in gitlab.
**For github (here):**
Development is handle with forked repos and you have your own (i.e beudbeud/moulinette).
```
git clone https://github.com/beudbeud/moulinette.git ``
git checkout -b dev
git rebase origin/dev
2012-10-26 12:08:38 +02:00
```
Do your modifications, then:
```
git commit -am 'My commit message'
git remote add vanilla https://github.com/YunoHost/moulinette.git
git pull vanilla dev (merge manually if conflicts)
git push origin dev
```
Then you could ask for a 'pull request' in github.
2012-10-06 16:22:15 +02:00
2012-10-22 21:25:55 +02:00
2012-10-14 22:05:15 +02:00