diff --git a/main.go b/main.go index 4facfcb..c40663e 100644 --- a/main.go +++ b/main.go @@ -49,14 +49,23 @@ func main() { // Running in headless mode if *headless { + Config, err := config.ConfigInit() + if err != nil { + log.Fatalln(err) + } + + // Returns the URl address type + Addr := Ip4or6(Config.IPAddress) + // Starting screen share headless - cmd := exec.Command("chromium" ,"--auto-select-desktop-capture-source=Entire screen","--url","https://" + *addr + "/?mode=headless","--ignore-certificate-errors") + cmd := exec.Command("chromium" ,"--auto-select-desktop-capture-source=Entire screen","--url","https://" + Addr + ":8888/?mode=headless","--ignore-certificate-errors") if err := cmd.Run(); err != nil { log.Fatalln(err) } return } + // kills laplace server if *killServer { cmd := exec.Command("pkill" ,"laplace") @@ -100,3 +109,18 @@ func PrettyPrint(data interface{}) { } fmt.Printf("%s \n", p) } + +// Ip4or6 Helper function to check if the IP address is IPV4 or +//IPV6 (https://socketloop.com/tutorials/golang-check-if-ip-address-is-version-4-or-6) +func Ip4or6(s string) string { + for i := 0; i < len(s); i++ { + switch s[i] { + case '.': + return s + case ':': + return "[" + s + "]" + } + } + return "[" + s + "]" + +} diff --git a/run.sh b/run.sh index a5dcd39..64fae77 100644 --- a/run.sh +++ b/run.sh @@ -4,7 +4,7 @@ go build . ./laplace -setconfig ./laplace -tls -addr 0.0.0.0:8888 & -./laplace -headless -addr 192.168.0.175:8888 & +./laplace -headless & sleep 2 diff --git a/site.yml b/site.yml deleted file mode 100644 index bb17b15..0000000 --- a/site.yml +++ /dev/null @@ -1,84 +0,0 @@ ---- - -- hosts: all - - tasks: - - name: Install VNC-required system packages - apt: pkg={{ item }} state=latest - with_items: - - firefox - - lubuntu-desktop - - vnc4server - - xinetd - - - name: Create novnc install dir - file: path={{ novnc_install_dir }} state=directory - - - name: Clone novnc - git: repo=https://github.com/novnc/noVNC.git dest="{{ novnc_install_dir }}" version="stable/v0.6" - - - name: Clone websockify - git: repo=https://github.com/novnc/websockify dest="{{ novnc_install_dir }}/utils/websockify" - - - name: Create ~/.vnc dir - file: path=~/.vnc state=directory - become_user: "{{ default_user }}" - - - name: Remove old vncpasswd dir - file: path=~/vncpasswd state=absent - become_user: "{{ default_user }}" - - - name: Clone vncpasswd - git: repo=https://github.com/trinitronx/vncpasswd.py dest=~/vncpasswd - become_user: "{{ default_user }}" - - - name: Create vnc password bridge - command: python ~/vncpasswd/vncpasswd.py {{ vnc_password }} -f ~/.vnc/passwd - become_user: "{{ default_user }}" - when: vnc_password is defined - - - name: Chmod on vnc password file - file: path=~/.vnc/passwd mode=0600 - become_user: "{{ default_user }}" - when: vnc_password is defined - - # Move vnc_lite.html which takes vnc_password as query argument - # to index.html and rewrite it so that password is autoset, no - # need to specify via query parameter. - - name: Autoset novnc passwd to match the vnc one - shell: sed 's/password\ =/password\ = "{{ vnc_password }}";\/\//' {{ novnc_install_dir }}/vnc_auto.html > {{ novnc_install_dir }}/index.html #" - - - name: Remove temp vncpasswd dir - file: path=~/vncpasswd state=absent - become_user: "{{ default_user }}" - - - name: Copy script for starting X - copy: src=xstartup dest=~/.vnc/xstartup mode=0755 - become_user: "{{ default_user }}" - - - name: Make sure /etc/X11/xinit/xinitrc has execute permissions set - file: path=/etc/X11/xinit/xinitrc mode=0755 - - - name: Copy novnc init file - copy: src=novnc_init dest=/etc/init.d/novnc mode=0755 - - - name: Copy novnc default file - template: src=novnc_default.j2 dest=/etc/default/novnc - - - name: Copy vncserver default file - template: src=vncserver_default.j2 dest=/etc/default/vncserver - - - name: Copy lightdm config file - copy: src=lightdm.conf dest=/etc/lightdm/lightdm.conf - - - name: "Make sure lightdm respawns - fix for race condition: https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/969489" - lineinfile: dest=/etc/init/lightdm.conf line="respawn" insertafter="stop on runlevel [016]" - - - name: "Remove a11y indicator to fix: https://bugs.launchpad.net/lightdm/+bug/1322275" - replace: dest=/etc/lightdm/lightdm-gtk-greeter.conf.d/30_lubuntu.conf regexp="show-indicators=~host;~spacer;~clock;~spacer;~session;~language;~a11y;~power" replace="show-indicators=~host;~spacer;~clock;~spacer;~session;~language;~power" - - - name: Copy vnc config file for xinetd - template: src=xinetd_vnc.j2 dest=/etc/xinetd.d/vnc - - - include: create_simple_service.yml src_file='novnc' -