#!/bin/bash

# root 권한 체크
if [ "$EUID" -ne 0 ]; then
    echo "Error: 이 스크립트는 root 권한으로 실행해야 합니다." >&2
    exit 1
fi

# Ubuntu 버전 코드명 가져오기
. /etc/os-release
echo "Ubuntu 버전 코드명: ${VERSION_CODENAME}"

export DEBIAN_FRONTEND=noninteractive
# Cockpit 설치 (Backports)
apt update
apt install -y -t ${VERSION_CODENAME}-backports cockpit

apt install udisks2-lvm2 udisks2-btrfs


# 온도 센서 확장 설치: https://github.com/ocristopfer/cockpit-sensors
wget https://github.com/ocristopfer/cockpit-sensors/releases/latest/download/cockpit-sensors.tar.xz &&   tar -xf cockpit-sensors.tar.xz cockpit-sensors/dist && sudo  mv cockpit-sensors/dist /usr/share/cockpit/sensors &&   rm -r cockpit-sensors &&   rm cockpit-sensors.tar.xz

# Docker 확장 설치: https://github.com/chrisjbawden/cockpit-dockermanager
curl -L -o dockermanager.deb https://github.com/chrisjbawden/cockpit-dockermanager/releases/download/latest/dockermanager.deb && sudo dpkg -i dockermanager.deb


# Cockpit 서비스 활성화
systemctl enable --now cockpit
echo "Cockpit 설치 및 서비스 시작 완료"

