# "x11vnc" doesn't run from startup script



## aurora (Nov 28, 2009)

Hello,

For the last several hours I've been trying to run "x11vnc" on my FreeBSD 7.2 from startup script, but it doesn't work. 

My startup script is (at /usr/local/etc/rc.d/x11vnc.sh)


```
#!/bin/sh
#

# PROVIDE: x11vnc
# REQUIRE: DAEMON 
# KEYWORD: shutdown

. /etc/rc.subr

name="x11vnc"
rcvar=`set rcvar`
load_rc_config $name
command="/usr/local/bin/x11vnc -many -rfbport 5901 -frbauth .vnc/passwd"

x11vnc_enable=${x11vnc_enable-"NO"}
x11vnc_pidfile=${x11vnc_pidfile-"/var/run/x11vnc.pid"}

pidfile="${x11vnc_pidfile}"

run_rc_command "$1"
```

I have enabled it also at /etc/rc.conf i.e. x11vnc_enable="YES"

My system uses XDM Display Manager and the reason I want x11vnc to run at startup is to have remote access at (graphical, XDM style) login screen. After logging in, at an xterm window:

`# /usr/local/bin/x11vnc -many -rfbport 5901 -frbauth .vnc/passwd`

or shortly

`# x11vnc -many -rfbport 5901 -frbauth .vnc/passwd`

work perfectly.

Now, how to make x11vnc run successfully at startup?

Thanks.


----------



## graudeejs (Nov 28, 2009)

To make it simple, you can add *x11vnc -many -rfbport 5901 -frbauth .vnc/passwd*

to xdm startup scripts....
I'm trying to remember whery they were....


----------



## graudeejs (Nov 28, 2009)

found them

look at 
*/usr/local/lib/X11/xdm*

there's this *Xsetup_0*.
I think if you append that line to this file you will get what you want


----------



## aurora (Nov 28, 2009)

Thank you for the reply.

I've found and edited that file and now it reads:


```
#!/bin/sh
# $Xorg: Xsetup_0,v 1.3 2000/08/17 19:54:17 cpqbld Exp $
xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed -exitOnfail
/usr/local/bin/x11vnc -many -rfbport 5901 -frbauth .vnc/passwd
```

But there's no change in circumstances, x11vnc still doesn't run at startup

Note: I have not deleted/disabled the /usr/local/etc/rc.d/x11vnc.sh while trying the Xsetup_0 solution.


----------



## graudeejs (Nov 28, 2009)

modify
*/usr/local/bin/x11vnc -many -rfbport 5901 -frbauth .vnc/passwd*
to
*/usr/local/bin/x11vnc -many -rfbport 5901 -frbauth .vnc/passwd 2&> /var/log/x11vnc.log*
this might give us idea what's going on here

try again, and post /var/log/x11vnc.log


----------



## aurora (Nov 28, 2009)

I've added the " 2&> /var/log/x11vnc.log" part and cat /var/log/x11vnc.log returns nothing. But there's another change: The X session starts with a lower resolution than usual (800x600 instead of usual 1024*768) which I think happened because of the addision of the " 2&> /var/log/x11vnc.log" part.


----------



## graudeejs (Nov 28, 2009)

No that can't be (well shouldn't) that ( *2&>* ) was supposed to redirect stderr to /var/log/x11vnc.log

Show /var/log/console


----------



## aurora (Nov 28, 2009)

At the  next reboot the resolution returned to normal so that was just a coincidence. 

There's no "console" file inside /var/log/ directory, so I cannot show the output of /var/log/console.
And, /var/log/x11vnc.log is still empty.


----------



## graudeejs (Nov 28, 2009)

ups, my bad....
It's /var/log/messages


----------



## aurora (Nov 29, 2009)

Here's the output of /var/log/messages. Hope it helps.

