Automated installs

Forum Forums antiX-development antiX Respins Automated installs

  • This topic has 20 replies, 4 voices, and was last updated Dec 1-12:57 pm by Keeely.
Viewing 6 posts - 16 through 21 (of 21 total)
  • Author
    Posts
  • #46188
    Member
    Keeely
    Helpful
    Up
    0
    :D

    It looks like I have a script that mostly works. My ‘setup.sh’ referred to in the other script. So long as I create the partition first, it’s just an answerfile that’s needed. The only problem is, the cli-installer clearly copies my doctored inittab out of the running root because my install antiX ends up including it. I guess I was hoping that file came from some kind of ‘base-files.deb’ package, but it doesn’t, so I’ll have to do something about that, maybe put aside the original in the root of the ISO. Not rocket science at least.

    Here’s the script, with a safety feature of checking the MBR is blank, just in case you’re silly enough to boot this ISO in a machine that you care about this should stop you losing all your data. It doesn’t set timezone or anything. One remaining problem is the prompt for cd-rom removal on poweroff, I have to figure out how to disable that, and just make it power off, then it’s on to installing some extra packages.

    EDIT: I’ve added an extra line, to edit live-umount and remove the line ‘read x’ because it includes an ENTER prompt which prevents a clean shutdown.

    DEVICE="/dev/sda"
    
    # Dump the mbr somewhere
    dd if=$DEVICE of=/tmp/mbr.bin bs=512 count=1
    # Dump a file of zeros of the same size
    dd if=/dev/zero of=/tmp/zero.bin bs=512 count=1
    
    # Only format if the disk is blank
    diff /tmp/mbr.bin /tmp/zero.bin >/dev/null
    
    if [ $? -ne 0 ]
    then
        echo "Disk appears to be formatted already, aborting."
        return
    fi
    
    # Partition the entire disk with single partition, no swap
    echo start=2048 | sfdisk $DEVICE
        
    # format it.
    mkfs.ext4 ${DEVICE}1
    
    cp /live/boot-dev/inittab_backup /etc/inittab
    cp /live/boot-dev/bashrc_backup /root/.bashrc
    
    cli-installer $DEVICE < /live/boot-dev/answers.txt
        
    cat <<ENDOFANSWERS | cli-installer
    n
    sda1
    y
    n
    n
    n
    y
    y
    antix1
    n
    n
    n
    n
    n
    n
    root
    root
    root
    n
    
    ENDOFANSWERS
    
    # Update live-umount to avoid any prompts for keypress.
    sed -i -e 's/^[[:space:]]*read x$//g' /live/bin/live-umount
    poweroff
    • This reply was modified 6 months, 3 weeks ago by Keeely.
    • This reply was modified 6 months, 3 weeks ago by Keeely.
    #46191
    Member
    Keeely
    Helpful
    Up
    0
    :D

    I got rid of this so it is not worth discussing and distracting the automatic installs discussion

    Writing GUIs is IMHO incredibly tedious unless you spend most of your day doing it already. Last one I did was for my daughter’s maths:
    https://github.com/keeely/timestables/blob/master/maths.py

    It wasn’t a particularly pleasant experience.

    • This reply was modified 6 months, 3 weeks ago by Brian Masinick.
    #46201
    Member
    skidoo
    Helpful
    Up
    0
    :D

    I need to change inittab which is in the squashfs,

    there’s nothing to round-trip decompress->compress a squashfs (and have it recreated the same way)

    The “round-trip” would be to mount the squashfs, then copy the contents into a working directory. Edit content within the working directory, then mksquashfs.

    #46207
    Member
    Keeely
    Helpful
    Up
    0
    :D

    The “round-trip” would be to mount the squashfs, then copy the contents into a working directory. Edit content within the working directory, then mksquashfs.

    I guess I need to clarify what I mean by ’round trip’, I mean you end up with the same file checksum when you’ve finished assuming no explicit changes. What I don’t want to do is come to a support forum asking questions about why my OS doesn’t work, because one of the sticky bits on some obscure file got changed.

    The closest I got to the round-trip was squashfs-tools-ng tar conversion. It’s not quite ideal but it does come with a diff tool for two squashfs filesystems. Unfortunately this tool always gives differences after a re-pack because some files get demoted from having extended attributes, but their effective attributes are actually the same after this. So I always have some differences to look through and check. Fortunately there aren’t very many.

    #46237
    Member
    Keeely
    Helpful
    Up
    0
    :D

    I updated my setup.sh script above. I needed to edit the file /live/bin/live-umount to prevent it from giving a prompt to the user. When it gets to the DVD-ROM (presumably one of the last things to be unmounted) it prompts the user to eject the DVD. The only way to prevent it from doing that is to unmount the DVD first. Unfortunately to do that I need to do most of the work of live-umount myself, so I simply ‘edited’ it in-place using sed to remove the prompt line. Whilst I could presumably just sync the FS and force an immediate shutdown bypassing that script I wasn’t sure if there would be any side-effects of this so I kept the execution path as close as possible to a ‘normal’ Core install.

    Next step is to get openssh-server automatically installed and running so I can communicate with the machine.

    #46247
    Member
    Keeely
    Helpful
    Up
    0
    :D

    I had to make another change to install openssh automatically. I needed to wait for the network to come up. In the end I did this, it’s really crude, but it seems to work:

    until ping -q -c 1 -W 1 debian.org >/dev/null; do
      echo "Waiting for network to come up, and debian.org to resolve..."
      sleep 2
    done
    
    apt update
    apt install --assume-yes openssh-server

    Also, if you want to try some of this stuff out without creating a virtual machine manually, here’s a VirtualBox script I’m using to test this. The poweroff/unregister will error if you haven’t run it before, but it works for the most part.

    #!/bin/bash
    VM_NAME=antiX_test
    ISO_NAME=new_antix.iso
    DISK_NAME=antiXtest.vdi
    VBoxManage controlvm $VM_NAME poweroff
    VBoxManage unregistervm $VM_NAME --delete
    VBoxManage createvm --name $VM_NAME --register
    VBoxManage modifyvm $VM_NAME --memory 2048
    VBoxManage modifyvm $VM_NAME --audio none
    VBoxManage modifyvm $VM_NAME --nic1 nat
    VBoxManage modifyvm $VM_NAME --boot1 dvd
    VBoxManage modifyvm $VM_NAME --graphicscontroller vmsvga
    VBoxManage modifyvm $VM_NAME --natpf1 "guestssh,tcp,,2222,,22"
    VBoxManage storagectl $VM_NAME --name IDE --add ide
    VBoxManage createmedium disk --filename $DISK_NAME --size 20480
    VBoxManage storageattach $VM_NAME --storagectl IDE --port 0 --device 0 --type hdd --medium $DISK_NAME
    VBoxManage storageattach $VM_NAME --storagectl IDE --port 1 --device 0 --type dvddrive --medium $ISO_NAME
    

    Then, ssh -p 2222 root@localhost will login, assuming you’ve changed /etc/ssh/sshd_config to allow that. Going to need to write something to do that as well I guess.

    • This reply was modified 6 months, 3 weeks ago by Keeely.
Viewing 6 posts - 16 through 21 (of 21 total)
  • You must be logged in to reply to this topic.