Support fedora 38, fix for debian and arch, added a script to easily make a lxc on proxmox.

This commit is contained in:
2023-06-19 13:47:33 +02:00
parent 6f824c0838
commit 98b1f563c1
2 changed files with 68 additions and 5 deletions

57
create-lxc.sh Normal file
View File

@@ -0,0 +1,57 @@
#!/bin/bash
set -e
CTID=""
CONTAINER_NAME=""
DISTRO=""
ROOTPASS=""
while getopts ":c:n:d:p:" flag; do
case "${flag}" in
c)
CTID="${OPTARG}"
;;
n)
CONTAINER_NAME="${OPTARG}"
;;
d)
DISTRO="${OPTARG}"
;;
p)
ROOTPASS="${OPTARG}"
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
if [[ -z $CTID || -z $CONTAINER_NAME || -z $DISTRO || -z $ROOTPASS ]]; then
echo "CTID, CONTAINER_NAME, DISTRO, ROOTPASS arguments are required."
echo "Usage: ./create-lxc.sh -c <CTID> -n <CONTAINER_NAME> -d <DISTRO> -p <ROOTPASS>"
exit 1
fi
template=$(pveam available | grep $DISTRO | sort -rV | head -n 1 | awk '{print $2}')
if [[ -z $template ]]; then
echo "$DISTRO template not found."
exit 1
fi
template=$(pveam list local | grep $template | awk '{print $1}')
if [[ -z $template ]]; then
echo "$DISTRO template not found. Downloading..."
pveam download local $template
fi
pct create $CTID $template --hostname $CONTAINER_NAME --memory 1024 --storage local-lvm --net0 name=eth0,bridge=vmbr0,firewall=1,ip=dhcp --unprivileged --ostype $DISTRO --password="$ROOTPASS"
echo -e "lxc.cgroup.devices.allow: c 10:200 rwm\nlxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file" >> /etc/pve/lxc/$CTID.conf
pct start $CTID
pct status $CTID | grep "status: running" || sleep 10
echo lxc now running

View File

@@ -3,19 +3,25 @@ set -e
update_package_manager() {
if command -v apt-get &>/dev/null; then
echo "Detected APT package manager."
if command -v sudo &>/dev/null; then
echo "sudo is installed."
else
su -c "apt-get update && apt-get install sudo -y"
fi
echo "Detected APT package manager."
sudo apt-get update && sudo apt-get upgrade -y
elif command -v dnf &>/dev/null; then
echo "Detected DNF package manager."
sudo dnf update -y
elif command -v pacman &>/dev/null; then
echo "Detected Pacman package manager."
sudo pacman-key --init && sudo pacman-key --populate && sudo pacman -Syu --noconfirm
if command -v sudo &>/dev/null; then
echo "sudo is installed."
sudo pacman-key --init && sudo pacman-key --populate && sudo pacman -Syu --noconfirm
else
su -c "pacman-key --init && pacman-key --populate && pacman -Syu --noconfirm && pacman -Sy sudo --noconfirm"
fi
else
echo "Unable to detect the package manager."
exit 1
@@ -24,11 +30,11 @@ update_package_manager() {
install_requirements() {
if command -v apt-get &>/dev/null; then
sudo apt install chromium chromium-driver network-manager network-manager-openvpn openvpn python3 python3-pip python3-tk xvfb git wget unzip nano -y
sudo apt install chromium chromium-driver network-manager network-manager-openvpn openvpn python3 python3-pip python3-tk xvfb git wget curl unzip nano -y
elif command -v dnf &>/dev/null; then
sudo dnf install chromium chromium-driver NetworkManager NetworkManager-openvpn openvpn python python*-pip python*-tkinter xorg-x11-server-Xvfb git wget unzip nano -y
sudo dnf install chromium chrom*driver NetworkManager NetworkManager-openvpn openvpn python python*-pip python*-tkinter xorg-x11-server-Xvfb git wget unzip nano -y
elif command -v pacman &>/dev/null; then
sudo pacman -Sy chromium networkmanager networkmanager-openvpn openvpn python python-pip xorg-server-xvfb git wget unzip nano base-devel --noconfirm
sudo pacman -Sy chromium networkmanager networkmanager-openvpn openvpn python python-pip xorg-server-xvfb git curl wget unzip nano base-devel --noconfirm
fi
}