Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(kasmvnc): refactor download logic to support multiple tools #323

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions kasmvnc/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,26 @@ check_installed() {
fi
}

# Function to download a file using wget, curl, or busybox as a fallback
download_file() {
local url=$1
local output=$2
if command -v wget &> /dev/null; then
wget $url -O $output
elif command -v curl &> /dev/null; then
curl -L $url -o $output
elif command -v busybox &> /dev/null; then
busybox wget -O $output $url
else
echo "Neither wget, curl, nor busybox is installed. Please install one of them to proceed."
exit 1
fi
}

# Function to install kasmvncserver for debian-based distros
install_deb() {
local url=$1
wget $url -O /tmp/kasmvncserver.deb
download_file $url /tmp/kasmvncserver.deb
sudo apt-get install --yes --no-install-recommends --no-install-suggests /tmp/kasmvncserver.deb
sudo adduser $USER ssl-cert
rm /tmp/kasmvncserver.deb
Expand All @@ -24,7 +40,7 @@ install_deb() {
# Function to install kasmvncserver for Oracle 8
install_rpm_oracle8() {
local url=$1
wget $url -O /tmp/kasmvncserver.rpm
download_file $url /tmp/kasmvncserver.rpm
sudo dnf config-manager --set-enabled ol8_codeready_builder
sudo dnf install oracle-epel-release-el8 -y
sudo dnf localinstall /tmp/kasmvncserver.rpm -y
Expand All @@ -35,7 +51,7 @@ install_rpm_oracle8() {
# Function to install kasmvncserver for CentOS 7
install_rpm_centos7() {
local url=$1
wget $url -O /tmp/kasmvncserver.rpm
download_file $url /tmp/kasmvncserver.rpm
sudo yum install epel-release -y
sudo yum install /tmp/kasmvncserver.rpm -y
sudo usermod -aG kasmvnc-cert $USER
Expand All @@ -45,15 +61,15 @@ install_rpm_centos7() {
# Function to install kasmvncserver for rpm-based distros
install_rpm() {
local url=$1
wget $url -O /tmp/kasmvncserver.rpm
download_file $url /tmp/kasmvncserver.rpm
sudo rpm -i /tmp/kasmvncserver.rpm
rm /tmp/kasmvncserver.rpm
}

# Function to install kasmvncserver for Alpine Linux
install_alpine() {
local url=$1
wget $url -O /tmp/kasmvncserver.tgz
download_file $url /tmp/kasmvncserver.tgz
tar -xzf /tmp/kasmvncserver.tgz -C /usr/local/bin/
rm /tmp/kasmvncserver.tgz
}
Expand Down