#!/bin/bash
echo "install depends now"

# 获取操作系统的 ID
distro_id=$(grep -w ID /etc/os-release | cut -d= -f2 | tr -d '"')

# 定义 repo 文件路径
repo_file_path="/etc/yum.repos.d/idste-AppStream.repo"

# 生成 repo 文件
echo "Creating repo file at $repo_file_path..."
cat <<EOF | sudo tee "$repo_file_path" > /dev/null
[IDsteAppStream]
name=IDste CEOC Server - AppStream
baseurl=http://mirrors.idste.org/rpm/$distro_id/\$releasever/\$basearch
enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ANOLIS
gpgcheck=0

[IDsteCommonStream]
name=IDste CEOC Server - CommonStream
baseurl=http://mirrors.idste.org/rpm/common/\$basearch
enabled=1
#gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ANOLIS
gpgcheck=0
EOF

echo "Repo file created and cache refreshed."

# 检查生成的文件内容
#echo "Repo file content:"
#cat "$repo_file_path"

# 删掉可能存在nginx
yum remove nginx-* -y
yum remove mosquitto -y
yum remove mariadb-* -y

echo "remove invalid rpm success"

wget http://mirrors.idste.org/anos8/rpmfusion-free-release-8.noarch.rpm 

yum install -y epel-release

yum clean all && yum makecache

rpm -Uvh ./rpmfusion-free-release-8.noarch.rpm

yum install -y supervisor

