#!/bin/sh # # This script is licensed under GPL V3 or higher # # EXTRA_REPOS="" check_and_install_nongpl(){ wget -q -O /extra-packages.netinstall http://preseed/extra-packages.netinstall if [ -f "/extra-packages.netinstall" ]; then oIFS=$IFS IFS="|" repos="$(egrep -i 'repository' /extra-packages.netinstall |sed -r 's% +% %g'|cut -d' ' -f2- )" packages="$(egrep -i 'package' /extra-packages.netinstall |sed -r 's% +% %g'|cut -d' ' -f2- )" for r in $repos ; do echo deb $r >> /target/etc/apt/sources.list done; EXTRA_REPOS=$repos if [ "x$packages" != "x" ]; then in-target apt-get update in-target apt-get -y install $packages fi rm /extra-packages.netinstall IFS=$oIFS fi } check_and_run_extra_commands(){ wget -q -O /extra-commands.netinstall http://preseed/extra-commands.netinstall scr="/extra-commands.netinstall" if [ -f "$scr" ]; then oIFS=$IFS IFS="|" sh $scr rm $scr IFS=$oIFS fi } # First fix the sources list for generic lliurex flavours put_apt_conf(){ base="${1}" param="${2}" if [ -z "${param}" ]; then param="desktop" fi if [ -n "${force_server}" ]; then SERVER="${force_server}" else case $param in "client") SERVER="http://mirror/llx21" ;; # NOT AVAILABLE IN NETINSTALL # "server") # SERVER="file:///net/mirror/llxXXXX" # ;; "desktop") SERVER="http://mirror/llx21" ;; ## INFANTIL CASE AND OTHERS *) SERVER="http://mirror/llx21" ;; esac fi echo "# LliureX Net-Installation ${param}" > ${BASE_DIR}/etc/apt/sources.list echo "deb ${SERVER} focal main universe restricted multiverse" >> ${BASE_DIR}/etc/apt/sources.list echo "deb ${SERVER} focal-updates main universe restricted multiverse" >> ${BASE_DIR}/etc/apt/sources.list echo "deb ${SERVER} focal-security main universe restricted multiverse" >> ${BASE_DIR}/etc/apt/sources.list if [ "x$EXTRA_REPOS" != "x" ]; then oIFS=$IFS IFS="|" for r in $EXTRA_REPOS; do echo deb $r >> ${BASE_DIR}/etc/apt/sources.list done IFS=$oIFS fi # if [ "$param" = "infantil" ]; then # echo "deb ${SERVER} focal preschool" >> ${BASE_DIR}/etc/apt/sources.list # fi } set_session(){ in-target systemctl disable gdm || true in-target systemctl enable sddm || true } remove_resolv_conf(){ RESOLV=/target/etc/resolv.conf if [ -f $RESOLV ];then rm -f $RESOLV fi } remove_netplan_configs(){ cp -r --backup=numbered /target/etc/netplan /target/etc/old.netplan.configs mv --backup=numbered /target/etc/netplan /tmp mkdir -p /target/etc/netplan } create_netplan_configs(){ BASE="/target" FILENAME="01-network-manager-all.yaml" LOCATION="/etc/netplan" fullpath="${BASE}${LOCATION}/${FILENAME}" if [ ! -f "${fullpath}" ];then touch ${fullpath} echo '#Let NetworkManager manage all devices on this system' >> ${fullpath} echo 'network:' >> ${fullpath} echo ' version: 2' >> ${fullpath} echo ' renderer: NetworkManager' >> ${fullpath} fi } log_in_target(){ d="$(date)" if [ -d "/target/var/log" ];then echo "$d NETINSTALL LOG: ""$@" >> /target/var/log/netinstall fi } fix_uefi_boot(){ if [ -d "/sys/firmware/efi/vars" ];then if [ -d "/target/boot/efi/EFI" ];then if [ -d "/target/boot/efi/EFI/neon" ];then cp -R /target/boot/efi/EFI/neon /target/boot/efi/EFI/ubuntu log_in_target "Netinstall completed (UEFI mode)" else log_in_target "Not detected neon dir inside EFI dir" fi else log_in_target "Not detected EFI dir on /target/boot/efi" fi else log_in_target "Netinstall completed (BIOS mode)" fi } # Initial param checking if [ -z "${1}" ]; then exit 1 else BASE_DIR="$1" fi if [ ! -d "${BASE_DIR}" -o ! -f "${BASE_DIR}/etc/apt/sources.list" ];then exit 1 fi class=$(cat /proc/cmdline |sed -r "s%.*preseed/url=http://preseed/([a-zA-Z_-]+).cfg\.*%\1%i;tx;d;:x") base_class=$(echo $class|cut -d- -f1|tr [A-Z] [a-z]) force_server=$(cat /proc/cmdline |sed -r "s%.*force_server=(http://[0-9a-zA-Z_/.:-]+).*%\1%i;tx;d;:x") check_and_install_nongpl put_apt_conf ${BASE_DIR} ${base_class} # in-target dpkg --add-architecture i386 check_and_run_extra_commands set_session remove_resolv_conf remove_netplan_configs create_netplan_configs fix_uefi_boot #if [ "x$base_class" = "xinfantil" ]; then # in-target apt-get update # in-target apt-get -y install lliurex-meta-infantil #fi exit 0