put source in

main
KoNicks 5 years ago
parent ee6ce7ca4a
commit 9280d6d1db
  1. 6
      README.md
  2. 53
      install
  3. 156
      koffe
  4. 71
      pi.is

@ -29,3 +29,9 @@ Installation is pretty easy, just boot from the iso and type `bash install`, the
# Who is this meant for?
For anyone in need of offline installers, may be people with wifi driver problems, sys admins with poor internet connections needing to install arch on many systems, etc. The interchangeable scripts and easy to edit nature of koffe make it very easy to turn into a specialized tool that can install arch without any user intervention. In general, it's for the people, use and publish it as you like as long as you respect the license
# A bit about the source code
Basically koffe is the actual program, install is the live env installation script (includes package installation and partitioning) while pi.is is copied and ran in chroot and handles stuff like timezones and user acounts, you can replace the two installation scripts with any of your choice using the `--scripts` flag
# Making ready to go installers with your exact configurations
Koffe is not really made for installing vanilla arch quickly as much as it is for installing the EXACT arch you want in minutes, with basic shell scripting skills you can do this yourself, make some custom scripts, include your dotfiles and configurations in the iso (put them in /usr/share/archiso/configs/releng/airootfs/root for easy acces), clone some gits, move some files and have the installation scripts handle compilation and installation, the goal is that when you reboot you will have your workflow there, waiting for you, arch as you picture it

@ -0,0 +1,53 @@
#!/bin/bash
whiptail --clear --backtitle "Koffe Offline Arch Installer - made by Konicks(GRI)" --title "Welcome screen" --msgbox "Welcome to Koffe, the offline arch installer, with your permission we'll get started :)" 0 0
echo "Unpacking linux and the other stuff:"
echo '' > /etc/pacman.conf
echo '[options]' >> /etc/pacman.conf
echo 'Architecture = auto' >> /etc/pacman.conf
echo 'SigLevel = Never' >> /etc/pacman.conf
echo 'LocalFileSigLevel = Never' >> /etc/pacman.conf
echo '[koffe]' >> /etc/pacman.conf
echo 'Server = file:///root/pkg' >> /etc/pacman.conf
pacman -Sy
whiptail --clear --backtitle "Koffe Offline Arch Installer - made by Konicks(GRI)" --title "CFdisk" --msgbox "So, we need to partition the disk. I'll launch cfdisk for you in just a sec, just choose the disk to partition" 0 0
lsblk -r | grep disk | cut -f 1 -d ' ' > drvs
sed -e 's/$/ disk/' -i drvs
declare -a disks
disks=(`cat drvs`)
drv=$(whiptail --title "Select drive to partition" --menu "Select drive to partition" 16 78 10 "${disks[@]}" 3>&1 1>&2 2>&3 3>&-)
cfdisk /dev/$drv
lsblk -r | grep part | cut -f 1 -d ' ' > drvs
sed -e 's/$/ part/' -i drvs
declare -a parts
parts=(`cat drvs`)
ppart=$(whiptail --title "Select the partiton to install linux to:" --menu "Select the partiton to install linux to (this will wipe the partition):" 16 78 10 "${parts[@]}" 3>&1 1>&2 2>&3 3>&-)
mkfs.ext4 /dev/$ppart
mount /dev/$ppart /mnt
echo no disk >> drvs
parts=(`cat drvs`)
pswap=$(whiptail --title "Select the partiton to install swap to:" --menu "Select the partiton to install swap to (no disk if none):" 16 78 10 "${parts[@]}" 3>&1 1>&2 2>&3 3>&-)
mkswap /dev/$pswap
swapon /dev/$pswap
pefi=$(whiptail --title "Select the partiton to install EFI to:" --menu "Select the partiton to install EFI to (no disk if you have legacy bios):" 16 78 10 "${parts[@]}" 3>&1 1>&2 2>&3 3>&-)
mkdir /mnt/boot
mkfs.fat -F32 /dev/$pefi
mount /dev/$pefi /mnt/boot
extraparts=$(whiptail --inputbox "If you want to mount any other partition manually, enter the commands here like this: command 1 ; command 2 ; command 3" 0 0 0 3>&1 1>&2 2>&3 3>&-)
echo $extraparts > coms
bash coms
whiptail --clear --backtitle "Koffe Offline Arch Installer - made by Konicks(GRI)" --title "Initial setup ready" --msgbox "Well, that was it for the initial setup, now press ok, grab a cup of coffee and wait for linux to install. Be sure to stick around for the post-install configurations tho." 0 0
#if one package errors out for whatever reason the whole pacstrap fails so i removed this implementation
#pacstrap /mnt - < install.list
for pac in $(cat install.list)
do
pacstrap /mnt $pac
done
genfstab -U /mnt >> /mnt/etc/fstab
cp pi.is /mnt/root/
echo 'bash /root/pi.is' > /mnt/root/.bashrc
echo 'echo "" > /root/.bashrc' >> /mnt/root/.bashrc
arch-chroot /mnt
whiptail --clear --backtitle "Koffe Offline Arch Installer - made by Konicks(GRI)" --title "Goodbye screen" --msgbox "Well, that was everything. Use reboot or poweroff to exit" 0 0
umount -a
clear
echo "use poweroff or reboot to exit"

