Showing posts with label vnc. Show all posts
Showing posts with label vnc. Show all posts

10 June 2024

r730xd Server Part 3: Software

 I will be using Proxmox Helper Scripts (https://tteck.github.io/Proxmox/ or https://Helper-Scripts.com) to help configure the different LXCs and VMs that I want.


Disable nag screen

As I was tired of having to confirm that I didn't have a subscription, I ripped these commands from Proxmox VE Tools -> Proxmox VE Post Install (https://raw.githubusercontent.com/tteck/Proxmox/main/misc/post-pve-install.sh) and ran on the Shell command line

  • echo "DPkg::Post-Invoke { \"dpkg -V proxmox-widget-toolkit | grep -q '/proxmoxlib\.js$'; if [ \$? -eq 1 ]; then { echo 'Removing subscription nag from UI...'; sed -i '/.*data\.status.*{/{s/\!//;s/active/NoMoreNagging/}' /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js; }; fi\"; };" >/etc/apt/apt.conf.d/no-nag-script
  • apt --reinstall install proxmox-widget-toolkit


Setup Users

My philosophy was to put all actual users in the 1000s and system users in the 2000s
  • user1
    • useradd user1
    • usermod -g users user1
    • adduser user1 user1
    • id user1
  • user2
    • useradd user2
    • usermod -g users user2
    • adduser user2 user2
    • id user2
  • mythtv
    • groupadd -g 2001 mythtv
    • useradd -u 2001 -g 2001 mythtv
  • nginx
    • groupadd -g 2002 nginx
    • useradd -u 2002 -g 2002 nginx
  • edit /etc/subuid and add
    • root:1000:1000
    • root:2000:1000
  • edit /etc/subgid and add
    • root:100:1
    • root:1000:1000
    • root:2000:1000


Import ZFS

  • zpool import storage
  • I decided not to map the drive in Proxmox, but if you wanted to you would do that here
    • proxmox -> Datacenter -> Storage -> Add -> ZFS


Fix Directory/File Permissions

  • /storage/mythtv
    • cd /storage/mythtv
    • ls -al
    • find ./ -user <current owner> -print0 | xargs -0 chown -h mythtv
    • find ./ -group <current group> -print0 | xargs -0 chgrp -h mythtv
  • /storage/containers/mythtv
    • cd /storage/containers/mythtv
    • ls -al
    • find ./ -user <current owner> -print0 | xargs -0 chown -h mythtv
    • find ./ -group <current group> -print0 | xargs -0 chgrp -h mythtv
  • /storage/containers/webserver
    • cd /storage/containers
    • chown -R nginx webserver
    • chgrp -R nginx webserver


Create a Docker LXC

Now I needed a Docker LXC to run my webserver and MythTV

  • bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/docker.sh)"
  • I then edited the config to set a static IP and change the hostname
    • docker -> Network -> net0 -> Edit
    • docker -> DNS -> Hostname -> Edit
  • Add users
    • nas
      • groupadd -g 2000 nas
      • useradd -u 2000 -g 2000 nas
    • mythtv
      • groupadd -g 2001 mythtv
      • useradd -u 2001 -g 2001 mythtv
    • nginx
      • groupadd -g 2002 nginx
      • useradd -u 2002 -g 2002 nginx


MythTV

  • Edit /storage/containers/mythtv/docker-compose.yml
    • Change the User Ids and Groups Ids to 2001
  • Test
    • docker compose up -d
  • If it looks like API port changed from 6544 to 6744, then you need to fix the IPs
  • Check pin and update backend ip
    • apt-get install default-mysql-client
    • mysql -p -h 127.0.0.1 -P 3306 mythconverg
      • select * from settings where value like '%pin%'
      • update settings set data = '192.168.1.31' where data = '192.168.1.11' ;
      • quit;
  • Restart MythTV and Test
    • docker compose down && docker compose up -d
  • This time I put a copy of docker-mythtv.service in /storage/container/mythtv so I can easily copy it to /etc/systemd/system/ in the future
    • make sure to change `docker-compose` to `docker compose`
  • docker compose down
  • systemctl enable docker-mythtv
  • systemctl start docker-mythtv


