-
Notifications
You must be signed in to change notification settings - Fork 0
/
novnc_ubuntu.sh
141 lines (120 loc) · 3.66 KB
/
novnc_ubuntu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
# required packages: curl
main(){
install_docker
install_docker_compose
if [ -e "docker-compose.yml" ]; then
echo "docker-compose.yml file exists, please delete it first"
exit 1
else
echo "ok"
fi
#########################
install_novnc_ubuntu
#########################
echo "Installation successful"
}
install_novnc_ubuntu(){
mkdir ubuntu-xfce-vnc
if [ -e "docker-compose.yml" ]; then
echo "docker-compose.yml file exists, please delete it first"
exit 1
else
echo "ok"
fi
touch docker-compose.yml
cat <<EOF > docker-compose.yml
version: '3.5'
services:
ubuntu-xfce-vnc:
container_name: xfce
image: imlala/ubuntu-xfce-vnc-novnc:latest
shm_size: "1gb" # Prevent Chromium from crashing at high resolutions, and increase it a little if there is enough memory
ports:
- 5900:5900 # TigerVNC service port (ensure that the port is not occupied, the port to the right of the colon cannot be changed, and the port on the left can be changed)
- 6080:6080 # noVNC service port, the precautions are the same as above
environment:
- VNC_PASSWD=password # Change to the password you want
- GEOMETRY=1400x800 # Screen resolution, 800×600/1024×768 and so on
- DEPTH=24 # The number of color bits is 16/24/32 available, the higher the picture, the more delicate the picture, but the network is not good, it will also be more stuck
volumes:
- ~/ubuntu-xfce-vnc/Downloads:/root/Downloads
- ~/ubuntu-xfce-vnc/Documents:/root/Documents
restart: unless-stopped
EOF
docker-compose up -d
mv docker-compose.yml ubuntu-xfce-vnc
}
install_docker(){
# check docker is installed
if ! command -v docker &> /dev/null; then
echo "docker could not be found"
else
echo "docker is installed"
return
fi
# shellcheck disable=SC2162
read -p "Do you want to download from Aliyun? (y/n) (default n): " choice
case "$choice" in
y|Y ) curl -fsSL https://github.com/tech-shrimp/docker_installer/releases/download/latest/linux.sh| bash -s docker --mirror Aliyun;;
* ) curl -sSL https://get.docker.com/ | sh;;
esac
}
install_docker_compose(){
# Determine the Linux distribution and call the appropriate function
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
ubuntu|debian)
install_docker_compose_on_ubuntu
;;
alpine)
install_docker_compose_on_alpine
;;
centos|rhel|fedora)
install_docker_compose_on_centos
;;
*)
echo "Unsupported Linux distribution: $ID"
exit 1
;;
esac
else
echo "Cannot determine the Linux distribution."
exit 1
fi
}
# Function to install packages on Ubuntu/Debian
install_docker_compose_on_ubuntu() {
# check docker-compose is installed
if ! command -v docker-compose &> /dev/null; then
echo "docker-compose could not be found"
apt update
apt install -y docker-compose
else
echo "docker-compose is installed"
fi
}
# Function to install packages on Alpine
install_docker_compose_on_alpine() {
# check docker-compose is installed
if ! command -v docker-compose &> /dev/null; then
echo "docker-compose could not be found"
apk update
apk add docker-compose
else
echo "docker-compose is installed"
fi
}
# Function to install packages on CentOS/RHEL
install_docker_compose_on_centos() {
# check docker-compose is installed
if ! command -v docker-compose &> /dev/null; then
echo "docker-compose could not be found"
yum -y update
yum install -y docker-compose
else
echo "docker-compose is installed"
fi
}
main