Quantcast
Channel: FedoraForum.org
Viewing all articles
Browse latest Browse all 35964

[BASH] Fun Project: CLI/TUI Installer for Fedora

$
0
0
Heyas

As I am a CLI lover, without denying the benefits for a GUI, and the recent changes with Anaconda, i'd like to take the challenge for fun and as a hobby enthusiast and write a text based installer.
Due to my almost 20 years of MS Windows experience where i started with basic, i want to write the installer in bash, mainly and for now only for fedora, but with options (handlers) to 'let one easy' add other distributions.

Some thoughts:
* Since Fedora has a release cycle of 6 months, we're doing installations quite frequent, so providing a file for repeative configuration might be of hand.
--> Argument handler
* Assumption: Advanced people prefer to set values by hand (eg: vi,fdisk)
* Assumption: Freshlings like to be guided (menus and handlers)
* Requires: Subs to be reused for both

I have never ever before written an 'OS' installer, and beside automated installs, i have not been eager to try such a challenging task.

So here are my thoughts of what might be required to handler, at this point, not in order:
dracut?
grub1/2
yum
rpm
packages (yum groups/xml?)
fdisk
gdisk
keybd
hostname
time-zone
user/s

Since i want to make it creating a workfile, and enable the user to easy reuse and modify that workfile as template for further installations, this workfile is plain text/code.

Lets focus now on what will be required to store, this is where i need your help:
(since everything is written in bash, why not make the config file bash too?)
PHP Code:

#!//bin/bash
# Installation config created on $(hostname) - $(date)
    /*    This (intended text) will NOT be in the actual config file, 
        it\'ll be placed to the script handler.
    #
    #    Clear all used arrays 
    #
        [ ! -z ${mnt_point[0]} ] && mnt_point[]=""
        [ ! -z ${mnt_mb[0]} ] && mnt_mb[]=""
        [ ! -z ${mnt_dev[0]} ] && mnt_dev[]=""
        [ ! -z ${mnt_lbl[0]} ] && mnt_lbl[]=""
        [ ! -z ${mnt_del[0]} ] && mnt_del[]=""
        [ ! -z ${mnt_format[0]} ] && mnt_format[]=""
        [ ! -z ${usr_name[0]} ] && usr_name[]=""
        [ ! -z ${usr_grp[0]} ] && usr_grp[]=""
        [ ! -z ${usr_pw[0]} ] && usr_pw[]=""
        [ ! -z ${usr_gid[0]} ] && usr_gid[]=""
        [ ! -z ${repo_name[0]} ] && repo_name[]=""
        [ ! -z ${repo_url[0]} ] && repo_url[]=""
        [ ! -z ${wifi_spotl[0]} ] && wifi_spot[]=""
        [ ! -z ${wifi_pw[0]} ] && wifi_pw[]=""
    */
#
#    User Config
#
    
country=CH            # |
    
language=de            # L-> de_CH.UTF-8
    
keyb=sg
    hostname
=thisname
    wifi_spot
[0]=mySpot        # if there is no wifi data, p3p1/eth0 is expected
    
wifi_pw[0]=password
    
# --
    
usr_name[0]=sea
    usr_grp
[0]=""
    
usr_pw[0]=somepassword
    usr_gid
[0]=1000
    
# --
    
usr_name[1]=esa
    usr_grp
[1]=""
    
usr_pw[1]=somepassword
    usr_gid
[1]=1001
#
#    Partitions
#
    
boot_format=mbr            # gdisk for gpt, fdisk otherwise
    
boot_target_install=yes
    boot_target_device
=/dev/sda    # which partition or device shall contain the bootloader
    # --
    
mnt_point[0]=/boot        # Write a handler to search for existing /boot entries in other /etc/fstabs
    
mnt_dev[0]=/dev/sda1
    mnt_mb
[0]=768
    mnt_lbl
[0]=init
    mnt_format
[0]=ext4
    mnt_del
[0]=yes
    
# --
    
mnt_point[1]=/
    
mnt_dev[1]=/dev/sda2
    mnt_mb
[1]=16384
    mnt_lbl
[1]=load
    mnt_format
[1]=ext4
    mnt_del
[0]=yes
    
# --
    
mnt_point[2]=/home        # Write a handler to search for existing /home entries in other /etc/fstabs
    
mnt_dev[2]=/dev/sda3
    mnt_mb
[2]=262144
    mnt_lbl
[2]=data
    mnt_format
[2]=ext4
    mnt_del
[0]=no
    
# --
    
mnt_point[3]=extended
    mnt_dev
[3]=/dev/sda4
    mnt_mb
[3]=0
    mnt_lbl
[3]=
    
mnt_format[3]=
    
mnt_del[3]=no
    
# --
    
mnt_point[4]=/etc/grub.d
    mnt_dev
[4]=/dev/sda5
    mnt_mb
[4]=1
    mnt_lbl
[4]=grub_cfg
    mnt_format
[4]=ext4
    mnt_del
[4]=no
    
# --
    
mnt_point[5]=swap        # Write a handler to search for existing swap entries in other /etc/fstabs
    
mnt_dev[5]=/dev/sda6
    mnt_mb
[5]=8192
    mnt_lbl
[5]=swap
    mnt_format
[5]=swap
    mnt_del
[5]=yes
#
#    Repos
#    This is where you can overwrite fedora repos with localhost/lan repo
#
    
repo_name[0]=Script-Tools
    repo_url
[0]="http://sea.hostingsociety.com/repo"
    
repo_name[1]=adobe-linux
    repo_url
[1]="http://linuxdownload.adobe.com/linux/\$basearch/"
    
repo_name[2]=awesome
    repo_url
[2]="http://repos.fedorapeople.org/repos/thm/awesome/fedora-17/\$basearch/"
    
repo_name[3]=livna
    repo_url
[3]="http://ftp-stud.fht-esslingen.de/pub/Mirrors/rpm.livna.org/repo/14/\$basearch/"
    
repo_name[4]=rpmfusion-free
    repo_url
[4]="http://mirrors.rpmfusion.org/mirrorlist?repo=free-fedora-\$releasever&arch=\$basearch"
    
repo_name[5]=rpmfusion-nonfree
    repo_url
[5]="http://mirrors.rpmfusion.org/mirrorlist?repo=nonfree-fedora-\$releasever&arch=\$basearch"
    
repo_name[6]=chromium
    repo_url
[6]="http://repos.fedorapeople.org/repos/spot/chromium-stable/fedora-\$releasever/\$basearch/"
#
#    Packages
#
    
package_list="\$(yum list installed || cat /some/list/file)"
#
#    Customize : Run script at the end
#
    
execute_script=/some/custom/script 

So given the not yet true fact the handlers are working and generate such a workfile, this is how it is planed to should work:
1) Mount (& format) partitions
2) write & apply user config to chroot
3) write repos to chroot
4) enable network in chroot
5) install packages in chroot
6) generate required boot infos (grub and ??)
optional: 7) run custom script in chroot

So if anyone thinks i'm missing something very important, please let me know before everything is written in stone ;)
Thank you.

Viewing all articles
Browse latest Browse all 35964

Trending Articles