@@ -39,34 +39,34 @@ download_file() {
3939 fi
4040
4141 # shellcheck disable=SC2288
42- " $$ {download_tool[@]}" " $url " > " $output " || {
43- echo " ERROR: Failed to download $url "
42+ " $$ {download_tool[@]}" " $$ url" > " $ $ output" || {
43+ echo " ERROR: Failed to download $$ url"
4444 exit 1
4545 }
4646}
4747
4848# Function to install kasmvncserver for debian-based distros
4949install_deb () {
50- local url=$1
50+ local url=$$ 1
5151 local kasmdeb=" /tmp/kasmvncserver.deb"
5252
53- download_file " $url " " $kasmdeb "
53+ download_file " $$ url" " $ $ kasmdeb"
5454
5555 CACHE_DIR=" /var/lib/apt/lists/partial"
5656 # Check if the directory exists and was modified in the last 60 minutes
57- if [[ ! -d " $CACHE_DIR " ]] || ! find " $CACHE_DIR " -mmin -60 -print -quit & > /dev/null; then
57+ if [[ ! -d " $$ CACHE_DIR" ]] || ! find " $ $ CACHE_DIR" -mmin -60 -print -quit & > /dev/null; then
5858 echo " Stale package cache, updating..."
5959 # Update package cache with a 300-second timeout for dpkg lock
6060 sudo apt-get -o DPkg::Lock::Timeout=300 -qq update
6161 fi
6262
63- DEBIAN_FRONTEND=noninteractive sudo apt-get -o DPkg::Lock::Timeout=300 install --yes -qq --no-install-recommends --no-install-suggests " $kasmdeb "
64- rm " $kasmdeb "
63+ DEBIAN_FRONTEND=noninteractive sudo apt-get -o DPkg::Lock::Timeout=300 install --yes -qq --no-install-recommends --no-install-suggests " $$ kasmdeb"
64+ rm " $$ kasmdeb"
6565}
6666
6767# Function to install kasmvncserver for rpm-based distros
6868install_rpm () {
69- local url=$1
69+ local url=$$ 1
7070 local kasmrpm=" /tmp/kasmvncserver.rpm"
7171 local package_manager
7272
@@ -88,26 +88,26 @@ install_rpm() {
8888 exit 1
8989 fi
9090
91- download_file " $url " " $kasmrpm "
91+ download_file " $$ url" " $ $ kasmrpm"
9292
9393 # shellcheck disable=SC2288
94- sudo " $$ {package_manager[@]}" " $kasmrpm " || {
95- echo " ERROR: Failed to install $kasmrpm "
94+ sudo " $$ {package_manager[@]}" " $$ kasmrpm" || {
95+ echo " ERROR: Failed to install $$ kasmrpm"
9696 exit 1
9797 }
9898
99- rm " $kasmrpm "
99+ rm " $$ kasmrpm"
100100}
101101
102102# Function to install kasmvncserver for Alpine Linux
103103install_alpine () {
104- local url=$1
104+ local url=$$ 1
105105 local kasmtgz=" /tmp/kasmvncserver.tgz"
106106
107- download_file " $url " " $kasmtgz "
107+ download_file " $$ url" " $ $ kasmtgz"
108108
109- tar -xzf " $kasmtgz " -C /usr/local/bin/
110- rm " $kasmtgz "
109+ tar -xzf " $$ kasmtgz" -C /usr/local/bin/
110+ rm " $$ kasmtgz"
111111}
112112
113113# Detect system information
118118
119119# shellcheck disable=SC1091
120120source /etc/os-release
121- distro=" $ID "
122- distro_version=" $VERSION_ID "
123- codename=" $VERSION_CODENAME "
124- arch=" $( uname -m) "
125- if [[ " $ID " == " ol" ]]; then
121+ distro=" $$ ID"
122+ distro_version=" $$ VERSION_ID"
123+ codename=" $$ VERSION_CODENAME"
124+ arch=" $$ (uname -m)"
125+ if [[ " $$ ID" == " ol" ]]; then
126126 distro=" oracle"
127127 distro_version=" $$ {distro_version%%.*}"
128- elif [[ " $ID " == " fedora" ]]; then
129- distro_version=" $( grep -oP ' \(\K[\w ]+' /etc/fedora-release | tr ' [:upper:]' ' [:lower:]' | tr -d ' ' ) "
128+ elif [[ " $$ ID" == " fedora" ]]; then
129+ distro_version=" $$ (grep -oP '\(\K[\w ]+' /etc/fedora-release | tr '[:upper:]' '[:lower:]' | tr -d ' ')"
130130fi
131131
132- echo " Detected Distribution: $distro "
133- echo " Detected Version: $distro_version "
134- echo " Detected Codename: $codename "
135- echo " Detected Architecture: $arch "
132+ echo " Detected Distribution: $$ distro"
133+ echo " Detected Version: $$ distro_version"
134+ echo " Detected Codename: $$ codename"
135+ echo " Detected Architecture: $$ arch"
136136
137137# Map arch to package arch
138138case " $arch " in
139139 x86_64)
140- if [[ " $distro " =~ ^(ubuntu| debian| kali)$ ]]; then
140+ if [[ " $$ distro" =~ ^(ubuntu| debian| kali)$ ]]; then
141141 arch=" amd64"
142142 fi
143143 ;;
144144 aarch64)
145- if [[ " $distro " =~ ^(ubuntu| debian| kali)$ ]]; then
145+ if [[ " $$ distro" =~ ^(ubuntu| debian| kali)$ ]]; then
146146 arch=" arm64"
147147 fi
148148 ;;
149149 arm64)
150150 : # This is effectively a noop
151151 ;;
152152 * )
153- echo " ERROR: Unsupported architecture: $arch "
153+ echo " ERROR: Unsupported architecture: $$ arch"
154154 exit 1
155155 ;;
156156esac
@@ -166,21 +166,21 @@ if ! check_installed; then
166166 base_url=" https://github.com/kasmtech/KasmVNC/releases/download/v${KASM_VERSION} "
167167
168168 echo " Installing KASM version: ${KASM_VERSION} "
169- case $distro in
169+ case $$ distro in
170170 ubuntu | debian | kali)
171171 bin_name=" kasmvncserver_$$ {codename}_${KASM_VERSION} _$$ {arch}.deb"
172- install_deb " $base_url /$bin_name "
172+ install_deb " $$ base_url/$ $ bin_name"
173173 ;;
174174 oracle | fedora | opensuse)
175175 bin_name=" kasmvncserver_$$ {distro}_$$ {distro_version}_${KASM_VERSION} _$$ {arch}.rpm"
176- install_rpm " $base_url /$bin_name "
176+ install_rpm " $$ base_url/$ $ bin_name"
177177 ;;
178178 alpine)
179179 bin_name=" kasmvnc.alpine_$$ {distro_version//./}_$$ {arch}.tgz"
180- install_alpine " $base_url /$bin_name "
180+ install_alpine " $$ base_url/$ $ bin_name"
181181 ;;
182182 * )
183- echo " Unsupported distribution: $distro "
183+ echo " Unsupported distribution: $$ distro"
184184 exit 1
185185 ;;
186186 esac
@@ -192,23 +192,23 @@ if command -v sudo &> /dev/null && sudo -n true 2> /dev/null; then
192192 kasm_config_file=" /etc/kasmvnc/kasmvnc.yaml"
193193 SUDO=sudo
194194else
195- kasm_config_file=" $HOME /.vnc/kasmvnc.yaml"
195+ kasm_config_file=" $$ HOME/.vnc/kasmvnc.yaml"
196196 SUDO=" "
197197
198198 echo " WARNING: Sudo access not available, using user config dir!"
199199
200- if [[ -f " $kasm_config_file " ]]; then
200+ if [[ -f " $$ kasm_config_file" ]]; then
201201 echo " WARNING: Custom user KasmVNC config exists, not overwriting!"
202202 echo " WARNING: Ensure that you manually configure the appropriate settings."
203203 kasm_config_file=" /dev/stderr"
204204 else
205205 echo " WARNING: This may prevent custom user KasmVNC settings from applying!"
206- mkdir -p " $HOME /.vnc"
206+ mkdir -p " $$ HOME/.vnc"
207207 fi
208208fi
209209
210- echo " Writing KasmVNC config to $kasm_config_file "
211- $SUDO tee " $kasm_config_file " > /dev/null << EOF
210+ echo " Writing KasmVNC config to $$ kasm_config_file"
211+ $$ SUDO tee " $ $ kasm_config_file" > /dev/null << EOF
212212network:
213213 protocol: http
214214 interface: 127.0.0.1
224224# This password is not used since we start the server without auth.
225225# The server is protected via the Coder session token / tunnel
226226# and does not listen publicly
227- echo -e " password\npassword\n" | vncpasswd -wo -u " $USER "
227+ echo -e " password\npassword\n" | vncpasswd -wo -u " $$ USER"
228228
229229get_http_dir () {
230230 # determine the served file path
@@ -240,41 +240,41 @@ get_http_dir() {
240240 fi
241241
242242 # Check the home directory for overriding values
243- if [[ -e " $HOME /.vnc/kasmvnc.yaml" ]]; then
244- d=$( grep -E ' ^\s*httpd_directory:.*$' " $HOME /.vnc/kasmvnc.yaml" | awk ' {print $$2}' )
243+ if [[ -e " $$ HOME/.vnc/kasmvnc.yaml" ]]; then
244+ d=$( grep -E ' ^\s*httpd_directory:.*$' " $$ HOME/.vnc/kasmvnc.yaml" | awk ' {print $$2}' )
245245 if [[ -n " $$ d" && -d " $$ d" ]]; then
246246 httpd_directory=$$ d
247247 fi
248248 fi
249- echo $httpd_directory
249+ echo $$ httpd_directory
250250}
251251
252252fix_server_index_file () {
253253 local fname=$$ {FUNCNAME[0]} # gets current function name
254254 if [[ $# -ne 1 ]]; then
255- error " $fname requires exactly 1 parameter:\n\tpath to KasmVNC httpd_directory"
255+ error " $$ fname requires exactly 1 parameter:\n\tpath to KasmVNC httpd_directory"
256256 fi
257- local httpdir=" $1 "
258- if [[ ! -d " $httpdir " ]]; then
259- error " $fname : $httpdir is not a directory"
257+ local httpdir=" $$ 1"
258+ if [[ ! -d " $$ httpdir" ]]; then
259+ error " $$ fname: $ $ httpdir is not a directory"
260260 fi
261- pushd " $httpdir " > /dev/null
261+ pushd " $$ httpdir" > /dev/null
262262
263263 cat << 'EOH ' > /tmp/path_vnc.html
264264${PATH_VNC_HTML}
265265EOH
266- $SUDO mv /tmp/path_vnc.html .
266+ $$ SUDO mv /tmp/path_vnc.html .
267267 # check for the switcheroo
268268 if [[ -f " index.html" && -L " vnc.html" ]]; then
269- $SUDO mv $httpdir /index.html $httpdir /vnc.html
269+ $$ SUDO mv $$ httpdir/index.html $ $ httpdir/vnc.html
270270 fi
271- $SUDO ln -s -f path_vnc.html index.html
271+ $$ SUDO ln -s -f path_vnc.html index.html
272272 popd > /dev/null
273273}
274274
275275patch_kasm_http_files () {
276276 homedir=$( get_http_dir)
277- fix_server_index_file " $homedir "
277+ fix_server_index_file " $$ homedir"
278278}
279279
280280if [[ " ${SUBDOMAIN} " == " false" ]]; then
@@ -287,17 +287,17 @@ VNC_LOG="/tmp/kasmvncserver.log"
287287printf " 🚀 Starting KasmVNC server...\n"
288288
289289set +e
290- vncserver -select-de " ${DESKTOP_ENVIRONMENT} " -disableBasicAuth > " $VNC_LOG " 2>&1
291- RETVAL=$?
290+ vncserver -select-de " ${DESKTOP_ENVIRONMENT} " -disableBasicAuth > " $$ VNC_LOG" 2>&1
291+ RETVAL=$$ ?
292292set -e
293293
294- if [[ $RETVAL -ne 0 ]]; then
295- echo " ERROR: Failed to start KasmVNC server. Return code: $RETVAL "
296- if [[ -f " $VNC_LOG " ]]; then
294+ if [[ $$ RETVAL -ne 0 ]]; then
295+ echo " ERROR: Failed to start KasmVNC server. Return code: $$ RETVAL"
296+ if [[ -f " $$ VNC_LOG" ]]; then
297297 echo " Full logs:"
298- cat " $VNC_LOG "
298+ cat " $$ VNC_LOG"
299299 else
300- echo " ERROR: Log file not found: $VNC_LOG "
300+ echo " ERROR: Log file not found: $$ VNC_LOG"
301301 fi
302302 exit 1
303303fi
0 commit comments