├── .gitattributes ├── .gitignore ├── GUI.JPG ├── change_kms.bash ├── help.JPG ├── menue_vnc.bash ├── menue_vnc2.bash ├── osmc_vnc.bash ├── osmc_vnc_install.bash └── osmc_vnc_install_cli.bash /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /GUI.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkusLange/VNC-Server-install-script-for-OSMC/e8859a84f6d32677203080ec19a20e025c4d5ba0/GUI.JPG -------------------------------------------------------------------------------- /change_kms.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function CHANGE_KMS_TO_KKMS { 4 | #Name: vc4-fkms-v3d 5 | #Info: Enable Eric Anholt's DRM VC4 V3D driver on top of the dispmanx 6 | #display stack. 7 | 8 | if grep -q 'dtoverlay=vc4-kms' '/boot/config.txt'; 9 | then 10 | echo "Found" 11 | sed -i /boot/config.txt -e 's/vc4-kms-v3d/vc4-fkms-v3d/' 12 | else 13 | echo "Not found" 14 | fi 15 | } 16 | 17 | function CHANGE_FKMS_TO_KMS { 18 | #Name: vc4-kms-v3d 19 | #Info: Enable Eric Anholt's DRM VC4 HDMI/HVS/V3D driver. 20 | 21 | if grep -q 'dtoverlay=vc4-fkms' '/boot/config.txt'; 22 | then 23 | echo "Found" 24 | sed -i /boot/config.txt -e 's/vc4-fkms-v3d/vc4-kms-v3d/' 25 | else 26 | echo "Not found" 27 | fi 28 | } 29 | 30 | CHANGE_KMS_TO_KKMS 31 | CHANGE_FKMS_TO_KMS 32 | -------------------------------------------------------------------------------- /help.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkusLange/VNC-Server-install-script-for-OSMC/e8859a84f6d32677203080ec19a20e025c4d5ba0/help.JPG -------------------------------------------------------------------------------- /menue_vnc.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Set UTF-8; e.g. "en_US.UTF-8" or "de_DE.UTF-8": 3 | #export LANG="C.UTF-8" 4 | export LC_ALL="C.UTF-8" 5 | 6 | # Tell ncurses to use line characters that work with UTF-8. 7 | export NCURSES_NO_UTF8_ACS=1 8 | 9 | separator=":" 10 | 11 | function CHECK_ROOT { 12 | # check if root for future installations 13 | if [ "$(id -u)" != "0" ]; 14 | then 15 | echo "This script must be run as root. Like this sudo $0" #1>&2 16 | exit 1 17 | else 18 | echo "This script runs as root." #1>&2 19 | fi 20 | } 21 | 22 | function OPTIONS { 23 | case $VALUE in 24 | 1) ONE;; 25 | 2) TWO;; 26 | 3) THREE;; 27 | 4) FOUR;; 28 | 5) echo "$VALUE";; 29 | 6) echo "$VALUE";; 30 | 7) echo "$VALUE";; 31 | 8) echo "$VALUE";; 32 | 9) CREATE_SERVICE_FILE;; 33 | esac 34 | } 35 | 36 | function APT_UPDATE { 37 | apt-get update 1> /dev/null 38 | } 39 | 40 | function APT_DISTUPGRADE { 41 | apt-get -y dist-upgrade 42 | apt-get -y autoclean 43 | apt-get -y autoremove 44 | } 45 | 46 | function ONE { 47 | APT_UPDATE 48 | APT_DISTUPGRADE 49 | DONE 50 | sleep 1 51 | MENU 52 | } 53 | 54 | function DONE { 55 | dialog --backtitle "Installing VNC-Server on OSMC" \ 56 | --infobox "Done" \ 57 | 5 20 58 | } 59 | 60 | function TWO () { 61 | FRESH_VARIABLES 62 | CONFS SET_VARIABLES 63 | } 64 | 65 | function TWO_PARTS { 66 | DONE 67 | sleep 1 68 | MENU 69 | } 70 | 71 | function THREE { 72 | CONFS FOUR 73 | } 74 | 75 | #function FOUR { 76 | # echo "4" 77 | # pass="4444" 78 | # sed -i /etc/dispmanx_vncserver.conf -e 's/password =.*/password = "'"$pass"'";/' 79 | # sed -i /etc/dispmanx_vncserver.conf -e 's/port =.*/port = '"$pass"';/' 80 | #} 81 | 82 | function FOUR { 83 | GREP_VARIABLES 84 | CONFIG SET_VARIABLES 85 | } 86 | 87 | function GREP_VARIABLES { 88 | port=$(egrep "port" /etc/dispmanx_vncserver.conf | egrep -o [0-9]+) 89 | framerate=$(egrep "frame-rate" /etc/dispmanx_vncserver.conf | egrep -o [0-9]+) 90 | mypassword=$(egrep "password" /etc/dispmanx_vncserver.conf | cut -d'"' -f2) 91 | } 92 | 93 | function FRESH_VARIABLES { 94 | port="5900" 95 | framerate="23" 96 | mypassword="" 97 | } 98 | 99 | function COPY_CONF { 100 | sudo cp dispmanx_vncserver.conf.sample /etc/dispmanx_vncserver.conf 101 | } 102 | 103 | function SET_VARIABLES { 104 | sed -i /etc/dispmanx_vncserver.conf -e 's/port =.*/port = '"$port"';/' 105 | sed -i /etc/dispmanx_vncserver.conf -e 's/frame-rate =.*/frame-rate = '"$framerate"';/' 106 | sed -i /etc/dispmanx_vncserver.conf -e 's/password =.*/password = "'"$mypassword"'";/' 107 | } 108 | 109 | function APT_INSTALL { 110 | apt-get install -y build-essential rbp-userland-dev-osmc libvncserver-dev libconfig++-dev unzip 1> /dev/null 111 | } 112 | 113 | function CLEAN { 114 | cd /home/osmc 115 | 116 | if [ -d "dispmanx_vnc-master/" ]; 117 | then 118 | rm -rf dispmanx_vnc-master/ 119 | fi 120 | 121 | if [ -d "master.zip" ]; 122 | then 123 | rm -f master.zip 124 | fi 125 | } 126 | 127 | function GET_DISPMANX { 128 | cd /home/osmc 129 | wget -q https://github.com/patrikolausson/dispmanx_vnc/archive/master.zip 130 | unzip -q -u master.zip -d /home/osmc/ 131 | } 132 | 133 | function MAKE_DISPMANX { 134 | cd dispmanx_vnc-master 135 | 136 | # --quiet after make to make it silent 137 | make --quiet clean 138 | make --quiet 139 | } 140 | 141 | function CREATE_SERVICE_FILE { 142 | cat > "/etc/systemd/system/dispmanx_vncserver.service" <<-EOF 143 | [Unit] 144 | Description=VNC Server 145 | After=network-online.target 146 | Requires=network-online.target 147 | 148 | [Service] 149 | Restart=on-failure 150 | RestartSec=30 151 | Nice=15 152 | User=root 153 | Group=root 154 | Type=simple 155 | ExecStartPre=/sbin/modprobe evdev 156 | ExecStart=/usr/bin/dispmanx_vncserver 157 | KillMode=process 158 | 159 | [Install] 160 | WantedBy=multi-user.target 161 | 162 | EOF 163 | } 164 | 165 | function CONFIG () { 166 | echo $1 167 | # Store data to $VALUES variable 168 | VALUES=$(dialog --title "" \ 169 | --stdout \ 170 | --backtitle "Installing VNC-Server on OSMC" \ 171 | --insecure \ 172 | --output-separator $separator \ 173 | --mixedform "Configuration" \ 174 | 10 50 0 \ 175 | "Port:" 1 2 "$port" 1 17 12 0 0 \ 176 | "Framerate:" 2 2 "$framerate" 2 17 12 0 0 \ 177 | "VNC-Password:" 3 2 "$mypassword" 3 17 12 0 1 \ 178 | ) 179 | rep=$? 180 | 181 | # display values just entered 182 | #echo "$VALUES" 183 | #echo "$response" 184 | 185 | port=$(echo "$VALUES" | cut -f 1 -d "$separator") 186 | framerate=$(echo "$VALUES" | cut -f 2 -d "$separator") 187 | mypassword=$(echo "$VALUES" | cut -f 3 -d "$separator") 188 | 189 | #echo "$port" 190 | #echo "$framerate" 191 | #echo "$mypassword" 192 | 193 | case $rep in 194 | 0) $1;; 195 | 1) MENU;; 196 | 255) MENU;; 197 | esac 198 | } 199 | 200 | function MENU { 201 | # Store data to $VALUES variable 202 | VALUE=$(dialog --backtitle "Installing VNC-Server on OSMC" --title "" \ 203 | --stdout \ 204 | --no-tags \ 205 | --cancel-label "Quit" \ 206 | --menu "Choose a Option" 17 54 9 \ 207 | "1" "OSMC System-Update with clean-up" \ 208 | "2" "Install VNC Server and Service" \ 209 | "3" "Update VNC Server (after a kernel update)" \ 210 | "4" "Change VNC settings" \ 211 | "5" "Start VNC Server (manual, no service)" \ 212 | "6" "Stop VNC Server"\ 213 | "7" "Install VNC Service (on boot)" \ 214 | "8" "Remove VNC Service" \ 215 | "9" "Remove/Clean all up" 216 | ) 217 | response=$? 218 | 219 | # display values just entered 220 | #echo "$response" 221 | #echo "$VALUE" 222 | 223 | case $response in 224 | 0) OPTIONS;; 225 | 1) ;; 226 | 255) ;; 227 | esac 228 | } 229 | 230 | CHECK_ROOT 231 | MENU -------------------------------------------------------------------------------- /menue_vnc2.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Set UTF-8; e.g. "en_US.UTF-8" or "de_DE.UTF-8": 3 | #export LANG="C.UTF-8" 4 | export LC_ALL="C.UTF-8" 5 | 6 | # Tell ncurses to use line characters that work with UTF-8. 7 | export NCURSES_NO_UTF8_ACS=1 8 | 9 | separator=":" 10 | 11 | function CHECK_ROOT { 12 | # check if root for future installations 13 | if [ "$(id -u)" != "0" ]; 14 | then 15 | echo "This script must be run as root. Like this sudo $0" #1>&2 16 | exit 1 17 | else 18 | echo "This script runs as root." #1>&2 19 | fi 20 | } 21 | 22 | function CHECK_SERVICE_ACTIVE { 23 | if [ "`systemctl show dispmanx_vncserver.service -p ActiveState`" = "ActiveState=active" ] 24 | then 25 | systemctl stop dispmanx_vncserver.service 26 | fi 27 | } 28 | function CHECK_SERVICE_INACTIVE { 29 | if [ "`systemctl show dispmanx_vncserver.service -p ActiveState`" = "ActiveState=inactive" ] 30 | then 31 | systemctl start dispmanx_vncserver.service 32 | fi 33 | } 34 | 35 | function CHECK_SERVICE_ENABLED { 36 | if [ "`systemctl is-enabled dispmanx_vncserver.service`" = "enabled" ] 37 | then 38 | systemctl disable dispmanx_vncserver.service 39 | fi 40 | } 41 | 42 | function CHECK_SERVICE_DISABLED { 43 | if [ "`systemctl is-enabled dispmanx_vncserver.service`" = "disable" ] 44 | then 45 | systemctl enable dispmanx_vncserver.service 46 | fi 47 | } 48 | 49 | function OPTIONS { 50 | case $VALUE in 51 | 1) OSMC_UPATE;; 52 | 2) INSTALL_VNC_SERVER_SERVICE;; 53 | 3) UPDATE_VNC_SERVER;; 54 | 4) CHANGE_VNC_SETTINGS;; 55 | 5) START_VNC_SERVER;; 56 | 6) STOP_VNC_SERVER;; 57 | 7) INSTALL_VNC_SERVICE;; 58 | 8) REMOVE_VNC_SERVICE;; 59 | 9) REMOVE_VNC;; 60 | esac 61 | } 62 | 63 | function APT_UPDATE { 64 | apt-get update 1> /dev/null 65 | apt-get -y dist-upgrade 66 | } 67 | 68 | function APT_CLEAN { 69 | apt-get -y autoclean 70 | apt-get -y autoremove 71 | } 72 | 73 | function OSMC_UPATE { 74 | APT_UPDATE 75 | APT_CLEAN 76 | REBOOT_FOLLOWS 77 | sleep 1 78 | reboot 79 | } 80 | 81 | function REBOOT_FOLLOWS { 82 | dialog --backtitle "Installing VNC-Server on OSMC" \ 83 | --infobox "Reboot follows" \ 84 | 5 20 85 | } 86 | 87 | function END { 88 | dialog --backtitle "Installing VNC-Server on OSMC" \ 89 | --infobox "Done" \ 90 | 5 20 91 | } 92 | 93 | function DONE { 94 | END 95 | sleep 1 96 | MENU 97 | } 98 | 99 | function INSTALL_VNC_SERVER_SERVICE () { 100 | APT_UPDATE 101 | APT_INSTALL 102 | GET_DISPMANX 103 | MAKE_DISPMANX 104 | COPY_BIN 105 | CREATE_SERVICE_FILE 106 | COPY_CONF 107 | GREP_VARIABLES 108 | CONFIG SET_VARIABLES 109 | CLEAN 110 | systemctl daemon-reload 111 | CHECK_SERVICE_DISABLED 112 | CHECK_SERVICE_INACTIVE 113 | DONE 114 | } 115 | 116 | function UPDATE_VNC_SERVER { 117 | APT_UPDATE 118 | CHECK_SERVICE_ACTIVE 119 | CHECK_SERVICE_ENABLED 120 | systemctl daemon-reload 121 | GET_DISPMANX 122 | MAKE_DISPMANX 123 | COPY_BIN 124 | CLEAN 125 | systemctl daemon-reload 126 | CHECK_SERVICE_DISABLED 127 | CHECK_SERVICE_INACTIVE 128 | DONE 129 | } 130 | 131 | function CHANGE_VNC_SETTINGS { 132 | GREP_VARIABLES 133 | CONFIG SET_VARIABLES 134 | DONE 135 | } 136 | 137 | function START_VNC_SERVER { 138 | CHECK_SERVICE_INACTIVE 139 | DONE 140 | } 141 | 142 | function STOP_VNC_SERVER { 143 | CHECK_SERVICE_ACTIVE 144 | DONE 145 | } 146 | 147 | function INSTALL_VNC_SERVICE { 148 | systemctl daemon-reload 149 | CHECK_SERVICE_DISABLED 150 | DONE 151 | } 152 | 153 | function REMOVE_VNC_SERVICE { 154 | CHECK_SERVICE_ENABLED 155 | systemctl daemon-reload 156 | DONE 157 | } 158 | 159 | function REMOVE_VNC { 160 | CHECK_SERVICE_ACTIVE 161 | CHECK_SERVICE_ENABLED 162 | systemctl daemon-reload 163 | REMOVE_CONF 164 | REMOVE_BIN 165 | DONE 166 | } 167 | 168 | function GREP_VARIABLES { 169 | port=$(egrep "port" /etc/dispmanx_vncserver.conf | egrep -o [0-9]+) 170 | framerate=$(egrep "frame-rate" /etc/dispmanx_vncserver.conf | egrep -o [0-9]+) 171 | mypassword=$(egrep "password" /etc/dispmanx_vncserver.conf | cut -d'"' -f2) 172 | } 173 | 174 | function COPY_CONF { 175 | sudo cp dispmanx_vncserver.conf.sample /etc/dispmanx_vncserver.conf 176 | } 177 | 178 | function COPY_BIN { 179 | sudo cp dispmanx_vncserver /usr/bin 180 | } 181 | 182 | function SET_VARIABLES { 183 | sed -i /etc/dispmanx_vncserver.conf -e 's/port =.*/port = '"$port"';/' 184 | sed -i /etc/dispmanx_vncserver.conf -e 's/frame-rate =.*/frame-rate = '"$framerate"';/' 185 | sed -i /etc/dispmanx_vncserver.conf -e 's/password =.*/password = "'"$mypassword"'";/' 186 | } 187 | 188 | function APT_INSTALL { 189 | apt-get update 1> /dev/null 190 | apt-get install -y build-essential rbp-userland-dev-osmc libvncserver-dev libconfig++-dev unzip 1> /dev/null 191 | } 192 | 193 | function CLEAN { 194 | cd /home/osmc 195 | 196 | if [ -d "dispmanx_vnc-master/" ]; 197 | then 198 | rm -rf dispmanx_vnc-master/ 199 | fi 200 | 201 | if [ -d "master.zip" ]; 202 | then 203 | rm -f master.zip 204 | fi 205 | } 206 | 207 | function REMOVE_CONF { 208 | cd /etc 209 | 210 | if [ -d "dispmanx_vncserver.conf" ]; 211 | then 212 | rm -f dispmanx_vncserver.conf 213 | fi 214 | } 215 | 216 | function REMOVE_BIN { 217 | cd /usr/bin 218 | 219 | if [ -d "dispmanx_vncserver" ]; 220 | then 221 | rm -f dispmanx_vncserver 222 | fi 223 | } 224 | 225 | function GET_DISPMANX { 226 | cd /home/osmc 227 | 228 | wget -q https://github.com/patrikolausson/dispmanx_vnc/archive/master.zip 229 | unzip -q -u master.zip -d /home/osmc/ 230 | } 231 | 232 | function MAKE_DISPMANX { 233 | cd /home/osmc/dispmanx_vnc-master 234 | 235 | # --quiet after make to make it silent 236 | make --quiet clean 237 | make --quiet 238 | } 239 | 240 | function CREATE_SERVICE_FILE { 241 | cat > "/etc/systemd/system/dispmanx_vncserver.service" <<-EOF 242 | [Unit] 243 | Description=VNC Server 244 | After=network-online.target 245 | Requires=network-online.target 246 | 247 | [Service] 248 | Restart=on-failure 249 | RestartSec=30 250 | Nice=15 251 | User=root 252 | Group=root 253 | Type=simple 254 | ExecStartPre=/sbin/modprobe evdev 255 | ExecStart=/usr/bin/dispmanx_vncserver 256 | KillMode=process 257 | 258 | [Install] 259 | WantedBy=multi-user.target 260 | 261 | EOF 262 | } 263 | 264 | function CONFIG () { 265 | echo $1 266 | # Store data to $VALUES variable 267 | VALUES=$(dialog --title "" \ 268 | --stdout \ 269 | --backtitle "Installing VNC-Server on OSMC" \ 270 | --insecure \ 271 | --output-separator $separator \ 272 | --mixedform "Configuration" \ 273 | 10 50 0 \ 274 | "Port:" 1 2 "$port" 1 17 12 0 0 \ 275 | "Framerate:" 2 2 "$framerate" 2 17 12 0 0 \ 276 | "VNC-Password:" 3 2 "$mypassword" 3 17 12 0 1 \ 277 | ) 278 | rep=$? 279 | 280 | # display values just entered 281 | #echo "$VALUES" 282 | #echo "$response" 283 | 284 | port=$(echo "$VALUES" | cut -f 1 -d "$separator") 285 | framerate=$(echo "$VALUES" | cut -f 2 -d "$separator") 286 | mypassword=$(echo "$VALUES" | cut -f 3 -d "$separator") 287 | 288 | #echo "$port" 289 | #echo "$framerate" 290 | #echo "$mypassword" 291 | 292 | case $rep in 293 | 0) $1;; 294 | 1) MENU;; 295 | 255) MENU;; 296 | esac 297 | } 298 | 299 | function MENU { 300 | # Store data to $VALUES variable 301 | VALUE=$(dialog --backtitle "Installing VNC-Server on OSMC" \ 302 | --title "" \ 303 | --stdout \ 304 | --no-tags \ 305 | --cancel-label "Quit" \ 306 | --menu "Choose a Option" 17 54 9 \ 307 | "1" "OSMC System-Update with clean-up" \ 308 | "2" "Install VNC Server and Service" \ 309 | "3" "Update VNC Server (after a kernel update)" \ 310 | "4" "Change VNC Settings" \ 311 | "5" "Start VNC Server (manual, no service)" \ 312 | "6" "Stop VNC Server"\ 313 | "7" "Install VNC Service (on boot)" \ 314 | "8" "Remove VNC Service" \ 315 | "9" "Remove/Clean all up" 316 | ) 317 | response=$? 318 | 319 | # display values just entered 320 | #echo "$response" 321 | #echo "$VALUE" 322 | 323 | case $response in 324 | 0) OPTIONS;; 325 | 1) ;; 326 | 255) ;; 327 | esac 328 | } 329 | 330 | CHECK_ROOT 331 | MENU -------------------------------------------------------------------------------- /osmc_vnc.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Set UTF-8; e.g. "en_US.UTF-8" or "de_DE.UTF-8": 3 | #export LANG="C.UTF-8" 4 | export LC_ALL="C.UTF-8" 5 | 6 | # Tell ncurses to use line characters that work with UTF-8. 7 | export NCURSES_NO_UTF8_ACS=1 8 | 9 | port="5900" 10 | framerate="23" 11 | mypassword="" 12 | 13 | function CHECK_SERVICE { 14 | if [ "`systemctl show dispmanx_vncserver.service -p ActiveState`" = "ActiveState=active" ] 15 | then 16 | systemctl stop dispmanx_vncserver.service 17 | fi 18 | } 19 | 20 | function CHECK_ROOT { 21 | # check if root for future installations 22 | if [ "$(id -u)" != "0" ]; 23 | then 24 | echo "This script must be run as root." #1>&2 25 | exit 1 26 | else 27 | echo "This script runs as root." #1>&2 28 | fi 29 | } 30 | 31 | function INSTALL { 32 | apt-get update 1> /dev/null 33 | apt-get install -y build-essential rbp-userland-dev-osmc libvncserver-dev libconfig++-dev unzip 1> /dev/null 34 | 35 | cd /home/osmc 36 | wget -q https://github.com/patrikolausson/dispmanx_vnc/archive/master.zip 37 | 38 | unzip -q -u master.zip -d /home/osmc/ 39 | cd dispmanx_vnc-master 40 | 41 | # --quiet after make to make it silent 42 | make clean 43 | make 44 | 45 | sudo cp dispmanx_vncserver /usr/bin 46 | sudo chmod +x /usr/bin/dispmanx_vncserver 47 | } 48 | 49 | function CLEAN { 50 | cd /home/osmc 51 | sudo rm -rf dispmanx_vnc-master/ 52 | sudo rm -f master.zip 53 | } 54 | 55 | function CONFIG { 56 | cat > "/etc/dispmanx_vncserver.conf" <<-EOF 57 | relative = false; 58 | port = $port; 59 | screen = 0; 60 | unsafe = false; 61 | fullscreen = false; 62 | multi-threaded = false; 63 | password = "$mypassword"; 64 | frame-rate = $framerate; 65 | downscale = false; 66 | localhost = false; 67 | vnc-params = ""; 68 | 69 | EOF 70 | 71 | cat > "/etc/systemd/system/dispmanx_vncserver.service" <<-EOF 72 | [Unit] 73 | Description=VNC Server 74 | After=network-online.target 75 | Requires=network-online.target 76 | 77 | [Service] 78 | Restart=on-failure 79 | RestartSec=30 80 | Nice=15 81 | User=root 82 | Group=root 83 | Type=simple 84 | ExecStartPre=/sbin/modprobe evdev 85 | ExecStart=/usr/bin/dispmanx_vncserver 86 | KillMode=process 87 | 88 | [Install] 89 | WantedBy=multi-user.target 90 | 91 | EOF 92 | 93 | systemctl daemon-reload 94 | systemctl start dispmanx_vncserver.service 95 | systemctl enable dispmanx_vncserver.service 96 | } 97 | 98 | function DONE { 99 | dialog --backtitle "Installing VNC-Server on OSMC" \ 100 | --infobox "Done" \ 101 | 5 20 102 | } 103 | 104 | function STEPS { 105 | CHECK_SERVICE 106 | INSTALL 107 | CONFIG 108 | CLEAN 109 | DONE 110 | sleep 2 111 | } 112 | 113 | CHECK_ROOT 114 | # open fd 115 | exec 3>&1 116 | 117 | # Store data to $VALUES variable 118 | VALUES=$(dialog --title "" \ 119 | --backtitle "Installing VNC-Server on OSMC" \ 120 | --insecure \ 121 | --output-separator : \ 122 | --mixedform "Configuration" \ 123 | 10 50 0 \ 124 | "Port:" 1 2 "$port" 1 17 12 0 0 \ 125 | "Framerate:" 2 2 "$framerate" 2 17 12 0 0 \ 126 | "VNC-Password:" 3 2 "$mypassword" 3 17 12 0 1 \ 127 | 2>&1 1>&3) 128 | response=$? 129 | 130 | # close fd 131 | exec 3>&- 132 | 133 | # display values just entered 134 | #echo "$VALUES" 135 | #echo "$response" 136 | 137 | port=$(echo "$VALUES" | cut -f 1 -d ":") 138 | framerate=$(echo "$VALUES" | cut -f 2 -d ":") 139 | mypassword=$(echo "$VALUES" | cut -f 3 -d ":") 140 | 141 | #echo "$port" 142 | #echo "$framerate" 143 | #echo "$mypassword" 144 | 145 | case $response in 146 | 0) STEPS;; 147 | 1) ;; 148 | 255) ;; 149 | esac 150 | -------------------------------------------------------------------------------- /osmc_vnc_install.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Set UTF-8; e.g. "en_US.UTF-8" or "de_DE.UTF-8": 3 | #export LANG="C.UTF-8" 4 | export LC_ALL="C.UTF-8" 5 | 6 | # Tell ncurses to use line characters that work with UTF-8. 7 | export NCURSES_NO_UTF8_ACS=1 8 | 9 | separator=":" 10 | 11 | function CHECK_ROOT { 12 | # check if root for future installations 13 | if [ "$(id -u)" != "0" ]; 14 | then 15 | echo "This script must be run as root. Like this sudo $0" #1>&2 16 | exit 1 17 | else 18 | echo "This script runs as root." #1>&2 19 | fi 20 | } 21 | 22 | function CHECK_SERVICE_ACTIVE { 23 | if [ "`systemctl show dispmanx_vncserver.service -p ActiveState`" = "ActiveState=active" ] 24 | then 25 | systemctl stop dispmanx_vncserver.service 26 | fi 27 | } 28 | function CHECK_SERVICE_INACTIVE { 29 | if [ "`systemctl show dispmanx_vncserver.service -p ActiveState`" = "ActiveState=inactive" ] 30 | then 31 | systemctl start dispmanx_vncserver.service 32 | fi 33 | } 34 | 35 | function CHECK_SERVICE_ENABLED { 36 | if [ "`systemctl is-enabled dispmanx_vncserver.service`" = "enabled" ] 37 | then 38 | systemctl disable dispmanx_vncserver.service 39 | fi 40 | } 41 | 42 | function CHECK_SERVICE_DISABLED { 43 | if [ "`systemctl is-enabled dispmanx_vncserver.service`" = "disabled" ] 44 | then 45 | systemctl enable dispmanx_vncserver.service 46 | fi 47 | } 48 | 49 | function OPTIONS { 50 | case $VALUE in 51 | 1) OSMC_UPATE;; 52 | 2) INSTALL_VNC_SERVER_AND_SERVICE;; 53 | 3) REMOVE_VNC_SERVER_AND_SERVICE;; 54 | 4) UPDATE_VNC_SERVER;; 55 | 5) CHANGE_VNC_SETTINGS;; 56 | 6) START_VNC;; 57 | 7) STOP_VNC;; 58 | 8) ACTIVATE_VNC_SERVICE;; 59 | 9) DEACTIVATE_VNC_SERVICE;; 60 | esac 61 | } 62 | 63 | function APT_UPDATE { 64 | apt-get update 1> /dev/null 65 | apt-get -y dist-upgrade 1> /dev/null 66 | } 67 | 68 | function APT_CLEAN { 69 | apt-get -y autoclean 70 | apt-get -y autoremove 71 | } 72 | 73 | function OSMC_UPATE { 74 | echo "starting" 75 | APT_UPDATE 76 | APT_CLEAN 77 | REBOOT_FOLLOWS 78 | sleep 1 79 | clear 80 | reboot 81 | } 82 | 83 | function REBOOT_FOLLOWS { 84 | dialog --backtitle "Installing VNC-Server on OSMC" \ 85 | --infobox "Reboot follows" \ 86 | 5 20 87 | } 88 | 89 | function DONE { 90 | dialog --backtitle "Installing VNC-Server on OSMC" \ 91 | --infobox "Done" \ 92 | 5 20 93 | sleep 1 94 | } 95 | 96 | function EXIT { 97 | dialog --backtitle "Installing VNC-Server on OSMC" \ 98 | --infobox "Exit" \ 99 | 5 20 100 | sleep 1 101 | clear 102 | } 103 | 104 | function INSTALL_VNC_SERVER_AND_SERVICE () { 105 | echo -n "starting" 106 | APT_UPDATE 107 | APT_INSTALL 108 | CREATE_VNC_SERVER 109 | COPY_CONF 110 | CLEANUP_INSTALL 111 | CREATE_SERVICE_FILE 112 | systemctl daemon-reload 113 | ACTIVATE_VNC_SERVICE 114 | GREP_VARIABLES 115 | CONFIG --nocancel 116 | } 117 | 118 | function UPDATE_VNC_SERVER { 119 | echo -n "starting" 120 | APT_UPDATE 121 | DEACTIVATE_VNC_SERVICE 122 | CREATE_VNC_SERVER 123 | CLEANUP_INSTALL 124 | ACTIVATE_VNC_SERVICE 125 | DONE 126 | MENU 127 | } 128 | 129 | function CHANGE_VNC_SETTINGS { 130 | GREP_VARIABLES 131 | CONFIG 132 | } 133 | 134 | function START_VNC { 135 | CHECK_SERVICE_INACTIVE 136 | } 137 | 138 | function STOP_VNC { 139 | CHECK_SERVICE_ACTIVE 140 | } 141 | 142 | function ACTIVATE_VNC_SERVICE { 143 | CHECK_SERVICE_DISABLED 144 | CHECK_SERVICE_INACTIVE 145 | } 146 | 147 | function DEACTIVATE_VNC_SERVICE { 148 | CHECK_SERVICE_ACTIVE 149 | CHECK_SERVICE_ENABLED 150 | } 151 | 152 | function REMOVE_VNC_SERVER_AND_SERVICE { 153 | DEACTIVATE_VNC_SERVICE 154 | systemctl daemon-reload 155 | REMOVE_FILES 156 | DONE 157 | MENU 158 | } 159 | 160 | function GREP_VARIABLES { 161 | port=$(egrep "port" /etc/dispmanx_vncserver.conf | egrep -o [0-9]+) 162 | framerate=$(egrep "frame-rate" /etc/dispmanx_vncserver.conf | egrep -o [0-9]+) 163 | mypassword=$(egrep "password" /etc/dispmanx_vncserver.conf | cut -d'"' -f2) 164 | } 165 | 166 | function COPY_CONF { 167 | cd /home/osmc/dispmanx_vnc-master 168 | 169 | sudo cp dispmanx_vncserver.conf.sample /etc/dispmanx_vncserver.conf 170 | sed -i /etc/dispmanx_vncserver.conf -e 's/port =.*/port = 5900;/' 171 | } 172 | 173 | function COPY_BIN { 174 | REMOVE_BIN 175 | cd /home/osmc/dispmanx_vnc-master 176 | 177 | sudo cp dispmanx_vncserver /usr/bin 178 | } 179 | 180 | function SET_VARIABLES { 181 | sed -i /etc/dispmanx_vncserver.conf -e 's/port =.*/port = '"$port"';/' 182 | sed -i /etc/dispmanx_vncserver.conf -e 's/frame-rate =.*/frame-rate = '"$framerate"';/' 183 | sed -i /etc/dispmanx_vncserver.conf -e 's/password =.*/password = "'"$mypassword"'";/' 184 | } 185 | 186 | function APT_INSTALL { 187 | apt-get update 1> /dev/null 188 | apt-get install -y build-essential rbp-userland-dev-osmc libvncserver-dev libconfig++-dev unzip 1> /dev/null 189 | } 190 | 191 | function CLEANUP_INSTALL { 192 | cd /home/osmc/ 193 | 194 | if [ -d "dispmanx_vnc-master/" ]; 195 | then 196 | rm -rf dispmanx_vnc-master/ 197 | fi 198 | 199 | if [ -e "master.zip" ]; 200 | then 201 | rm -f master.zip 202 | fi 203 | } 204 | 205 | function REMOVE_FILES { 206 | REMOVE_CONF 207 | REMOVE_BIN 208 | REMOVE_SERVICE_FILE 209 | } 210 | 211 | function REMOVE_CONF { 212 | cd /etc 213 | 214 | if [ -e "dispmanx_vncserver.conf" ]; 215 | then 216 | rm -f dispmanx_vncserver.conf 217 | fi 218 | } 219 | 220 | function REMOVE_BIN { 221 | cd /usr/bin 222 | 223 | if [ -e "dispmanx_vncserver" ]; 224 | then 225 | rm -f dispmanx_vncserver 226 | fi 227 | } 228 | 229 | function REMOVE_SERVICE_FILE { 230 | cd /etc/systemd/system 231 | 232 | if [ -e "dispmanx_vncserver.service" ]; 233 | then 234 | rm -f dispmanx_vncserver.service 235 | fi 236 | } 237 | 238 | function GET_DISPMANX { 239 | cd /home/osmc/ 240 | 241 | wget -q https://github.com/patrikolausson/dispmanx_vnc/archive/master.zip 242 | unzip -q -u master.zip -d /home/osmc/ 243 | } 244 | 245 | function MAKE_DISPMANX { 246 | cd /home/osmc/dispmanx_vnc-master 247 | 248 | # --quiet after make to make it silent 249 | make --quiet clean 250 | make --quiet 251 | } 252 | 253 | function CREATE_VNC_SERVER { 254 | GET_DISPMANX 255 | MAKE_DISPMANX 256 | COPY_BIN 257 | } 258 | 259 | function CREATE_SERVICE_FILE { 260 | cat > "/etc/systemd/system/dispmanx_vncserver.service" <<-EOF 261 | [Unit] 262 | Description=VNC Server 263 | After=network-online.target 264 | Requires=network-online.target 265 | 266 | [Service] 267 | Restart=on-failure 268 | RestartSec=30 269 | Nice=15 270 | User=root 271 | Group=root 272 | Type=simple 273 | ExecStartPre=/sbin/modprobe evdev 274 | ExecStart=/usr/bin/dispmanx_vncserver 275 | KillMode=process 276 | 277 | [Install] 278 | WantedBy=multi-user.target 279 | 280 | EOF 281 | } 282 | 283 | function CONFIG () { 284 | #echo $1 285 | # Store data to $VALUES variable 286 | VALUES=$(dialog --title "" \ 287 | --stdout \ 288 | --backtitle "Installing VNC-Server on OSMC" \ 289 | --insecure \ 290 | --ok-label Set \ 291 | $1 \ 292 | --output-separator $separator \ 293 | --mixedform "Configuration" \ 294 | 10 50 0 \ 295 | "Port: (eg. 5900)" 1 2 "$port" 1 21 12 0 0 \ 296 | "Framerate: (10-25)" 2 2 "$framerate" 2 21 12 0 0 \ 297 | "VNC-Password:" 3 2 "$mypassword" 3 21 12 0 1 \ 298 | ) 299 | rep=$? 300 | 301 | # display values just entered 302 | #echo "$VALUES" 303 | #echo "$response" 304 | 305 | port=$(echo "$VALUES" | cut -f 1 -d "$separator") 306 | framerate=$(echo "$VALUES" | cut -f 2 -d "$separator") 307 | mypassword=$(echo "$VALUES" | cut -f 3 -d "$separator") 308 | 309 | #echo "$port" 310 | #echo "$framerate" 311 | #echo "$mypassword" 312 | 313 | case $rep in 314 | 0) SET_VARIABLES 315 | DONE 316 | MENU 317 | ;; 318 | 1) MENU 319 | ;; 320 | 255) MENU 321 | ;; 322 | esac 323 | } 324 | 325 | function MENU { 326 | # Store data to $VALUES variable 327 | VALUE=$(dialog --backtitle "Installing VNC-Server on OSMC" \ 328 | --title "" \ 329 | --stdout \ 330 | --no-tags \ 331 | --cancel-label "Quit" \ 332 | --menu "Choose a Option" 17 57 9 \ 333 | "1" "OSMC System-Update" \ 334 | "2" "Install VNC Server and Service" \ 335 | "3" "Remove VNC Server and Service" \ 336 | "4" "Update VNC Server (mandatory after a kernel update)" \ 337 | "5" "Change VNC Configuration" \ 338 | "6" "Start VNC (manual, not Service)" \ 339 | "7" "Stop VNC (manual, not Service)" \ 340 | "8" "Activate VNC Service" \ 341 | "9" "Deactivate VNC Service" 342 | ) 343 | response=$? 344 | 345 | # display values just entered 346 | #echo "$response" 347 | #echo "$VALUE" 348 | 349 | case $response in 350 | 0) OPTIONS 351 | ;; 352 | 1) EXIT 353 | ;; 354 | 255) EXIT 355 | ;; 356 | esac 357 | } 358 | 359 | CHECK_ROOT 360 | MENU -------------------------------------------------------------------------------- /osmc_vnc_install_cli.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Set UTF-8; e.g. "en_US.UTF-8" or "de_DE.UTF-8": 3 | #export LANG="C.UTF-8" 4 | export LC_ALL="C.UTF-8" 5 | 6 | # Tell ncurses to use line characters that work with UTF-8. 7 | export NCURSES_NO_UTF8_ACS=1 8 | 9 | NARGS=$# 10 | VALUE=$1 11 | 12 | port=$2 13 | framerate=$3 14 | mypassword=$4 15 | 16 | separator=":" 17 | 18 | function ROOT_CHECK { 19 | # check if root for future installations 20 | if [ "$(id -u)" != "0" ]; 21 | then 22 | HELP 23 | exit 1 24 | else 25 | OPTIONS 26 | fi 27 | } 28 | 29 | function CHECK_SERVICE_ACTIVE { 30 | if [ "`systemctl show dispmanx_vncserver.service -p ActiveState`" = "ActiveState=active" ] 31 | then 32 | systemctl stop dispmanx_vncserver.service 33 | fi 34 | } 35 | 36 | function CHECK_SERVICE_INACTIVE { 37 | if [ "`systemctl show dispmanx_vncserver.service -p ActiveState`" = "ActiveState=inactive" ] 38 | then 39 | systemctl start dispmanx_vncserver.service 40 | fi 41 | } 42 | 43 | function CHECK_SERVICE_ENABLED { 44 | if [ "`systemctl is-enabled dispmanx_vncserver.service`" = "enabled" ] 45 | then 46 | systemctl disable dispmanx_vncserver.service 47 | fi 48 | } 49 | 50 | function CHECK_SERVICE_DISABLED { 51 | if [ "`systemctl is-enabled dispmanx_vncserver.service`" = "disabled" ] 52 | then 53 | systemctl enable dispmanx_vncserver.service 54 | fi 55 | } 56 | 57 | function CHANGE_KMS_TO_FKMS { 58 | #Name: vc4-fkms-v3d 59 | #Info: Enable Eric Anholt's DRM VC4 V3D driver on top of the dispmanx display stack. 60 | if grep -q 'dtoverlay=vc4-kms' '/boot/config.txt'; 61 | then 62 | sed -i /boot/config.txt -e 's/vc4-kms-v3d/vc4-fkms-v3d/' 63 | FORCED_REBOOT 64 | fi 65 | } 66 | 67 | function CHANGE_FKMS_TO_KMS { 68 | #Name: vc4-kms-v3d 69 | #Info: Enable Eric Anholt's DRM VC4 HDMI/HVS/V3D driver. 70 | if grep -q 'dtoverlay=vc4-fkms' '/boot/config.txt'; 71 | then 72 | sed -i /boot/config.txt -e 's/vc4-fkms-v3d/vc4-kms-v3d/' 73 | FORCED_REBOOT 74 | fi 75 | } 76 | 77 | function CHANGE_AUDIO_TO_DTPARAM { 78 | #Change audio directing to dtparam since fKMS does not support audio trough HMDI by default 79 | if [ -e "/boot/config-user.txt" ]; 80 | then 81 | if grep -q '[all]' '/boot/config-user.txt'; 82 | then 83 | : 84 | else 85 | echo [all] >> /boot/config-user.txt 86 | fi 87 | 88 | if grep -q '#dtparam=audio=on' '/boot/config-user.txt'; 89 | then 90 | sed -i /boot/config-user.txt -e 's/#dtparam=audio=on/dtparam=audio=on/' 91 | else 92 | if grep -q 'dtparam=audio=on' '/boot/config-user.txt'; 93 | then 94 | : 95 | else 96 | sed -i '/[all]/a dtparam=audio=on' /boot/config-user.txt 97 | fi 98 | fi 99 | fi 100 | } 101 | 102 | function CHANGE_AUDIO_TO_CV4 { 103 | #Change audio directing to KMS support by vc4 104 | if [ -e "/boot/config-user.txt" ]; 105 | then 106 | if grep -q 'dtparam=audio=on' '/boot/config-user.txt'; 107 | then 108 | sed -i /boot/config-user.txt -e 's/dtparam=audio=on/#dtparam=audio=on/' 109 | fi 110 | fi 111 | } 112 | 113 | function AKTIVE_FKMS { 114 | if [ -e "/boot/config-user.txt" ]; 115 | then 116 | CHANGE_AUDIO_TO_DTPARAM 117 | fi 118 | CHANGE_KMS_TO_FKMS 119 | } 120 | 121 | function AKTIVE_KMS { 122 | if [ -e "/boot/config-user.txt" ]; 123 | then 124 | CHANGE_AUDIO_TO_CV4 125 | fi 126 | CHANGE_FKMS_TO_KMS 127 | } 128 | 129 | function APT_UPDATE { 130 | apt-get update 1> /dev/null 131 | } 132 | 133 | function APT_UPGRADE { 134 | apt-get -y dist-upgrade 1> /dev/null 135 | } 136 | 137 | function APT_CLEAN { 138 | apt-get -y autoclean 1> /dev/null 139 | apt-get -y autoremove 1> /dev/null 140 | } 141 | 142 | function OSMC_UPATE { 143 | echo "starting" 144 | APT_UPDATE 145 | APT_UPGRADE 146 | APT_CLEAN 147 | FORCED_REBOOT 148 | } 149 | 150 | function FORCED_REBOOT { 151 | #echo $NARGS 152 | if [ $NARGS -ne 1 ]; 153 | then 154 | REBOOT_FOLLOWS 155 | fi 156 | sleep 0.5 157 | clear 158 | reboot 159 | } 160 | 161 | function REBOOT_FOLLOWS { 162 | dialog --backtitle "Installing VNC-Server on OSMC" \ 163 | --infobox "Reboot follows" \ 164 | 5 20 165 | } 166 | 167 | function DONE { 168 | dialog --backtitle "Installing VNC-Server on OSMC" \ 169 | --infobox "Done" \ 170 | 5 20 171 | sleep 0.5 172 | } 173 | 174 | function EXIT { 175 | dialog --backtitle "Installing VNC-Server on OSMC" \ 176 | --infobox "Exit" \ 177 | 5 20 178 | sleep 0.5 179 | clear 180 | } 181 | 182 | function INSTALL_VNC { 183 | INSTALL_VNC_SERVER_AND_SERVICE 184 | if [ $NARGS -ne 1 ]; 185 | then 186 | CHANGE_VNC_SETTINGS --nocancel 187 | else 188 | SET_VARIABLES 189 | fi 190 | AKTIVE_FKMS 191 | } 192 | 193 | function REMOVE_VNC { 194 | REMOVE_VNC_SERVER_AND_SERVICE 195 | AKTIVE_KMS 196 | if [ $NARGS -ne 1 ]; 197 | then 198 | DONE 199 | MENU 200 | fi 201 | } 202 | 203 | function UPDATE_VNC { 204 | UPDATE_VNC_SERVER 205 | if [ $NARGS -ne 1 ]; 206 | then 207 | DONE 208 | MENU 209 | fi 210 | CHANGE_KMS_TO_FKMS 211 | } 212 | 213 | function INSTALL_VNC_SERVER_AND_SERVICE { 214 | echo -n "starting" 215 | APT_UPDATE 216 | APT_INSTALL 217 | CREATE_VNC_SERVER 218 | COPY_CONF 219 | CLEANUP_INSTALL 220 | CREATE_SERVICE_FILE 221 | systemctl daemon-reload 222 | ACTIVATE_VNC_SERVICE 223 | } 224 | 225 | function UPDATE_VNC_SERVER { 226 | echo -n "starting" 227 | APT_UPDATE 228 | DEACTIVATE_VNC_SERVICE 229 | CREATE_VNC_SERVER 230 | CLEANUP_INSTALL 231 | ACTIVATE_VNC_SERVICE 232 | } 233 | 234 | function CHANGE_VNC_SETTINGS() { 235 | GREP_VARIABLES 236 | CONFIG $1 237 | } 238 | 239 | function START_VNC { 240 | CHECK_SERVICE_INACTIVE 241 | } 242 | 243 | function STOP_VNC { 244 | CHECK_SERVICE_ACTIVE 245 | } 246 | 247 | function ACTIVATE_VNC_SERVICE { 248 | CHECK_SERVICE_DISABLED 249 | CHECK_SERVICE_INACTIVE 250 | } 251 | 252 | function DEACTIVATE_VNC_SERVICE { 253 | CHECK_SERVICE_ACTIVE 254 | CHECK_SERVICE_ENABLED 255 | } 256 | 257 | function REMOVE_VNC_SERVER_AND_SERVICE { 258 | DEACTIVATE_VNC_SERVICE 259 | systemctl daemon-reload 260 | REMOVE_FILES 261 | } 262 | 263 | function GREP_VARIABLES { 264 | port=$(egrep "port" /etc/dispmanx_vncserver.conf | egrep -o [0-9]+) 265 | framerate=$(egrep "frame-rate" /etc/dispmanx_vncserver.conf | egrep -o [0-9]+) 266 | mypassword=$(egrep "password" /etc/dispmanx_vncserver.conf | cut -d'"' -f2) 267 | } 268 | 269 | function COPY_CONF { 270 | cd /home/osmc/dispmanx_vnc-master 271 | 272 | sudo cp dispmanx_vncserver.conf.sample /etc/dispmanx_vncserver.conf 273 | sed -i /etc/dispmanx_vncserver.conf -e 's/port =.*/port = 5900;/' 274 | } 275 | 276 | function COPY_BIN { 277 | REMOVE_BIN 278 | cd /home/osmc/dispmanx_vnc-master 279 | 280 | sudo cp dispmanx_vncserver /usr/bin 281 | } 282 | 283 | function SET_VARIABLES { 284 | sed -i /etc/dispmanx_vncserver.conf -e 's/port =.*/port = '"$port"';/' 285 | sed -i /etc/dispmanx_vncserver.conf -e 's/frame-rate =.*/frame-rate = '"$framerate"';/' 286 | sed -i /etc/dispmanx_vncserver.conf -e 's/password =.*/password = "'"$mypassword"'";/' 287 | } 288 | 289 | function APT_INSTALL { 290 | apt-get update 1> /dev/null 291 | apt-get install -y build-essential rbp-userland-dev-osmc libvncserver-dev libconfig++-dev unzip 1> /dev/null 292 | } 293 | 294 | function CLEANUP_INSTALL { 295 | cd /home/osmc/ 296 | 297 | if [ -d "dispmanx_vnc-master/" ]; 298 | then 299 | rm -rf dispmanx_vnc-master/ 300 | fi 301 | 302 | if [ -e "master.zip" ]; 303 | then 304 | rm -f master.zip 305 | fi 306 | } 307 | 308 | function REMOVE_FILES { 309 | REMOVE_CONF 310 | REMOVE_BIN 311 | REMOVE_SERVICE_FILE 312 | } 313 | 314 | function REMOVE_CONF { 315 | cd /etc 316 | 317 | if [ -e "dispmanx_vncserver.conf" ]; 318 | then 319 | rm -f dispmanx_vncserver.conf 320 | fi 321 | } 322 | 323 | function REMOVE_BIN { 324 | cd /usr/bin 325 | 326 | if [ -e "dispmanx_vncserver" ]; 327 | then 328 | rm -f dispmanx_vncserver 329 | fi 330 | } 331 | 332 | function REMOVE_SERVICE_FILE { 333 | cd /etc/systemd/system 334 | 335 | if [ -e "dispmanx_vncserver.service" ]; 336 | then 337 | rm -f dispmanx_vncserver.service 338 | fi 339 | } 340 | 341 | function GET_DISPMANX { 342 | cd /home/osmc/ 343 | 344 | wget -q https://github.com/patrikolausson/dispmanx_vnc/archive/master.zip 345 | unzip -q -u master.zip -d /home/osmc/ 346 | } 347 | 348 | function MAKE_DISPMANX { 349 | cd /home/osmc/dispmanx_vnc-master 350 | 351 | # --quiet after make to make it silent 352 | make --quiet clean 353 | make --quiet 354 | } 355 | 356 | function CREATE_VNC_SERVER { 357 | GET_DISPMANX 358 | MAKE_DISPMANX 359 | COPY_BIN 360 | } 361 | 362 | function CREATE_SERVICE_FILE { 363 | cat > "/etc/systemd/system/dispmanx_vncserver.service" <<-EOF 364 | [Unit] 365 | Description=VNC Server 366 | After=network-online.target 367 | Requires=network-online.target 368 | 369 | [Service] 370 | Restart=on-failure 371 | RestartSec=30 372 | Nice=15 373 | User=root 374 | Group=root 375 | Type=simple 376 | ExecStartPre=/sbin/modprobe evdev 377 | ExecStart=/usr/bin/dispmanx_vncserver 378 | KillMode=process 379 | 380 | [Install] 381 | WantedBy=multi-user.target 382 | 383 | EOF 384 | } 385 | 386 | function CONFIG () { 387 | #echo $1 388 | # Store data to $VALUES variable 389 | VALUES=$(dialog --title "" \ 390 | --stdout \ 391 | --backtitle "Installing VNC-Server on OSMC" \ 392 | --insecure \ 393 | --ok-label Set \ 394 | $1 \ 395 | --output-separator $separator \ 396 | --mixedform "Configuration" \ 397 | 10 50 0 \ 398 | "Port: (eg. 5900)" 1 2 "$port" 1 21 12 0 0 \ 399 | "Framerate: (10-25)" 2 2 "$framerate" 2 21 12 0 0 \ 400 | "VNC-Password:" 3 2 "$mypassword" 3 21 12 0 1 \ 401 | ) 402 | response=$? 403 | 404 | # display values just entered 405 | #echo "$VALUES" 406 | #echo "$response" 407 | 408 | port=$(echo "$VALUES" | cut -f 1 -d "$separator") 409 | framerate=$(echo "$VALUES" | cut -f 2 -d "$separator") 410 | mypassword=$(echo "$VALUES" | cut -f 3 -d "$separator") 411 | 412 | #echo "$port" 413 | #echo "$framerate" 414 | #echo "$mypassword" 415 | 416 | case $response in 417 | 0) SET_VARIABLES 418 | DONE 419 | MENU;; 420 | 1|255) MENU;; 421 | esac 422 | } 423 | 424 | function MENU { 425 | menu_options=("1" "OSMC System-Update (with forced reboot)" 426 | "2" "Install VNC Server and Service" 427 | "3" "Remove VNC Server and Service" 428 | "4" "Update VNC Server (mandatory after a kernel update)" 429 | "5" "Change VNC Configuration" 430 | "6" "Start VNC (manual, not Service)" 431 | "7" "Stop VNC (manual, not Service)" 432 | "8" "Activate VNC Service" 433 | "9" "Deactivate VNC Service") 434 | 435 | if grep -q 'dtoverlay=vc4' '/boot/config.txt'; 436 | then 437 | menu_options+=("A" "Activate fake-KMS driver" 438 | "B" "Activate KMS driver (mandatory update)") 439 | fi 440 | 441 | # Store data to $VALUES variable 442 | VALUE=$(dialog --backtitle "Installing VNC-Server on OSMC" \ 443 | --title "" \ 444 | --stdout \ 445 | --no-tags \ 446 | --cancel-label "Quit" \ 447 | --menu "Choose a Option" 17 57 9 "${menu_options[@]}" 448 | ) 449 | response=$? 450 | 451 | # display values just entered 452 | #echo "$response" 453 | #echo "$VALUE" 454 | 455 | case $response in 456 | 0) OPTIONS;; 457 | 1|255) EXIT;; 458 | esac 459 | } 460 | 461 | function HELP { 462 | echo "This script has to run as root: sudo $0" 463 | echo 464 | echo "You can start this script as GUI without parameter, or by using the" 465 | echo "following parameter to run it in CLI-Mode:" 466 | echo 467 | echo "--system-update, updates OSMC and the system (with forced reboot)" 468 | echo "--install-vnc, install VNC with three additional parameter needed port," 469 | echo " framerate and password" 470 | echo " e.g. --install-vnc 5900 25 osmc" 471 | echo "--remove-vnc, removes all files from VNC" 472 | echo "--update-vnc, recompile VNC after an OSMC update" 473 | echo "--change-config, changes the config with three additional parameter needed" 474 | echo " port, framerate and password" 475 | echo " e.g. --change-config 5900 25 osmc" 476 | echo "--start-vnc, start VNC-Server" 477 | echo "--stop-vnc, stop VNC-Server" 478 | echo "--activate-service, activate VNC as service" 479 | echo "--deactivate-service, deactivate VNC as service" 480 | 481 | if grep -q 'dtoverlay=vc4' '/boot/config.txt'; 482 | then 483 | echo "--change-to-fkms, change to fake-KMS driver" 484 | echo "--change-to-kms, change to KMS driver (mandatory update)" 485 | fi 486 | 487 | echo "--help, this!" 488 | echo 489 | } 490 | 491 | function OPTIONS { 492 | case $VALUE in 493 | 1|--system-update) OSMC_UPATE;; 494 | 2|--install-vnc) INSTALL_VNC;; 495 | 3|--remove-vnc) REMOVE_VNC;; 496 | 4|--update-vnc) UPDATE_VNC;; 497 | 5|--change-config) SET_VARIABLES;; 498 | 6|--start-vnc) START_VNC;; 499 | 7|--stop-vnc) STOP_VNC;; 500 | 8|--activate-service) ACTIVATE_VNC_SERVICE;; 501 | 9|--deactivate-service) DEACTIVATE_VNC_SERVICE;; 502 | A|--change-to-fkms) CHANGE_KMS_TO_FKMS;; 503 | B|--change-to-kms) CHANGE_FKMS_TO_KMS;; 504 | --clean-up) CLEANUP_INSTALL;; 505 | --help) HELP;; 506 | *) MENU;; 507 | esac 508 | } 509 | 510 | ROOT_CHECK --------------------------------------------------------------------------------