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

Create A Pull request #515

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
221 changes: 221 additions & 0 deletions Depend-on/Bash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
#!/bin/bash

identify_and_run() {
os=$(uname)
if [ "$os" = "Linux" ]; then
distro=$(lsb_release -si)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the lsb_release command is unavailable?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well they're screwed for the moment in future I will test with all operating systems but maybe now we could keep it like that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if the plan is to stick with lsb_release for this detection, this just highlights the other comment I made - that the default case for the subsequent case statement should not be to assume that SuSE is in use, but to provide an error that tells the user something useful: "Your distribution was not detected, please make sure your distribution supports the lsb_release command" - or something like that.

case "$distro" in
CentOS|RedHatEnterpriseServer)
CooperDActor marked this conversation as resolved.
Show resolved Hide resolved
if command -v dnf &>/dev/null; then
echo "The following packages will be installed:"
echo "FFmpeg"
echo "libavcodec-devel libavformat-devel libavutil-devel libswscale-devel"
echo "freerdp2-devel"
echo "pango-devel"
echo "libssh2-devel"
echo "libtelnet-devel"
echo "libvncserver-devel"
echo "libwebsockets-devel"
echo "pulseaudio-libs-devel"
echo "openssl-devel"
echo "libvorbis-devel"
echo "libwebp-devel"

read -p "Do you understand? (yes/no): " choice
CooperDActor marked this conversation as resolved.
Show resolved Hide resolved
case "$choice" in
yes|YES|y|Y)
sudo dnf install -y FFmpeg
sudo dnf install -y libavcodec-devel libavformat-devel libavutil-devel libswscale-devel
sudo dnf install -y freerdp2-devel
sudo dnf install -y pango-devel
sudo dnf install -y libssh2-devel
sudo dnf install -y libtelnet-devel
sudo dnf install -y libvncserver-devel
sudo dnf install -y libwebsockets-devel
sudo dnf install -y pulseaudio-libs-devel
sudo dnf install -y openssl-devel
sudo dnf install -y libvorbis-devel
sudo dnf install -y libwebp-devel
CooperDActor marked this conversation as resolved.
Show resolved Hide resolved
;;
*)
echo "Installation cancelled."
;;
esac
elif command -v yum &>/dev/null; then
echo "The following packages will be installed:"
echo "FFmpeg"
echo "libavcodec-devel libavformat-devel libavutil-devel libswscale-devel"
echo "freerdp2-devel"
echo "pango-devel"
echo "libssh2-devel"
echo "libtelnet-devel"
echo "libvncserver-devel"
echo "libwebsockets-devel"
echo "pulseaudio-libs-devel"
echo "openssl-devel"
echo "libvorbis-devel"
echo "libwebp-devel"

read -p "Do you understand? (yes/no): " choice
case "$choice" in
yes|YES|y|Y)
sudo yum install -y FFmpeg
sudo yum install -y libavcodec-devel libavformat-devel libavutil-devel libswscale-devel
sudo yum install -y freerdp2-devel
sudo yum install -y pango-devel
sudo yum install -y libssh2-devel
sudo yum install -y libtelnet-devel
sudo yum install -y libvncserver-devel
sudo yum install -y libwebsockets-devel
sudo yum install -y pulseaudio-libs-devel
sudo yum install -y openssl-devel
sudo yum install -y libvorbis-devel
sudo yum install -y libwebp-devel
;;
*)
echo "Installation cancelled."
;;
esac
else
echo "Neither dnf nor yum found. Unsupported package manager."
fi
;;
Ubuntu|Debian)
CooperDActor marked this conversation as resolved.
Show resolved Hide resolved
if command -v apt-get &>/dev/null; then
echo "The following packages will be installed:"
echo "ffmpeg"
echo "libavcodec-dev libavformat-dev libavutil-dev libswscale-dev"
echo "freerdp2-dev"
echo "libpango1.0-dev"
echo "libssh2-1-dev"
echo "libtelnet-dev"
echo "libvncserver-dev"
echo "libwebsockets-dev"
echo "libpulse-dev"
echo "libssl-dev"
echo "libvorbis-dev"
echo "libwebp-dev"

