DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm using Debian 8 and at some point , quite a while ago, I started having issues with one of my scripts / services , the script is in /etc/init.d/vncserver , it meant to start tightvnc server for 4 different users.
When I write "service vnvserver start / stop / restart" it works and it does exactly what I expect, the issue I started having is that it would not give me any of the messages that you see in the script (Starting vncserver... , stoping vncserver...)
That on is own is not that annoying, the really annoying issue is that if I would not kill manually one of the vncservers (just kill PID) and I try to run "service vncserver start" , it wouldn't start the missing instant (it used to work!)
not sure what changed... thank you for your help.
btw, I tried running it directly from the init.d folder as well (without service command), same result .
Code:
#!/bin/bash
PATH="$PATH:/usr/bin/"
users=("user1" "user2" "user3" "user4")
for index in ${!users[*]}
do
export USER=${users[$index]}
disp=$((index+1))
DISPLAY=$disp
DEPTH="16"
if [ "${users[$index]}" = "user2" ] || [ "${users[$index]}" = "user1" ] ; then
GEOMETRY="1600x1200"
else
GEOMETRY="1280x1024"
fi
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"
. /lib/lsb/init-functions
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
restart)
$0 stop
$0 start
;;
esac
done
exit 0
When I write "service vnvserver start / stop / restart" it works and it does exactly what I expect, the issue I started having is that it would not give me any of the messages that you see in the script (Starting vncserver... , stoping vncserver...)
That on is own is not that annoying, the really annoying issue is that if I would not kill manually one of the vncservers (just kill PID) and I try to run "service vncserver start" , it wouldn't start the missing instant (it used to work!)
jessie already made the transition to systemd, but still uses many sysvinit scripts.
they are started by systemd though, via some compatibility layer.
that would explain the first problem.
i suspect that the second problem is also related; but i have to point out that simply killing the process in question is "inelegant".
how did you install the vncserver?
maybe there's a version in backports that relies fully on systemd?
jessie already made the transition to systemd, but still uses many sysvinit scripts.
they are started by systemd though, via some compatibility layer.
that would explain the first problem.
i suspect that the second problem is also related; but i have to point out that simply killing the process in question is "inelegant".
how did you install the vncserver?
maybe there's a version in backports that relies fully on systemd?
1) I understand, Is there something I can do with the script that you saw to fully work with systemd ?
2) When I said 'kill', I wasn't only referring to actually killing it manually (sometimes needed, I don't know how I can close just one instant out of the 4 without killing the PID), sometimes one of the instances stops and I need to run it again, but if I use 'service vncserver start' , it wouldn't start the missing instant, only Restart or stop/start will do that, but of course will also restart all the rest....
as far as I remember I first installed it with Apt-get, current version is up-to-date 'tightvncserver 1.3.9-6.5'
Not sure I'm following you, that is basically what the current script was suppose do, go over each user and start it if is not already running
The version of the script you posted does not seem to have any line that checks the existence of sessions, and takes different action depending upon what it finds. I would expect such a test in the start or restart procedures. A restart uncoditionally STOPS and then STARTS all defined sessions without protecting sessions in use. I was suggesting the ADDITION of a routine that ONLY starts defined sessions that are NOT running.
as far as I remember I first installed it with Apt-get, current version is up-to-date 'tightvncserver 1.3.9-6.5'
check the installation if it already comes with a systemd service.
if it does, use that instead:
1) disable the sysvinit script (dunno how)
2) use systemd commands to enable and start the systemd service.
The version of the script you posted does not seem to have any line that checks the existence of sessions, and takes different action depending upon what it finds. I would expect such a test in the start or restart procedures. A restart uncoditionally STOPS and then STARTS all defined sessions without protecting sessions in use. I was suggesting the ADDITION of a routine that ONLY starts defined sessions that are NOT running.
I know it doesn't check if the session already exists or not, but it does go over each user and tries to start it, so if the session already exists, the start will have no affect, and if it doesn't , it suppose to start.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.