LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 01-16-2020, 03:46 AM   #1
Jinux75
Member
 
Registered: Jul 2017
Location: The Netherlands
Distribution: Linux Mint, Ubuntu 20.04
Posts: 97

Rep: Reputation: Disabled
Question systemd or init.d


Hello, i have some questions because i do not understand the logic of it.
It is a bit hard for me to explain, but here goes:

I have some program.sh and that can be started with init.d or systemd.
The wiki of the program tells me it is preferred to use systemd, so i setup a service file and it works. But i just do not understand how this works.

Here is the service file:
Code:
[Unit]
       Description=program_service
[Service]
       User=me
       Group=me
       ExecStart=/home/me/program/program
       WorkingDirectory=/home/me/program

[Install]
       WantedBy=multi-user.target
Here is the program.sh file where the service file points to:

Code:
#! /bin/sh
### BEGIN INIT INFO
# Provides:          program
# Required-Start:    $network $remote_fs $syslog
# Required-Stop:     $network $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Some program example
# Description:       This daemon will start some program example
### END INIT INFO

# Do NOT "set -e"

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
DESC="Some program"
NAME=program
USERNAME=me
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

DAEMON=/home/$USERNAME/program/$NAME
DAEMON_ARGS="-daemon"
#DAEMON_ARGS="$DAEMON_ARGS -daemonname $NAME -pidfile $PIDFILE"
DAEMON_ARGS="$DAEMON_ARGS -log /tmp/program.txt"
#DAEMON_ARGS="$DAEMON_ARGS -syslog"
As you can see in the program.sh the scriptname points to init.d, but it is setup in systemd so i just do not get the logic. And when i start it with init.d logging works, but if it crashes it is not started automatically. And when i use systemd the logging does not work but if it crashes it just restarts.

Also when in the wiki i choose the preferred method to start, every change they describe is made when starting it from init.d. So it is a bit hard to understand how to make changes if i use the systemd method.
Can any one explain to me why in the program.sh it is pointed to /etc/init.d as the preferred method in systemd?
Do i need to put the program.sh also in init.d?

Here is the programs wiki and the preferred method of starting it:
https://www.domoticz.com/wiki/Linux

And here is one of the many changes that can be made, where they use it in init.d:
https://www.domoticz.com/wiki/Setup_fail2ban
https://www.domoticz.com/wiki/Plugins/BatteryLevel.html

As i said it is a bit hard for me to explain, i just like to see the logic of it so i can understand what to do when making changes and using systemd.

Does it just work like this? Should the program.sh be edited so the script point to somewhere else? Why is the script pointed to init.d as there is nothing there it still works.

Here is my computer and linux:
Code:
Architecture: i686
CPU op-mode(s): 32-bit
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0,1
Thread(s) per core: 2
Core(s) per socket: 1
Socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 28
Model name: Intel(R) Atom(TM) CPU N270 @ 1.60GHz
Stepping: 2
CPU MHz: 1187.069
CPU max MHz: 1600,0000
CPU min MHz: 800,0000
BogoMIPS: 3192.14
L1d cache: 24K
L1i cache: 32K
L2 cache: 512K

on the ssd it runs:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.10
DISTRIB_CODENAME=cosmic
DISTRIB_DESCRIPTION="Ubuntu 18.10"
NAME="Ubuntu"
VERSION="18.10 (Cosmic Cuttlefish)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.10"
VERSION_ID="18.10"
Thanks for reading.
 
Old 01-16-2020, 04:54 AM   #2
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,597
Blog Entries: 19

Rep: Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455
init.d is just a directory where things get put. The opposite of systemd is sysvinit, which depends on the hierarchy of init directories. systemd doesn't depend on these but that doesn't mean you can't use them.

btw it's probably a bad idea to post questions about systemd in this forum because they tend to degenerate into flame wars.
 
2 members found this post helpful.
Old 01-16-2020, 05:43 AM   #3
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,359

Rep: Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591
Your signature says Linux Mint, which uses systemd. Some distros don't use systemd but sysvinit or something else. I suspect the program.sh was written to be able to run on either system, but apparently has different issues depending on the system it is being used on. I can't say for sure but I think systemd has some backward compatabilty with sysvinit.

Last edited by colorpurple21859; 01-16-2020 at 05:48 AM.
 
Old 01-16-2020, 05:54 AM   #4
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,597
Blog Entries: 19

Rep: Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455
Quote:
Originally Posted by colorpurple21859 View Post
I can't say for sure but I think systemd has some backward compatabilty with sysvinit.
There's considerable backward compatibility. systemd couldn't have got such a hold otherwise. One of the components of systemd can take existing init/rc files and run them as jobs.
 
2 members found this post helpful.
Old 01-16-2020, 04:25 PM   #5
Jinux75
Member
 
