diff options
author | Sebastian Schmelzer | 2008-03-10 00:48:30 +0100 |
---|---|---|
committer | Sebastian Schmelzer | 2008-03-10 00:48:30 +0100 |
commit | 52d800555b4e1df6be9d0f6b80f79ca3ab5ca27b (patch) | |
tree | 88863ad0238e8ec850c315144ec108034071e8cd /os-plugins/plugins/x11vnc | |
parent | * vmpasswd link will now be created by makeinitramfs (diff) | |
download | core-52d800555b4e1df6be9d0f6b80f79ca3ab5ca27b.tar.gz core-52d800555b4e1df6be9d0f6b80f79ca3ab5ca27b.tar.xz core-52d800555b4e1df6be9d0f6b80f79ca3ab5ca27b.zip |
initial import of x11vnc plugin - further testing required (especially on suse system)
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1613 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/plugins/x11vnc')
-rw-r--r-- | os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm | 235 | ||||
-rw-r--r-- | os-plugins/plugins/x11vnc/XX_x11vnc.sh | 95 | ||||
-rwxr-xr-x | os-plugins/plugins/x11vnc/files/x11vnc | 72 |
3 files changed, 402 insertions, 0 deletions
diff --git a/os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm b/os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm new file mode 100644 index 00000000..6525ccc7 --- /dev/null +++ b/os-plugins/plugins/x11vnc/OpenSLX/OSPlugin/x11vnc.pm @@ -0,0 +1,235 @@ +# Copyright (c) 2007 - OpenSLX GmbH +# +# This program is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# x11vnc.pm +# ----------------------------------------------------------------------------- +package OpenSLX::OSPlugin::x11vnc; + +use strict; +use warnings; + +use base qw(OpenSLX::OSPlugin::Base); + +use OpenSLX::Basics; +use OpenSLX::Utils; + +sub new +{ + my $class = shift; + my $self = { + name => 'x11vnc', + }; + + return bless $self, $class; +} + +sub getInfo +{ + my $self = shift; + return { + description => unshiftHereDoc(<<' End-of-Here'), + enables x11vnc server + End-of-Here + mustRunAfter => [], + }; +} + +sub getAttrInfo +{ + my $self = shift; + + return { + 'x11vnc::active' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + should the 'x11vnc' plugin be executed during boot? + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => '1 means active - 0 means inactive', + default => '1', + }, + + 'x11vnc::precedence' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + the execution precedence of the 'x11vnc' plugin + End-of-Here + content_regex => qr{^\d\d$}, + content_descr => 'allowed range is from 01-99', + default => 50, + }, + + 'x11vnc::mode' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + set x11vnc to listen on X11(default) or console fb + End-of-Here + content_regex => qr{^(x11|fb)$}, + content_descr => 'x11 means listen current X session - fb means listen to tty1 console', + default => 'x11', + }, + + 'x11vnc::scale' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + scale screen size (e.g. as fraction 2/3 or as decimal 0.5) + End-of-Here + content_regex => undef, + content_descr => undef, + default => '', + }, + + 'x11vnc::shared' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + by default x11vnc is always called with the -shared option + End-of-Here + content_regex => qr{^(yes|no|1|0)$}, + content_descr => 'use 1 or yes to enable - 0 or no to disable', + default => 'yes', + }, + + 'x11vnc::force_viewonly' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + disable user interaction with vnc + End-of-Here + content_regex => qr{^(yes|no|1|0)$}, + content_descr => 'use 1 or yes to enable - 0 or no to disable', + default => 'no', + }, + + 'x11vnc::auth_type' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + set authentication type of the vnc connection + End-of-Here + content_regex => qr{^(passwd|rfbauth|none)$}, + content_descr => 'choose: passwd, rfbauth, none', + default => 'passwd', + }, + + 'x11vnc::allowed_hosts' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + set allowed hosts (multiple hosts are seperated by semicolons, (simple) subnets are possible too + e.g. "192.168.") + End-of-Here + content_regex => undef, + content_descr => undef, + default => '', + }, + + 'x11vnc::force_localhost' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + force x11vnc to only accept local connections and only listen on the loopback device + End-of-Here + content_regex => qr{^(1|0|yes|no)$}, + content_descr => 'use 1 or yes to enable - 0 or no to disable', + default => 'no', + }, + + 'x11vnc::pass' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + viewonly password (you can add multiple passwords seperated by semicolons) + (if you're using rfb-auth only the first one is used) + End-of-Here + content_regex => undef, + content_descr => undef, + default => '', + }, + + 'x11vnc::viewonlypass' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + viewonly password (you can add multiple passwords seperated by semicolons) + (disabled with rfb-auth) + End-of-Here + content_regex => undef, + content_descr => undef, + default => 'viewonly', + }, + + 'x11vnc::logging' => { + applies_to_systems => 1, + applies_to_clients => 0, + description => unshiftHereDoc(<<' End-of-Here'), + enable logging + End-of-Here + content_regex => qr{^(1|0|yes|no)$}, + content_descr => 'use 1 or yes to enable - 0 or no to disable', + default => 'yes', + }, + + }; +} + +sub installationPhase +{ + my $self = shift; + my $pluginRepositoryPath = shift; + my $pluginTempPath = shift; + my $openslxPath = shift; + + # get path of files we need to install + my $pluginFilesPath = "$openslxPath/lib/plugins/$self->{'name'}/files"; + + # copy all needed files now + copyFile("$pluginFilesPath/x11vnc", "/etc/init.d"); + vlog(3, "install init file"); + + if ( !-x "/usr/bin/x11vnc" ) { + # let's install x11vnc + if ( $self->{'os-plugin-engine'}->{'vendor-os-name'} =~ m/(debian|ubuntu)/i ) { + my $cmd = "aptitude -y install x11vnc"; + vlog(3, "executing: $cmd"); + if (slxsystem($cmd)) { + die _tr( + "unable to execute shell-cmd\n\t%s", $cmd + ); + } + } + if ( $self->{'os-plugin-engine'}->{'vendor-os-name'} =~ m/suse/i ) { + # PLEASE TEST THIS!!! + my $cmd = "yast --install x11vnc"; + vlog(3, "executing: $cmd"); + if (slxsystem($cmd)) { + die _tr( + "unable to execute shell-cmd\n\t%s", $cmd + ); + } + } + } else { + vlog(3, "x11vnc is already installed"); + } + +} + +sub removalPhase +{ + my $self = shift; + my $pluginRepositoryPath = shift; + my $pluginTempPath = shift; +} + +1; diff --git a/os-plugins/plugins/x11vnc/XX_x11vnc.sh b/os-plugins/plugins/x11vnc/XX_x11vnc.sh new file mode 100644 index 00000000..35245aef --- /dev/null +++ b/os-plugins/plugins/x11vnc/XX_x11vnc.sh @@ -0,0 +1,95 @@ +#! /bin/sh +# + +if [ -e /initramfs/plugin-conf/x11vnc.conf ]; then + . /initramfs/plugin-conf/x11vnc.conf + if [ $x11vnc_active -ne 0 ]; then + [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'x11vnc' os-plugin ..."; + + # create config dir for stage 3 + mkdir -p /mnt/etc/x11vnc + + # default parameters + PARAMS="-bg -forever" + + # client restrictions + if [ -z x11vnc_allowed_hosts ]; then + PARAMS="$PARAMS -allow $x11vnc_allowd_hosts" + fi + + # mode + case "$x11vnc_mode" in + x11) + PARAMS="$PARAMS -display :0" + X11VNC_X11=1 + ;; + fb) + PARAMS="$PARAMS -rawfb console" + ;; + esac + + # auth type + case "$x11vnc_auth_type" in + passwd) + # use x11vnc passwd style - recommended + echo "$x11vnc_pass" > /mnt/etc/x11vnc/passwd + echo "__BEGIN_VIEWONLY__" >> /mnt/etc/x11vnc/passwd + echo "$x11vnc_viewonlypass" >> /mnt/etc/x11vnc/passwd + + # multiuser handling + sed -i "s/,/\n/" /mnt/etc/x11vnc/passwd + + # add parameter to commandline + PARAMS="$PARAMS -passwdfile rm:/etc/x11vnc/passwd" + ;; + rfbauth) + # use rfbauth + vncpasswd "$x11vnc_pass" > /mnt/etc/x11vnc/passwd + PARAMS="$PARAMS -rfbauth /etc/x11vnc/passwd" + ;; + *) + # no password + PARAMS="$PARAMS -nopw" + ;; + esac + + # force viewonly + if [ "$x11vnc_force_viewonly" = "1" -o "$x11vnc_force_viewonly" = "yes" ]; then + PARAMS="$PARAMS -viewonly" + fi + + # force localhost + if [ "$x11vnc_force_localhost" = "1" -o "$x11vnc_force_localhost" = "yes" ]; then + PARAMS="$PARAMS -localhost" + fi + + # enable logging + if [ "$x11vnc_logging" = "1" -o "$x11vnc_logging" = "yes" ]; then + PARAMS="$PARAMS -o /var/log/x11vnc.log" + fi + + # shared desktops + if [ "$x11vnc_shared" = "1" -o "$x11vnc_shared" = "yes" ]; then + PARAMS="$PARAMS -shared" + fi + + # scale desktop + if [ "$x11vnc_scale" != "" ]; then + $PARAMS="$PARAMS -scale $x11vnc_scale" + fi + + # write config file + echo "# parameters generated by $0" > /mnt/etc/x11vnc/x11vnc.conf + echo "X11VNC_PARAMS=\"$PARAMS\"" >> /mnt/etc/x11vnc/x11vnc.conf + echo "X11VNC_X11=\"$X11VNC_X11\"" >> /mnt/etc/x11vnc/x11vnc.conf + + ln -sf ../init.d/x11vnc /mnt/etc/rc0.d/K20x11vnc + ln -sf ../init.d/x11vnc /mnt/etc/rc1.d/K20x11vnc + ln -sf ../init.d/x11vnc /mnt/etc/rc6.d/K20x11vnc + ln -sf ../init.d/x11vnc /mnt/etc/rc2.d/S20x11vnc + ln -sf ../init.d/x11vnc /mnt/etc/rc3.d/S20x11vnc + ln -sf ../init.d/x11vnc /mnt/etc/rc4.d/S20x11vnc + + [ $DEBUGLEVEL -gt 0 ] && echo "done with 'x11vnc' os-plugin ..."; + fi +fi diff --git a/os-plugins/plugins/x11vnc/files/x11vnc b/os-plugins/plugins/x11vnc/files/x11vnc new file mode 100755 index 00000000..f51ce83b --- /dev/null +++ b/os-plugins/plugins/x11vnc/files/x11vnc @@ -0,0 +1,72 @@ +#!/bin/bash +# -------------------------------- +# /etc/init.d/x11vnc +# -------------------------------- + +if [ -f /etc/x11vnc/x11vnc.conf ] +then + . /etc/x11vnc/x11vnc.conf +fi + +# find xauthority file +find_xauth () { + TIMEOUT=5 + XPID=`pidof X` + XRUNNING=$? + while [ "$XRUNNING" -ne "0" -a "$TIMEOUT" -gt "0" ] + do + echo -n "." + sleep 1 + let "TIMEOUT-=1" + XPID=`pidof X` + XRUNNING=$? + done + if [ "$XRUNNING" -eq "0" ]; then + XAUTHORITY=`ps ex|grep bin/X|sed -e "s/ /\n/g"|grep "^XAUTHORITY"|sed -e "s/XAUTHORITY=//"` + else + echo " .. FAILED (no running X found)" + fi +} + +START_COMMAND="x11vnc" + +case "$1" in + start) + echo -n " * Loading x11vnc " + + if [ ! -f /etc/x11vnc/passwd ]; then + echo " .. FAILED (/etc/x11vnc/passwd not found)" + echo " Create it manualy and retry starting x11vnc" + exit -1; + fi + + #su -c "$COMMAND" -l x11vnc & + if [ $X11VNC_X11 = 1 ]; then + find_xauth + START_COMMAND="$START_COMMAND -auth $XAUTHORITY $X11VNC_PARAMS" + else + START_COMMAND="$START_COMMAND $X11VNC_PARAMS" + fi + OUTPUT=`$START_COMMAND` + echo "$START_COMMAND" >>/var/log/x11vnc.debug + echo "$OUTPUT" >>/var/log/x11vnc.debug + echo " .. OK" + ;; + stop) + pid=`pidof x11vnc` + if [ -z "$pid" ] + then + echo " * x11vnc not running.." + exit -1; + else + kill -9 $pid + echo " * x11vnc stopped" + fi + + ;; + *) + echo "x11vnc startscript" + echo "Usage: $0 (start|stop)" + ;; +esac +exit 0 |