Module Creation: Best Practices

Technical issues/questions of an intermediate or advanced nature.
Post Reply
igreka
White ninja
White ninja
Posts: 29
Joined: 05 Oct 2014, 21:48
Distribution: porteus 3
Location: lincoln

Module Creation: Best Practices

Post#1 by igreka » 05 Jun 2016, 21:17

Hi all,

I have been experimenting with Linux via Porteus for a while now given that I use it for web development. This means that I have installed a bunch of tools on it, from editors such as Atom and Sublime Text 3 to browsers like Vivaldi and Firefox to package managers like npm, nvm and such.

The problem is that none of these are modules. I could easily turn their containing directories into modules. But given that I also create symbolic links into /bin or /usr/bin and add executables to PATH, I don't know how to include those in my modules so they are removed / injected as the module is (des)activated.

It would be great if someone could update the module creation tutorials to reflect those use cases. Or just show me how to effectively create modules that have CLI commands, start menu items, etc.

Thanks.

Evan
Warlord
Warlord
Posts: 519
Joined: 11 Apr 2016, 09:00
Distribution: Anything Cinnamon
Location: London

Re: Module Creation: Best Practices

Post#2 by Evan » 05 Jun 2016, 22:43

<removed>
Last edited by Evan on 24 Jun 2016, 12:52, edited 1 time in total.

User avatar
brokenman
Site Admin
Site Admin
Posts: 5436
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: Module Creation: Best Practices

Post#3 by brokenman » 05 Jun 2016, 23:44

You can create the module as per tutorials/videos and a script can be executed upon activation by placing it (the executable script) at:
/etc/rc.d/rc.scriptname (in the module obviously)

Code: Select all

#!/bin/sh

test_start() {
  touch /tmp/testme
}

test_stop() {
  rm -f /tmp/testme
}

case "$1" in
  start)
    test_start
    ;;
  stop)
    test_stop
    ;;
  restart)
    test_stop
    sleep 1
    test_start
    ;;
  *)
    echo "Usage: $N {start|stop|restart}\n"
    exit 1
    ;;
esac
How do i become super user?
Wear your underpants on the outside and put on a cape.

Evan
Warlord
Warlord
Posts: 519
Joined: 11 Apr 2016, 09:00
Distribution: Anything Cinnamon
Location: London

Re: Module Creation: Best Practices

Post#4 by Evan » 06 Jun 2016, 00:05

<removed>
Last edited by Evan on 24 Jun 2016, 12:51, edited 1 time in total.

User avatar
brokenman
Site Admin
Site Admin
Posts: 5436
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: Module Creation: Best Practices

Post#5 by brokenman » 06 Jun 2016, 01:56

No they are not mine but yes the coincidence is there. I plan on creating tutorial videos when I get a chance.
How do i become super user?
Wear your underpants on the outside and put on a cape.

Evan
Warlord
Warlord
Posts: 519
Joined: 11 Apr 2016, 09:00
Distribution: Anything Cinnamon
Location: London

Re: Module Creation: Best Practices

Post#6 by Evan » 06 Jun 2016, 04:47

<removed>
Last edited by Evan on 24 Jun 2016, 12:51, edited 1 time in total.

Bogomips
Full of knowledge
Full of knowledge
Posts: 2522
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: Module Creation: Best Practices

Post#7 by Bogomips » 06 Jun 2016, 20:20

Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
brokenman
Site Admin
Site Admin
Posts: 5436
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: Module Creation: Best Practices

Post#8 by brokenman » 06 Jun 2016, 23:45

Thanks Bogomips. I was looking for that link for a bit. Also added a late reply to it.
How do i become super user?
Wear your underpants on the outside and put on a cape.

igreka
White ninja
White ninja
Posts: 29
Joined: 05 Oct 2014, 21:48
Distribution: porteus 3
Location: lincoln

Re: Module Creation: Best Practices

Post#9 by igreka » 13 Jun 2016, 13:49

Hi all,

Thank you so much for your answers. I'll have a look at the tutorials and the links and try to make the best out of them to apply them to my case. :good:

I really think we need to update the 'tutorials' link and resources on the site to show noobs things like 'updating Porteus', 'injecting files into the file system via modules', 'creating modules (with a much better explanation of how activating modules alters the file system or the start menu)' . You know, practical blog style tutorials. :)

Post Reply