Registered: Jul 2017
Location: The Netherlands
Distribution: Linux Mint, Ubuntu 20.04
Posts: 97

Original Poster
Rep: Reputation: Disabled
Ok but does it not matter that the program.sh points to a scriptname in init.d? This is done for compatability then? Is there any good place to ask questions about systemd or init.d?

I just try to understand. I still have very much trouble understanding permissions groups and users too. I know the permissions, i can look them up. But sometimes things do not work because of wrong permissions and then i do not get why. But for now i like to sort this out.

It is not mint im having this problem it is ubuntu lite.

Last edited by Jinux75; 01-16-2020 at 04:34 PM.
 
Old 01-16-2020, 05:08 PM   #6
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
I'd say take the init script and convert it to systemd if possible. I'm still trying to hash out what that script does but here is my idea. This eliminates the init.d altogether as far as i'm concerned. would need to see it to be sure.

Code:
[Unit]
Description = no clue
After = network.target

[Service]
User = youruser
Group = yourgroup
WorkingDirectory = /home/"$USER"/program
Type = forking
ExecStart = /home/"$USER"/program/program -daemon -log /tmp/program.txt

[Install]
WantedBy = multi-user.target
I'm not sure if you even need the init.d file with this. But I am far from experienced. This is just stuff I picked up today. Much simpler than init scripts imho.

Don't be afraid of systemd. Yes there is tons of hate for it. I don't understand why. Maybe in certain niche cases it isn't good. Or people just don't like change for the sake of change. Regardless, it is here to stay. Might as well learn to use it. Make the most of it instead of pining away for something that most likely won't come back.

Last edited by jmgibson1981; 01-16-2020 at 05:14 PM.
 
Old 01-16-2020, 05:26 PM   #7
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,359

Rep: Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591
Quote:
It is not mint im having this problem it is ubuntu lite.
So the script works correctly in linux mint, but not in ubuntu lite, is that correct? They both should be using systemd, so the issue is somewhere else, either a permission issue, or something isn't installed and/or a service isn't running in linux lite that is in linux mint.

Last edited by colorpurple21859; 01-16-2020 at 05:31 PM.
 
Old 01-16-2020, 05:31 PM   #8
freemedia2018
Member
 
Registered: Mar 2019
Distribution: various automated remasters
Posts: 216

Rep: Reputation: 208Reputation: 208Reputation: 208
Quote:
Originally Posted by hazel View Post
it's probably a bad idea to post questions about systemd in this forum because they tend to degenerate into flame wars.
As they probably should. Mmaybe not on this forum-- but certainly somewhere.

I'd say why they should, but not saying why lets it remain a neutral comment. Maybe we actually need "ugly" debates. But (obviously) not here, where they are sort-of forbidden. Some forums similar to this one used to have a subforum for such things. Today, every forum inches (a little) closer to the sterility of the Ubuntu forums. (I'm happy to say we aren't there yet.)

Last edited by freemedia2018; 01-16-2020 at 05:36 PM.
 
1 members found this post helpful.
Old 01-16-2020, 07:32 PM   #9
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,141

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
Quote:
As they probably should. Mmaybe not on this forum-- but certainly somewhere.
Why should they have flame wars? Why do people have to have a holy war about an init system? Aggressive zealotry shouldn't be acceptable anywhere I think. All the arguing about systemd or any other software vs software on any forum around has done nothing but make people angry. No one ever wins. Both sides need to get over it and themselves.

I just don't want to see forums with decent people degenerate into a powder keg like most of the middle east in this world. Ethnic cleansing and stuff for some of the most stupid reasons.

Last edited by jmgibson1981; 01-16-2020 at 07:43 PM.
 
Old 01-16-2020, 07:52 PM   #10
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,337
Blog Entries: 28

Rep: Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144Reputation: 6144
OP, if your system uses SystemD for its init system, use SystemD to init things.
 
Old 01-16-2020, 07:53 PM   #11
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,359

Rep: Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591Reputation: 1591
Quote:
im having this problem it is ubuntu lite.
What are you calling ubuntu lite, lubuntu, linux lite, something else?
 
Old 01-16-2020, 08:24 PM   #12
freemedia2018
Member
 
Registered: Mar 2019
Distribution: various automated remasters
Posts: 216

Rep: Reputation: 208Reputation: 208Reputation: 208
Quote:
Originally Posted by jmgibson1981 View Post
Why should they have flame wars? Why do people have to have a holy war about an init system?
Your questions are preventing you from getting meaningful answers.

1. It's not a holy war. It's corporate monopolies vs. free users. Next you'll say it's not a monopoly-- the term "de facto" applies here.

