From: Michael Prokop Date: Sat, 12 Dec 2009 10:36:53 +0000 (+0100) Subject: Add VNC support. [Closes: issue781] X-Git-Tag: v0.9.2~1 X-Git-Url: http://git.grml.org/?p=grml-autoconfig.git;a=commitdiff_plain;h=394341318bdafc64bc63ccdc2ed1be53af91c5b4 Add VNC support. [Closes: issue781] --- diff --git a/autoconfig b/autoconfig index 2cfb247..b527425 100644 --- a/autoconfig +++ b/autoconfig @@ -61,7 +61,7 @@ CONFIG_BLANKING='yes' # check for bootoption noblank to disable console CONFIG_BLINDSOUND='yes' # play 'beep' and play welcome message CONFIG_BLIND='yes' # check for blind option or brltty CONFIG_CDROM_PERM='yes' # for burning on IDE-CD-Roms, k3b (and others) check for special permissions -CONFIG_CONFIG='yes' # do we want config unpacking to work? +CONFIG_CONFIG='yes' # do we want config unpacking to work? CONFIG_CONSOLE='yes' # activate mgetty when using console=... as bootparam CONFIG_CREATE_MNT_DIRS='no' # create /mnt-directories CONFIG_DEBOOTSTRAP='yes' # support automatic installation of Debian via grml-deboostrap @@ -74,7 +74,7 @@ CONFIG_DISTRI='yes' # support some customization via bootoption distri CONFIG_DMA='yes' # Enable DMA for all IDE drives CONFIG_EXTRACT='yes' # specify which (only in combination with bootparam myconfig/netconfig useful) CONFIG_FAST='yes' # skip startup of w3m on tty1 -CONFIG_FINDDCSDIR='yes' # search for a debs, config, scripts directory +CONFIG_FINDDCSDIR='yes' # search for a debs, config, scripts directory CONFIG_FIREWIRE_DEV='no' # bugfix for kernel >=2.6.11 - create some firewire-devices CONFIG_FIX_PASSWD='yes' # fix unionfs-problem with passwd CONFIG_FIX_UNIONFS='yes' # fix/workaround for unionfs @@ -103,11 +103,11 @@ CONFIG_MYPATH='yes' # provide setting additional paths via bootoption CONFIG_NETCONFIG='yes' # download configuration archive provided by bootoption netconfig=... CONFIG_NETSCRIPT='yes' # download and run script/executable provided by bootoption netscript=... CONFIG_NETIPV6='yes' # check for bootparam ipv6 -CONFIG_PARTCONF='yes' # do we want partconf to work? +CONFIG_PARTCONF='yes' # do we want partconf to work? CONFIG_PASSWD='yes' # set password via bootparam passwd CONFIG_PCMCIA='no' # check for pcmcia and start cardmgr CONFIG_QEMU='yes' # qemu specific stuff -CONFIG_SCRIPTS='yes' # execute scripts from the scripts option +CONFIG_SCRIPTS='yes' # execute scripts from the scripts option CONFIG_SERVICES='yes' # check for services to run, provided via bootparam CONFIG_SETKEYCODES='yes' # run setkeycodes when bootoption setkeycodes found CONFIG_SMALL='yes' # use a less "bloat" /etc/inittab for small computer with less RAM @@ -120,6 +120,7 @@ CONFIG_TIMEZONE='yes' # get bootparam 'tz' and set it as /etc/localtime CONFIG_TOHD='yes' # bootoption tohd=... CONFIG_USERFSTAB='yes' # check for username of uid 1000 CONFIG_VMWARE='yes' # vmware specific stuff (use xorg.conf.vmware) +CONFIG_VNC='yes' # check for bootparam vnc CONFIG_WELCOME='yes' # play welcome sound (audio) CONFIG_WONDERSHAPER='yes' # start wondershaper with options provided via bootparam CONFIG_XSTARTUP='yes' # start X window system via grml-x [only in live-mode] diff --git a/autoconfig.functions b/autoconfig.functions index f9a70ba..6c729c6 100755 --- a/autoconfig.functions +++ b/autoconfig.functions @@ -1501,6 +1501,56 @@ fi } # }}} +# {{{ autostart of x11vnc +config_vnc(){ + +USER=grml # TODO: make it dynamically configurable +if checkbootparam 'vnc' ; then + VNC_PASSWD='' + VNC_PASSWD="$(getbootparam 'vnc' 2>>$DEBUG)" + einfo "Bootoption vnc found, trying to set password for user $USER." + eindent + if [ -z "$VNC_PASSWD" ] ; then + if [ -x /usr/bin/apg ] ; then + VNC_PASSWD="$(apg -M NL -a 0 -m 8 -x 12 -n 1)" + elif [ -x /usr/bin/gpw ] ; then + VNC_PASSWD="$(gpw 1)" + elif [ -x /usr/bin/pwgen ] ; then + VNC_PASSWD="$(pwgen -1 8)" + elif [ -x /usr/bin/hexdump ] ; then + VNC_PASSWD="$(dd if=/dev/urandom bs=14 count=1 2>/dev/null | hexdump | awk '{print $3 $4}')" + elif [ -n "$RANDOM" ] ; then + VNC_PASSWD="${USER}${RANDOM}" + else + VNC_PASSWD='' + eerror "Empty passphrase and neither pwgen nor hexdump nor \$RANDOM found. Skipping." + eend 1 + fi + + if [ -n "$VNC_PASSWD" ] ; then + ewarn "No given password for vnc found. Using random password: $VNC_PASSWD" ; eend 0 + fi + fi + eoutdent + + # finally check if we have a password we can use: + if [ -n "$VNC_PASSWD" ] ; then + + VNCDIR="/home/${USER}/.vnc" + [ -d "$VNCDIR" ] || mkdir "$VNCDIR" + + if [ ! -x /usr/bin/x11vnc ] ; then + eerror "Error: x11vnc not found - can not set up vnc. Please make sure to install the x11vnc package." + eend 1 + else + /usr/bin/x11vnc -storepasswd "$VNC_PASSWD" "$VNCDIR"/passwd ; eend $? + /bin/chown -R "$USER": "$VNCDIR" + fi + fi +fi +} +# }}} + # {{{ set password for user grml config_passwd(){ if checkbootparam 'passwd' >>$DEBUG 2>&1; then diff --git a/grml-autoconfig b/grml-autoconfig index 03febd7..f0e0702 100755 --- a/grml-autoconfig +++ b/grml-autoconfig @@ -194,6 +194,8 @@ checkvalue $CONFIG_CPU && config_cpu checkvalue $CONFIG_SSH && config_ssh +checkvalue $CONFIG_VNC && config_vnc + checkvalue $CONFIG_PASSWD && config_passwd checkvalue $CONFIG_EXTRACT && config_extract