oginstaller/graf_installer/buildlib.sh

121 lines
3.0 KiB
Bash

#!/usr/bin/bash
function set_root_passwd(){
echo "root:root" | chpasswd
}
function setup_sources_list () {
echo "Setting up sources.list"
cat <<EOF > $CHROOT_DIR/etc/apt/sources.list
deb $DEBOOT_STRAP_URL noble main restricted universe multiverse
deb-src $DEBOOT_STRAP_URL noble main restricted universe multiverse
deb $DEBOOT_STRAP_URL noble-security main restricted universe multiverse
deb-src $DEBOOT_STRAP_URL noble-security main restricted universe multiverse
deb $DEBOOT_STRAP_URL noble-updates main restricted universe multiverse
deb-src $DEBOOT_STRAP_URL noble-updates main restricted universe multiverse
EOF
apt update -y
apt-get -y upgrade
}
function configure_divert() {
echo "Configuring divert"
dbus-uuidgen > /etc/machine-id
mkdir -p /var/lib/dbus/
ln -fs /etc/machine-id /var/lib/dbus/machine-id
dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl
}
function mount_proc_sys_dev() {
echo "Mounting proc, sys and dev"
mount -t proc proc /proc
mount -t sysfs sys /sys
mount -t devpts devpts /dev/pts
}
function install_packages() {
echo "Installing packages"
apt install -y $@
}
function install_non_interactive() {
echo "Installing packages non interactive"
apt install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" $@
}
function install_no_recommends() {
echo "Installing packages without recommends"
apt install -y --no-install-recommends $@
}
function setup_chroot() {
echo "Setting up chroot"
dbus-uuidgen > /etc/machine-id
apt update -y
ln -fs /etc/machine-id /var/lib/dbus/machine-id
ln -s /bin/true /sbin/initctl
}
function remove_unneeded_packages() {
echo "Removing unneeded packages"
apt remove -y --purge --auto-remove snapd
}
function reconfigure_locales() {
echo "Configuring locales"
sed -i 's/# es_ES.UTF-8 UTF-8/es_ES.UTF-8 UTF-8/' /etc/locale.gen
sed -i 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
locale-gen
ln -sf /usr/share/zoneinfo/Europe/Madrid /etc/localtime
echo "Europe/Madrid" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
}
function reconfigure_network_manager() {
echo "Configuring network manager"
mkdir -p /etc/NetworkManager
cat <<EOF > /etc/NetworkManager/NetworkManager.conf
[main]
plugins=keyfile
[keyfile]
unmanaged-devices=none
EOF
mkdir -p /etc/NetworkManager/system-connections/
cat <<EOL > /etc/NetworkManager/system-connections/dhcp-all.nmconnection
[connection]
id=Cable
type=ethernet
autoconnect=true
[ipv4]
method=auto
EOL
systemctl enable NetworkManager
}
function clean (){
truncate -s 0 /etc/machine-id
rm /sbin/initctl
dpkg-divert --rename --remove /sbin/initctl
apt-get clean
rm -rf /tmp/* ~/.bash_history
umount /proc
umount /sys
umount /dev/pts
export HISTSIZE=0
}
function user_add() {
useradd -m -s /bin/bash -G sudo og
echo "og:og" | chpasswd
}