Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
2
votes
1
answers
4665
views
How can I install Policykit with System V?
I created a minimal install on my Raspbian Raspberry Pi running Debian Jessie. Among other things, I removed `libx11-.*` and dependencies, which included removal of `policykit-1`. I'm trying to reinstall `policykit-1`, but hit the following errors. $ sudo apt-get install policykit-1 ... The followin...
I created a minimal install on my Raspbian Raspberry Pi running Debian Jessie. Among other things, I removed
libx11-.*
and dependencies, which included removal of policykit-1
. I'm trying to reinstall policykit-1
, but hit the following errors.
$ sudo apt-get install policykit-1
...
The following packages will be REMOVED:
sysvinit-core
...
dpkg: sysvinit-core: dependency problems, but removing anyway as you requested:
sysvinit depends on sysvinit-core | upstart | systemd-sysv; however:
Package sysvinit-core is to be removed.
Package upstart is not installed.
Package systemd-sysv is not installed.
After this, booting now hangs, and I have to restore the SD card to an image before this install command. (N.B. booting worked fine before the creation of the minimal install, and after the removal of libx11-.*
and dependencies.) How can I reinstall policykit-1
?
-------
## Edit
This worked for a little while, but no longer.
There is a long thread here discussing how policykit-1
can break your system in Debian. I didn't read it all, but this (closed) bug report suggests that systemd-shim
might be helpful.
Running the following command allowed me to reboot the computer, although I'm unsure as to how functional policykit-1
is.
sudo apt-get install systemd-shim policykit-1
However, a recent update to Debian Jessie prevents this from working. policykit-1
was uninstalled after sudo apt-get dist-upgrade
, and running this command still asks you to uninstall sysvinit-core
.
Sparhawk
(20499 rep)
Jul 15, 2014, 10:38 AM
• Last activity: Jul 20, 2025, 07:03 PM
2
votes
2
answers
19237
views
Default-Start contains no runlevels
I am trying to make my custom made daemon run at startup and when I call `update-rc.d ydcd enable` I get the error update-rc.d: using dependency based boot sequencing update-rc.d: error: MyDaemon Default-Start contains no runlevels, aborting. I'm running Debian wheezy, init is SysVinit. Googling it...
I am trying to make my custom made daemon run at startup
and when I call
update-rc.d ydcd enable
I get the error
update-rc.d: using dependency based boot sequencing
update-rc.d: error: MyDaemon Default-Start contains no runlevels, aborting.
I'm running Debian wheezy, init is SysVinit.
Googling it does not give me any valuable info, so I come here as a last resort.
What's going on here?
What do I need to change in my init.d script in order to make this work?
Edit:
Here's the script:
#!/bin/bash
#
#ydcd.daemon
#
# chkconfig: 2345 85 15
# description: MyServiceName
# processname: MyServiceName
# source function library
. /lib/lsb/init-functions
RETVAL=0
NAME=ydcd.daemon
# YOU CAN SET ANY PATH BUT IS RECOMENDED TO USE THE DISTRO'S STANDARD ONE.
DAEMON=/home/debian/yd_cd/$NAME
prog=$(basename $DAEMON)
lockfile=/var/lock/$NAM
SVC_FILE=$DAEMON
start() {
if [ -f $SVC_FILE ]; then
#reset
echo -n "Starting "$SVC_FILE": "
RETVALS=$(start-stop-daemon -S -b -x $SVC_FILE -- -r)
Count=${#RETVALS[@]}
RETVAL="[FAIL]"
if [ $Count -eq 0 ]; then
RETVAL="[OK]"
elif [ $Count -eq 1 ]; then
if [ ${#RETVALS} -eq 0 ]; then
RETVAL="[OK]"
else
iStart=${#SVC_FILE}
iLength=${#RETVALS}
Response=${RETVALS:(iStart+1):7}
RETVAL=$Response
if [ "$Response" == "already" ]; then
RETVAL="[OK]"
fi
fi
fi
echo $RETVAL
return 0
else
echo $SVC_ALIAS" not installed" $SVC_DIR
exit 2;
fi
}
stop() {
echo -n "Shutting down "$SVC_FILE":"
RETVALS=$(start-stop-daemon -K -x $SVC_FILE -- s)
#additional PROCKILLS=$(killall -w -q -e $SVC_PROCESS_NAME $SVC_FILENAME)
Count=${#RETVALS[@]}
Index=0
RETVAL="[FAIL]"
if [ $Count -eq 1 ]; then
if [ ${#RETVALS} -eq 0 ]; then
RETVAL="[OK]"
else
Response=${RETVALS:0:2}
RETVAL=$Response
if [ "$Response" == "No" ]; then
RETVAL="[OK]"
fi
fi
else
RETVAL="[OK]"
fi
echo $RETVAL
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $SVC_SERVICE_SCRIPT
;;
restart)
stop
start
;;
*)
echo $SVC_ALIAS" [Invalid Startup Parameters]"
echo "Usage: {start|stop|status|restart}"
exit 1
;;
esac
exit $?
vaid
(129 rep)
Jan 24, 2016, 02:17 AM
• Last activity: Jun 26, 2025, 12:04 AM
49
votes
3
answers
120676
views
The rc0.d,rc1.d,... directories in /etc
I'm running Ubuntu where I have the directories `/etc/rc0.d`, `/etc/rc1.d`, `/etc/rc2.d`, ..., `/etc/rc6.d`. Example files from my machine: directory example symlinks in the dir ------------------------------------------ /etc/rc1.d: K76dovecot, K77ntp /etc/rc2.d: S23ntp, S24dovecot /etc/rc3.d: S23nt...
I'm running Ubuntu where I have the directories
/etc/rc0.d
, /etc/rc1.d
, /etc/rc2.d
, ..., /etc/rc6.d
.
Example files from my machine:
directory example symlinks in the dir
------------------------------------------
/etc/rc1.d: K76dovecot, K77ntp
/etc/rc2.d: S23ntp, S24dovecot
/etc/rc3.d: S23ntp, S24dovecot
/etc/rc4.d: S23ntp, S24dovecot
/etc/rc5.d: S23ntp, S24dovecot
Questions:
1. What's the purpose of the multiple "rc" directories?
2. Why did Ubuntu install duplicates of dovecot
and ntp
into all the directories except rc0.d
and rc6.d
?
3. If they are specified multiple times like above, are they actually executed multiple times?
4. Can you tell from the above in what order dovecot
and ntp
will execute at startup?
5. What is the proper way to tell Ubuntu to always execute ntp
before dovecot
at startup?
roger.james
(605 rep)
Jul 20, 2013, 01:06 PM
• Last activity: Jun 21, 2025, 07:54 AM
2
votes
2
answers
2729
views
openfire chat server Daemon not getting started while server starts up every time
We are using a Chat server It is installed with openfire, for local office use. Every morning while server getting ON openfire service is not getting started, I have added it in run levels too, Using command , `chkconfig` , Operating system we are using is CentOS 6.5 final. chkconfig --level 0123456...
We are using a Chat server It is installed with openfire, for local office use. Every morning while server getting ON openfire service is not getting started, I have added it in run levels too, Using command ,
chkconfig
, Operating system we are using is CentOS 6.5 final.
chkconfig --level 0123456 openfire on
The output of chkconfig was below
openfire 0:on 1:on 2:on 3:on 4:on 5:on 6:on
And still it is not getting started when ever the Server was up and running, Every time I have to start the service manually using
/etc/init.d/openfire start
So this step has not worked for me, so I edited the rc.local file and added the service too. It too is not working for me
vim /etc/rc.local
Entered as below in the rc.local
sh /etc/init.d/openfire start
If any one faces the same issue, please let me know how can I get the fix.
Babin Lonston
(3451 rep)
Apr 10, 2014, 04:23 AM
• Last activity: Jun 10, 2025, 06:03 PM
3
votes
1
answers
2530
views
Reason to use startproc, killproc and checkproc in Sys-V type init scripts in OpenSUSE
In OpenSUSE 11.4 `sysvinit-tools` package contains `startproc`, `killproc` and `checkproc` binaries which according to `/etc/init.d/skeleton` file and OpenSUSE documentation should be used in Sys-V type of init scripts. What is the idea of those binaries? Couldn't one achieve the same functionality...
In OpenSUSE 11.4
sysvinit-tools
package contains startproc
, killproc
and checkproc
binaries which according to /etc/init.d/skeleton
file and OpenSUSE documentation should be used in Sys-V type of init scripts. What is the idea of those binaries? Couldn't one achieve the same functionality of startproc
, killproc
and checkproc
with nice
, sudo
, sleep
and other similar tools?
Martin
(8156 rep)
Dec 8, 2015, 01:12 PM
• Last activity: Jun 6, 2025, 07:03 AM
0
votes
0
answers
39
views
Docker attach on a container running /sbin/init
I run a Cisco XRd docker container on my Linux Ubuntu host. I run the image using `docker run -it -d` command. The image's entrypoint is `/usr/sbin/init`, indeed: root@eve-ng-6:/opt/unetlab/html# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2ed1b2e66197 ios-xr/xrd-control-plane:la...
I run a Cisco XRd docker container on my Linux Ubuntu host. I run the image using
docker run -it -d
command. The image's entrypoint is /usr/sbin/init
, indeed:
root@eve-ng-6:/opt/unetlab/html# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2ed1b2e66197 ios-xr/xrd-control-plane:latest "/usr/sbin/init" 20 hours ago Up 3 hours 75bc86e8-108a-4300-863a-2141b5718b55-0-2
root@eve-ng-6:/opt/unetlab/html#
Then by using docker attach
, I can attach to the running docker container.
Af far as I understand, see Comparing Docker Exec and Docker Attach , docker attach
does not start any new process within the container but simply attaches the current terminal to the stdin/stdout/stderr
of the container's primary process (i.e. to the process running the image's entrypoint). In my case it is /usr/sbin/init
from Cisco XRd.
My question: is the /usr/sbin/init
process that is actually "talking" with the user (me) by reading and writing to the attached pseudo-terminal ?
P.s. note that a pseudo-terminal is allocated by virtue of the -d
option in docker run
command.
CarloC
(385 rep)
May 30, 2025, 04:31 PM
• Last activity: May 30, 2025, 05:07 PM
4
votes
2
answers
1997
views
ssh connection hangs on server shutdown / restart
When I shut down or restart my server while logged in via SSH, the SSH connection hangs or freezes. The terminal becomes completely unresponsive, and it takes up to one minute for the SSH session to recognize that the connection has been lost. This issue occurs on the new Debian 12 (openssh-server 1...
When I shut down or restart my server while logged in via SSH, the SSH connection hangs or freezes. The terminal becomes completely unresponsive, and it takes up to one minute for the SSH session to recognize that the connection has been lost.
This issue occurs on the new Debian 12 (openssh-server 1:9.2p1-2) but does not happen on the older Debian 10.
On Debian 10, when I restart the server, the SSH connection cleanly logs out immediately, displaying the following message:
Connection to debian10 closed by remote host.
Connection to debian10 closed.
When I connect with verbose options to both servers, and then restart them, I see some differences:
ssh session ends cleanly:
$ ssh -vvv -E /tmp/a debian10
debug3: send packet: type 1
debug1: channel 0: free: client-session, nchannels 1
debug3: channel 0: status: The following connections are open:
#0 client-session (t4 r0 i0/0 o0/0 e[write]/0 fd 6/7/8 sock -1 cc -1)
debug3: fd 1 is not O_NONBLOCK
Transferred: sent 4668, received 7428 bytes, in 34.8 seconds
Bytes per second: sent 134.3, received 213.7
debug1: Exit status -1
ssh session freezes:
$ ssh -vvv -E /tmp/b debian12
debug3: send packet: type 80
debug3: receive packet: type 82
debug3: send packet: type 80
debug3: send packet: type 80
debug3: send packet: type 80
Timeout, server debian12 not responding.
I have found similar questions, but all the answers suggest something to do with systemd. I am not using systemd, I am using sysvinit on both servers.
So, to sum up:
The two servers behave differently using same ssh client, therefore I suspect something is different on the server side (presumably behavior of openssh-server)
UPDATE:
======
Here is my restart sequence (runlevel 6):
/etc/rc6.d/K01cron
/etc/rc6.d/K01ssh
/etc/rc6.d/K01urandom
/etc/rc6.d/K02sendsigs
/etc/rc6.d/K03rsyslog
/etc/rc6.d/K05networking
/etc/rc6.d/K06umountfs
/etc/rc6.d/K07umountroot
/etc/rc6.d/K08reboot
note that
ssh
daemon is terminated before networking
. But that should not have any effect anyway, because shutting down sshd
normally does not affect existing ssh connections.
UPDATE2:
=======
Here is the shutdown sequence, as I see it on the console:
[ ok Sending processes configured via /etc/ini[....] Stopping: cron
[ ok ] Stopping: sshd
[ ok ] Asking all remaining processes to terminate...done.
[ ok ] All processes ended within 1 seconds...done.
[ ok ] Stopping: rsyslogd
[ ok ] Deconfiguring network interfaces...done.
[ ok ] Will now unmount temporary filesystems: /tmp
[ ok ] Will now unmount local filesystems: /var
[ ok ] Mounting root filesystem read-only...done.
[info] Will now halt.
[79896.954129] reboot: Power down
Martin Vegter
(586 rep)
Jun 17, 2023, 05:23 PM
• Last activity: May 27, 2025, 05:08 AM
0
votes
1
answers
2462
views
RedHat init.d script will not start with service after stop
I have the service script below, which calls a shell script. We changed something in the script When I run the shell script directly, everything works fine. When I restart the servER, everything works fine. If I call `sudo service my-service stop` then `sudo service my-service start`, it will stop,...
I have the service script below, which calls a shell script. We changed something in the script When I run the shell script directly, everything works fine. When I restart the servER, everything works fine. If I call
sudo service my-service stop
then sudo service my-service start
, it will stop, but never start again. It says systemctl OK, but a process never kicks off, and no logs are ever written from the shell script. Even if I call sudo /etc/init.d/my-service
it won't start. Again, mind you, this will start fine automatically on restart of the server. Any thoughts on what could be the problem, or how to get better logging from this failed start?
#!/bin/bash
#
# my-service
#
# chkconfig: 345 84 15
# description: Start up the My Service process.
# config: /etc/sysconfig/my-service
# processname: java
# Source function library.
. /etc/init.d/functions
# Loading the configuration parameters.
if [ -f /etc/sysconfig/my-service ]; then
source /etc/sysconfig/my-service
fi
RETVAL=0
case "$1" in
start)
if [ -f /opt/my-service/latest/bin/my-service-start.sh ];
then
logger -s "Starting My Service"
/bin/su -p -s /bin/sh myserviceuser /opt/my-service/latest/bin/my-service-start.sh
RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/my-service
fi
;;
stop)
if [ -f /opt/my-service/latest/bin/my-service-stop.sh ];
then
logger -s "Stopping My Service"
/bin/su -p -s /bin/sh myserviceuser /opt/my-service/latest/bin/my-service-stop.sh
RETVAL=$?
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/my-service
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit $RETVAL
Spencer Kormos
(109 rep)
Nov 4, 2014, 08:00 PM
• Last activity: May 19, 2025, 08:07 AM
3
votes
2
answers
2063
views
Resuming Linux from hibernate on ThinkPad X220 fails with black screen or reboot
I have installed Debian 8 with sysvinit and Xfce on a ThinkPad X220. The video card is `Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)`/`Integrated Graphics Chipset: Intel(R) HD Graphics 3000`. Kernel versions available to me are 4.7 from backports and...
I have installed Debian 8 with sysvinit and Xfce on a ThinkPad X220. The video card is
Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
/Integrated Graphics Chipset: Intel(R) HD Graphics 3000
. Kernel versions available to me are 4.7 from backports and 3.16 (heavily patched by Canonical kernel team) from stable.
When I hibernate using pure kernel (echo disk > /sys/power/state
done by pm-hibernate run by xfce4-pm-helper) and XScreenSaver turns the screen off, on resume the screen is still turned off (not just the backlight: I checked with a flashlight), and nothing seems to turn it on again (I tried Ctrl+Alt+F* suggested at ThinkWiki and Alt+SysRq+V), but the remaining system seems to be working (at least, when I do an Alt+SysRq+E,I,S,U,B, I can find messages from a successful resume and syslogd being terminated by signal 15 in /var/log/syslog
).
I'm able to connect via ssh, but both chvt 1; chvt 7
and various combinations of export DISPLAY=:0; xrandr --output LVDS1 --off; xrandr --output LVDS1 --auto
do nothing. I disabled LVDS1 and tried to reenable it, I got: xrandr: Configure crtc 0 failed
and the following lines in dmesg
:
[ 390.432051] [drm:drm_framebuffer_remove [drm]] *ERROR* failed to reset crtc ffff9ae6caa2f000 when fb was deleted
[ 390.432066] [drm:drm_plane_force_disable [drm]] *ERROR* failed to disable plane with busy fb
Some people suggested ddccontrol
, but it doesn't detect DDC on my system. Is screen is on while hibernating, it stays working after resume.
If I install uswsusp , hibernate works (as a bonus, I get some form of compression and ability to cancel hibernating at the last second), but only most of the time. The usual resume procedure looks like this:
1. resume: Loading image data pages
(in default video mode)
1. Video mode is switched to native resolution, screen is filled with noise (full screen when EFI-booting, a small horizontal stripe on the top when BIOS-booting)
1. Loud click from speakers, screen momentarily turns black with s2disk: returned to userspace
, then I get my XScreenSaver lock dialog.
Sooner or later, right after the Loading data pages
screen turns black and the laptop resets (I see the BIOS boot logo).
I installed grub-efi on a thumbdrive (to avoid repartitioning) for the sake of efi-backed pstore. For a week, I hibernated and resumed the laptop once or twice per day without problems and almost beleived that EFI has solved the problem, but then the failure occured again, and no logs were found in /sys/fs/pstore
(pstore: Registered efi as persistent store backend
is visible in dmesg). I think that when resuming successfully for the last time before the next one failed the screen was not fully filled with noise and a black stripe was wisible on the bottom before I got returned to userspace
and X screen back.
As far as I know, suspend to RAM works flawlessly both with echo mem > /sys/power/state
and s2ram
. I do that more frequently than hibernating (several times per day) and so far, no glitches have occured.
For now, I set up XScreenSaver to never turn the screen off, thus preventing the most common cause of the failure (XScreenSaver locking and turning screen off before hibernation), but I'm still able to encounter the glitch by closing the lid fast enough after choosing "hibernate".
**UPD**: I've been using pure kernel hibernate for some time now, and I've just encountered the same reset after loading saved image which has been happening to me when using uswsusp. Apparently I've never used it on this X220 for long enough for it to happen before. So, as it turns out, I have no reliable ways to hibernate: both echo disk > /sys/power/state
and s2disk
fail after 5-7 hibernations, but pure kernel doesn't restore video card state properly, too.
What else can I try to make some form of hibernate working?
aitap
(583 rep)
Dec 3, 2016, 11:29 AM
• Last activity: May 17, 2025, 10:05 PM
6
votes
1
answers
3252
views
Creating .deb with systemd service but without SysV init scripts
I'm trying to add a systemd service file to an existing Debian package. I followed https://wiki.debian.org/Teams/pkg-systemd/Packaging, so I created `debian/packagename.service`. Because my `debhelper` is version 9.x, I also: - added `dh-systemd` to `Build-Depends` in `debian/control` - added `--wit...
I'm trying to add a systemd service file to an existing Debian package. I followed https://wiki.debian.org/Teams/pkg-systemd/Packaging , so I created
debian/packagename.service
. Because my debhelper
is version 9.x, I also:
- added dh-systemd
to Build-Depends
in debian/control
- added --with systemd
to the dh
command in debian/rules
.
Now when I rebuild the package with debuild -i -us -uc -b
, it fails with this output:
Now running lintian...
[...]
W: packagename: init.d-script-not-marked-as-conffile etc/init.d/packagename
E: packagename: init.d-script-not-included-in-package etc/init.d/packagename
It seems like the build script expects an init.d script if there is a .service
file. And indeed, the generated DEBIAN/postinst
includes this section:
# Automatically added by dh_installinit
if [ -x "/etc/init.d/infinoted" ]; then
update-rc.d infinoted defaults >/dev/null
invoke-rc.d infinoted start || exit $?
fi
# End automatically added section
Is this expected behavior? Should I always include SysV init scripts when I include a .service
file? If not, what is the recommended way to prevent the generation of this section?
My system is Debian Jessie.
segfault
(81 rep)
Feb 19, 2017, 02:20 PM
• Last activity: May 17, 2025, 01:06 AM
47
votes
2
answers
148823
views
How do I set the user of php-fpm to be php-user instead of www-data?
I am using php-fpm on debian with nginx for php5 support. I would like to have php-fpm to be under the user&group php-user instead of www-data. I thought the init.d script would have the user mentioned or uses a file which has www-data written in it. Yet I don't see it. How do I spawn this process t...
I am using php-fpm on debian with nginx for php5 support.
I would like to have php-fpm to be under the user&group php-user instead of www-data.
I thought the init.d script would have the user mentioned or uses a file which has www-data written in it. Yet I don't see it. How do I spawn this process to be under user php-user:php-user? Here is the php5-fpm init.d script on my server.
I tried looking at start-stop-daemon man pages but didn't see it. I'm sure this is simple but I don't know how to do it.
#!/bin/sh
### BEGIN INIT INFO
# Provides: php-fpm php5-fpm
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts php5-fpm
# Description: Starts PHP5 FastCGI Process Manager Daemon
### END INIT INFO
# Author: Ondrej Sury
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="PHP5 FastCGI Process Manager"
NAME=php5-fpm
DAEMON=/usr/sbin/$NAME
DAEMON_ARGS="--fpm-config /etc/php5/fpm/php-fpm.conf"
PIDFILE=/var/run/php5-fpm.pid
TIMEOUT=30
SCRIPTNAME=/etc/init.d/$NAME
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function to check the correctness of the config file
#
do_check()
{
[ "$1" != "no" ] && $DAEMON $DAEMON_ARGS -t 2>&1 | grep -v "\[ERROR\]"
FPM_ERROR=$($DAEMON $DAEMON_ARGS -t 2>&1 | grep "\[ERROR\]")
if [ -n "${FPM_ERROR}" ]; then
echo "Please fix your configuration file..."
$DAEMON $DAEMON_ARGS -t 2>&1 | grep "\[ERROR\]"
return 1
fi
return 0
}
#
# Function that starts the daemon/service
#
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS 2>/dev/null \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/$TIMEOUT/KILL/5 --pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
#
# If the daemon can reload its configuration without
# restarting (for example, when it is sent a SIGHUP),
# then implement that here.
#
start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
return 0
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_check $VERBOSE
case "$?" in
0)
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
;;
check)
do_check yes
;;
reload|force-reload)
log_daemon_msg "Reloading $DESC" "$NAME"
do_reload
log_end_msg $?
;;
restart)
log_daemon_msg "Restarting $DESC" "$NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2
exit 1
;;
esac
:
user4069
Jan 27, 2012, 07:32 PM
• Last activity: May 16, 2025, 12:11 PM
1
votes
1
answers
3150
views
Does Yocto linux use SysVinit or systemd?
I'm struggling to understand boot process on Yocto linux (Dizzy) which I got as pre-built image. It boots in xfce; pidof /sbin/init shows "1" which should mean that it's SysVinit. However, there is no /etc/inittab file and systemd process is started. I just want to change default runlevel to 3.
I'm struggling to understand boot process on Yocto linux (Dizzy) which I got as pre-built image.
It boots in xfce; pidof /sbin/init shows "1" which should mean that it's SysVinit. However, there is no /etc/inittab file and systemd process is started.
I just want to change default runlevel to 3.
Amomum
(141 rep)
Aug 31, 2016, 09:47 AM
• Last activity: Apr 24, 2025, 08:36 PM
0
votes
1
answers
2285
views
Automatically start a script while booting on OpenSuse 11
I need the following sample script to run when OpenSuSe 11 is booting: #!/bin/sh i=0; while true; do "SOME COMMAND FOR SAVING i TO ANOTHER PLACE" &> /dev/null i=$((i+1)) sleep 1 done So basically just add 1 every second on a variable and then send the variable to another system. I saved this script...
I need the following sample script to run when OpenSuSe 11 is booting:
#!/bin/sh
i=0;
while true; do
"SOME COMMAND FOR SAVING i TO ANOTHER PLACE" &> /dev/null
i=$((i+1))
sleep 1
done
So basically just add 1 every second on a variable and then send the variable to another system. I saved this script at /bin/user/script.sh
Starting the script from console works perfectly..
/bin/user/script.sh > /dev/null 2>&1 &
First I added this line to the existing /etc/init.d/boot.local that comes with OpenSuSe, however this was not working so stable. Sometimes it was started and sometimes not. I thought because of user rights, but even after
chmod 755 script.sh
The problem continues. So then I made my own /etc/init.d/myscript
Content of /etc/init.d/myscript:
#! /bin/sh
#
# /etc/init.d/myscript
#
### BEGIN INIT INFO
# Provides: myscript
# Required-Start:
# Required-Stop:
# Default-Start: 3 5
# Default-Stop: 0
# Short-Description: Start myscript while booting
# Description: ...
### END INIT INFO
#
#
#
case "$1" in
start)
echo "Starting myscript."
/bin/user/script.sh > /dev/null 2>&1 &
;;
stop)
echo "Stopping myscript."
killall -9 script.sh
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac
Then I did the insserv command for my script:
insserv myscript
Starting and stopping from console works..
/etc/init.d/myscript start
/etc/init.d/myscript stop
but again no sign of life for myscript after booting.
What am I doing wrong? How can I successfully run a script every time when the system starts?
**Update 2015.11.12: This script is working and starting correctly on boot on OpenSuSe 11.**
Ñhosko
(101 rep)
Nov 11, 2015, 05:01 PM
• Last activity: Apr 13, 2025, 05:00 PM
0
votes
1
answers
2824
views
Autostart services in System V system
In systemD, we need to execute this command to autostart an application on system startup: `sudo systemctl enable `. What will be the equivalent command for sysvinit since chkconfig is no longer supported? I could not find any.
In systemD, we need to execute this command to autostart an application on system startup:
sudo systemctl enable
. What will be the equivalent command for sysvinit since chkconfig is no longer supported? I could not find any.
belmont
(328 rep)
Sep 11, 2022, 04:32 AM
• Last activity: Apr 11, 2025, 06:03 PM
1
votes
2
answers
147
views
systemd-random-seed.service takes a lot of time to start / timeout
I have a Linux device with several services of my own. Kernel: `4.14.151` `systemd`: `systemd 249 (249.11-0ubuntu3.12)` My services are written as `sysvinit` services and automatically generated as `systemd` services using the `/run/systemd/generator.early`. Everything worked fine until I wanted to...
I have a Linux device with several services of my own.
Kernel:
4.14.151
systemd
: systemd 249 (249.11-0ubuntu3.12)
My services are written as sysvinit
services and automatically generated as systemd
services using the /run/systemd/generator.early
.
Everything worked fine until I wanted to call /usr/bin/ssh-keygen -t ed25519 ...
from one of my services.
At that moment, my call to ssh-keygen
gets blocked until systemd-random-seed.service
is done. But it's not done, it gets to timeout. So the whole boot takes a lot of time.
- I understand systemd-random-seed.service
is in charge of starting the entropy pool for randomness, that's why ssh-keygen
is blocked.
- But, why do they go into dead lock? I would expect systemd-random-seed.service
to finish unrelated to ssh-keygen
.
- Before my changes, systemd-random-seed.service
took ~16 seconds. (I can see using systemd-analyze blame
and systemd-analyze plot > chain.svg
.
- After my changes it can get to 10 minutes timeout.
- Regardless of my change. Meaning, without adding ssh-keygen
call to one of my services, I've tried to remove one of my sysvinit
service. Doing that makes systemd-random-seed.service
even more unpredictable - it finishes after 2-6 minutes.
- My purpose was re-writing my sysvinit
service as a systemd
service After=systemd-random-seed.service
so it will surely pass.
The bottom line is systemd-random-seed.service
is not clear to me.
Can you please explain its behavior? Why doesn't it start regardless of ssh-keygen
?
How can I start another service after it finishes?
hudac
(791 rep)
Mar 13, 2025, 09:30 AM
• Last activity: Mar 13, 2025, 04:07 PM
1
votes
3
answers
9866
views
Understand the /etc/inittab
I am using the following `/etc/inittab` file (systemv): ``` # /etc/inittab: init(8) configuration. # $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $ # The default runlevel. id:5:initdefault: # Boot-time system configuration/initialization script. # This is run first except when booting in emer...
I am using the following
/etc/inittab
file (systemv):
# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $
# The default runlevel.
id:5:initdefault:
# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS
# What to do in single-user mode.
~~:S:wait:/sbin/sulogin
# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.
l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
S0:12345:respawn:/sbin/getty -L 115200 ttyS0
In order to understand how things really work I'll appreciate if your answers to 1-3 you'll distinguish between two situations:
1. I'm connected to my system using a serial port.
2. I have a "regular" desktop pc.
Questions:
1. If I'll add another getty line, once linux startup I will see two separate terminals?
2. If I open several getty lines, how I assigned which getty will run my
si::sysinit:/etc/init.d/rcS
command and which getty will run the other script's commands? (the ones who run scripts according to the system run level)
in other words: in the /etc/inittab
file - can i assign different commands to different gettys? (i mean to the terminals which will open by these gettys)
3. the last script in /etc/init.d/rc5 folder run the following command:
su nobody -c /bin/sh
and the output is:
sh: cannot set terminal process group (1618): Inappropriate ioctl for device
sh: no job control in this shell
sh-4.3$ whoami
nobody
So I verified that i am nobody but why it writes the first two lines?
also why the prompt is sh-4.3$ and not nobody@...
4. I'm using serial connection. Can I change the /etc/inittab file and the last script that will run by init in order to:
1. run a program before login as low privileged user (init process will wait for termination)
2. once the program exits get the regular login prompt to my system
3. what is the best way to create a low privileged user and let him run this program during init process (if I don't want to use the nobody user)
hutcruchi
(399 rep)
Nov 5, 2019, 07:58 AM
• Last activity: Feb 13, 2025, 05:02 AM
103
votes
3
answers
216459
views
What does status "active (exited)" mean for a systemd service?
I'm working with a custom service which essentially runs a web server, called thisismywebserver. Currently it's not working (ie I get an "Unable to Connect" error trying to access a page). **When I run this command `service thisismywebserver status` to see the status of the service I see that the st...
I'm working with a custom service which essentially runs a web server, called thisismywebserver. Currently it's not working (ie I get an "Unable to Connect" error trying to access a page).
**When I run this command
service thisismywebserver status
to see the status of the service I see that the status is "active (exited)". Does this mean the service has stopped working? If not, then what does this mean?**
root@thisismywebserver-testing:~# service thisismywebserver status
● thisismywebserver.service - LSB: ThisIsMyWebServer server
Loaded: loaded (/etc/init.d/thisismywebserver)
Active: active (exited) since Sun 2015-11-08 23:01:33 EST; 18h ago
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
Highly Irregular
(2545 rep)
Nov 9, 2015, 10:15 PM
• Last activity: Dec 10, 2024, 02:41 PM
2
votes
1
answers
148
views
start-stop-daemon does not start because: "process already running"
I have an init script to start qbittorrent-nox on my server. It works fine when I first start the server, but if I shut down the qbittorrent-nox process (`service qbittorrent stop`) it will not start again (`service qbittorrent start`), with this error: process already running. I am sure there is no...
I have an init script to start qbittorrent-nox on my server. It works fine when I first start the server, but if I shut down the qbittorrent-nox process (
service qbittorrent stop
) it will not start again (service qbittorrent start
), with this error:
process already running.
I am sure there is no process running, I looked with ps
. this is the exact command to start:
start-stop-daemon --start --chdir '/home/testuser' --user 'testuser' --chuid 'testuser:testuser' --startas /usr/bin/env HOME="/home/testuser" /usr/bin/qbittorrent-nox
There are no files in /run
related to qbittorrent.
Martin Vegter
(586 rep)
Nov 30, 2024, 06:11 AM
• Last activity: Nov 30, 2024, 07:43 AM
0
votes
1
answers
57
views
Why does KDE's Discover and Apper show "orphan-sysvinit-scripts" should be updated but not apt-get upgrade --- should it be installed?
After upgrading to Debain12 with KDE, the package managers Apper and Discover show that a package "orphan-sysvinit-scripts" should be updated. But I don't have that package installed so why would it need to be updated? In addition, `sudo apt-get upgrade` does not show the package should be installed...
After upgrading to Debain12 with KDE, the package managers Apper and Discover show that a package "orphan-sysvinit-scripts" should be updated.
But I don't have that package installed so why would it need to be updated?
In addition,
sudo apt-get upgrade
does not show the package should be installed (it only shows The following packages have been kept back: sysv-rc-conf
which likely causes some users to install it manually accidentally removing hundreds of essential packages that it wants to remove).
It wants to install version 0.14 from +auto:debian-stable-main. I thought it only uses apt-get and should only display packages that the apt-get upgrade command also shows. It also shows no file-size for the package (nothing in the "Size" column of Apper).
Bug report is here .
mYnDstrEAm
(4708 rep)
Apr 7, 2024, 10:39 AM
• Last activity: Nov 13, 2024, 05:02 PM
0
votes
1
answers
199
views
Why can I not upgrade sysv-rc-conf on Debian as it's held back? (is there an alternative tool)
Why was sysv-rc-conf removed from the Debian repos? Is there for example a better alternative with a GUI? When I run `sudo apt-get upgrade` it's the only package held back: ``` The following packages have been kept back: sysv-rc-conf ``` When I run `sudo sysv-rc-conf` I can still configure autostart...
Why was sysv-rc-conf removed from the Debian repos? Is there for example a better alternative with a GUI?
When I run
sudo apt-get upgrade
it's the only package held back:
The following packages have been kept back:
sysv-rc-conf
When I run sudo sysv-rc-conf
I can still configure autostarting services in the console. I find it difficult to use as it's not a GUI and has just unexplained numbers as columns. Nevertheless, instead of removing I'd like to install some substitution tool that can also configure autostarting services.
Description: SysV init runlevel configuration tool for the terminal
sysv-rc-conf provides a terminal GUI for managing "/etc/rc{runlevel}.d/"
symlinks. The interface comes in two different flavors, one that simply
allows turning services on or off and another that allows for more fine tuned
management of the symlinks. Unlike most runlevel config programs, you can
edit startup scripts for any runlevel, not just your current one.
It probably has something to do with "orphan-sysvinit-scripts" showing up in KDE Discover and Apper to be installed (but getting installed or upgraded when upgrading).
mYnDstrEAm
(4708 rep)
Nov 13, 2024, 08:52 AM
• Last activity: Nov 13, 2024, 04:50 PM
Showing page 1 of 20 total questions