Page 1 of 1

How can I add commands to system init (SysV)?

Posted: Thu Jun 20, 2019 3:06 pm
by davejones
- OS: MX Linux 18
- Window Manager: i3 version 4.13

I wish for the Emacs server (emacsclient) and Tmux to be started at boot. Is it possible to add the service to MX Linux's init system (SysV)?

I tried adding it those to my i3wm init but it doesn't work.

This is the command I use to start emacsclient:

Code: Select all

exec --no-startup-id "emacsclient --socket-name=gui-emacs --no-wait --create-frame"
And this is the script I use to start my tmux sessions.

Both commands work fine in the command-line.

Re: How can I add commands to system init (SysV)?

Posted: Thu Jun 20, 2019 3:31 pm
by Jerry3904
You can add commands using MX Boot options

Re: How can I add commands to system init (SysV)?

Posted: Thu Jun 20, 2019 3:36 pm
by Davo
Put it somewhere in /etc/init.d/directory. Make it owned by root (chown) and executable (chmod 755 stuff) and that it is S in the right runlevel should just work

Re: How can I add commands to system init (SysV)?

Posted: Thu Jun 20, 2019 5:44 pm
by yoshi
hi
first check if in /etc/init.d if a script was created during installation of your apps.

(If not you need to write a script to tell what need to happen -
see https://www.thegeekstuff.com/2012/03/lsbinit-script )


then start

Code: Select all

sudo sysv-rc-conf
and add the script to the runlevels in which it should be started.
default runlevel seems to be 5 (use command $>

Code: Select all

runlevel
to check or cat /etc/inittab | grep initdefault )

some general understanding of sysV is given here:
https://www.digitalocean.com/community/ ... -reference

way easier would it be to start your apps on start of the XFCE session.
For that you just start

Code: Select all

xfce4-session-settings
-> goto Autostart Applications and there you add your commands

Re: How can I add commands to system init (SysV)?

Posted: Thu Jun 20, 2019 6:44 pm
by UncleBaldie
exec --no-startup-id "emacsclient --socket-name=gui-emacs --no-wait --create-frame

Maybe I'm missing something here, or maybe I'm a bit thick, but shouldn't there be closing quotes ?

Just saying....

Phil

Re: How can I add commands to system init (SysV)?

Posted: Fri Jun 21, 2019 7:19 pm
by yoshi
I completely forgot the easiest way.
What I do on single user systems (if only one user is using the machine eg. on my laptop and Raspberry Pi Embedded Systems) is to put a script in
my home folder and call it from /etc/rc.local
Alternatively you can also put your commands directly into /etc/rc.local
It will automatically get called on startup

example:

Code: Select all

more /etc/rc.local 

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#

/home/your_/_path/your_script.sh &         #script in home folder needs to be exectutable
#or
your_command1 &
your command2 &

exit 0
another way is to use cron: https://www.a2hosting.com/kb/developer- ... ver-reboot

Re: How can I add commands to system init (SysV)?

Posted: Wed Jun 26, 2019 2:07 am
by davejones
UncleBaldie wrote: Thu Jun 20, 2019 6:44 pm exec --no-startup-id "emacsclient --socket-name=gui-emacs --no-wait --create-frame

Maybe I'm missing something here, or maybe I'm a bit thick, but shouldn't there be closing quotes ?

Just saying....

Phil
Yes, it should, and there are closing quotes in my actual config. Sorry, I didn't paste it properly. This is now fixed.

Re: How can I add commands to system init (SysV)?

Posted: Wed Jun 26, 2019 2:14 am
by davejones
Jerry3904 wrote: Thu Jun 20, 2019 3:31 pm You can add commands using MX Boot options
Are you referring to this screen?. Cause I don't any a field for inserting commands, nor any such indication in the help file.

Re: How can I add commands to system init (SysV)?

Posted: Wed Jun 26, 2019 5:26 am
by Jerry3904
"Kernel commands" is not what you want?