Webserver

  • Test
    • docker compose up -d
    • docker compose down
  • This time I put a copy of docker-webserver.service, certbot.service, and certbot.timer in /storage/container/webserver/systemd so I can easily copy it to /etc/systemd/system/ in the future
    • make sure to change `docker-compose` to `docker compose`
  • cp certbot.service certbot.timer docker-webserver.server /etc/systemd/system/
  • systemctl enable docker-webserver
  • systemctl start docker-webserver
  • systemctl enable certbot.timer


Create a Debian LXC for File Sharing

  • following:
  • bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/debian.sh)"
  • Add users/groups
    • <container> -> Console
    • user1
      • useradd user1
      • usermod -g users user1
      • adduser user1 user1
      • id user2
    • user2
      • useradd user2
      • usermod -g users user2
      • adduser user2 user2
      • id user2
    • nas
      • groupadd -g 2000 nas
      • useradd nas -u 2000 -g 2000 -m -s /bin/bash
      • adduser nas sudo
      • passwd nas
  • shutdown the container
  • Set a static IP and change the hostname
    • <container> -> Network -> net0 -> Edit
    • <container> -> DNS -> Hostname -> Edit
  • Add more compute/memory (2 cores/1024MB)
    • <container> -> Resources -> Cores -> Edit
    • <container> -> Resources -> Memory -> Edit
  • Add our storage
    • edit /etc/pve/lxc/<container id>.conf
    • add a line for each of your datasets like the below examples:
      • mp0: /storage/folder1/dataset1,mp=/storage/folder1/dataset1
      • mp1: /storage/folder1/dataset2,mp=/storage/folder1/dataset2
      • mp2: /storage/dataset3,mp=/storage/dataset3
  • Map the users
    • Notes
      • /etc/subuid and /etc/subgid need to specify the user starting the lxc container (root)
      • /etc/pve/lxc/<container id>.conf needs to map all ids and not just the ones you want to remap
    • edit /etc/pve/lxc/<container id>.conf add these lines
      • lxc.idmap: u 0 100000 1000
      • lxc.idmap: u 1000 1000 1000
      • lxc.idmap: u 2000 102000 63535
      • lxc.idmap: g 0 100000 100
      • lxc.idmap: g 100 100 1
      • lxc.idmap: g 101 100101 899
      • lxc.idmap: g 1000 1000 1000
      • lxc.idmap: g 2000 102000 63535
  • Change the drive permissions
    • I couldn't get the container to boot with trying to remap root so don't do this step
    • cd /rpool/data/subvol-<container id>-disk-0
    • find ./ -user 100000 -print0 | xargs -0 chown -h 2000
    • find ./ -group 100000 -print0 | xargs -0 chgrp -h 2000
  • Start the container
  • Install cockpit
    • apt install cockpit --no-install-recommends
    • wget https://github.com/45Drives/cockpit-file-sharing/releases/download/v3.3.7/cockpit-file-sharing_3.3.7-1focal_all.deb
    •  wget https://github.com/45Drives/cockpit-navigator/releases/download/v0.5.10/cockpit-navigator_0.5.10-1focal_all.deb
    • wget https://github.com/45Drives/cockpit-identities/releases/download/v0.1.12/cockpit-identities_0.1.12-1focal_all.deb
    • apt install ./*.deb
    • rm *.deb
  • Configure cockpit
    • https://192.168.X.X:9090
    • use nas to login
    • enable administrative access
    • Identities
      • Set a Samba password for each of the users
    • File Sharing
      • Click "Fix Now"
      • Global Settings
        • Toggle Global MacOS Shares
        • Add `allow insecure wide links = yes` to Advanced
        • Apply
      • Add your shares
      • I used the following to ensure all users can access others files in advanced
        • create mask = 0664
        • force create mode = 0664
        • directory mask = 0775
        • force directory mode = 0775
      • I used the following to be able to follow symlinks
        • follow symlinks = yes
        • wide links = yes


Create a Ubuntu VM for VNC and Handbrake

I have read that x264 sees reduced performance with over 6 threads, so I gave the VM 12 virtual cores since I want to be able to process 2 discs at a time.

  • bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/vm/ubuntu2404-vm.sh)"
  • Edit Cloud-Init
    • ubuntu -> Cloud-Init
    • set user/pass
    • set static IP
  • Disable start at boot
    • ubuntu -> Options -> Start at boot -> Edit
    • uncheck and the hit OK
  • Change resources
    • 12 Cores
    • 24 GB of memory (2 GB per core)
    • added 16 GB of storage
  • Console
    • start VM
    • login
  • Enable ssh with password
    • /etc/ssh/sshd_config.d/10_users.conf
      • Match User username
        • PasswordAuthentication yes
    • sudo systemctl restart ssh
  • VNC server
    • sudo apt install tigervnc-standalone-server
  • A window manager and terminal to use inside VNC
    • sudo apt install xfce4 xfce4-terminal
  • Keep proxmox console as text
    • sudo systemctl set-default multi-user.target
  • Start VNC
    • tigervncserver :1 -geometry 1600x900 -depth 24 -localhost no -SecurityTypes VncAuth,TLSVnc -xstartup /usr/bin/startxfce4
  • Add handbrake
    • sudo apt install handbrake libdvd-pkg
    • sudo dpkg-reconfigure libdvd-pkg
  • Set timezone (Added 2024-0620)
    • timedatectl list-timezones
    • sudo timedatectl set-timezone America/New_York
  • Setup samba shares
    • sudo apt install cifs-utils
    • create a file to save samba credentials in (eg smbcredentials)
      • username=username
      • password=password
    • mount the shares
      • sudo mount -t cifs //192.168.1.XX/nas /storage/encrypted/nas -o credentials=/home/<username>/smbcredentials,uid=<username>,gid=users
  • Add qemu agent (added 2024-07-29)
    • sudo apt install qemu-guest-agent
    • sudo systemctl start qemu-guest-agent


Appendix

Error
  •  Failed to run lxc.hook.pre-start for container
    • are your zfs pools mounted?
  • make sure cifs-utils are installed
    • sudo apt install cifs-utils
  • samba files are all owned by root
    • make sure to add the uid and gid to the mount command
Sources

02 February 2024

New VNC client for ChromeOS

As RealVNC discontinued their ChromeOS version and it was giving me issues with disconnections, I decided to look for a replacement.


The search

  • xtightvncviewer
    • Bad connection dialog
    • Does not handle ChromeOS scaling properly
    • No client window scaling without changing host resolution
  • ssvnc
    • Bad connection dialog
    • Does not handle ChromeOS scaling properly
    • No client window scaling without changing host resolution
    • Puts 2 icons on the dock
    • Supports ssh/ssl encryption
  • tigervnc-viewer
    • Acceptable connection dialog
    • Does not handle ChromeOS scaling properly
    • No client window scaling without changing host resolution
    • Support TLS encryption
  • vinagre
    • Acceptable connection dialog
    • Handles ChromeOS scaling properly
    • Suppports client window scaling without changing host resolution
    • Dock icon didn't load properly
    • Touchpad scrolling does not work
    • No longer maintained, superseded by Gnome Connections
  • Gnome Connections
    • Slick looking connections page
    • Handles ChromeOS scaling properly
    • Supports client window scaling without changing host resolution
    • Supports TLS encryption
    • Touchpad scrolling does not work
    • Does not remember/resize window when connecting
After my search I decided to go with TigerVNC viewer, but will keep Gnome Connections installed as it may eventually overtake it. Below is how I installed each

Installing TigerVNC viewer

  • Launch terminal
    • sudo apt install tigervnc-viewer
  • Configure it to scale properly
    • First determine your Chromebooks scaling
      • Settings -> Displays -> Display size
    • Test to make sure it is what you like, where .8 == 80% from above
      • /usr/bin/sommelier -X --scale=.8 /usr/bin/xtigervncviewer
    • Edit xtightvncviewer.desktop
      • mkdir ${HOME}/.local/share/applications/
      • cp /usr/share/applications/xtigervncviewer.desktop ${HOME}/.local/share/applications/
      • vi ${HOME}/.local/share/applications/xtigervncviewer.desktop
      • find "Exec"
      • and set it to the command that you tested
  • Launch the App
    • Search Key -> TigerVNC
  • Connect
    • 192.168.1.XXX:1

Installing Gnome Connections

  • Resize your linux storage size
    • Settings -> Advanced -> Linux development environment -> Disk size "Change"
    • I set it to 16 GB
  • Launch terminal
    • Make sure apt is up to date
      • sudo apt update
      • sudo apt upgrade
    • Install flatpak
      • sudo apt install flatpak
      • flatpak --user remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
      • Restart the linux container by right clicking on your terminal icon and select "Shut down Linux"
    • Install and start Gnome Connections
      • flatpak install flathub org.gnome.Connections
      • flatpak run org.gnome.Connections
    • Add your VNC server
      • 192.168.1.XXX:5901
      • Make sure to select VNC

Appendix

Sources:

03 December 2021

Xubuntu Server Ubgrade 16.04 to 18.04 to 20.04

As I have been busy the past few months, I failed to notice that 16.04 went past it's support window and hasn't been getting updates. Here are the steps that I went through to get current and fix the issues that I encountered

Perform the Upgrade

I upgraded using the GUI to walk me thru the steps
  • upgrade to 18.04
    • sudo do-release-upgrade -f DistUpgradeViewGtk3
  • reboot
  • upgrade to 20.04
    • sudo do-release-upgrade -f DistUpgradeViewGtk3
  • When prompted for debian-sys-maint password find it here:
    • sudo cat /etc/mysql/debian.cnf


Getting Unifi Web working again

127.0.0.1:8443 was giving a 404 error

  • Check the logs
    • tail -n 50 /usr/lib/unifi/logs/server.log
      • [2021-10-24TXX:XX:XX,XXX] <db-server> INFO  db     - DbServer stopped
    • tail -n 50 /usr/lib/unifi/logs/mongod.log
      • 2021-10-24TXX:XX:XX.XXX-XXXX F CONTROL  [initandlisten] ** IMPORTANT: UPGRADE PROBLEM: The data files need to be fully upgraded to version 3.4 before attempting an upgrade to 3.6; see http://dochub.mongodb.org/core/3.6-upgrade-fcv for more details.

So I needed to upgrade the mongo data files, but can't do that in version 3.6 so I used a combination of the following posts

Here are the actual steps that I used:

  • sudo apt-get install docker.io
  • sudo docker run --name mongo-migrate -v /var/lib/unifi/db:/data/db -p 127.0.0.1:27888:27017 -d mongo:3.4
  • mongo localhost:27888
    • db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
    • db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
    • exit
  • sudo docker stop mongo-migrate
  • sudo chown -R unifi:unifi /var/lib/unifi/db
  • sudo systemctl restart unifi


Fixing MythTV

I was seeing the following Fatal Error when accessing mythweb:

!!NoTrans: You are missing a php extension for mysql interaction. Please install php-mysqli or similar!!

I solved this error with the following steps:

  • apt-get install php7.4
  • sudo a2dismod php7.0
  • sudo a2enmod php7.4
  • sudo systemctl restart apache2

It then became this error:

!!NoTrans: MasterServerIP or MasterServerPort not found! You may need to check your mythweb.conf file or re-run mythtv-setup!!

I determined this to be an error with mysql

  • tail -n 100 /var/log/mysql/error.log
    • 2021-10-24TXX:XX:XX.XXXXXXZ 0 [ERROR] [MY-000067] [Server] unknown variable 'query_cache_limit=1M'.
    • 2021-10-24TXX:XX:XX.XXXXXXZ 0 [ERROR] [MY-000067] [Server] unknown variable 'query_cache_size=16M'.
  • sudo vi /etc/mysql/my.cnf
    • commented out the 2 lines regarding query_cache
  • sudo systemctl restart mysql

This got mysql running but, mythweb still had the same error. I tried a reboot of the server, but that didn't seem to help. It turns out that I needed to change the bind_address

  • sudo vi /etc/mysql/my.cnf
    • bind-address            = 127.0.0.1,192.168.X.X


VNC

I needed to fix my vnc setup and came across this:

  • vnc4server is no longer in the repo
  • tightvncserver works with the exception of window buttons. This is due to it not supporting Render: https://bugs.launchpad.net/ubuntu/+source/xfwm4/+bug/1860921
  • Solution: Use tigervncserver

Here are the steps that I used:

  • sudo apt-get install tigervnc-standalone-server
  • touch ${HOME}/.Xresources
  • tigervncserver :1 -geometry 1366x768 -depth 24 -localhost no


Let's Encrypt

Update 2021-12-14: Apparently, the upgrade broke my Let's Encrypt certificate, but fixing it was easy enough, I just needed to install 2 packages: sudo apt-get install certbot python3-certbot-apache


21 September 2014

Update to VNC: tightvncserver instability

Update to http://zmodemz.blogspot.com/2010/03/ubuntu-vnc.html


tightvncserver was crashing on me when doing simple things like opening file manager. I was getting the following error:


/var/log/syslog
Sep 14 00:21:45 servername kernel: [440445.907880] Xtightvnc[12447]: segfault at 7fffaf355000 ip 0000000000448a2e sp 00007fffaf352c80 error 6 in Xtightvnc[400000+178000]


Turns out that the instability is just in this version of tightvncserver, should be fixed in 1.3.10. So for the time being, I swapped out tightvncserver for vnc4server. The commands are identical as far as I can tell, so the switch was easy.


Software Versions:
Xubuntu 14.04.1 LTS (Trusty Tahr)
tightvncserver 1.3.9
vnc4server 4.1.1

28 October 2012

Upgrade from Xubuntu 10.04 LTS to 12.04 LTS


Here are the couple things that I found that I had to fix when upgrading from Xubuntu 10.04 LTS to 12.04 LTS:

  1. I was not getting DNS resolution
    • sudo vi /etc/resolv.conf
    • add:
      nameserver 192.168.1.1 
    • UPDATE: the above does not last you should instead:
      • sudo vi /etc/network/interfaces
      • add:
        dns-nameserver 192.168.1.1
  2. My VNC session was not loading a window manage (giving a failure to load gnome message -- I also got a trash not supported error and application crashes when starting xfce4-session)
    • vi ~/.vnc/xstartup
    • make sure it has:
      startxfce4 &
  3. When running synaptic from the application menu, it would ask for a password then fail to load 
    • xhost +localhost
  4. noip2 was removed and not in the package list
    • cd /usr/local/src
    • sudo wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
    • sudo tar xf noip-duc-linux.tar.gz
    • cd noip2-2.1.9-1/
    • sudo make install
    • sudo /usr/local/bin/noip2 -C
    • sudo vi /etc/init.d/noip2
      • change:
        DAEMON=/usr/local/bin/$NAME
        CONFFILE=/usr/local/etc/noip2.conf
    • sudo /etc/init.d/noip2 start

16 March 2010

Ubuntu VNC

Yesterday, I decided that I wanted to add VNC to my Xubuntu server so that I could get a remote GUI as well as my normal SSH.

Throughout my trials and tribulations getting VNC installed, I learned one very important fact: there are 2 types of VNC. The first is one that shares your current X11 session. This is like remote desktops that tech support would use to fix problems. The second is one that spawns a new X11 session that is maintained by the vncserver.

Here is how to install the remote desktop version (from lifehacker):

1. Install packages. Code: sudo apt-get install x11vnc vnc-java
2. Set up a password for clients. Code: x11vnc -storepasswd
3. Open up ports 5800 and 5900 on your firewall
4. Run the terminal command: x11vnc -forever -usepw -httpdir /usr/share/vnc-java/ -httpport 5800 and add it for auto-starting in future sessions


Here is how to install the vncserver that spawns new sessions:

1. Install packages. Code: sudo apt-get install tightvncserver vnc-java
2. Set up a password for clients. Code: vncpasswd
3. Run the terminal command: tightvncserver :1 -geometry 1024x768 -depth 24 -httpd /usr/share/vnc-java/ -httpport 5800


Now since we enabled the java client, you can connect by just opening up a java-enabled browser and going to http://:5800
However, it appears to do some weird coloring/dithering. You can also connect a full vncviewer to :5901

Warnings:
  • VNC is not encrypted and should not be streamed over the internet without tunneling through a secure protocol (e.g. ssh).
Advanced Setup:


Drag and Drop not working:
  • To fix it run the below
  • sudo apt-get install libgtk2.0-0=2.20.0-0ubuntu4 libgtk2.0-bin=2.20.0-0ubuntu4 libgail18=2.20.0-0ubuntu4 libgail-common=2.20.0-0ubuntu4 gtk2-engines-pixbuf=2.20.0-0ubuntu4