```
Nov 29 04:38:20 IBM syslogd: kernel boot file is /boot/kernel/kernel
Nov 29 04:38:20 IBM kernel: Copyright (c) 1992-2009 The FreeBSD Project.
Nov 29 04:38:20 IBM kernel: Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
Nov 29 04:38:20 IBM kernel: The Regents of the University of California. All rights reserved.
Nov 29 04:38:20 IBM kernel: FreeBSD is a registered trademark of The FreeBSD Foundation.
Nov 29 04:38:20 IBM kernel: FreeBSD 7.2-RELEASE #0: Fri May  1 08:49:13 UTC 2009
Nov 29 04:38:20 IBM kernel: root@walker.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC
Nov 29 04:38:20 IBM kernel: Timecounter "i8254" frequency 1193182 Hz quality 0
Nov 29 04:38:20 IBM kernel: CPU: Pentium II/Pentium II Xeon/Celeron (331.83-MHz 686-class CPU)
Nov 29 04:38:20 IBM kernel: Origin = "GenuineIntel"  Id = 0x651  Stepping = 1
Nov 29 04:38:20 IBM kernel: Features=0x183f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR>
Nov 29 04:38:20 IBM kernel: real memory  = 134205440 (127 MB)
Nov 29 04:38:20 IBM kernel: avail memory = 117174272 (111 MB)
Nov 29 04:38:20 IBM kernel: kbd1 at kbdmux0
Nov 29 04:38:20 IBM kernel: acpi0: <IBM CDTPWSPD> on motherboard
Nov 29 04:38:20 IBM kernel: acpi0: [ITHREAD]
Nov 29 04:38:20 IBM kernel: acpi0: Power Button (fixed)
Nov 29 04:38:20 IBM kernel: acpi0: reservation of 0, a0000 (3) failed
Nov 29 04:38:20 IBM kernel: acpi0: reservation of 100000, f00000 (3) failed
Nov 29 04:38:20 IBM kernel: acpi0: reservation of 1000000, 7000000 (3) failed
Nov 29 04:38:20 IBM kernel: Timecounter "ACPI-safe" frequency 3579545 Hz quality 850
Nov 29 04:38:20 IBM kernel: acpi_timer0: <24-bit timer at 3.579545MHz> port 0xfd08-0xfd0b on acpi0
Nov 29 04:38:20 IBM kernel: pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
Nov 29 04:38:20 IBM kernel: pci0: <ACPI PCI bus> on pcib0
Nov 29 04:38:20 IBM kernel: agp0: <Intel 82443BX (440 BX) host to PCI bridge> on hostb0
Nov 29 04:38:20 IBM kernel: pcib1: <PCI-PCI bridge> at device 1.0 on pci0
Nov 29 04:38:20 IBM kernel: pci1: <PCI bus> on pcib1
Nov 29 04:38:20 IBM kernel: vgapci0: <VGA-compatible display> mem 0xf4000000-0xf7ffffff irq 9 at device 1.0 on pci1
Nov 29 04:38:20 IBM kernel: isab0: <PCI-ISA bridge> at device 2.0 on pci0
Nov 29 04:38:20 IBM kernel: isa0: <ISA bus> on isab0
Nov 29 04:38:20 IBM kernel: atapci0: <Intel PIIX4 UDMA33 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376 at device 2.1 on pci0
Nov 29 04:38:20 IBM kernel: ata0: <ATA channel 0> on atapci0
Nov 29 04:38:20 IBM kernel: ata0: [ITHREAD]
Nov 29 04:38:20 IBM kernel: ata1: <ATA channel 1> on atapci0
Nov 29 04:38:20 IBM kernel: ata1: [ITHREAD]
Nov 29 04:38:20 IBM kernel: uhci0: <Intel 82371AB/EB (PIIX4) USB controller> port 0xff00-0xff1f irq 11 at device 2.2 on pci0
Nov 29 04:38:20 IBM kernel: uhci0: [GIANT-LOCKED]
Nov 29 04:38:20 IBM kernel: uhci0: [ITHREAD]
Nov 29 04:38:20 IBM kernel: usb0: <Intel 82371AB/EB (PIIX4) USB controller> on uhci0
Nov 29 04:38:20 IBM kernel: usb0: USB revision 1.0
Nov 29 04:38:20 IBM kernel: uhub0: <Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1> on usb0
Nov 29 04:38:20 IBM kernel: uhub0: 2 ports with 2 removable, self powered
Nov 29 04:38:20 IBM kernel: pci0: <bridge> at device 2.3 (no driver attached)
Nov 29 04:38:20 IBM kernel: rl0: <RealTek 8139 10/100BaseTX> port 0x7800-0x78ff mem 0xf3ffff00-0xf3ffffff irq 9 at device 18.0 on pci0
Nov 29 04:38:20 IBM kernel: miibus0: <MII bus> on rl0
Nov 29 04:38:20 IBM kernel: rlphy0: <RealTek internal media interface> PHY 0 on miibus0
Nov 29 04:38:20 IBM kernel: rlphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
Nov 29 04:38:20 IBM kernel: rl0: Ethernet address: 00:02:44:37:3d:62
Nov 29 04:38:20 IBM kernel: rl0: [ITHREAD]
Nov 29 04:38:20 IBM kernel: fdc0: <floppy drive controller> port 0x3f2-0x3f5,0x3f7 irq 6 drq 2 on acpi0
Nov 29 04:38:20 IBM kernel: fdc0: [FILTER]
Nov 29 04:38:20 IBM kernel: fd0: <1440-KB 3.5" drive> on fdc0 drive 0
Nov 29 04:38:20 IBM kernel: atkbdc0: <Keyboard controller (i8042)> port 0x60,0x64 irq 1 on acpi0
Nov 29 04:38:20 IBM kernel: atkbd0: <AT Keyboard> irq 1 on atkbdc0
Nov 29 04:38:20 IBM kernel: kbd0 at atkbd0
Nov 29 04:38:20 IBM kernel: atkbd0: [GIANT-LOCKED]
Nov 29 04:38:20 IBM kernel: atkbd0: [ITHREAD]
Nov 29 04:38:20 IBM kernel: psm0: <PS/2 Mouse> irq 12 on atkbdc0
Nov 29 04:38:20 IBM kernel: psm0: [GIANT-LOCKED]
Nov 29 04:38:20 IBM kernel: psm0: [ITHREAD]
Nov 29 04:38:20 IBM kernel: psm0: model IntelliMouse Explorer, device ID 4
Nov 29 04:38:20 IBM kernel: sio0: <16550A-compatible COM port> port 0x3f8-0x3ff irq 4 flags 0x10 on acpi0
Nov 29 04:38:20 IBM kernel: sio0: type 16550A
Nov 29 04:38:20 IBM kernel: sio0: [FILTER]
Nov 29 04:38:20 IBM kernel: sio1: <16550A-compatible COM port> port 0x2f8-0x2ff irq 3 on acpi0
Nov 29 04:38:20 IBM kernel: sio1: type 16550A
Nov 29 04:38:20 IBM kernel: sio1: [FILTER]
Nov 29 04:38:20 IBM kernel: cpu0: <ACPI CPU> on acpi0
Nov 29 04:38:20 IBM kernel: pmtimer0 on isa0
Nov 29 04:38:20 IBM kernel: orm0: <ISA Option ROM> at iomem 0xc0000-0xc7fff pnpid ORM0000 on isa0
Nov 29 04:38:20 IBM kernel: ppc0: <Parallel port> at port 0x378-0x37f irq 7 on isa0
Nov 29 04:38:20 IBM kernel: ppc0: SMC-like chipset (ECP/EPP/PS2/NIBBLE) in COMPATIBLE mode
Nov 29 04:38:20 IBM kernel: ppc0: FIFO with 16/16/8 bytes threshold
Nov 29 04:38:20 IBM kernel: ppbus0: <Parallel port bus> on ppc0
Nov 29 04:38:20 IBM kernel: ppbus0: [ITHREAD]
Nov 29 04:38:20 IBM kernel: plip0: <PLIP network interface> on ppbus0
Nov 29 04:38:20 IBM kernel: plip0: WARNING: using obsoleted IFF_NEEDSGIANT flag
Nov 29 04:38:20 IBM kernel: lpt0: <Printer> on ppbus0
Nov 29 04:38:20 IBM kernel: lpt0: Interrupt-driven port
Nov 29 04:38:20 IBM kernel: ppi0: <Parallel I/O> on ppbus0
Nov 29 04:38:20 IBM kernel: ppc0: [GIANT-LOCKED]
Nov 29 04:38:20 IBM kernel: ppc0: [ITHREAD]
Nov 29 04:38:20 IBM kernel: sc0: <System console> at flags 0x100 on isa0
Nov 29 04:38:20 IBM kernel: sc0: VGA <16 virtual consoles, flags=0x300>
Nov 29 04:38:20 IBM kernel: vga0: <Generic ISA VGA> at port 0x3c0-0x3df iomem 0xa0000-0xbffff on isa0
Nov 29 04:38:20 IBM kernel: fuse4bsd: version 0.3.9-pre1, FUSE ABI 7.8
Nov 29 04:38:20 IBM kernel: Timecounter "TSC" frequency 331831725 Hz quality 800
Nov 29 04:38:20 IBM kernel: Timecounters tick every 1.000 msec
Nov 29 04:38:20 IBM kernel: ad0: 4028MB <WDC AC14200R 15.01J15> at ata0-master UDMA33
Nov 29 04:38:20 IBM kernel: acd0: CDRW <ASUS CRW-4012A/1.0> at ata1-master UDMA33
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label for provider ad0s1a is ufsid/4a3406109841b851.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label for provider ad0s1d is ufsid/4a3406111e168422.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label for provider ad0s1e is ufsid/4a3406100d446985.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label for provider ad0s1f is ufsid/4a340610f6c14ff8.
Nov 29 04:38:20 IBM kernel: Trying to mount root from ufs:/dev/ad0s1a
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label ufsid/4a3406109841b851 removed.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label for provider ad0s1a is ufsid/4a3406109841b851.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label ufsid/4a3406100d446985 removed.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label for provider ad0s1e is ufsid/4a3406100d446985.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label ufsid/4a340610f6c14ff8 removed.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label for provider ad0s1f is ufsid/4a340610f6c14ff8.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label ufsid/4a3406111e168422 removed.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label for provider ad0s1d is ufsid/4a3406111e168422.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label ufsid/4a3406109841b851 removed.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label ufsid/4a3406100d446985 removed.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label ufsid/4a340610f6c14ff8 removed.
Nov 29 04:38:20 IBM kernel: GEOM_LABEL: Label ufsid/4a3406111e168422 removed.
Nov 29 04:38:20 IBM savecore: no dumps found
Nov 29 04:38:21 IBM mountd[602]: -mask requires -network
Nov 29 04:38:21 IBM mountd[602]: bad exports list line /root/share  192.168.1.252 -mask
```


