diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/install.sh | 139 | ||||
-rwxr-xr-x | scripts/installer.sh | 306 | ||||
-rwxr-xr-x | scripts/mkiso.sh | 92 |
3 files changed, 0 insertions, 537 deletions
diff --git a/scripts/install.sh b/scripts/install.sh deleted file mode 100755 index 89ee11b..0000000 --- a/scripts/install.sh +++ /dev/null @@ -1,139 +0,0 @@ -#!/bin/sh - -default_packages="base linux-libre xipkg dracut grub bash" -additional_packages="doas neofetch vim networkmanager" -default_key="davidovski https://xi.davidovski.xyz/keychain/xi.pub" - -XIPKG="/usr/bin/xi" -XIFLAGS="-ylu" -TMPDIR=/tmp -SYSROOT=$1 - -umask 0022 - -[ ! -e $XIPKG ] && { - git clone https://xi.davidovski.xyz/git/xiutils.git $TMPDIR/xiutils - make && make install - - git clone https://xi.davidovski.xyz/git/xipkg.git $TMPDIR/xipkg - make && make install -} - -echo "Please make sure that you have correctly formatted any partitions and mounted them as desired under $SYSROOT" - -[ $# -eq 0 ] && echo "Please specify where you would like to instal the system" && exit 1 - -[ -e $SYSROOT ] && { - printf "Remove existing system at $SYSROOT? [Y/n] " - read response - [ "$response" != "n" ] && rm -rf $SYSROOT && echo "removed $SYSROOT" -} - -$XIPKG $XIFLAGS sync -mkdir -p $SYSROOT -$XIPKG $XIFLAGS -r $SYSROOT bootstrap -mkdir -p $SYSROOT -$XIPKG $XIFLAGS -r $SYSROOT install $default_packages -$XIPKG $XIFLAGS -r $SYSROOT keyimport $default_key - -configuring_users () { - echo "Setting root password: " - xichroot $SYSROOT passwd - - echo - echo "Creating user" - read -p "Enter username: " username - xichroot $SYSROOT useradd -s /bin/bash -m $username - xichroot $SYSROOT passwd $username -} - -configuring_system () { - read -p "Enter system hostname: " hostname - - echo $hostname > $SYSROOT/etc/hostname - - cat > $SYSROOT/etc/hosts << EOF -127.0.0.1 localhost -::1 localhost -127.0.1.1 $hostname.local $hostname -EOF -} - -configuring_nameservers () { - echo "Configuring nameservers..." - - cat > $SYSROOT/etc/resolv.conf << EOF -nameserver 80.80.80.80 -EOF -} - -generating_fstab () { - echo "Generating fstab..." - xichroot $SYSROOT genfstab -U / > $SYSROOT/etc/fstab -} - -building_initramfs () { - echo "Building initramfs..." - kernel_version=$(ls $SYSROOT/usr/lib/modules | tail -1) - xichroot $SYSROOT mkdir /var/tmp - xichroot $SYSROOT dracut --kver $kernel_version 2>$TMPDIR/dracut.log > $TMPDIR/dracut.log -} - -installing_bootloader () { - read -p "Install Grub? [y]" r - [ "$r" != "n" ] && { - opts="--target=x86_64-efi" - - xichroot $SYSROOT lsblk - read -p "Enter efi directory: " efi_part - opts="$opts --efi-directory=$efi_part" - - read -p "Removable system? [y]" r - [ "$r" != "n" ] && { - opts="$opts --removable" - } - - xichroot $SYSROOT grub-install $opts - xichroot $SYSROOT grub-mkconfig -o /boot/grub/grub.cfg - } -} - -fixing_permissions () { - xichroot $SYSROOT chmod 755 / - xichroot $SYSROOT chmod 755 /usr - xichroot $SYSROOT chmod 755 /usr/bin - xichroot $SYSROOT chmod 755 /usr/lib -} - -downloading_additional_packages () { - echo "Syncing repos..." - xichroot $SYSROOT xi sync - echo "Downloading additional packages..." - xi -r $SYSROOT $XIFLAGS install $additional_packages -} - -steps=" -configuring_nameservers -generating_fstab -building_initramfs -configuring_system -installing_bootloader -configuring_users -fixing_permissions -downloading_additional_packages -" - -len=$(echo "$steps" | wc -l) -i=0 - -echo "Press [return] to enter configuration" -read response - -for step in $steps; do - i=$((i+1)) - clear - hbar -t -T "$(echo $step | sed "s/_/ /g")" $i $len - $step -done - -echo "Installation finished!" diff --git a/scripts/installer.sh b/scripts/installer.sh deleted file mode 100755 index 589574d..0000000 --- a/scripts/installer.sh +++ /dev/null @@ -1,306 +0,0 @@ -#!/bin/sh - -. /usr/lib/xitui.sh -. /usr/lib/glyphs.sh -. /usr/lib/colors.sh - -logfile="installer.log" -default_packages="base linux xipkg dracut grub mksh sudo neofetch vim tzdata" -additional_services="networkmanager xorg iwd" - -list_disks () { - lsblk -r | while read -r line; do - set - $line - [ "$6" = "disk" ] && { - printf '"/dev/%s (%s)" ' $1 $4 - } - done -} - -list_partitions () { - ls $1* - echo "none" -} - -partition_disk () { - t_msg "Partitioning $1..." - export EFI_PART=$11 - export SYS_PART=$12 - export SWAP_PART=none - echo " - unit: sectors - sector-size: 512 - - type=ef, start=2048, size=210000 - type=83 - " | sfdisk $1 >$logfile && - t_msg "Partitioned $1!" -} - -partition_disks () { - eval "t_radio 'Select install disk' $(list_disks)" - local selected=$(echo $T_RESULT | cut -d' ' -f1) - - t_yesno "${BLUE}Auto-partition $selected disk?\n${RED}(Warning: existing data will be overwritten)" && { - partition_disk $selected || return 1 - } || { - cfdisk $selected && { - t_radio 'Select primary system partition' $(list_partitions $selected) - export SYS_PART=$T_RESULT - - t_radio 'Select efi system partition' $(list_partitions $selected) - export EFI_PART=$T_RESULT - - t_radio 'Select swap partition' $(list_partitions $selected) - export SWAP_PART=$T_RESULT - } - } -} - -format_disks () { - t_msg "Formatting partitions... -${TABCHAR}System Partition -${TABCHAR}EFI Partition -" - - - [ -b "$SYS_PART" ] && mkfs.ext4 $SYS_PART > $logfile - t_msg "Formatting partitions... -${GREEN}${TABCHAR}System partition ${CHECKMARK} (ext4) -${TABCHAR}EFI Partition -" - - [ -b "$EFI_PART" ] && mkfs.fat -F 32 $EFI_PART > $logfile - t_msg "Formatting partitions... -${GREEN}${TABCHAR}System partition ${CHECKMARK} (ext4) -${GREEN}${TABCHAR}EFI Partition ${CHECKMARK} (fat32) -" - - [ -b "$SWAP_PART" ] && mkswap $SWAP_PART > $logfile - return 0 -} - -mount_disks () { - t_msg "Mounting disks..." - export sysroot=/xilinux.mnt - export efi_mntpoint=/xilinux.mnt/boot/efi - - [ ! -f "$sysroot" ] && mkdir -p $sysroot - - [ -b "$SYS_PART" ] && { - mount $SYS_PART $sysroot - } || { - t_prompt "${RED}No system partition is available!" - return 1 - } - - [ -b "$EFI_PART" ] && { - mkdir -p $efi_mntpoint - mount $EFI_PART $efi_mntpoint - } - - [ -b "$SWAP_PART" ] && swapon $SWAP_PART - return 0 -} - -bootstrap_system () { - t_msg "Creating directories..." - xi -vy -r $sysroot bootstrap >> $logfile -} - -install_base () { - t_msg "Installing packages..." - xi -vy -r $sysroot sync >> $logfile - xi -vy -r $sysroot install $default_packages >> $logfile -} - -copy_resolvconf () { - [ ! -d $sysroot/etc ] && mkdir $sysroot/etc - cp /etc/resolv.conf $sysroot/etc/resolv.conf -} - -sync_system () { - t_msg "Syncing system..." - xichroot $sysroot xi sync >> $logfile -} - -generate_fstab () { - t_msg "Generating fstab..." - xichroot $sysroot genfstab -U / > $sysroot/etc/fstab -} - -build_initramfs () { - t_msg "Build initramfs" - - kernel_version=$(ls $SYSROOT/usr/lib/modules | tail -1) - - mkdir -p $sysroot/var/tmp - xichroot $sysroot dracut --kver $kernel_version 2>&1 >> $logfile -} - -install_grub () { - t_yesno "Install grub?" && { - target="x86_64-efi" - opts="--target=$target --efi-directory=$efi_mntpoint" - - t_yesno "Install as removable system?" && opts="$opts --removable" - - t_msg "Installing grub for target $target..." - xichrooot $sysroot grub-install $opts >> $logfile - - t_msg "Creating grub configuration..." - xichrooot $sysroot grub-mkconfig -o /boot/grub/grub.cfg - } || return 0 -} - -enter_password () { - export password="" - t_input_hidden "Enter Password:" - passwd=$T_RESULT - t_input_hidden "Confirm Password:" - local cpasswd=$T_RESULT - - [ "$passwd" = "$cpasswd" ] || { - t_prompt "Passwords do not match!" - enter_password - } - -} - -configure_users () { - t_input_cmd "xichroot $sysroot passwd" "Enter root password" - - t_input "Enter username:" - local username=$T_RESULT - enter_password - - t_msg "Creating user..." - xichroot $sysroot useradd -s /bin/mksh -m $username - printf "$passwd\n$passwd\n" | xichroot $sysroot passwd $username - - t_yesno "Allow this user to use sudo?" && { - echo "$username ALL=(ALL:ALL) ALL" >> $sysroot/etc/sudoers - } - - t_yesno "Set a password for the root user?" && { - enter_password - printf "$passwd\n$passwd\n" | xichroot $sysroot passwd - } - - return 0 -} - -fix_permissions () { - xichroot $sysroot chmod 755 / - xichroot $sysroot chmod 755 /usr - xichroot $sysroot chmod 755 /usr/bin - xichroot $sysroot chmod 755 /usr/lib -} - -set_timezone () { - zoneinfo="$sysroot/usr/share/zoneinfo" - cp $zoneinfo/$1 $sysroot/etc/localtime - echo "$1" > /etc/timezone - - t_cls_ptrn - t_prompt "Successfully set timezone!" -} - -select_timezone () { - t_clean_ptrn - zoneinfo="$sysroot/usr/share/zoneinfo" - selection=$1 - t_paged_radio "Select your timezone: $selection" $(ls "$zoneinfo/$selection") "more..." - [] - selection="$selection/$T_RESULT" - - [ -f "$zoneinfo/$selection" ] && { - - t_yesno "Use $selection as your system timezone? " && { - set_timezone $selection - } || { - select_timezone - } - return 0 - } - - [ -d "$zoneinfo/$selection" ] && { - select_timezone $selection - } || { - t_prompt "The timezone you entered does not exist!" - select_timezone - } -} - -install_additional () { - t_check "Install and configure additional services: " $additional_services - local services=$T_RESULT - - for service in $services; do - service_$service - done -} - -service_networkmanager () { - t_msg "Installing NetworkManager..." - { - xi -ly -r $sysroot install networkmanager - xichroot $sysroot rc-update add networkmanager - } >> $logfile -} - -service_iwd () { - t_msg "Installing iwd..." - { - xi -ly -r $sysroot install iwd - xichroot $sysroot rc-update add iwd - } >> $logfile -} - -service_xorg () { - t_msg "Installing xorg..." - xi -r $sysroot install base-xorg base-fonts >> $logfile - t_check "Select video drivers:" $(xi search xd86-video- | cut -f2 -d/) - [ "${#T_RESULT}" != "0" ] && xi -r $sysroot install $T_RESULT - t_prompt "Installed basic xorg functionality -TODO: preconfigured window managers, for now you need to configure them yourself" -} - - -umount_disks () { - umount -R $sysroot - [ -b "$SWAP_PART" ] && swapoff $SWAP_PART - return 0 -} - -t_init -t_no_cur -checkroot - -steps="partition_disks -format_disks -mount_disks -bootstrap_system -install_base -copy_resolvconf -sync_system -generate_fstab -build_initramfs -configure_users -fix_permissions -select_timezone -install_additional -umount_disks -" - -for step in $steps; do - t_cls_ptrn - $step 2>> $logfile || { - t_prompt "${RED}An error occured!" - t_clean - exit 1 - } -done -t_prompt "Completed install!" - -t_clean diff --git a/scripts/mkiso.sh b/scripts/mkiso.sh deleted file mode 100755 index 264b802..0000000 --- a/scripts/mkiso.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh - -ISO_NAME="xilinux-$(date -u +%Y%m%d)" -ISO_LABEL="xilinux" -PUBLISHER="davidovski" -SYSLINUX_VER=6.04-pre1 - -XI_ARGS="" - -chroot=/tmp/chroot -isoroot=/tmp/iso -iso_pkgs="linux linux-firmware base dracut grub bash xipkg squashfs-tools lvm2 cryptsetup networkmanager stty" - -create_basesystem () { - xi $XI_ARGS sync - xi $XI_ARGS -r "$chroot" bootstrap - xi $XI_ARGS -r "$chroot" install "$iso_pkgs" - - cat > $chroot/etc/resolv.conf << EOF -nameserver 80.80.80.80 -EOF - - hostname=xilinux - echo xilinux > $chroot/etc/hostname - - cat > $chroot/etc/hosts << EOF -127.0.0.1 localhost -::1 localhost -127.0.1.1 $hostname.local $hostname -EOF - - xichroot $SYSROOT passwd - - xichroot "$chroot" -} - -build_initramfs () { - kernel_version=$(ls $chroot/usr/lib/modules | tail -1) - mkdir -p "$chroot"/var/tmp - xichroot "$chroot" dracut --nomdadmconf --nolvmconf --xz --add dmsquash-live --add bash --add convertfs --add pollcdrom --force --kver $kernel_version -} - -create_isoroot() { - mkdir -p $isoroot/ - cp $chroot/boot/vmlinuz-** $isoroot/vmlinuz - cp $chroot/boot/initramfs-** $isoroot/initrd.img - - mkdir -p $isoroot/isolinux -} - -install_syslinux () { - curl https://mirrors.edge.kernel.org/pub/linux/utils/boot/syslinux/Testing/$(echo $SYSLINUX_VER | cut -d'-' -f1)/syslinux-$SYSLINUX_VER.tar.xz > syslinux-$SYSLINUX_VER.tar.xz - - tar -C /tmp -xf syslinux-$SYSLINUX_VER.tar.xz - #cp syslinux-$SYSLINUX_VER - cp /tmp/syslinux-$SYSLINUX_VER/bios/core/isolinux.bin $isoroot/isolinux/isolinux.bin - cp /tmp/syslinux-$SYSLINUX_VER/bios/com32/elflink/ldlinux/ldlinux.c32 $isoroot/isolinux/ldlinux.c32 -} - -build_iso () { - cat > $isoroot/isolinux/isolinux.cfg << EOF -default 1 - -label 1 - kernel /vmlinuz - append initrd=/initrd.img splash console=tty0 console=ttyS0,9600 root=live:CDLABEL=xilinux rd.live.dir=/ rd.live.squashimg=filesystem.squashfs rd.live.debug=1 - - - -EOF - - mksquashfs $chroot $isoroot/filesystem.squashfs -noappend -no-progress -e "/proc/*" -e "/dev/*" -e "/sys/*" - genisoimage -r -V "$ISO_LABEL" -cache-inodes -J -l \ - -allow-limited-size -udf \ - -b isolinux/isolinux.bin -c isolinux/boot.cat \ - -no-emul-boot -boot-load-size 4 -boot-info-table \ - -p "$PUBLISHER <xi@davidovski.xyz>" \ - -A "$ISO_LABEL" -o "$ISO_NAME.iso" $isoroot -} - - -[ "$#" = 0 ] && { - create_basesystem - build_initramfs - create_isoroot - install_syslinux - build_iso -} || { - for task in $*; do - $task - done -} |