read -p "Do you understand? (yes/no): " choice
case "$choice" in
yes|YES|y|Y)
sudo apt-get install -y ffmpeg
sudo apt-get install -y libavcodec-dev libavformat-dev libavutil-dev libswscale-dev
sudo apt-get install -y freerdp2-dev
sudo apt-get install -y libpango1.0-dev
sudo apt-get install -y libssh2-1-dev
sudo apt-get install -y libtelnet-dev
sudo apt-get install -y libvncserver-dev
sudo apt-get install -y libwebsockets-dev
sudo apt-get install -y libpulse-dev
sudo apt-get install -y libssl-dev
sudo apt-get install -y libvorbis-dev
sudo apt-get install -y libwebp-dev
;;
*)
echo "Installation cancelled."
;;
esac
elif command -v dpkg &>/dev/null; then
echo "The following packages will be installed:"
echo "ffmpeg"
echo "libavcodec-dev libavformat-dev libavutil-dev libswscale-dev"
echo "freerdp2-dev"
echo "libpango1.0-dev"
echo "libssh2-1-dev"
echo "libtelnet-dev"
echo "libvncserver-dev"
echo "libwebsockets-dev"
echo "libpulse-dev"
echo "libssl-dev"
echo "libvorbis-dev"
echo "libwebp-dev"

read -p "Do you understand? (yes/no): " choice
case "$choice" in
yes|YES|y|Y)
sudo dpkg -i <package.deb>
;;
*)
echo "Installation cancelled."
;;
esac
else
echo "Neither apt-get nor dpkg found. Unsupported package manager."
fi
;;
*)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think making the assumption that anything that isn't Ubuntu or EL is automatically SuSE is the right thing to do. While EL-based, Debian-based, and SuSE-based covers most available distributions, there are others out there (like Alpine, which is what we use for the Docker image) and other ways of managing packages.

If you/we don't want to build out and maintain package commands for each of these, that's fine, but then the *) should throw an error, not assume that everything not EL or Ubuntu-based is SuSE.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any thing simpler for my 12yo brain to understand?

what I believe your talking about is the pkg managers and not working if it errors all of the time

see the redundancy talk of my idea

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference would be to create a "SuSE" section of the case statement above this * (default) handler, and put the SuSE commands in that section, and then use the * area to provide feedback that the distribution is either undetected or unsupported. Roughly, something like this:

case "distro" in
    CentOS|RedHatEnterpriseServer|Rocky)
        // Run EL commands here
    Debian|Ubuntu|Xubuntu)
        // Run Debian commands here
    SuSE)
        // Run SuSE commands here
    *)
        // Throw error output and exit - distro not detected, not supported, etc.
esac

if command -v zypper &>/dev/null; then
echo "The following packages will be installed:"
echo "FFmpeg"
echo "libavcodec-devel libavformat-devel libavutil-devel libswscale-devel"
echo "freerdp2-devel"
echo "pango-devel"
echo "libssh2-devel"
echo "libtelnet-devel"
echo "libvncserver-devel"
echo "libwebsockets-devel"
echo "pulseaudio-libs-devel"
echo "openssl-devel"
echo "libvorbis-devel"
echo "libwebp-devel"

read -p "Do you understand? (yes/no): " choice
case "$choice" in
yes|YES|y|Y)
sudo zypper install -y FFmpeg
sudo zypper install -y libavcodec-devel libavformat-devel libavutil-devel libswscale-devel
sudo zypper install -y freerdp2-devel
sudo zypper install -y pango-devel
sudo zypper install -y libssh2-devel
sudo zypper install -y libtelnet-devel
sudo zypper install -y libvncserver-devel
sudo zypper install -y libwebsockets-devel
sudo zypper install -y pulseaudio-libs-devel
sudo zypper install -y openssl-devel
sudo zypper install -y libvorbis-devel
sudo zypper install -y libwebp-devel
;;
*)
echo "Installation cancelled."
;;
esac
elif command -v pkg &>/dev/null; then
echo "The following packages will be installed:"
echo "FFmpeg"
echo "libavcodec-devel libavformat-devel libavutil-devel libswscale-devel"
echo "freerdp2-devel"
echo "pango-devel"
echo "libssh2-devel"
echo "libtelnet-devel"
echo "libvncserver-devel"
echo "libwebsockets-devel"
echo "pulseaudio-libs-devel"
echo "openssl-devel"
echo "libvorbis-devel"
echo "libwebp-devel"

read -p "Do you understand? (yes/no): " choice
case "$choice" in
yes|YES|y|Y)
sudo pkg install -y <package>
;;
*)
echo "Installation cancelled."
;;
esac
else
echo "Unsupported Linux distribution."
fi
;;
esac
else
echo "Unsupported operating system."
fi
}

identify_and_run


#done
#Rick Astley
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try not Rick-roll people as part of the source code ;-).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for noticing its like a little easter egg lol but if I cant then I won't put rick Astley

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will put his video there nah when you say no I will follow that to the T