156
koffe

@ -0,0 +1,156 @@
#!/bin/bash
x=1
pts=/usr/share/koffe/
pathto=$(realpath ./)
if [ $1 ];
then
for argument in $@
do
if [[ $argument == "--help" ]];
then
echo "koffe is a tool for making simple and intuitive offline archlinux installers"
echo "with support for most packages, package groups or aur packages."
echo
echo "The programs you select are the only ones getting installed"
echo "(and the dependencies, of course), so make sure to include packages that are needed for a"
echo "healthy arch install. So smthng like "
echo "'koffe --pacs=base,linux,linux-firmware,sudo,grub,xorg,gnome,minecraft-launcher,code,yay'"
echo "and any other packages you want to install,"
echo "you can also use whatever WM or DE you want, just keep in mind if the greeter is anything"
echo "other than gdm, sddm or lightdm you need to enable it yourself. Also, if you're"
echo "making an archiso to be used on many computers and include multiple sets of drivers,"
echo "in the live disk you can edit 'install.list' to manage what programs to install"
echo
echo "Once you're done with the iso, to install arch just boot from it and do 'bash install'"
echo ---------------------------------------------------
echo
echo Flags:
echo "koffe --pacs=Prog1,Prog2 -----> starts koffe and creates"
echo " an iso with the programs Prog1 and Prog2"
echo " IMPORTANT: Separate the progs with commas"
echo " and do not use spaces"
echo
echo "koffe --clean ----------------> cleans building dirs after unexpected"
echo " exit or unsuccesful iso generation. Will"
echo " nullify any other args parsed with it and will"
echo " not create an iso"
echo
echo "koffe --scripts=/path/path/ --> copies the scripts in the specified path"
echo " and uses them instead of the default koffe"
echo " scripts in /usr/share/koffe/. Avoid paths with spaces"
exit
fi
if [[ $(echo $argument | cut -f 1 -d '=') == "--pacs" ]];
then
declare -a prog
x=0
prog=$(echo $argument | cut -f 2 -d '=')
prog=${prog//,/ }
echo $prog
fi
if [[ $(echo $argument | cut -f 1 -d '=') == "--scripts" ]];
then
pts=$(echo $argument | cut -f 2 -d '=')
fi
if [[ $argument == "--clean" ]];
then
if [[ $(whoami) == root ]];
then
rm -rf ~/koffeiso
rm -rf /usr/share/archiso/configs/releng/airootfs/root/*
rm -rf /tmp/koffe/
exit
fi
fi
done
fi
if [ $(whoami) != root ];
then
echo
echo WARNING: the program needs to be ran as root
echo $prog
fi
if [ $(whoami) == root ];
then
cp $pts/* /usr/share/archiso/configs/releng/airootfs/root/
echo '' > /usr/share/archiso/configs/releng/airootfs/root/install.list
pacman -Sy
mkdir /tmp/koffe/
mkdir /tmp/koffe/l/
mkdir /tmp/koffe/n/
mkdir /tmp/koffe/aur/
mkdir /tmp/koffe/aurbg/
mkdir /usr/share/archiso/configs/releng/airootfs/root/pkg/
mkdir ~/koffeiso
mkdir ~/out
rm -rf /var/cache/pacman/pkg/*
pactree -u -s libnewt > /tmp/koffe/n/libnewt
pacman -Sp --noconfirm - < /tmp/koffe/n/libnewt > /tmp/koffe/l/libnewt
echo libnewt >> /usr/share/archiso/configs/releng/airootfs/root/install.list
wget -nc -i /tmp/koffe/l/libnewt -P /usr/share/archiso/configs/releng/airootfs/root/pkg/
pactree -u -s grub > /tmp/koffe/n/grub
pacman -Sp --noconfirm - < /tmp/koffe/n/grub > /tmp/koffe/l/grub
echo grub >> /usr/share/archiso/configs/releng/airootfs/root/install.list
wget -nc -i /tmp/koffe/l/grub -P /usr/share/archiso/configs/releng/airootfs/root/pkg/
if [[ x == 1 ]];
then
declare -a prog
prog=$(whiptail --inputbox "Please enter all the programs to be included in the installer separated by a space, you can also include package groups like gnome or xorg or AUR packages" 0 0 4 3>&1 1>&2 2>&3 3>&-)
fi
for app in $prog
do
clear
echo $app
variable=$(pacman -Sg $app)
if [[ $variable == '' ]];
then
#base
pactree -u -s $app > /tmp/koffe/n/$app
pacman -Sp --noconfirm - < /tmp/koffe/n/$app > /tmp/koffe/l/$app
echo $app >> /usr/share/archiso/configs/releng/airootfs/root/install.list
wget -nc -i /tmp/koffe/l/$app -P /usr/share/archiso/configs/releng/airootfs/root/pkg/
fi
if [[ $variable != '' ]];
then
#gnome
pacman -Sg $app > /tmp/koffe/generaltemp
cut -f 2- -d ' ' /tmp/koffe/generaltemp > /tmp/koffe/grlist
grlist=$(cat /tmp/koffe/grlist)
echo '' > /tmp/koffe/grtree
for component in $grlist
do
pactree -s -u $component >> /tmp/koffe/grtree
echo $component >> /usr/share/archiso/configs/releng/airootfs/root/install.list
done
pacman -Sp --noconfirm - < /tmp/koffe/grtree > /tmp/koffe/grlinks
wget -nc -i /tmp/koffe/grlinks -P /usr/share/archiso/configs/releng/airootfs/root/pkg/
fi
mkdir /tmp/koffe/home
sudo usermod -d /tmp/koffe/home/ nobody
git clone https://aur.archlinux.org/$app /tmp/koffe/aurbg/$app
chown -hR nobody /tmp/koffe/
cd /tmp/koffe/aurbg/$app
sudo -u nobody makepkg --noconfirm --skippgpcheck
cp /tmp/koffe/aurbg/$app/*.pkg.tar.zst /usr/share/archiso/configs/releng/airootfs/root/pkg
echo $app >> /usr/share/archiso/configs/releng/airootfs/root/install.list
declare -a bb
bb=$(cat /tmp/koffe/aurbg/$app/.SRCINFO | grep depends | cut -f 2 -d '=' | cut -f 1 -d '>' | cut -f 1 -d '"')
for depend in $bb
do
pactree -u -s $depend > /tmp/koffe/n/$depend
pacman -Sp --noconfirm - < /tmp/koffe/n/$depend > /tmp/koffe/l/$depend
wget -nc -i /tmp/koffe/l/$depend -P /usr/share/archiso/configs/releng/airootfs/root/pkg/
git clone https://aur.archlinux.org/$depend /tmp/koffe/aurbg/$depend
chown -hR nobody /tmp/koffe/$depend
cd /tmp/koffe/aurbg/$depend
sudo -u nobody makepkg --noconfirm --skippgpcheck
cp /tmp/koffe/aurbg/$depend/*.pkg.tar.zst /usr/share/archiso/configs/releng/airootfs/root/pkg
done
done
repo-add /usr/share/archiso/configs/releng/airootfs/root/pkg/koffe.db.tar.gz /usr/share/archiso/configs/releng/airootfs/root/pkg/*
mkarchiso -v -w ~/koffeiso -o $pathto/ /usr/share/archiso/configs/releng
rm -rf ~/koffeiso
rm -rf /usr/share/archiso/configs/releng/airootfs/root/*
rm -rf /tmp/koffe/
fi

71
pi.is

@ -0,0 +1,71 @@
systemctl enable NetworkManager
systemctl enable sddm.service
systemctl enable gdm.service
systemctl enable lightdm
whiptail --clear --backtitle "Koffe Offline Arch Installer - made by Konicks(GRI)" --title "Finishing setup" --msgbox "Well, linux is installed (kinda), let's go through the final setup and configure it a bit" 0 0
cd /usr/share/zoneinfo
echo */ | tr " " "\n" > ~/reg
sed -e 's/$/ region/' -i ~/reg
declare -a regs
regs=(`cat ~/reg`)
region_vague=$(whiptail --title "Finishing setup" --menu "Let's start with the region, select your region from below" 0 0 0 "${regs[@]}" 3>&1 1>&2 2>&3 3>&-)
echo $region_vague
cd /usr/share/zoneinfo/$region_vague
echo * | tr " " "\n" > ~/reg
sed -e 's/$/ region/' -i ~/reg
declare -a regs
regs=(`cat ~/reg`)
region_close=$(whiptail --title "Finishing setup" --menu "Select your city from below" 0 0 0 "${regs[@]}" 3>&1 1>&2 2>&3 3>&-)
ln -sf /usr/share/zoneinfo/$region_vague/$region_close /etc/localtime
hwclock --systohc
touch /etc/locale.conf
echo "LANG=en_US.UTF-8" > /etc/locale.conf
echo en_US.UTF-8 UTF-8 >> /etc/locale.gen
rm ~/reg
locale-gen
cd /
myhostname=$(whiptail --inputbox "Now choose a name for your computer" 0 0 4 3>&1 1>&2 2>&3 3>&-)
echo "127.0.0.1 localhost
::1 localhost
127.0.1.1 $myhostname.localdomain $myhostname" > /etc/hosts
echo "$myhostname" > /etc/hostname
archit=$(whiptail --backtitle "Koffe" --title "Architecture selector" --menu "Choose the bit count of your x86 chip" 0 0 4 \
64 "BIT" \
32 "BIT" 3>&1 1>&2 2>&3 3>&-)
efiornot=$(whiptail --backtitle "Koffe" --title "Boot selector" --menu "Is your soon-to-be-arch computer legacy or EUFI?" 0 0 4 \
1 "Bios/Legacy" \
2 "UEFI" 3>&1 1>&2 2>&3 3>&-)
if [[ "$efiornot" == "2" ]]
then
if [[ "$archit" == "64" ]]
then
grub-install --target=x86_64-efi --efi-directory=/boot
grub-mkconfig -o /boot/grub/grub.cfg
fi
if [[ "$archit" == "32" ]]
then
grub-install --target=i386-efi --efi-directory=/boot
grub-mkconfig -o /boot/grub/grub.cfg
fi
fi
if [[ "$efiornot" == "1" ]]
then
lsblk | grep disk | cut -f 1 -d ' ' > ~/drvs
sed -e 's/$/ disk/' -i ~/drvs
declare -a lname
disks=(`cat ~/drvs`)
lname=$(whiptail --title "Select drive to install grub to" --menu "Select drive to install grub to" 16 78 10 "${disks[@]}" 3>&1 1>&2 2>&3 3>&-)
grub-install --recheck /dev/$lname
grub-mkconfig -o /boot/grub/grub.cfg
fi
clear
echo Now choose a root password
passwd
myusername1=$(whiptail --inputbox "Now lets create a user, pick a username: " 0 0 4 3>&1 1>&2 2>&3 3>&-)
echo "%wheel ALL=(ALL) ALL" >> /etc/sudoers
useradd -m -G wheel $myusername1
echo "and a password"
passwd $myusername1
clear
echo "If you need to run any special commands to enable or configure something in chroot do so now"
echo "Then type 'exit' to go back to the installer"
Loading…
Cancel
Save