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 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 $? }
Could you please also add some description to this stuff for the conf file? Thanks
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 $?
Created attachment 323952 [details, diff] Patch for init script customized user options
Created attachment 323954 [details] Patch for confd for customized user options
Created attachment 323956 [details, diff] Patch for init script for customized users options and init script operations
I've applied your first part of the changes. I'll review the second one later on. Thanks!
What is pending here currently with latest version?
*** Bug 552048 has been marked as a duplicate of this bug. ***