----------



## graudeejs (Nov 29, 2009)

I think I got bingo....
[red]-frbauth .vnc/passwd[/red] - this is wrong
for now just put your passwd file in /root and change this to 

*-frbauth /root/passwd*

it didn't work because you gave relative directory... 
but when you started this from terminal, your current dir was your home dir, So relative dir was correct... when X starts it's current dir is different

EDIT:

or change it to absolute path like */home/aurora72/.vnc/passwd*, if you're the only one who will use vnc


----------



## aurora (Nov 29, 2009)

killasmurf86 said:
			
		

> I think I got bingo....
> [red]-frbauth .vnc/passwd[/red] - this is wrong
> for now just put your passwd file in /root and change this to
> 
> *-frbauth /root/passwd*...



Yeah that part seems wrong. .vnc/passwd is located at the root (my machine has got only one account and it's root; it's machine used for testing)

Now it reads:
*....-frbauth /root/.vnc/passwd*

But it still doesn't run at startup, unfortunately 

Now there are 2 things that come to my mind:

1- The other startup scripts at /usr/local/etc/rc.d are printed in red color with a "*" , e.g. apache22* or hald* but my script is all system color (black) with no *.

2- Inside the script there's the line:

# REQUIRE: DAEMON 

does this line make sense, I'm not sure. Why "DAEMON" should be there and not something like XDM, I have no idea.


