Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 434382 - net-misc/tigervnc - init.d script multi-user improvement
Summary: net-misc/tigervnc - init.d script multi-user improvement
Status: RESOLVED NEEDINFO
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: No maintainer - Look at https://wiki.gentoo.org/wiki/Project:Proxy_Maintainers if you want to take care of it
URL:
Whiteboard:
Keywords: PATCH
: 552048 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-09-09 00:50 UTC by Rafal Lalik
Modified: 2016-05-24 08:42 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Improved version of init script (tigervnc,1.71 KB, text/plain)
2012-09-09 00:50 UTC, Rafal Lalik
Details
Patch for init script customized user options (tigervnc.initd-customized_users.patch,733 bytes, patch)
2012-09-15 22:27 UTC, Rafal Lalik
Details | Diff
Patch for confd for customized user options (tigervnc.confd-customized_users.patch,818 bytes, text/plain)
2012-09-15 22:28 UTC, Rafal Lalik
Details
Patch for init script for customized users options and init script operations (tigervnc.initd-customized_users_and_operations.patch,1.05 KB, patch)
2012-09-15 22:29 UTC, Rafal Lalik
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rafal Lalik 2012-09-09 00:50:36 UTC
Created attachment 323242 [details]
Improved version of init script

Hi guys,

I was always annoyed that I can't customize different vnc displays in Gentoo, but I know that this is possible in other distros (I think in Fedora I saw this). So I improved my init script, maybe you find it useful.

How does it work
================

Currently list of users and displays are taken from DISPLAY variable and options from VNC_OPTS variable.

In my version you can add extra variables for each user and each display to customize it. Imagine that you have users "foo" and "bar". Standard variables may look like
DISPLAYS="foo:1 foo:2 foo:3 bar:1 bar:2"
VNC_OPTS="args"

but for display ":2" of user "bar" I would like to have different arguments, so I put extra variable:

VNC_OPTS_bar[2]="different_args"

Init script while looping over DISPLAYS takes user name and display, and check whether variable VNC_OPTS_username[display] is not zero and if is not then takes its content. Otherwise it takes default VNC_OPTS. Script then is fully compatible with old tigervnc.conf file.


I think this changes you can also apply for other vnc servers init scripts.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2012-09-09 15:41:58 UTC
Comment on attachment 323242 [details]
Improved version of init script

--- files/tigervnc.initd        2010-03-06 17:30:03.000000000 +0100
+++ -   2012-09-09 17:41:50.762714657 +0200
@@ -37,7 +37,12 @@
        checkconfig start || return 1
        ebegin "Starting TigerVNC server"
        for user in $DISPLAYS; do
-               su -s /bin/sh ${user%%:*} -c "cd ~${user%%:*} && vncserver :${user##*:} $VNC_OPTS" &>/dev/null
+               usrname=${user%%:*}
+               usropts=VNC_OPTS_${usrname}
+               usrdisp=${user##*:}
+               usrvar=$usropts"["$usrdisp"]"
+               [ -z ${!usrvar} ] && vnc_opts=$VNC_OPTS || vnc_opts=${!usrvar}
+               su -s /bin/sh ${user%%:*} -c "cd ~${user%%:*} && vncserver :${user##*:} $vnc_opts" &>/dev/null
        done
        eend $?
 }
Comment 2 Raúl Porcel (RETIRED) gentoo-dev 2012-09-15 17:59:36 UTC
Could you please also add some description to this stuff for the conf file?

Thanks
Comment 3 Rafal Lalik 2012-09-15 22:26:14 UTC
In meantime I improved a bit my script. For now script also checks for variable VNC_OPTS_user to set options for all desktops for the user. Before it was searching only for VNC_OPTS_user[display].
Comment for this changes is inside the patch for conf file. Because my English is full of grammar leaks please check whether there is no stupid mistakes :)
Files:
tigervnc.initd-customized_users.patch
tigervnc.confd-customized_users.patch

From my experience with vnc I know that it is needed sometimes to restart single desktop (for example famous Alt-problem when vnc screen doesn't grab properly key and mouse events and only rescue sometimes is to restart vnc desktop). Because current script doesn't allow to restart single or selected desktops (and I had to temporarily manipulate with DISPLAYS variable) I add extra feature to init script. For now you can set variable AFFECT_ONLY which will restrict actions only to selected there user:desktop pairs, i.e.
AFFECT_ONLY="foo:1 foo:2 bar:3" /etc/init.d/tigervnc restart

This requires to enable or add AFFECT_ONLY to rc_env_allow variable in /etc/rc.conf:

rc_env_allow="AFFECT_ONLY"

This text can be add to conf or init script for information:
--- BEGIN OF SNIPPET
# For now you can set variable AFFECT_ONLY which will restrict init script
# actions only to selected there user:desktop pairs, i.e.
# AFFECT_ONLY="foo:1 foo:2 bar:3" /etc/init.d/tigervnc restart
# This requires to enable and/or add AFFECT_ONLY to rc_env_allow variable in /etc/rc.conf:
# rc_env_allow="AFFECT_ONLY"
--- END OF SNIPPET

File containing changes:
tigervnc.initd-customized_users_and_operations.patch - this patch must be used instead of tigervnc.initd-customized_users.patch

If tigervnc.initd-customized_users.patch was already applied then this patch will add extra feature:
--- files/tigervnc.initd      2012-09-16 00:19:55.759707344 +0200
+++ files/tigervnc.initd      2012-09-16 00:20:02.059738576 +0200
@@ -37,6 +37,8 @@
        checkconfig start || return 1
        ebegin "Starting TigerVNC server"
        for user in $DISPLAYS; do
+               [[ -n $AFFECT_ONLY ]] && [[ ! $AFFECT_ONLY == *${user}* ]] && continue;
+
                usrname=${user%%:*}
                usropts=VNC_OPTS_${usrname}
                usrdisp=${user##*:}
@@ -57,6 +59,7 @@
        checkconfig stop || return 2
        ebegin "Stopping TigerVNC server"
        for user in $DISPLAYS; do
+               [[ -n $AFFECT_ONLY ]] && [[ ! $AFFECT_ONLY == *${user}* ]] && continue;
                su -s /bin/sh ${user%%:*} -c "vncserver -kill :${user##*:}" &>/dev/null
        done
        eend $?
Comment 4 Rafal Lalik 2012-09-15 22:27:26 UTC
Created attachment 323952 [details, diff]
Patch for init script customized user options
Comment 5 Rafal Lalik 2012-09-15 22:28:14 UTC
Created attachment 323954 [details]
Patch for confd for customized user options
Comment 6 Rafal Lalik 2012-09-15 22:29:27 UTC
Created attachment 323956 [details, diff]
Patch for init script for customized users options and init script operations
Comment 7 Raúl Porcel (RETIRED) gentoo-dev 2012-09-16 16:16:13 UTC
I've applied your first part of the changes.

I'll review the second one later on.

Thanks!
Comment 8 Pacho Ramos gentoo-dev 2016-05-24 08:33:41 UTC
What is pending here currently with latest version?
Comment 9 Pacho Ramos gentoo-dev 2016-05-24 08:42:18 UTC
*** Bug 552048 has been marked as a duplicate of this bug. ***