Browsed by
Category: Development

[PIGET] Save and share your projects

[PIGET] Save and share your projects

We are going to see how tu use git module to create your own modules.

Modules are a great way to works on your project on a Raspberry Pi.
You can save your project and make it available at the beginning of it and share all your scripts to automate tasks.

You can also use all availables modules on Piget , and works with anyone on it.

In this tutorial we are going to :

  • Install git module
  • Create an example module
  • Save this module

Install git module

You can easily create and save module using git module.

To install git module type :

/pi/install git

Git must know your username and email to identify you.
This information is not mandatory, but it is adviced to fill it.
To setup git type :

/do/git/setup

  • Enter your username on github
  • Enter your email on github
When you save a module, your password will be cached for 15 minutes before you need to enter it againr

Create a module

You can do all theses directly on Windows with samba module

We are going to create an example module.

  • Create /do/example folder

mkdir /do/example

Module name must be in lowercase
  • Create install script

nano /do/example/install

  • Make it executable (This also check compatibility)

/system/convertScript /do/example/install

A module always starts with a install script
The install script have all the commands needed to make the module works, When the module is installed, this command will be launch .

A good way to start a module is to copy all the commands from a tutorial inside this script, so you won’t need to go back back to it, and you can make and keep modifications.
Don’t forget to put a link to the tutorial, and his author name inside your script. This will help people to know where to find more information.

Try to avoid as much as possible user interactions in your install script. If you need to ask something to the user, put it inside a setup script

Since we have an install script, we can already upload it, so be can easily save it and get some help to make it.

Save your module

On github

  • Create a new repository

repo

  • Put inside Repository name, the name of your module

name

  • Click on Create repository

In your terminal

  • Inside the module folder /do/example

cd /do/example

  • Type

/do/git/create username/example
/do/git/create benzaie/example

  • Enter your email (github)
  • Enter your password (github)

Your module is now available on github !

Some advice

  • No settings and password inside your module ! Use the folder /user/config/module_name instead !
  • Only put scripts in the main folder, put code / settings / documentations in subfolders.
  • Check out modules inside github.com/pigetnet (especially those who have a documentation)
  • We see how to document your scripts in another tutorial.
  • We see how to use system commands in another tutorial.

Others commands

Coming Soon!

[PIGET] Modify a module

[PIGET] Modify a module

We will see how to modify a module on Piget

Modules can be easily update, so anyone can contribute easily !

Thans to Github, You can work on your own version of piget modules without asking it, and share it with the rest of the world.
If your changes are interesting, I can add it easily.

In this tutorial we are going to :

  • Copy led module
  • Modify it on Github
  • Install your own led module

Copy a module

All Piget modules are on Github, you can copy any module on your own account.

For example, Benzaie want to improve led module, he need to clone (fork) it :

Benzaie now have his own led module at github.com/benzaie/led

Modify a module on Github

You can modify files directly on Github website.
Let’s say Benzaie want to add comments on script on

  • Click on

on

  • Click on the pencil (left)

crayon

  • Modify the code
  • Add a title and a description
  • Click on commit changes

Et voilà , you can see the modification here : https://github.com/pigetnet/led/commit/7433163094076de271f1ae6748c49124c994914d

Install your module

Benzaie want to see his modules or even share them with his friends.

We need to

  • Delete the led module

rm -rf /do/led

/pi/install benzaie/led

Update a module

To update all modules, type

/pi/update

To update led module, type

cd /do/led
/do/git/update

We’ll see in another tutorial, how to create your own modules.