----------



## graudeejs (Nov 29, 2009)

xdm is not started by rc scripts, its strarted form /etc/ttys
ye, you should chmod +x your script....

Using system as root all the time (even for testing) is windowsm


----------



## aurora (Nov 29, 2009)

I've changed it to chmod +x, the script still doesn't run.


----------



## aurora (Nov 29, 2009)

I have even applied the directions found at x11vnc's web site but it still doesn't run in anyway.


----------



## graudeejs (Nov 29, 2009)

did you try:

```
/usr/local/bin/x11vnc -rfbauth /etc/x11vnc.passwd -forever -bg -o /var/log/x11vnc.log
```
modified of corse?
Try it, and show x11vnc.log also show Xorg.0.log


----------



## aurora (Nov 29, 2009)

killasmurf86 said:
			
		

> did you try:
> 
> ```
> /usr/local/bin/x11vnc -rfbauth /etc/x11vnc.passwd -forever -bg -o /var/log/x11vnc.log
> ...



I've misspelled the "-*rf*bauth" as "-*fr*bauth" (!) and that was why it refused to run. Having seen the correct form in your last post I've instantly corrected it and it has finally run.

I guess I should start to use a better editor then "vi" as it has no easy copy&paste capabilities. All this trouble stemmed from me typing all commands by hand. Hrrr!

And finally it's verified that startup script should be placed at /usr/local/lib/X11/xdm/Xsetup_0 (and not under directory /usr/local/etc/rc.d/)

Now everthing about the x11vnc works as expected. Thanks!


----------



## graudeejs (Nov 29, 2009)

Use vim, I TOTALY LOVE IT....
But to start loving it, you need to read it's manual
type :help and start reading....

It's the best, if you wan't copy/past build vim with gui


----------



## aurora (Nov 30, 2009)

killasmurf86 said:
			
		

> Use vim, I TOTALY LOVE IT....
> But to start loving it, you need to read it's manual
> type :help and start reading....
> 
> It's the best, *if you wan't copy/past build vim with gui*



I'll take care of this advice, especially the part printed in bold. It's just a matter of time.


----------



## graudeejs (Nov 30, 2009)

an alternative [for copying/pasting] is to use x11/xclip


----------

