SliTaz SliTaz Forum

You are not logged in.

#1 2015-12-01 23:11:21

emninger
Member
Registered: 2015-10-24
Posts: 53

How to start a service automatically

How do i start in slitaz a service automatically? In this case i'd like to have tor started automatically on boot ...

TIA

Offline

#2 2015-12-02 14:12:23

llev
Member
Registered: 2011-12-09
Posts: 568

Re: How to start a service automatically

Add it to the RUN_DAEMONS variable in /etc/rcS.conf, if it is a standard init script. Or you can add custom commands in /etc/init.d/local.sh .

Offline

#3 2015-12-02 16:03:41

emninger
Member
Registered: 2015-10-24
Posts: 53

Re: How to start a service automatically

Thanks a lot!

Offline

#4 2015-12-02 18:07:19

llev
Member
Registered: 2011-12-09
Posts: 568

Re: How to start a service automatically

Please mark as solved, if it does work of course!

Offline

#5 2015-12-02 18:40:18

mojo
Administrator
Registered: 2011-03-29
Posts: 2,174

Re: How to start a service automatically

@emninger

Please try tord the new tor init script.

Install directions:

[c]wget http://people.slitaz.org/~mojo/stuff/tord[/c]

[c]mv tord /etc/init.d[/c]

[c]chown root:root /etc/init.d/tord[/c]

[c]chmod 755 /etc/init.d/tord[/c]

[c]echo "PIDFile /var/run/tor.pid" >> /etc/tor/torrc[/c]

Usage:[c]/etc/init.d/tord start|stop|restart[/c]

Tord init script /dev/nulls tor terminal output.

Start tor at the command line to verify it is configured and running properly by observing terminal output before using tord init script.

Offline

#6 2015-12-02 19:04:40

emninger
Member
Registered: 2015-10-24
Posts: 53

Re: How to start a service automatically

Hi mojo! Thanks that's something i was looking for.

Generally, is there something equivalent in Slitaz to slackware/debian/... service start|stop|restart or sv start|stop|restart (for openrc or runit distros)?

Actually, i'm killing via htop and restart than manually - that's not really very elegant.

Offline

#7 2015-12-02 19:16:55

mojo
Administrator
Registered: 2011-03-29
Posts: 2,174

Re: How to start a service automatically

>=slitaz-5.0 has stopd|startd abbreviation for init scripts in /etc/init.d

Enables leaving off path /etc/init.d to script command.

Example: [c]startd tord[/c] and [c]stopd tord[/c]

Offline

#8 2015-12-02 19:17:27

llev
Member
Registered: 2011-12-09
Posts: 568

Re: How to start a service automatically

Yes, this is simply like any other Linux using init.d (not systemd):

[c]/etc/init.d/service restart[/c]

Offline

#9 2015-12-02 19:36:07

mojo
Administrator
Registered: 2011-03-29
Posts: 2,174

Re: How to start a service automatically

slitaz-tools owns /usr/bin/startd

Startd - Small wrapper to start daemons on SliTaz

It's simple to copy rename edit to make a /usr/bin/restartd.

Offline

#10 2015-12-02 20:38:12

emninger
Member
Registered: 2015-10-24
Posts: 53

Re: How to start a service automatically

@mojo:

Just to control/check tor i'd suggest tor-arm, which is a nice ncurses program to control tor (also suggested by the tor people). I used since a long time on slackware and i'm happy with. You only have to activate the control port (and to create a password, obviously).

Offline

#11 2015-12-02 22:48:35

emninger
Member
Registered: 2015-10-24
Posts: 53

Re: How to start a service automatically

@ilev

>Add it to the RUN_DAEMONS variable in /etc/rcS.conf, if it is a standard init script. Or you can add >custom commands in /etc/init.d/local.sh .

So i could simply put in local.sh, just as an example:

tord &

polipo &

(Seems easier to me than to probably mess up rcS ... (?) )

Offline

#12 2015-12-02 22:50:54

emninger
Member
Registered: 2015-10-24
Posts: 53

Re: How to start a service automatically

@mojo

I see i've 2 times tord: Once on / and once in /etc/init.d - is it safe to delete the topmost one?

Offline

#13 2015-12-03 11:59:05

llev
Member
Registered: 2011-12-09
Posts: 568

Re: How to start a service automatically

Why do you want to delete something, if all is working? If the topmost one is the binary, and the other one is a symlink, you'll have a (bad) surprise!

As for local.sh/rcS.conf, it's equivalent as far as running services is concerned. Note I told you to edit /etc/rcS.conf, NOT /etc/init.d/rcS .

Offline

#14 2015-12-03 13:29:56

mojo
Administrator
Registered: 2011-03-29
Posts: 2,174

Re: How to start a service automatically

@llev

[c]/etc/init.d/tord[/c] => init shell script that starts [c]/usr/bin/tor[/c]

[c]/tord[/c] => copy of init shell script can be deleted

@emninger

tord belongs in /etc/init.d

You were in / when you downloaded tord with wget

I changed cp to mv in directions above so there is not a duplicate copy of tord.

[c]wget http://people.slitaz.org/~mojo/stuff/tord[/c]

[c]mv tord /etc/init.d[/c]

Add [c]tord[/c] to RUN_DAEMONS in [c]/etc/rcS.conf[/c] to start tor on boot.

Offline

#15 2015-12-03 22:59:14

emninger
Member
Registered: 2015-10-24
Posts: 53

Re: How to start a service automatically

@ilev

Yes, i'm aware of that wink

@mojo

Would it be sufficient to simply add tord in there. Actually my line would look like this:

RUN_DAEMONS="firewall httpd tord" Is that ok? Or does tord need a start command?

Then a systematic (or systemic wink ) question: Since local.sh is included, tor would also be started if put in local.sh (for example in this way: "tor -d &")? But with a different owner? In the first case owned by root in the second owned by <user> (as far as i know the tor people do not recommend to run tor as root (?) ).

Offline

#16 2015-12-04 20:48:34

llev
Member
Registered: 2011-12-09
Posts: 568

Re: How to start a service automatically

1) No start command. Check /etc/init.d/rcS: it simply runs "daemon start" where "daemon" is given each value in RUN_DAEMONS in turn.

2) Both ways are run by root. If you really need another user, you could put the following in local.sh:

[c]su -c "tor -d &" - username &[/c]

3) Maybe does tord automatically run the service as another user? You can check, after starting it, who is the owner by:

[c]ps | grep tor[/c]

Offline

#17 2015-12-05 15:45:49

emninger
Member
Registered: 2015-10-24
Posts: 53

Re: How to start a service automatically

I did it this way: In local.sh i defined:

> su -c "/etc/init.d/tord start &" - myusername &

That seems to work and allows me to control tor locally via tor-arm (since in slitaz there is no sudo, that's the most convenient way). Obviously, the access to the control port is password protected.

Generally, i'm not so sure about how tor has to be run; in slackware tor runs as user tor. In any case, the tor manual says it's not a good idea to run it as root.

Anyway, thanks for the lesson in busybox smile

Offline

#18 2015-12-05 20:44:47

llev
Member
Registered: 2011-12-09
Posts: 568

Re: How to start a service automatically

[c]# tazpkg -gi sudo[/c]

smile

(please mark topic as solved)

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.017 seconds, 7 queries executed - Memory usage: 1.56 MiB (Peak: 1.77 MiB) ]