LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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, 12:52 AM   #1
isaac.dvorz
Member
 
Registered: Apr 2015
Posts: 33

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, 03:38 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
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, 04:56 AM   #3
isaac.dvorz
Member
 
Registered: Apr 2015
Posts: 33

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, 05:17 AM   #4
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,625

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
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, 05:32 AM   #5
isaac.dvorz
Member
 
Registered: Apr 2015
Posts: 33

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, 08:38 AM   #6
onebuck
Moderator
 
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,925
Blog Entries: 44

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
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, 06:31 PM   #7
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,625

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
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, 04:17 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
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, 12:10 AM   #9
isaac.dvorz
Member
 
Registered: Apr 2015
Posts: 33

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



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 08:18 AM
grep | xargs -I echo $(foo; bar; echo $(fee; fi; fo; fum)) == questionable output.. GrapefruiTgirl Programming 11 12-07-2010 07:02 PM
echo issue... DoME69 Programming 6 02-07-2008 04:38 AM

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

All times are GMT -5. The time now is 10:35 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
Open Source Consulting | Domain Registration