2. If you want to know who does consider it a holy war, I've got a Bill Gates quote where he calls it one. But even if Microsoft weren't involved, they learned their tactics from IBM who wrote the book (literally. There's a book. In fact there are a few now.)

Quote:
Aggressive zealotry shouldn't be acceptable anywhere I think.
Good, then you're against the cult-like abuse and military tactics the corporations are using against users.

Quote:
All the arguing about systemd or any other software vs software on any forum around has done nothing but make people angry.
That isn't true at all, but people do say that so the conversation remains one-sided. There are several communities manufacturing consensus by censoring critics, and this goes beyond systemd. They were happily doing it to hurt Stallman as well.

Quote:
No one ever wins. Both sides need to get over it and themselves.
So nobody should stand up to corporations, we should just bend over and take it? That's freedom in your book?

Quote:
I just don't want to see forums with decent people degenerate into a powder keg like most of the middle east in this world. Ethnic cleansing and stuff for some of the most stupid reasons.
This has nothing to do with the Middle East or ethnic cleansing-- though there are defense contracts involved, if it's peace you really want.

If you want to stop Forever Wars, dialogue is a must-- not Codes of Conduct and Cones of Silence. I assume you know what JFK said about "those who make peaceful revolution impossible"?

Arguments, unlike Forever Wars, are natural. I'm just saying there should be a place for them. If everybody runs from those places there won't be a lot of Web left, just pictures of cats and instructions on installing Ubuntu on your Indoor Amazon voice-recording home cameras.
 
2 members found this post helpful.
Old 01-16-2020, 08:29 PM   #13
andigena
Member
 
Registered: Sep 2019
Location: USA
Distribution: nixos, but i prefer plan 9
Posts: 141

Rep: Reputation: 66
Quote:
Originally Posted by jmgibson1981 View Post
Don't be afraid of systemd. Yes there is tons of hate for it. I don't understand why. Maybe in certain niche cases it isn't good. Or people just don't like change for the sake of change. Regardless, it is here to stay. Might as well learn to use it. Make the most of it instead of pining away for something that most likely won't come back.
Just accepting poor systems because they're going to be implemented anyway is contrary to the spirit of GNU/Linux and free software more generally. This attitude is how Microsoft can get away with having bloated, terribly-designed products and updates that break Windows. (Blind reactionaryism is no better, of course. The goal should be to improve systemd or design a better init system, not revert to ancient SysV init.)
I don't mean to get in an argument about systemd, but I feel that it's important to say - this is a thought process that should be avoided at all costs.
 
1 members found this post helpful.
Old 01-16-2020, 08:54 PM   #14
freemedia2018
Member
 
Registered: Mar 2019
Distribution: various automated remasters
Posts: 216

Rep: Reputation: 208Reputation: 208Reputation: 208
Quote:
Originally Posted by jmgibson1981 View Post
Regardless, it is here to stay. Might as well learn to use it. Make the most of it instead of pining away for something that most likely won't come back.
Practically nobody cares about sysvinit, they aren't pining for anything except control of their computers.

If the means which led to their predicament were honest, instead of dishonestly manufactured, there would be less cause for protest. But then there would be less protest, and less of a problem-- fatalism goes against the spirit of freedom. Nobody who finds this intolerable is simply going to accept it. "Just shut up and use it" isn't much of a pitch to people who have choices-- and if they don't have choices, they'll spend years working to ensure they get choices. That's why people are angry. It's because they were cheated, lied to, and after years of fighting for freedom, told "shut up and like it-- it's good for you." I can't understand one single person who is OK with that kind of sales pitch.

Last edited by freemedia2018; 01-16-2020 at 09:07 PM.
 
1 members found this post helpful.
Old 01-16-2020, 09:47 PM   #15
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,883
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Seems the topic cannot be discussed with civility after all.

Thread closed.

Please review the LQ Rules, and note:
Quote:
Flame Wars will not be tolerated
@Jinux75,

Please note that you've done nothing wrong here, and I regret your actual questions cannot be answered further in this thread.
 
1 members found this post helpful.
  


Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
init.d script to systemd with systemd-sysv-generator tankzeu Linux - Newbie 1 09-17-2018 04:41 AM
LXer: The Story Behind ‘init’ and ‘systemd’: Why ‘init’ Needed to be Replaced with ‘systemd’ in Linu LXer Syndicated Linux News 1 04-07-2017 11:33 PM
LXer: Is systemd as bad as boycott systemd is trying to make it? LXer Syndicated Linux News 0 09-03-2014 05:50 PM
Boot Delay 30min: systemd-analyze blame systemd-tmpfiles-setup.service BGHolmes Fedora 0 07-27-2011 09:02 AM
What is the exact diff between init 1,init S and init s challavijay Linux - Newbie 1 08-05-2010 06:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration