LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 01-05-2018, 01:52 AM   #1
isaac.dvorz
LQ Newbie
 
Registered: Apr 2015
Posts: 28

Rep: Reputation: Disabled
Service feedback / Echo issue


Hi,

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
 
Old 01-05-2018, 04:38 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 9,957
Blog Entries: 7

Rep: Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451
Quote:
Originally Posted by isaac.dvorz View Post
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?
 
Old 01-05-2018, 05:56 AM   #3
isaac.dvorz
LQ Newbie
 
Registered: Apr 2015
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post
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'
 
Old 01-05-2018, 06:17 AM   #4
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 2,731

Rep: Reputation: 1130Reputation: 1130Reputation: 1130Reputation: 1130Reputation: 1130Reputation: 1130Reputation: 1130Reputation: 1130Reputation: 1130
Perhaps a different refresh start, that only does a stop if that session is NOT running. Or an option to only do a restart on one specified. Or both.
 
Old 01-05-2018, 06:32 AM   #5
isaac.dvorz
LQ Newbie
 
Registered: Apr 2015
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wpeckham View Post
Perhaps a different refresh start, that only does a stop if that session is NOT running. Or an option to only do a restart on one specified. Or both.
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
 
Old 01-05-2018, 09:38 AM   #6
onebuck
Moderator
 
Registered: Jan 2005
Location: Summer Midwest USA, Central Illinois, Winter Central Florida
Distribution: SlackwareŽ
Posts: 13,238
Blog Entries: 29

Rep: Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437Reputation: 2437
Moderator response

Moved: This thread is more suitable in <Debian> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 01-05-2018, 07:31 PM   #7
wpeckham
Senior Member
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, Fedora, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, Vsido, tinycore, Q4OS
Posts: 2,731

Rep: Reputation: 1130Reputation: 1130Reputation: 1130Reputation: 1130Reputation: 1130Reputation: 1130Reputation: 1130Reputation: 1130Reputation: 1130
Quote:
Originally Posted by isaac.dvorz View Post
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.
 
Old 01-06-2018, 05:17 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 9,957
Blog Entries: 7

Rep: Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451Reputation: 2451
Quote:
Originally Posted by isaac.dvorz View Post
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.
 
Old 01-08-2018, 01:10 AM   #9
isaac.dvorz
LQ Newbie
 
Registered: Apr 2015
Posts: 28

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wpeckham View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] enable echo - stream service in RHEL 6.3 harig Programming 1 04-03-2013 09:18 AM
grep | xargs -I echo $(foo; bar; echo $(fee; fi; fo; fum)) == questionable output.. GrapefruiTgirl Programming 11 12-07-2010 08:02 PM
echo issue... DoME69 Programming 6 02-07-2008 05:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 01:10 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration