The officially official Devuan Forum!

You are not logged in.

#1 2018-08-30 22:53:03

inukaze
Member
Registered: 2018-01-28
Posts: 84  

How i must write "openrc-run" script for launch boot service?

Hi there. some days ago, i post this thread -> https://dev1galaxy.org/viewtopic.php?id=2306
and well yesterday i upgrade the software on my Devuan Jessie.

Right now, the Service don't start at boot. the first was the "/sbin/runscript" don't exist anymore
the second is i modify the first line on the script, there are the command to generate the script :

echo '#!/sbin/openrc-run

description="Start/Stop the no-ip daemon"

depend()
{
        after *
        keyword notimeout
}

start()
{
        ebegin "Starting NoIP"

        /usr/bin/noip2

        eend $? "Failed to start NoIP"
}

stop()
{
        ebegin "Stopping NoIP"

        killall -TERM /usr/bin/noip2

        eend $? $"Failed to stop NoIP"
}' | sudo tee /etc/init.d/noip2 ; sudo chmod a+rx /etc/init.d/noip2

and right now in the /var/log/boot :

Thu Aug 30 18:31:38 2018:  ^[[1m^[[31m*^[[m noip2: not enough arguments^[[K
Thu Aug 30 18:31:38 2018:  ^[[1m^[[31m*^[[m ERROR: noip2 failed to start^[[K

when i reach my desktop environment and i try to run it directly from cli :

sudo service noip2 start
 * WARNING: noip2 has already been started

ps -A | grep noip

the "noip2" is not running. with the old version of runscript works perfectly. but right now i don't have idea how to make it work.

Last edited by inukaze (2018-08-31 22:44:24)

Offline

#2 2018-08-31 00:13:27

dxrobertson
Member
Registered: 2017-05-04
Posts: 232  

Re: How i must write "openrc-run" script for launch boot service?

I am not sure exactly what your problem is, but here is how OpenRC init process are run.

OpenRC init scripts need to be in /etc/init.d/, this is what "runs".

OpenRC runlevels are defined in /etc/runlevels/, you need a symlink here under the desired runlevel pointing to the script in /etc/init.d/ so the script gets run.

Once you have the script in /etc/init.d/, you enter "rc-update add <service> <runlevel>" where <service> is your script name in /etc/init.d/ and <runlevel> is your desired runlevel under /etc/runlevel.

From your post, it seems you need some sort of "noip" startup script in /etc/init.d, and then perform the rc-update add noip default (for default runlevel, or whatever runlevel).

Last edited by dxrobertson (2018-08-31 00:51:00)

Offline

#3 2018-08-31 01:57:22

inukaze
Member
Registered: 2018-01-28
Posts: 84  

Re: How i must write "openrc-run" script for launch boot service?

The problem is the noip2 don't start at boot anymore, after the last upgrade, when the runscript dont exist anymore in /sbin/runinit, instead follow gentoo wiki, i should use openrc-run for the shebang in the first line.

Offline

#4 2018-08-31 06:53:55

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,251  

Re: How i must write "openrc-run" script for launch boot service?

echo '#!/sbin/openrc-run

is an unusual first line for a script. Or was it a mistake when copying to here? Otherwise you should remove the first 6 characters, so that the very first character is the "#" character. Or equally, make it so to say:

#!/sbin/openrc-run

Offline

#5 2018-08-31 09:37:18

inukaze
Member
Registered: 2018-01-28
Posts: 84  

Re: How i must write "openrc-run" script for launch boot service?

That are a command to generate the script from cli. its not directly the script. the first line inside the script is :

#!/sbin/openrc-run

if you read the lines, you see at the end, the command :

sudo tee /etc/init.d/noip2 ; sudo chmod a+rx /etc/init.d/noip2

For generate the file and make executable for all users.

Offline

#6 2018-08-31 10:49:41

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,251  

Re: How i must write "openrc-run" script for launch boot service?

ah. of course.

If you've done the set up as @dxrobertson mentioned, maybe the problem is that the noip2 daemon needs some configuration that is missing? E.g., should it have "-i IPaddress" on the command line? Though, I must admit I know less about noip2 than is written at https://github.com/jamesstout/no-ip/blo … ADME.FIRST.

Offline

#7 2018-08-31 23:52:02

dxrobertson
Member
Registered: 2017-05-04
Posts: 232  

Re: How i must write "openrc-run" script for launch boot service?

Confused.

Your original post states "How i must write "openrc-run" script for launch boot service?".  Assuming OpenRC is the init process.

But you used the command "sudo service noip2 start", which is a sysvinit command.

OpenRC or sysvinit?

Please post contents of  /etc/init.d/rcS.  OpenRC should be:

#!/bin/sh
# Wrapper of OpenRC called from inittab

set -e
exec /sbin/openrc sysinit

It might help to also post /etc/inittab, should have:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

Offline

#8 2018-09-01 09:57:54

inukaze
Member
Registered: 2018-01-28
Posts: 84  

Re: How i must write "openrc-run" script for launch boot service?

$ cat /etc/init.d/rcS
#!/bin/sh
# Wrapper of OpenRC called from inittab

set -e
exec /sbin/openrc sysinit
$ cat /etc/inittab
# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

Offline

#9 2018-09-01 12:16:09

dxrobertson
Member
Registered: 2017-05-04
Posts: 232  

Re: How i must write "openrc-run" script for launch boot service?

OK, you are using OpenRC.

I am guessing that noip2 is an init script, and that it is supposed to run the actual program noip?  Assuming so...

There should be a noip2 script in /etc/init.d, does it exist?  If so, is it formatted correctly, similar to the other scripts in /etc/init.d?  You can post the contents if you like.

OpenRC commands you can use, you can post the output here if you like:

display all init scripts and what runlevel they run under:

rc-update show

noip2 should display

display what is setup to run by runlevel

rc-status -a

noip2 should display as started

manually run noip2

rc-service noip2 start

set noip2 to run automatically under runlevel default

rc-update add noip2 default

Last edited by dxrobertson (2018-09-01 12:31:48)

Offline

#10 2018-09-01 23:02:15

inukaze
Member
Registered: 2018-01-28
Posts: 84  

Re: How i must write "openrc-run" script for launch boot service?

$ sudo rc-update show | grep no
            mono-xsp4 |      default                              
                noip2 |      default                              
            rmnologin |      default
$ sudo rc-status -a | grep no
 mono-xsp4                                                         [  started  ]
 rmnologin                                                         [  started  ]
$ sudo rc-service noip2 start

Not show nothing

$ sudo rc-update add noip2 default
 * rc-update: noip2 already installed in runlevel `default'; skipping
$ sudo rc-service noip2 stop
 * Caching service dependencies ...
 * Found a solvable dependency loop: cryptdisks a> umountfs u> hwclock.sh a> checkroot n> cryptdisks-early a> lvm2 u> cryptdisks.
 * Found a solvable dependency loop: cryptdisks a> umountfs u> hwclock.sh a> checkroot n> cryptdisks.
 * Found a solvable dependency loop: cryptdisks a> umountfs u> hwclock.sh a> checkroot n> cryptdisks-early n> cryptdisks.
 * Solving the loop by breaking umountfs u> hwclock.sh.
 * Solving the loop by breaking lvm2 u> cryptdisks.
 * Found a solvable dependency loop: rc.local u> rmnologin u> single u> stop-bootlogd u> rc.local.
 * Found a solvable dependency loop: rc.local u> rmnologin u> single u> stop-bootlogd u> stop-bootlogd-single u> rc.local.
 * Found a solvable dependency loop: rc.local u> rmnologin u> single u> stop-bootlogd-single u> rc.local.
 * Found a solvable dependency loop: rc.local u> rmnologin u> single u> rc.local.
 * Found a solvable dependency loop: rc.local u> rmnologin u> stop-bootlogd u> rc.local.
 * Found a solvable dependency loop: rc.local u> rmnologin u> stop-bootlogd u> stop-bootlogd-single u> rc.local.
 * Found a solvable dependency loop: rc.local u> rmnologin u> stop-bootlogd-single u> rc.local.
 * Found a solvable dependency loop: rc.local u> rmnologin u> rc.local.
 * Found a solvable dependency loop: rc.local u> single u> stop-bootlogd u> rc.local.
 * Found a solvable dependency loop: rc.local u> single u> stop-bootlogd u> stop-bootlogd-single u> rc.local.
 * Found a solvable dependency loop: rc.local u> single u> stop-bootlogd-single u> rc.local.
 * Found a solvable dependency loop: rc.local u> single u> rc.local.
 * Found a solvable dependency loop: rc.local u> stop-bootlogd u> rc.local.
 * Found a solvable dependency loop: rc.local u> stop-bootlogd u> stop-bootlogd-single u> rc.local.
 * Found a solvable dependency loop: rc.local u> stop-bootlogd-single u> rc.local.
 * Solving the loop by breaking rc.local u> rmnologin.
 * Solving the loop by breaking single u> stop-bootlogd.
 * Solving the loop by breaking rmnologin u> single.
 * Solving the loop by breaking stop-bootlogd u> rc.local.
 * Solving the loop by breaking stop-bootlogd-single u> rc.local.
 * Found a solvable dependency loop: rc.local u> stop-bootlogd-single u> rmnologin u> rc.local.
 * Found a solvable dependency loop: rc.local u> stop-bootlogd-single u> single u> rc.local.
 * Found a solvable dependency loop: rc.local u> stop-bootlogd u> rmnologin u> rc.local.
 * Found a solvable dependency loop: rc.local u> stop-bootlogd u> stop-bootlogd-single u> rmnologin u> rc.local.
 * Found a solvable dependency loop: rc.local u> single u> rc.local.
 * Found a solvable dependency loop: rc.local u> stop-bootlogd u> single u> rc.local.
 * Found a solvable dependency loop: rc.local u> stop-bootlogd u> stop-bootlogd-single u> single u> rc.local.
 * Solving the loop by breaking rc.local u> stop-bootlogd-single.
 * Solving the loop by breaking stop-bootlogd u> rmnologin.
 * Solving the loop by breaking single u> rc.local.
 * Solving the loop by breaking stop-bootlogd-single u> rmnologin.
 * Solving the loop by breaking rmnologin u> rc.local.
 * Found a solvable dependency loop: rmnologin u> stop-bootlogd u> single u> rmnologin.
 * Found a solvable dependency loop: rmnologin u> stop-bootlogd u> stop-bootlogd-single u> single u> rmnologin.
 * Found a solvable dependency loop: rmnologin u> stop-bootlogd-single u> single u> rmnologin.
 * Solving the loop by breaking single u> rmnologin.
 * Solving the loop by breaking rmnologin u> stop-bootlogd.
 * Solving the loop by breaking stop-bootlogd u> single.
 * Found a solvable dependency loop: single u> stop-bootlogd-single u> single.
 * Solving the loop by breaking stop-bootlogd-single u> single.
 * Found a solvable dependency loop: stop-bootlogd u> stop-bootlogd-single u> stop-bootlogd.
 * Solving the loop by breaking stop-bootlogd-single u> stop-bootlogd.                          [ ok ]
$ sudo rc-service noip2 start ; ps -A | grep noip
 5100 ?        00:00:00 noip2

Well let me restart to test the changes. because with manual start using rc-service, now run big_smile
The Process don't run automatically at boot. i don't understand why.
but right now, i not got errors with noip2 during boot process.

Last edited by inukaze (2018-09-02 08:25:18)

Offline

#11 2018-09-02 11:50:18

dxrobertson
Member
Registered: 2017-05-04
Posts: 232  

Re: How i must write "openrc-run" script for launch boot service?

OpenRC logging may help with init process problems.  You can enable logging in /etc/rc.conf.  The log file will be /var/log/rc.log".

To enable OpenRC logging, edit /etc/rc.conf:

rc_logger="YES" 
rc_verbose=yes

Offline

#12 2018-09-02 12:05:32

inukaze
Member
Registered: 2018-01-28
Posts: 84  

Re: How i must write "openrc-run" script for launch boot service?

dxrobertson wrote:

OpenRC logging may help with init process problems.  You can enable logging in /etc/rc.conf.  The log file will be /var/log/rc.log".

To enable OpenRC logging, edit /etc/rc.conf:

rc_logger="YES" 
rc_verbose=yes
 cat /var/log/rc.log 
rc sysinit logging started at Sun Sep  2 08:15:57 2018

   OpenRC 0.13.1 is starting up Linux 3.16.0-6-amd64 (x86_64)

 * /proc is already mounted
 * /run/openrc: creating directory
 * /run/lock: correcting mode
 * /run/lock: correcting owner
[....] Starting the hotplug events dispatcher: udevd[ ok .
[....] Synthesizing the initial hotplug events...[ ok done.
[....] Waiting for /dev to be fully populated...[ ok done.
[....] Setting parameters of disc: (none)[ ok .
[....] Setting preliminary keymap...[ ok done.
[....] Activating swap...[ ok done.
[....] btrfs root detected, so skipping root file system check. ...[warn (warning).
[....] Setting up LVM Volume Groups...  No volume groups found
[ ok done.
[....] Activating lvm and md swap...[ ok done.
[....] Checking file systems...fsck from util-linux 2.25.2
Compartido: clean, 579517/39321600 files, 145635887/157286400 blocks
Slack64: clean, 427214/2940928 files, 3838220/11748352 blocks
Slack32: clean, 329559/2940928 files, 1923647/11747584 blocks
1SlackIni: clean, 964/65536 files, 113016/262144 blocks
2SlackIni: clean, 942/65808 files, 22250/263168 blocks
[ ok done.
[....] Cleaning up temporary files... /tmp[ ok .
[....] Mounting local filesystems...[ ok done.
[....] Activating swapfile swap...[ ok done.
[....] Cleaning up temporary files...[ ok .
[....] Setting kernel variables ...[ ok done.
[....] Setting up resolvconf...[ ok done.
[....] Configuring network interfaces...[ ok done.
[....] Cleaning up temporary files...[ ok .
[....] Setting up ALSA...[ ok done.
[info] Setting console screen modes.
etting up console font and keymap...[ ok done.
[info] Loading kernel module lp.
[info] Loading kernel module ppdev.
[info] Loading kernel module parport_pc.
[info] Loading kernel module vboxdrv.
[info] Loading kernel module fuse.
[info] Loading kernel module vhba.
[....] Setting sensors limits[ ok .
[....] Skip starting firewall: ufw (not enabled)...[ ok done.
[....] Setting up X socket directories... /tmp/.X11-unix /tmp/.ICE-unix[ ok .

rc sysinit logging stopped at Sun Sep  2 08:15:57 2018

rc default logging started at Sun Sep  2 08:15:57 2018

[....] Starting enhanced syslogd: rsyslogd[ ok .
[....] Starting ACPI services...[ ok .
[....] Starting anac(h)ronistic cron: anacron[ ok .
[....] Starting web server: apache2[ ok .
[....] Starting deferred execution scheduler: atd[ ok .
[....] Starting system message bus: dbus[ ok .
[....] Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon[ ok .
[....] Enabling additional executable binary formats: binfmt-support[ ok .
[....] Starting the Winbind daemon: winbind[ ok .
[....] Starting periodic command scheduler: cron[ ok .
[....] Starting Common Unix Printing System: cupsd[ ok .
[....] Starting CUPS Bonjour daemon: cups-browsed[ ok .
[....] Starting DirMngr: dirmngr[ ok .
[....] Starting mouse interface server: gpm[ ok .
[....] Starting SMP IRQ Balancer: irqbalance[ ok .
[....] Starting libvirt management daemon: libvirtd[ ok .
[....] Updating the system logo...[ ok done.
[....] Starting UPnP devices daemon: MiniSSDPd[ ok .
[....] Starting XSP 4.0 WebServer: mono-xsp4[ ok .
[....] Starting Music Player Daemon: mpd[ ok .
[....] Starting network connection manager: NetworkManager[ ok .
[....] Starting NetBIOS name server: nmbd[ ok .
Iniciando noip2.
[....] Starting NTP server: ntpd[ ok .
[....] Starting Postfix Mail Transport Agent: postfix[ ok .
[....] saned disabled; edit /etc/default/saned[ ok .
[....] Starting slim: slim[ ok .
[....] Starting SMB/CIFS daemon: smbd[ ok .
[....] Starting SNMP services::  snmpd[....] Starting OpenBSD Secure Shell server: sshd[ ok .
[....] Starting SSHGuard Server: sshguard enabling firewall[ ok .
[....] Starting TiMidity++ ALSA midi emulation...[ ok .
[....] Starting uuid generator: uuidd[ ok .
[....] Starting FTP server: vsftpd[ ok .
[....] Starting internet superserver: xinetd[ ok .

rc default logging stopped at Sun Sep  2 08:16:42 2018

This morning i purge some packages of sysvinit installed on my distro, anothers i dont use like upstart, plymouth, mdadm, cryptset or something similar.

Well i copy /etc/init.d/mpd to /etc/init.d/noip2 and i start the modifications. but one part i can't understand fine :

ok the main modification was things like :

MPDCONF=/etc/mpd.conf by NOIP2CONF=/usr/etc/no-ip2.conf
DAEMON=/usr/bin/noip2

and well the unique thing i don't understand what do is the line :
PIDFILE=$(sed -n 's/^[[:space:]]*pid_file[[:space:]]*"\?\([^"]*\)\"\?/\1/p' $MPDCONF)

because with mpd :

echo $PIDFILE
/run/mpd/pid

if i try with my modification
PIDFILE=$(sed -n 's/^[[:space:]]*pid_file[[:space:]]*"\?\([^"]*\)\"\?/\1/p' $NOIP2CONF)

echo $PIDFILE
                  

nothing happened.

Well i try to make accord to the system. but i change at the final i just let the file with the follow content :

#!/bin/sh

### BEGIN INIT INFO
# Provides:          noip2
# Required-Start:    $local_fs
# Required-Stop:     $local_fs
# Should-Start:      autofs $network
# Should-Stop:       autofs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: NoIP
# Description:       Inicia el Servicio noip2
#                    Para conectarse a traves de internet usando un nombre y no la IP{v4,6}
### END INIT INFO

. /lib/lsb/init-functions

PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=noip2
DESC="noip2"
DAEMON=/usr/bin/noip2

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

#PIDFILE=$(sed -n 's/^[[:space:]]*pid_file[[:space:]]*"\?\([^"]*\)\"\?/\1/p' $NOIP2CONF)
PIDFILE=$(mkdir -p /run/noip2 ; echo "$RANDOM" >> pid)
noip2_start () {
	echo "Iniciando noip2."
        "$DAEMON" 2>/dev/null
}

noip2_stop () {
	echo -n "Finalizando noip2 : "
	kill -15 $(pgrep noip2)
}

# note to self: don't call the non-standard args for this in
# {post,pre}{inst,rm} scripts since users are not forced to upgrade
# /etc/init.d/noip2 when noip2 is updated
case "$1" in
    start)
        noip2_start
        ;;
    stop)
        noip2_stop
        ;;
    restart)
        noip2_stop
        noip2_start
        ;;
    *)
        echo "Usage: $0 {start|stop|restart}"
        exit 2
        ;;
esac

now in the /var/log/boot

Sun Sep  2 07:53:13 2018: [....] Starting Music Player Daemon: mpd^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Sun Sep  2 07:53:23 2018: [....] Starting network connection manager: NetworkManager^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Sun Sep  2 07:53:24 2018: [....] Starting NetBIOS name server: nmbd^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Sun Sep  2 07:53:24 2018: Iniciando noip2.
Sun Sep  2 07:53:25 2018: [....] Starting NTP server: ntpd^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.
Sun Sep  2 07:53:26 2018: [....] Starting Postfix Mail Transport Agent: postfix^[[?25l^[[?1c^[7^[[1G[^[[32m ok ^[[39;49m^[8^[[?25h^[[?0c.

during boot the another process show
[ ok ] <service>

i try to make it equal with my noip2 script, but i can't understand the PIDFILE and what do the sed in that variable.

Last edited by inukaze (2018-09-02 12:20:12)

Offline

#13 2018-09-02 12:27:04

dxrobertson
Member
Registered: 2017-05-04
Posts: 232  

Re: How i must write "openrc-run" script for launch boot service?

I cant help much with the init script writing.  Hopefully someone else can help. 

I think the mpd script is using the sed command to generate a pid file name.  I dont think you need to do that.  Some scripts just use a hard-coded pid file name.

If you look at some of the other init scripts such as rsyslog or cups; they use start-stop-daemon to run and the pid file is used as a parm. 

Sorry I cant be of much help here.

Offline

Board footer