implement installer for Debian, Fedora and CentOS

This commit is contained in:
Late Night Defender 2024-05-17 15:39:55 +07:00
parent d36910474a
commit 16cd4a20e5

View file

@ -7,11 +7,13 @@ import(
func instDepsUbuntu() {
fmt.Printf("\033[1;32mInstalling OpenSSL from Ubuntu repo\033[0m\n")
ExecSystem("/usr/bin/apt update")
ExecSystem("/usr/bin/apt install -y openssl")
}
func instDepsDebian() {
fmt.Printf("\033[1;32mInstalling OpenSSL from Debian repo\033[0m\n")
ExecSystem("/usr/bin/apt update")
ExecSystem("/usr/bin/apt install -y openssl")
}
@ -20,18 +22,14 @@ func instDepsFedora() {
ExecSystem("/usr/bin/dnf install -y openssl")
}
func instDepsRedHat() {
fmt.Printf("\033[1;32mInstalling OpenSSL\033[0m\n")
func instDepsCentOS() {
fmt.Printf("\033[1;32mInstalling OpenSSL from CentOS repo\033[0m\n")
ExecSystem("/usr/bin/dnf install -y openssl")
}
func instDepsOpenSUSE() {
fmt.Printf("\033[1;32mInstalling OpenSSL\033[0m\n")
ExecSystem("/usr/bin/zypper install -y openssl")
}
func instDockerUbuntu() {
fmt.Printf("\033[1;32mInstalling Docker CE from official repo\033[0m\n")
fmt.Printf("\033[1;32mInstalling Docker Engine from official repo\033[0m\n")
docker_install := `
apt update
install -m 0755 -d /etc/apt/keyrings
@ -44,26 +42,61 @@ func instDockerUbuntu() {
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin`
apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl enable --now docker`
ExecSystem(docker_install)
}
func instDockerDebian() {
fmt.Println()
fmt.Printf("\033[1;32mInstalling Docker Engine from official repo\033[0m\n")
docker_install := `
apt update
apt install ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl enable --now docker`
ExecSystem(docker_install)
}
func instDockerFedora() {
fmt.Println()
fmt.Printf("\033[1;32mInstalling Docker Engine from official repo\033[0m\n")
docker_install := `
dnf -y install dnf-plugins-core
dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl enable --now docker`
ExecSystem(docker_install)
}
func instDockerRedHat() {
fmt.Println()
func instDockerCentOS() {
fmt.Printf("\033[1;32mInstalling Docker Engine from official repo\033[0m\n")
docker_install := `
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
systemctl enable --now docker`
ExecSystem(docker_install)
}
func instDockerOpenSUSE() {
fmt.Println()
}
func instDeps() {
if getDistro() == "ubuntu" {
@ -75,12 +108,9 @@ func instDeps() {
} else if getDistro() == "fedora" {
instDepsFedora()
instDockerFedora()
} else if getDistro() == "redhat" {
instDepsRedHat()
instDockerRedHat()
} else if getDistro() == "opensuse" {
instDepsOpenSUSE()
instDockerOpenSUSE()
} else if getDistro() == "centos" {
instDepsCentOS()
instDockerCentOS()
} else {
fmt.Println("OS not supported")
os.Exit(3)