fix broken repo
This commit is contained in:
@@ -0,0 +1 @@
|
||||
.config
|
||||
@@ -0,0 +1,19 @@
|
||||
Minimal Linux Booter
|
||||
|
||||
Copyright (C) 2023 Tomas M <slax.org, linux-live.org>.
|
||||
Copyright (C) 2023 Danuel K. <danielisko.net, git.danielisko.net>.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301 USA.
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
Minimal Linux Booter
|
||||
====================
|
||||
|
||||
This project is to minimize Linux-Live Kit (https://github.com/Tomas-M/linux-live)
|
||||
|
||||
Note:
|
||||
* Your distro must have installed:
|
||||
- squashfs-tools,
|
||||
- xorriso,
|
||||
- cpio,
|
||||
- file,
|
||||
- gzip,
|
||||
- sed,
|
||||
- tar,
|
||||
- grep,
|
||||
- rsync,
|
||||
- syslinux-utils,
|
||||
- bash,
|
||||
- (Optional) mdadm.
|
||||
- (Optional for light "system.sfs", (if most on left then best compression)) zstd, xz, lzma, bzip2 and gzip.
|
||||
* Your linux kernel must have overlayfs and squashfs module.
|
||||
- If zstd compressor is not found, mksquashfs try: xz, lzma, bzip2 and gzip - in this order.
|
||||
* Installer is included in this project.
|
||||
- In your booted linux distro, open terminal and type as root `install-linux`.
|
||||
- In order to install your distro to hdd you also must have installed:
|
||||
- dialog,
|
||||
- fdisk,
|
||||
- cfdisk,
|
||||
- mke2fs,
|
||||
- grub2.
|
||||
* You can also boot your linux distro in frugal mode (for Windows and Linux):
|
||||
- For Linux (All hdd free space in frugal mode):
|
||||
- Boot your linux distro,
|
||||
- Format partition (for ex. /dev/sda1) as linux filesystem (for ex. ext4),
|
||||
- Create directory (for ex. /mnt/sda1),
|
||||
- Mount /dev/sda1 to /mnt/sda1,
|
||||
- Create loop directory to unpack files from iso image (for ex. /mnt/iso),
|
||||
- Mount YOUR_BUILT_LINUX_DISTRO_WITH_THIS_TOOL.iso /mnt/iso,
|
||||
- Copy files from /mnt/iso to /mnt/sda1,
|
||||
- cd to /mnt/sda1,
|
||||
- Add executable permission by: `chmod +x bootinst.sh`,
|
||||
- Run: `./bootinst.sh`,
|
||||
- Cleanup: `umount -f /mnt/sda1 /mnt/iso && rmdir /mnt/sda1 /mnt/iso`,
|
||||
- Now `reboot` to your frugal mode linux distro.
|
||||
- For Windows (Only 4 GB free space in frugal mode due to fat32 limits):
|
||||
- Format partition (for ex. d:\) to fat32 (is more stable that ntfs),
|
||||
- Copy files from iso image to formated d:\,
|
||||
- Open cmd as admin,
|
||||
- cd to d:\,
|
||||
- Run in cmd `bootinst.bat`,
|
||||
- Now you can reboot your device to your linux distro,
|
||||
- OR Use rufus to write image to pendrive.
|
||||
* The iso image uses legacy MBR and UEFI bootloader.
|
||||
- The `install-linux` uses legacy MBR bootloader at this time!
|
||||
* You should be chrooted to linux distro.
|
||||
* You should not be run that tool on *YOUR* **REAL** running linux.
|
||||
* The final iso image will be in your root device (means /) (If you ran this tool in *YOUR* **REAL** running linux) or in your chrooted linux distro (means /path/to/chroot/folder).
|
||||
@@ -0,0 +1,16 @@
|
||||
menuentry "Run __DISTRO__ with persistence" {
|
||||
linux /vmlinuz perch
|
||||
initrd /initrd.img
|
||||
}
|
||||
menuentry "Run __DISTRO__ from RAM without persistence" {
|
||||
linux /vmlinuz toram
|
||||
initrd /initrd.img
|
||||
}
|
||||
menuentry "Run __DISTRO__ with debug" {
|
||||
linux /vmlinuz debug
|
||||
initrd /initrd.img
|
||||
}
|
||||
menuentry "Run __DISTRO__ with debug and first stage shell" {
|
||||
linux /vmlinuz debug shell
|
||||
initrd /initrd.img
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
@echo off
|
||||
cls
|
||||
echo ===============================================================================
|
||||
echo Setting your drive to boot
|
||||
echo ===============================================================================
|
||||
echo.
|
||||
|
||||
set DISK=none
|
||||
set BOOTFLAG=boot666s.tmp
|
||||
|
||||
echo This file is used to determine current drive letter. It should be deleted. >\%BOOTFLAG%
|
||||
if not exist \%BOOTFLAG% goto readOnly
|
||||
|
||||
echo wait please ...
|
||||
for %%d in ( C D E F G H I J K L M N O P Q R S T U V W X Y Z ) do if exist %%d:\%BOOTFLAG% set DISK=%%d
|
||||
del \%BOOTFLAG%
|
||||
if %DISK% == none goto DiskNotFound
|
||||
|
||||
echo.
|
||||
echo Setting up boot record for %DISK%:, wait please...
|
||||
|
||||
if %OS% == Windows_NT goto setupNT
|
||||
goto setup95
|
||||
|
||||
:setupNT
|
||||
\syslinux.exe -maf %DISK%:
|
||||
goto setupDone
|
||||
|
||||
:setup95
|
||||
\syslinux.com -maf %DISK%:
|
||||
|
||||
:setupDone
|
||||
echo Installation finished.
|
||||
goto pauseit
|
||||
|
||||
:readOnly
|
||||
echo You're starting boot installer from a read-only media, this will not work.
|
||||
goto pauseit
|
||||
|
||||
:DiskNotFound
|
||||
echo Error: can't find out current drive letter
|
||||
|
||||
:pauseit
|
||||
echo Press any key to exit...
|
||||
pause > nul
|
||||
|
||||
:end
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
# Setup booting from disk (USB or harddrive)
|
||||
# Requires: fdisk, df, tail, tr, cut, dd, sed
|
||||
|
||||
# change working directory to dir from which we are started
|
||||
CWD="$(pwd)"
|
||||
BOOT="$(dirname "$0")"
|
||||
cd "$BOOT"
|
||||
|
||||
# find out device and mountpoint
|
||||
PART="$(df . | tail -n 1 | tr -s " " | cut -d " " -f 1)"
|
||||
DEV="$(echo "$PART" | sed -r "s:[0-9]+\$::" | sed -r "s:([0-9])[a-z]+\$:\\1:i")"
|
||||
|
||||
./extlinux.exe --install "$BOOT"
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error installing boot loader."
|
||||
echo "Read the errors above and press enter to exit..."
|
||||
read junk
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ "$DEV" != "$PART" ]; then
|
||||
# Setup MBR on the first block
|
||||
dd bs=440 count=1 conv=notrunc if="$BOOT/mbr.bin" of="$DEV" 2>/dev/null
|
||||
|
||||
# Toggle a bootable flag
|
||||
PART="$(echo "$PART" | sed -r "s:.*[^0-9]::")"
|
||||
(
|
||||
fdisk -l "$DEV" | fgrep "*" | fgrep "$DEV" | cut -d " " -f 1 \
|
||||
| sed -r "s:.*[^0-9]::" | xargs -I '{}' echo -ne "a\n{}\n"
|
||||
echo a
|
||||
echo $PART
|
||||
echo w
|
||||
) | fdisk $DEV >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
echo "Boot installation finished."
|
||||
cd "$CWD"
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 7.2 KiB |
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
UI vesamenu.c32
|
||||
MENU BACKGROUND logo.png
|
||||
|
||||
TIMEOUT 140
|
||||
MENU CLEAR
|
||||
|
||||
LABEL default
|
||||
MENU LABEL Run __DISTRO__ with persistence
|
||||
KERNEL /vmlinuz
|
||||
APPEND initrd=/initrd.img perch
|
||||
|
||||
LABEL toram
|
||||
MENU LABEL Run __DISTRO__ from RAM without persistence
|
||||
KERNEL /vmlinuz
|
||||
APPEND initrd=/initrd.img toram
|
||||
|
||||
LABEL debug
|
||||
MENU LABEL Run __DISTRO__ with debug
|
||||
KERNEL /vmlinuz
|
||||
APPEND initrd=/initrd.img debug
|
||||
|
||||
LABEL debugshell
|
||||
MENU LABEL Run __DISTRO__ with debug and first stage shell
|
||||
KERNEL /vmlinuz
|
||||
APPEND initrd=/initrd.img debug shell
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
for i in mksquashfs cpio gzip sed grep xorriso tar file; do
|
||||
if [ ! -x "$(command -v ${i})" ]; then
|
||||
case ${i} in
|
||||
mksquashfs) a="squashfs-tools";;
|
||||
readelf) a="binutils";;
|
||||
*) a="${i}"
|
||||
esac
|
||||
echo "Please install ${a} package to run this tool"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
exec > >(tee -i /tmp/mlb.log) 2>&1
|
||||
cd "$(dirname $(readlink -f ${0}))" || exit 1
|
||||
cp -f config .config
|
||||
|
||||
mapfile -t list < <(ls -A /boot | egrep "^bzImage*|*kernel*|^vmlinuz*" 2>/dev/null | grep -v "init")
|
||||
if [ ${#list[@]} -gt 1 ]; then
|
||||
n=0
|
||||
echo -e "Please choose your kernel to proceed:\nChoose number from ${n} to ${#list[@]}\n-----\n"
|
||||
for a in "${list[@]}"; do
|
||||
echo "[${n}] - ${a}"
|
||||
((n++))
|
||||
done
|
||||
echo "-----"
|
||||
read kernel
|
||||
kernel="/boot/${list[${kernel}]}"
|
||||
unset list n
|
||||
else
|
||||
kernel="/boot/${list[0]}"
|
||||
fi
|
||||
set -x
|
||||
time (
|
||||
echo "KERNEL=\"${kernel}\"" >>.config
|
||||
echo "LMK=\"/lib/modules/$(file -bL ${kernel} | grep -o 'version .*' | cut -d' ' -f2)\"" >>.config
|
||||
unset kernel
|
||||
top="$(pwd)"
|
||||
. .config
|
||||
workTmpDir="$(mktemp -d /tmp/Mlb_WorkDir_XXXXXXX)"
|
||||
DATA="${workTmpDir}/isoImage"
|
||||
INITRD="$(initrd/create)"
|
||||
ret="${?}"
|
||||
tmpRoot="${workTmpDir}/tmpRoot"
|
||||
trap "rm -rf ${workTmpDir} /tmp/MlbInitRd{,.img}&&exit 1" 2 6 15
|
||||
mkdir -p ${DATA}/changes ${DATA}/${DISTRO}/modules
|
||||
rsync --force -aAP $(for i in $(awk '{print $2}' /proc/mounts) /tmp; do echo "--exclude=${i}/*"; done) / ${tmpRoot}
|
||||
chmod +x -R inc2sys
|
||||
cp -rf inc2sys/* ${tmpRoot}
|
||||
mknod ${tmpRoot}/dev/console c 5 1
|
||||
mknod ${tmpRoot}/dev/null c 1 3
|
||||
mknod ${tmpRoot}/dev/ram0 b 1 0
|
||||
mknod ${tmpRoot}/dev/tty1 c 4 1
|
||||
mknod ${tmpRoot}/dev/tty2 c 4 2
|
||||
mknod ${tmpRoot}/dev/tty3 c 4 3
|
||||
mknod ${tmpRoot}/dev/tty4 c 4 4
|
||||
for i in zstd xz lzma bzip2 gzip; do
|
||||
mksquashfs ${tmpRoot} ${DATA}/${DISTRO}/system.sfs -comp ${i} -noappend
|
||||
[ -e ${DATA}/${DISTRO}/system.sfs ]&&break
|
||||
done
|
||||
mv -f ${INITRD} ${DATA}/initrd.img
|
||||
cp -rf bootfiles/* ${DATA}
|
||||
mv -f ${tmpRoot}/tmp/grub_efi.img ${DATA}/efi.img
|
||||
for i in ${DATA}/syslinux.cfg ${DATA}/boot/grub/grub.cfg; do
|
||||
sed -i -r "s/__DISTRO__/${DISTRO}/" ${i}
|
||||
done
|
||||
cp -f ${KERNEL} ${DATA}/vmlinuz
|
||||
cd ${DATA}
|
||||
utc="$(date +%s)"
|
||||
v="$(git rev-parse HEAD 2>/dev/null)"&&v="${v}:GIT"||v="INFINITY:LOCAL"
|
||||
cat <<eot >.MlbMeta
|
||||
# Built using Minimal-Linux-Booter.
|
||||
MLB_VERSION="${v}"
|
||||
MLB_NAME="${DISTRO}"
|
||||
MLB_UTC="${utc}"
|
||||
eot
|
||||
[[ ${ret} = 2 ]]&&echo "MLB_ELF_STATIC_INITRD=\"1\"" >>.MlbMeta||echo "MLB_ELF_STATIC_INITRD=\"0\"" >>.MlbMeta
|
||||
xorriso -as mkisofs -o /${DISTRO}-${utc}.iso -J -R -D -A ${DISTRO} -V ${DISTRO} -no-emul-boot -boot-info-table -boot-load-size 4 -b isolinux.bin -c isolinux.boot -eltorito-alt-boot -e /efi.img -no-emul-boot .
|
||||
isohybrid --version >/dev/null 2>&1&&isohybrid -u /${DISTRO}-${utc}.iso
|
||||
cd ${top}
|
||||
rm -rf ${workTmpDir}
|
||||
)
|
||||
Binary file not shown.
@@ -0,0 +1,279 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# installation-help for Slax
|
||||
# 22.05.2007
|
||||
# shell script for installation of SLAX to harddisk
|
||||
# written by Thomas Schoenhuetl <pilleus.pulcher@arcor.de> 22.05.2007
|
||||
# It contains parts of the official Slackware installer.
|
||||
# This shell script is contributed under the terms of GPL v2 by Thomas Schoenhuetl <pilleus.pulcher@arcor.de> 22.05.2007.
|
||||
|
||||
# Modified script "slax2hd" for installing Generic Linux to hdd
|
||||
# BY: Daniel K. aka *DANiO*
|
||||
|
||||
for i in dialog fdisk cfdisk sed grep mke2fs grub-install; do
|
||||
if [ ! -x $(command -v ${i}) ]; then
|
||||
req_app+="${i} "
|
||||
fail="true"
|
||||
fi
|
||||
done
|
||||
[ ${fail} ] && echo "Please install \"${req_app}\" to run this installer" && exit 1
|
||||
|
||||
dialog --clear --title "GENERAL INFORMATION" --msgbox "Generic installer is a gui-based tool to install your running Linux to your harddisk.\n\n You are able to partition and format your harddisk and install in the end a bootloader.\n\n You will use this installer at your own risk. I am not responsible for lost of datas or something else.\n\n If you accept this, you can start now! Or you may cancel the installer!" 20 70
|
||||
if [ $? = 1 ] ; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# run cfdisk to partition the harddrive
|
||||
dialog --clear --title "PARTITION THE HARDDISK" --msgbox "Generic installer will now start 'cfdisk' so that you are able to create new partitions for Generic.\n\n Two partitions are recommended. 1 for the system and 1 for SWAP.\n\n I think 3 GB are enough for the root-partition - Generic plus additional programs - and twice the amount of your RAM for the swap-partition.\n\n Just follow the menu, store your changes and quit cfdisk to go on!\n\n IMPORTANT: Read the instructions and the output of cfdisk carefully. Sometimes you have to reboot to update the partition table!" 20 70
|
||||
if [ $? = 1 ] ; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# Create partitions using fdisk or cfdisk.
|
||||
TMP=/tmp/tmp
|
||||
if [ ! -d $TMP ]; then
|
||||
mkdir -p $TMP
|
||||
fi
|
||||
|
||||
fdisk -l | grep -vE "loop|zram|ram" | sed -n 's/^Disk \(\/dev\/[^:]*\): \([^,]*\).*$/"\1" "\2" \\/p' >> $TMP/drivelist
|
||||
|
||||
while [ 0 ]; do
|
||||
echo dialog --ok-label Select \
|
||||
--cancel-label Continue \
|
||||
--title \"PARTITIONING\" \
|
||||
--menu \"Select drive to partition:\" 11 40 4 \\\
|
||||
> $TMP/tmpscript
|
||||
cat $TMP/drivelist >> $TMP/tmpscript
|
||||
echo "2> $TMP/tmpanswer" >> $TMP/tmpscript
|
||||
. $TMP/tmpscript
|
||||
[ $? != 0 ] && break
|
||||
PARTITION=$(cat $TMP/tmpanswer)
|
||||
|
||||
if [ ! -f /etc/expert-mode ]; then
|
||||
cfdisk $PARTITION
|
||||
else
|
||||
echo dialog --title \"PARTITIONING $PARTITION\" \
|
||||
--menu \"Select which fdisk program you want to use. cfdisk is \
|
||||
strongly recommended for newbies while advanced users may prefer fdisk.\" \
|
||||
11 50 2 \
|
||||
cfdisk \"Curses based partitioning program\" \
|
||||
fdisk \"Traditional fdisk\" \
|
||||
"2> $TMP/tmpanswer" > $TMP/tmpscript
|
||||
. $TMP/tmpscript
|
||||
[ $? != 0 ] && continue
|
||||
FDISKPROGRAM=`cat $TMP/tmpanswer`
|
||||
clear
|
||||
if [ "$FDISKPROGRAM" = "cfdisk" ]; then
|
||||
cfdisk $PARTITION
|
||||
elif [ "$FDISKPROGRAM" = "fdisk" ]; then
|
||||
fdisk $PARTITION
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
rm -f $TMP/drivelist $TMP/tmpscript $TMP/tmpanswer
|
||||
|
||||
REDIR=/dev/tty4
|
||||
NDIR=/dev/null
|
||||
crunch() {
|
||||
read STRING;
|
||||
echo $STRING;
|
||||
}
|
||||
rm -f $TMP/SeTswap $TMP/SeTswapskip
|
||||
SWAPLIST="`fdisk -l | fgrep "Linux swap" | sort 2> $NDIR`"
|
||||
if [ "$SWAPLIST" = "" ]; then
|
||||
dialog --title "NO SWAP SPACE DETECTED" --yesno "You have not created \
|
||||
a swap partition with Linux fdisk. \
|
||||
Do you want to continue installing without one? " 6 60
|
||||
if [ "$?" = "1" ]; then
|
||||
dialog --title "ABORTING INSTALLATION" --msgbox "Create a swap partition with Linux fdisk, and then try this again." 6 40
|
||||
exit 1
|
||||
fi
|
||||
else # there is at least one swap partition:
|
||||
echo > $TMP/swapmsg
|
||||
if [ "$(echo "$SWAPLIST" | sed -n '2 p')" = "" ]; then
|
||||
echo "Generic Installer has detected a swap partition:\n\n" >> $TMP/swapmsg
|
||||
echo >> $TMP/swapmsg
|
||||
echo " Device Boot Start End Blocks Id System\\n" >> $TMP/swapmsg
|
||||
echo "`echo "$SWAPLIST" | sed -n '1 p'`\\n\n" >> $TMP/swapmsg
|
||||
echo >> $TMP/swapmsg
|
||||
echo "Do you wish to install this as your swap partition?" >> $TMP/swapmsg
|
||||
dialog --title "SWAP SPACE DETECTED" --cr-wrap --yesno "`cat $TMP/swapmsg`" 12 72
|
||||
REPLY=$?
|
||||
else
|
||||
echo "Generic Installer has detected the following swap partitions:" >> $TMP/swapmsg
|
||||
echo >> $TMP/swapmsg
|
||||
echo " Device Boot Start End Blocks Id System\\n" >> $TMP/swapmsg
|
||||
echo "$SWAPLIST\\n\n" >> $TMP/swapmsg
|
||||
echo >> $TMP/swapmsg
|
||||
echo "Do you wish to install these as your swap partitions? " >> $TMP/swapmsg
|
||||
dialog --title "SWAP SPACE DETECTED" --cr-wrap --yesno "`cat $TMP/swapmsg`" 13 72
|
||||
REPLY=$?
|
||||
fi
|
||||
rm -f $TMP/swapmsg
|
||||
if [ $REPLY = 0 ]; then # yes
|
||||
if grep "SwapTotal: * 0 kB" /proc/meminfo 1> $NDIR 2> $NDIR ; then
|
||||
USE_SWAP=0 # swap is not currently mounted
|
||||
else # warn of possible problems:
|
||||
# This 10231808 below is the size of a swapfile pre-supplied by install.zip that we'd like to ignore.
|
||||
if grep 10231808 /proc/meminfo 1> $NDIR 2> $NDIR ; then
|
||||
USE_SWAP=0
|
||||
else
|
||||
cat << EOF > $TMP/swapmsg
|
||||
IMPORTANT NOTE: If you have already made any of your swap
|
||||
partitions active (using the swapon command), then you
|
||||
should not allow Setup to use mkswap on your swap partitions,
|
||||
because it may corrupt memory pages that are currently
|
||||
swapped out. Instead, you will have to make sure that your
|
||||
swap partitions have been prepared (with mkswap) before they
|
||||
will work. You might want to do this to any inactive swap
|
||||
partitions before you reboot.
|
||||
EOF
|
||||
dialog --title "MKSWAP WARNING" --msgbox "`cat $TMP/swapmsg`" 12 67
|
||||
rm -f $TMP/swapmsg
|
||||
dialog --title "USE MKSWAP?" --yesno "Do you want Setup to use mkswap on your swap partitions?" \
|
||||
5 65
|
||||
USE_SWAP=$?
|
||||
fi
|
||||
fi
|
||||
CURRENT_SWAP="1"
|
||||
while [ ! "`echo "$SWAPLIST" | sed -n "$CURRENT_SWAP p"`" = "" ]; do
|
||||
SWAP_PART=`fdisk -l | fgrep "Linux swap" | sed -n "$CURRENT_SWAP p" | crunch | cut -f 1 -d ' '`
|
||||
if [ $USE_SWAP = 0 ]; then
|
||||
dialog --title "FORMATTING SWAP PARTITION" --infobox "Formatting \
|
||||
$SWAP_PART as a Linux swap partition (and checking for bad blocks)..." 4 55
|
||||
mkswap -c $SWAP_PART 1> $REDIR 2> $REDIR
|
||||
fi
|
||||
echo "Activating swap partition $SWAP_PART:"
|
||||
echo "swapon $SWAP_PART"
|
||||
swapon $SWAP_PART 1> $REDIR 2> $REDIR
|
||||
printf "%-11s %-11s %-11s %-27s %-2s %s\n" "$SWAP_PART" "swap" "swap" "defaults" "0" "0" >> $TMP/SeTswap
|
||||
CURRENT_SWAP="`expr $CURRENT_SWAP + 1`"
|
||||
sleep 1
|
||||
done
|
||||
echo "Your swapspace has been configured. This information will" > $TMP/swapmsg
|
||||
echo "be added to your /etc/fstab:" >> $TMP/swapmsg
|
||||
echo >> $TMP/swapmsg
|
||||
cat $TMP/SeTswap >> $TMP/swapmsg
|
||||
dialog --title "SWAP SPACE CONFIGURED" --exit-label OK --textbox $TMP/swapmsg 10 72
|
||||
cat $TMP/SeTswap > $TMP/SeTfstab
|
||||
rm -f $TMP/swapmsg $TMP/SeTswap
|
||||
fi
|
||||
fi
|
||||
|
||||
# format root partition
|
||||
fdisk -l | grep -vE "loop|zram|ram" | grep Linux | sed -e '/swap/d' | cut -b 1-9 > $TMP/pout 2>/dev/null
|
||||
|
||||
dialog --clear --title "ROOT PARTITION DETECTED" --exit-label OK --msgbox "Generic installer has detected\n\n `cat /tmp/tmp/pout` \n\n as your linux partition(s).\n\n In the next box you can choose the linux filesystem for your root partition or choose the partition if you have more linux partitions!" 20 70
|
||||
if [ $? = 1 ] ; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# choose root partition
|
||||
dialog --clear --title "CHOOSE ROOT PARTITION" --inputbox "Please give me your prefered root partition in this way:\n\n /dev/hdaX --- X = number of the partition, e. g. 2 for /dev/hda2!" 10 70 2> $TMP/pout
|
||||
|
||||
dialog --clear --title "FORMAT ROOT PARTITION" --radiolist "Now you can choose the filesystem for your root partition.\n" 10 70 0 \
|
||||
"1" "ext2" off \
|
||||
"2" "ext3" off \
|
||||
"3" "ext4" on \
|
||||
2> $TMP/part
|
||||
if [ $? = 1 ] ; then
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ `cat $TMP/part` = "1" ] ; then
|
||||
mkfs.ext2 `cat $TMP/pout`
|
||||
dialog --clear --title "FORMAT ROOT PARTITION" --msgbox "Now your partition has been formatted with ext2 filesystem." 10 70
|
||||
echo "UUID='$(blkid -s UUID -o value $(cat $TMP/pout))' / ext2 defaults 1 1" >> $TMP/SeTfstab2
|
||||
# mount the root partition to copy the system
|
||||
mkdir /mnt/`cat $TMP/pout | cut -b 6-9`
|
||||
mount /dev/`cat $TMP/pout | cut -b 6-9` /mnt/`cat $TMP/pout | cut -b 6-9`
|
||||
fi
|
||||
|
||||
if [ `cat $TMP/part` = "2" ] ; then
|
||||
mkfs.ext3 `cat $TMP/pout`
|
||||
dialog --clear --title "FORMAT ROOT PARTITION" --msgbox "Now your partition has been formatted with ext3 filesystem." 10 70
|
||||
echo "UUID='$(blkid -s UUID -o value $(cat $TMP/pout))' / ext3 defaults 1 1" >> $TMP/SeTfstab2
|
||||
# mount the root partition to copy the system
|
||||
mkdir /mnt/`cat $TMP/pout | cut -b 6-9`
|
||||
mount /dev/`cat $TMP/pout | cut -b 6-9` /mnt/`cat $TMP/pout | cut -b 6-9`
|
||||
fi
|
||||
|
||||
if [ `cat $TMP/part` = "3" ] ; then
|
||||
mkfs.ext4 `cat $TMP/pout`
|
||||
dialog --clear --title "FORMAT ROOT PARTITION" --msgbox "Now your partition has been formatted with ext4 filesystem." 10 70
|
||||
echo "UUID='$(blkid -s UUID -o value $(cat $TMP/pout))' / ext4 defaults 1 1" >> $TMP/SeTfstab2
|
||||
# mount the root partition to copy the system
|
||||
mkdir /mnt/`cat $TMP/pout | cut -b 6-9`
|
||||
mount /dev/`cat $TMP/pout | cut -b 6-9` /mnt/`cat $TMP/pout | cut -b 6-9`
|
||||
fi
|
||||
|
||||
# copy the system
|
||||
dialog --clear --title "COPYING THE SYSTEM" --msgbox "Generic installer will now copy the running system to your harddisk.\n\n Press OK to start ..." 10 70
|
||||
if [ $? = 1 ] ; then
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "rsync --force -ar /run/initramfs/memory/system/* /mnt/`cat $TMP/pout | cut -b 6-9`" > $TMP/rsync_cmd
|
||||
chmod +x $TMP/rsync_cmd
|
||||
|
||||
#from: https://www.linuxquestions.org/questions/programming-9/dialog-command-buffering-problem-in-pipe-4175423593/#post4762038
|
||||
dialog --title "COPYING PROCESS" --msgbox "Generic installer is copying the system to your harddisk.\n\n Please be patient ... it may take up to 10 minutes depending on your system!" 10 70
|
||||
$TMP/rsync_cmd
|
||||
|
||||
mkdir -p /mnt/`cat $TMP/pout | cut -b 6-9`/dev /mnt/`cat $TMP/pout | cut -b 6-9`/proc /mnt/`cat $TMP/pout | cut -b 6-9`/sys /mnt/`cat $TMP/pout | cut -b 6-9`/tmp
|
||||
|
||||
dialog --clear --title "TRANSACTION FINISHED" --msgbox "Now Generic installer has finished the transaction." 10 70
|
||||
if [ $? = 1 ] ; then
|
||||
exit
|
||||
fi
|
||||
|
||||
# create new fstab
|
||||
cat $TMP/SeTfstab > /mnt/`cat $TMP/pout | cut -b 6-9`/etc/fstab 2>/dev/null
|
||||
cat $TMP/SeTfstab2 >> /mnt/`cat $TMP/pout | cut -b 6-9`/etc/fstab 2>/dev/null
|
||||
|
||||
mount --bind /dev /mnt/`cat $TMP/pout | cut -b 6-9`/dev
|
||||
mount --bind /proc /mnt/`cat $TMP/pout | cut -b 6-9`/proc
|
||||
mount --bind /sys /mnt/`cat $TMP/pout | cut -b 6-9`/sys
|
||||
|
||||
grub-install --recheck --force --root-directory=/mnt/`cat $TMP/pout | cut -b 6-9` `cat $TMP/pout | cut -b 1-8`
|
||||
if ! chroot /mnt/`cat $TMP/pout | cut -b 6-9` grub-mkconfig -o /boot/grub/grub.cfg; then
|
||||
# if here is error then panic!
|
||||
dialog --title "ERROR" --infobox "Can't generate grub.cfg file!\n---\nI'm panic!\n" 10 70
|
||||
umount -f /mnt/`cat $TMP/pout | cut -b 6-9`/dev /mnt/`cat $TMP/pout | cut -b 6-9`/proc /mnt/`cat $TMP/pout | cut -b 6-9`/sys
|
||||
#umount -f /mnt/`cat $TMP/pout | cut -b 6-9`
|
||||
exit 1
|
||||
fi
|
||||
|
||||
umount -f /mnt/`cat $TMP/pout | cut -b 6-9`/dev /mnt/`cat $TMP/pout | cut -b 6-9`/proc /mnt/`cat $TMP/pout | cut -b 6-9`/sys
|
||||
|
||||
rm -f /mnt/`cat $TMP/pout | cut -b 6-9`/etc/hostname
|
||||
while :; do
|
||||
clear
|
||||
echo "What is your hostname (computer name)?"
|
||||
read hostname
|
||||
if [ -z "$hostname" ]; then
|
||||
clear
|
||||
echo "This hostname can not be empty"
|
||||
sleep 2
|
||||
else
|
||||
echo "$hostname" >/mnt/`cat $TMP/pout | cut -b 6-9`/etc/hostname
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Installation completed!
|
||||
--------------------------------"
|
||||
sleep 4
|
||||
|
||||
rm -rf $TMP
|
||||
while :; do
|
||||
clear
|
||||
echo -e "Would you like to reboot in to new system?\n[Y]es or [N]o?\n"
|
||||
read choice
|
||||
case $choice in
|
||||
[Yy][Ee][Ss]|[Yy]) reboot ;;
|
||||
[Nn][Oo]|[Nn]) exit ;;
|
||||
*) echo "Bad option '${choice}'"; sleep 2 ;;
|
||||
esac
|
||||
done
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -x
|
||||
cd "$(dirname $(readlink -f ${0}))"||exit 1
|
||||
|
||||
. ../.config
|
||||
|
||||
INITRAMFS="/tmp/MlbInitRd"
|
||||
trap "rm -rf ${INITRAMFS}&&exit 1" 2 3 6 15
|
||||
|
||||
# copy file to initramfs tree, including
|
||||
# all library dependencies (as shown by ldd)
|
||||
# $1 = file to copy (full path)
|
||||
copy_including_deps()
|
||||
{
|
||||
# if source doesn't exist or target exists, do nothing
|
||||
if [ ! -e "$1" -o -e "$INITRAMFS"/"$1" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
cp -R --parents "$1" "$INITRAMFS"
|
||||
if [ -L "$1" ]; then
|
||||
DIR="$(dirname "$1")"
|
||||
LNK="$(readlink "$1")"
|
||||
copy_including_deps "$(cd "$DIR"; realpath -s "$LNK")"
|
||||
fi
|
||||
|
||||
ldd "$1" 2>/dev/null | sed -r "s/.*=>|[(].*//g" | sed -r "s/^\\s+|\\s+\$//" \
|
||||
| while read LIB; do
|
||||
copy_including_deps "$LIB"
|
||||
done
|
||||
|
||||
for MOD in $(find "$1" -type f -name "*.ko"); do
|
||||
for DEP in $(cat /$LMK/modules.dep | fgrep /$(basename $MOD):); do
|
||||
copy_including_deps "/$LMK/$DEP"
|
||||
done
|
||||
done
|
||||
|
||||
shift
|
||||
if [ "$1" != "" ]; then
|
||||
copy_including_deps "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
rm -Rf $INITRAMFS
|
||||
mkdir -p $INITRAMFS/{bin,dev,etc,lib,lib64,mnt,proc,root,run,sys,tmp,usr,var/log}
|
||||
mkdir -p $INITRAMFS/usr/{sbin,bin}
|
||||
ln -s bin $INITRAMFS/sbin
|
||||
|
||||
# If bb is not found use all static prebuilt
|
||||
copy_including_deps /bin/busybox || { cp static/busybox $INITRAMFS/bin;static="true"; }
|
||||
for i in $($INITRAMFS/bin/busybox --list|egrep -v "tar|init"); do [ ! -e $INITRAMFS/bin/$i ]&&ln -sf busybox $INITRAMFS/bin/$i; done
|
||||
|
||||
mknod $INITRAMFS/dev/console c 5 1
|
||||
mknod $INITRAMFS/dev/null c 1 3
|
||||
mknod $INITRAMFS/dev/ram0 b 1 0
|
||||
mknod $INITRAMFS/dev/tty1 c 4 1
|
||||
mknod $INITRAMFS/dev/tty2 c 4 2
|
||||
mknod $INITRAMFS/dev/tty3 c 4 3
|
||||
mknod $INITRAMFS/dev/tty4 c 4 4
|
||||
|
||||
copy_including_deps /$LMK/kernel/fs
|
||||
for LINE in $(find /$LMK/kernel/ | grep crc32c); do
|
||||
copy_including_deps $LINE
|
||||
done
|
||||
copy_including_deps /$LMK/kernel/drivers/staging/zsmalloc # needed by zram
|
||||
copy_including_deps /$LMK/kernel/drivers/block/zram
|
||||
copy_including_deps /$LMK/kernel/drivers/block/loop.*
|
||||
# usb drivers
|
||||
copy_including_deps /$LMK/kernel/drivers/usb/storage/usb-storage.*
|
||||
copy_including_deps /$LMK/kernel/drivers/usb/host
|
||||
copy_including_deps /$LMK/kernel/drivers/usb/common
|
||||
copy_including_deps /$LMK/kernel/drivers/usb/core
|
||||
copy_including_deps /$LMK/kernel/drivers/hid/usbhid
|
||||
copy_including_deps /$LMK/kernel/drivers/hid/hid.*
|
||||
copy_including_deps /$LMK/kernel/drivers/hid/uhid.*
|
||||
copy_including_deps /$LMK/kernel/drivers/hid/hid-generic.*
|
||||
# disk and cdrom drivers
|
||||
copy_including_deps /$LMK/kernel/drivers/cdrom
|
||||
copy_including_deps /$LMK/kernel/drivers/scsi/sr_mod.*
|
||||
copy_including_deps /$LMK/kernel/drivers/scsi/sd_mod.*
|
||||
copy_including_deps /$LMK/kernel/drivers/scsi/scsi_mod.*
|
||||
copy_including_deps /$LMK/kernel/drivers/scsi/sg.*
|
||||
copy_including_deps /$LMK/kernel/drivers/ata
|
||||
copy_including_deps /$LMK/kernel/drivers/nvme
|
||||
copy_including_deps /$LMK/kernel/drivers/mmc
|
||||
|
||||
# copy all custom-built modules
|
||||
copy_including_deps /$LMK/updates
|
||||
copy_including_deps /$LMK/modules.*
|
||||
|
||||
cp static/mount.dynfilefs $INITRAMFS/bin
|
||||
cp static/fsck $INITRAMFS/bin
|
||||
[[ ${static} ]]&&cp static/bash $INITRAMFS/bin||copy_including_deps /bin/bash
|
||||
[[ ${static} ]]&&cp static/tar $INITRAMFS/bin||copy_including_deps /bin/tar||copy_including_deps /usr/bin/tar
|
||||
[[ ${static} ]]&&cp static/e2fsck $INITRAMFS/bin||copy_including_deps /sbin/e2fsck
|
||||
[[ ${static} ]]&&cp static/fsck.fat $INITRAMFS/bin||copy_including_deps /sbin/fsck.fat
|
||||
[[ ${static} ]]&&cp static/f2fs $INITRAMFS/bin||copy_including_deps /sbin/fsck.f2fs
|
||||
[[ ${static} ]]&&cp static/mdadm $INITRAMFS/bin||copy_including_deps /sbin/mdadm
|
||||
[[ ${static} ]]&&cp static/mount.ntfs-3g $INITRAMFS/bin||copy_including_deps /sbin/mount.ntfs-3g
|
||||
#[[ ${static} ]]&&cp static/blkid $INITRAMFS/bin||copy_including_deps /sbin/blkid
|
||||
#copy_including_deps /usr/bin/eject || cp static/eject $INITRAMFS/bin
|
||||
|
||||
# trim modules.order file. Perhaps we could remove it entirely
|
||||
MODULEORDER="$(cd "$INITRAMFS/$LMK/"; find -name "*.ko" | sed -r "s:^./::g" | tr "\n" "|" | sed -r "s:[.]:.:g")"
|
||||
cat $INITRAMFS/$LMK/modules.order | sed -r "s/.ko.gz\$/.ko/" | grep -E "$MODULEORDER"/foo/bar > $INITRAMFS/$LMK/_
|
||||
mv $INITRAMFS/$LMK/_ $INITRAMFS/$LMK/modules.order
|
||||
|
||||
depmod -b $INITRAMFS $(ls $INITRAMFS/lib/modules | sort)
|
||||
|
||||
echo "root::0:0::/root:/bin/sh" >$INITRAMFS/etc/passwd
|
||||
touch $INITRAMFS/etc/{m,fs}tab
|
||||
|
||||
cp shutdown $INITRAMFS
|
||||
cp functions $INITRAMFS/lib
|
||||
cp init $INITRAMFS
|
||||
ln -s ../init $INITRAMFS/bin/init
|
||||
cp ../.config $INITRAMFS/lib
|
||||
chmod a+x -R $INITRAMFS
|
||||
|
||||
cd $INITRAMFS
|
||||
find | cpio -R root:root -o -H newc 2>/dev/null | gzip -cf9 >$INITRAMFS.img
|
||||
echo $INITRAMFS.img
|
||||
|
||||
cd ..
|
||||
rm -rf $INITRAMFS
|
||||
[[ ${static} ]]&&exit 2||exit 0
|
||||
@@ -0,0 +1,200 @@
|
||||
# shellcheck disable=SC2148
|
||||
export PATH=".:/:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
export LD_LIBRARY_PATH="/lib:/lib/i386-linux-gnu:/lib64:/lib64/x86_64-linux-gnu:/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu:/usr/lib64/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu"
|
||||
export MEMORY="/memory"
|
||||
export MODULES="${MEMORY}/modules"
|
||||
export CHANGES_MNT="${MEMORY}/changes"
|
||||
export CHANGES="${CHANGES_MNT}/changes"
|
||||
export WORK="${CHANGES_MNT}/work"
|
||||
export UNION="${MEMORY}/union"
|
||||
export DATAMNT="${MEMORY}/data"
|
||||
export SYSTEM="${MEMORY}/system"
|
||||
export SHELL_IS_ENABLED="_SHELL_ENABLED_"
|
||||
|
||||
progress()
|
||||
{
|
||||
sh -c "${1}" >/dev/null 2>&1&
|
||||
local pid="${!}"
|
||||
while :; do
|
||||
if [ -d /proc/${pid} ]; then
|
||||
echo -n "."
|
||||
sleep 0.25
|
||||
else
|
||||
echo -en " DONE!\n"
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
grepCmdLine()
|
||||
{
|
||||
for i in `</proc/cmdline`; do egrep "^${1}|^${1}=.*" <<<${i}|cut -f2 -d=; done
|
||||
return ${?}
|
||||
}
|
||||
d()
|
||||
{
|
||||
grepCmdLine debug >/dev/null 2>&1
|
||||
return ${?}
|
||||
}
|
||||
isShellEnabled()
|
||||
{
|
||||
d&&echo -n "Is 'shell' bootloader variable set? "
|
||||
if grepCmdLine shell; then
|
||||
d&&echo -en "Yes\n"
|
||||
sed -i "s/_SHELL_ENABLED_/true/g" /lib/functions >/dev/null 2>&1
|
||||
echo "[!] Reloading /lib/functions"
|
||||
if . /lib/functions; then
|
||||
echo -en "Done\n"
|
||||
else
|
||||
echo -en "Failed\n"
|
||||
emergencyShell
|
||||
fi
|
||||
else
|
||||
d&&echo -en "No\n"
|
||||
fi
|
||||
}
|
||||
isZramEnabled()
|
||||
{
|
||||
d&&echo -n "Is zram supported? "
|
||||
if [ -e /sys/block/zram0/disksize ]; then
|
||||
d&&echo -en "Yes\n"
|
||||
echo 536870912 >/sys/block/zram0/disksize
|
||||
mkswap /dev/zram0 >/dev/null 2>&1
|
||||
swapon /dev/zram0 >/dev/null 2>&1
|
||||
echo 100 >/proc/sys/vm/swappiness
|
||||
else
|
||||
d&&echo -en "No\n"
|
||||
fi
|
||||
}
|
||||
findData()
|
||||
{
|
||||
d&&echo -n "Searching ${DISTRO} in /dev -> "
|
||||
#local from="$(grepCmdLine from)"
|
||||
for i in ${root:-/dev/[hmnsv][dmrv][0-9a-z]*}; do
|
||||
d&&echo -n "${i#/dev/} "
|
||||
mount -o ro ${i} ${DATAMNT} >/dev/null 2>&1
|
||||
sleep 0.5
|
||||
#[[ ${from} ]]&&mount ${DATAMNT}/${from} ${DATAMNT} >/dev/null 2>&1
|
||||
if [ -e ${DATAMNT}/${DISTRO}/system.sfs ]; then
|
||||
d&&echo -e "\nFound ${DISTRO} in ${i}"
|
||||
grepCmdLine fsck&&fsck ${i} >/dev/null 2>&1||true
|
||||
d&&echo -n "Is 'toram' bootloader variable set and enought RAM space? "
|
||||
if grepCmdLine toram; local a=${?}&&[[ "$(grep MemFree /proc/meminfo|awk '{print $2}')" -gt $(("$(du ${DATAMNT}|tail -n1|awk '{print $1}')"-"$(du ${DATAMNT}/changes|tail -n1|awk '{print $1}')")) ]]; then
|
||||
d&&echo -en "Yes\n"
|
||||
mkdir -p /tmp/data
|
||||
d&&echo -n "Copying to RAM "
|
||||
d&&progress "tar -c -C ${DATAMNT} --exclude ./changes -f - . | tar -xf - -C /tmp/data"
|
||||
umount -f ${DATAMNT} >/dev/null 2>&1
|
||||
#[[ ${from} ]]&&umount -f ${DATAMNT} >/dev/null 2>&1
|
||||
mv -f /tmp/data/* ${DATAMNT} >/dev/null 2>&1
|
||||
rm -rf /tmp/data >/dev/null 2>&1
|
||||
else
|
||||
d&&if [[ "${a}" != "0" ]]; then echo -ne "Not requested by bootloader or low RAM space!\n"; else echo -ne "Internal error? Trying tmpfs, so data after power-off will be erased permanently!\n"; fi
|
||||
mount -o remount,rw ${DATAMNT} >/dev/null 2>&1||true
|
||||
fi
|
||||
mount ${DATAMNT}/${DISTRO}/system.sfs ${SYSTEM} >/dev/null 2>&1
|
||||
sleep 0.5
|
||||
break
|
||||
else
|
||||
umount -f ${DATAMNT} >/dev/null 2>&1
|
||||
fi
|
||||
done
|
||||
if ! grep -q ${SYSTEM} /proc/mounts; then
|
||||
d&&echo "Can not find compatible distro!"
|
||||
emergencyShell
|
||||
fi
|
||||
}
|
||||
findModules()
|
||||
{
|
||||
d&&echo -n "Trying to mount modules from ${DATAMNT}/${DISTRO}/modules -> "
|
||||
if ls ${DATAMNT}/${DISTRO}/modules/*.sfs >/dev/null 2>&1; then
|
||||
for i in $(find ${DATAMNT}/${DISTRO}/modules -maxdepth 1 -type f -name "*.sfs"|sort); do
|
||||
mkdir -p ${MODULES}/$(basename ${i} .sfs)
|
||||
d&&echo -n "$(basename ${i}) "
|
||||
mount ${i} ${MODULES}/$(basename ${i} .sfs) >/dev/null 2>&1
|
||||
done
|
||||
d&&echo -en "Done\n"
|
||||
else
|
||||
d&&echo -en "Failed, modules not found! Continuing...\n"
|
||||
fi
|
||||
}
|
||||
mountOverlay()
|
||||
{
|
||||
if grep -q ${MODULES} /proc/mounts; then
|
||||
mount -t overlay -o lowerdir=${SYSTEM}:$(find ${MODULES} -mindepth 1 -maxdepth 1 | tac | tr "\n" ":" | sed -r "s/:$//"),upperdir=${CHANGES},workdir=${WORK} overlay ${UNION}
|
||||
else
|
||||
mount -t overlay -o lowerdir=${SYSTEM},upperdir=${CHANGES},workdir=${WORK} overlay ${UNION}
|
||||
fi
|
||||
}
|
||||
persistentChanges()
|
||||
{
|
||||
if ! grepCmdLine perch&&grepCmdLine toram; then
|
||||
return
|
||||
fi
|
||||
local CHANGES T1 T2 EXISTS
|
||||
CHANGES=$DATAMNT/changes
|
||||
T1="$CHANGES/.empty"
|
||||
T2="$T1"2
|
||||
mkdir -p "$2"
|
||||
touch "$T1" 2>/dev/null && rm -f "$T1" 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
return
|
||||
fi
|
||||
d&&echo "Testing persistent changes for posix compatibility"
|
||||
touch "$T1" && ln -sf "$T1" "$T2" 2>/dev/null && \
|
||||
chmod +x "$T1" 2>/dev/null && test -x "$T1" && \
|
||||
chmod -x "$T1" 2>/dev/null && test ! -x "$T1" && \
|
||||
rm "$T1" "$T2" 2>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
d&&echo "Activating native persistent changes"
|
||||
mount --bind "$CHANGES" "$2" >/dev/null 2>&1
|
||||
return
|
||||
fi
|
||||
if [ -e "$CHANGES/changes.dat.0" ]; then
|
||||
d&&echo "Restoring persistent changes"
|
||||
EXISTS="true"
|
||||
else
|
||||
d&&echo "Creating new persistent changes"
|
||||
EXISTS=""
|
||||
fi
|
||||
mount.dynfilefs -f "$CHANGES/changes.dat" -s 16000 -m "$2" -p 4000 >/dev/null 2>&1
|
||||
[ ! "$EXISTS" ] && mke2fs -F -L "DATA" "$2/virtual.dat" >/dev/null 2>&1
|
||||
grepCmdLine fsck && fsck ${2}/virtual.dat >/dev/null 2>&1
|
||||
mount "$2/virtual.dat" "$2" >/dev/null 2>&1
|
||||
rm "$T1" "$T2" >/dev/null 2>&1
|
||||
rmdir "$2/lost+found" >/dev/null 2>&1
|
||||
}
|
||||
debugShell()
|
||||
{
|
||||
if [ "$SHELL_IS_ENABLED" = "true" ]; then
|
||||
echo -e "Debug shell!\nControl+D or 'exit' to contiunue boot.\n"
|
||||
setsid cttyhack sh
|
||||
fi
|
||||
}
|
||||
changeRoot()
|
||||
{
|
||||
cd "$1"
|
||||
umount -f /sys /proc
|
||||
cat <<eot >etc/fstab
|
||||
proc /proc proc defaults 0 0
|
||||
sysfs /sys sysfs defaults 0 0
|
||||
devpts /dev/pts devpts gid=5,mode=620 0 0
|
||||
tmpfs /dev/shm tmpfs defaults 0 0
|
||||
overlay / overlay defaults 0 0
|
||||
eot
|
||||
mkdir -p run
|
||||
mount -t tmpfs tmpfs run
|
||||
mkdir -p run/initramfs
|
||||
mount -o remount,ro overlay .
|
||||
pivot_root . run/initramfs
|
||||
exec chroot . init
|
||||
}
|
||||
emergencyShell()
|
||||
{
|
||||
exec >/dev/console >&1 2>&1 <&1
|
||||
echo "Error: Please inspect '/tmp/mlb.log' file"
|
||||
export PS1="RESCUE # "
|
||||
while :; do
|
||||
echo "Rescue shell!"
|
||||
setsid cttyhack sh
|
||||
done
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
. /lib/.config
|
||||
. /lib/functions
|
||||
|
||||
if [ ! -e /lib/.escaped ]; then
|
||||
SWITCH=/m
|
||||
mkdir -p ${SWITCH}
|
||||
mount -t tmpfs -o size="100%" tmpfs ${SWITCH}
|
||||
cp -a /??* ${SWITCH} 2>/dev/null
|
||||
cd ${SWITCH}
|
||||
mount -t proc proc /proc
|
||||
echo "0" >/proc/sys/kernel/printk
|
||||
>lib/.escaped
|
||||
d&&echo "[!] Reloading ${0}"
|
||||
mount --move /proc proc
|
||||
exec switch_root . ${0}
|
||||
fi
|
||||
mount -t devtmpfs devtmpfs /dev >/dev/null 2>&1
|
||||
ln -sf /proc/self/fd /dev/fd
|
||||
exec > >(tee -i /tmp/mlb.log) 2>&1
|
||||
d&&echo "'debug' bootloader variable is set!"&&set -x
|
||||
mount -t sysfs sysfs /sys >/dev/null 2>&1
|
||||
mkdir -p ${UNION} ${DATAMNT} ${SYSTEM}
|
||||
isShellEnabled
|
||||
ln -sf /proc/mounts /etc/mtab
|
||||
find /lib/modules/`uname -r` -name "*.ko" -type f | sed -r "s:^.*/|[.]ko\$::g" | xargs -n 1 modprobe >/dev/null 2>&1
|
||||
sleep 3
|
||||
mdev -s
|
||||
debugShell
|
||||
isZramEnabled
|
||||
mdadm --assemble --scan >/dev/null 2>&1
|
||||
sleep 0.5
|
||||
debugShell
|
||||
findData
|
||||
debugShell
|
||||
findModules
|
||||
debugShell
|
||||
persistentChanges ${SYSTEM} ${CHANGES_MNT}
|
||||
mkdir -p ${CHANGES} ${WORK}
|
||||
debugShell
|
||||
mountOverlay >/dev/null 2>&1
|
||||
debugShell
|
||||
d&&echo "Starting ${DISTRO}"
|
||||
d&&sleep 2
|
||||
changeRoot "$UNION" || clear; echo "!!ERROR occured, you shouldn't be here.!!"; sleep 3
|
||||
emergencyShell
|
||||
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
# Original Author: Tomas M <http://www.linux-live.org/>
|
||||
# Author: Daniel K. <http://danielisko.net, http://git.danielisko.net>
|
||||
|
||||
action="${1}"
|
||||
. /lib/.config
|
||||
. /lib/functions
|
||||
detach_loops()
|
||||
{
|
||||
losetup -a | cut -d : -f 1 | xargs -r -n 1 losetup -d
|
||||
}
|
||||
umount_all()
|
||||
{
|
||||
for i in $(tac /proc/mounts | cut -d" " -f2 | grep "^${1}"); do
|
||||
umount -fld ${i}
|
||||
detach_loops
|
||||
done
|
||||
}
|
||||
|
||||
exec </dev/console >>/dev/console 2>>/dev/console
|
||||
[ "${DEBUG_IS_ENABLED}" = "true" ]&&set -x
|
||||
debugShell
|
||||
echo "Minimal Linux Booter - Shutdown Magic!"
|
||||
echo "Entering to clean-up things before final step."
|
||||
(
|
||||
mdev -s
|
||||
sleep 1.5
|
||||
detach_loops
|
||||
umount_all /oldroot
|
||||
NR=100
|
||||
for i in $(tac /proc/mounts | cut -d" " -f2 | grep ^/oldroot/.); do
|
||||
NR=$((${NR}+1))
|
||||
mkdir -p /move/${NR}
|
||||
mount --move ${i} /move/${NR}
|
||||
umount -fld /oldroot
|
||||
done
|
||||
for i in 1 2 3 4; do
|
||||
for d in $(ls -1 /move 2>/dev/null | sort); do
|
||||
umount_all /move/${d}
|
||||
done
|
||||
done
|
||||
umount_all /memory
|
||||
) >/dev/null 2>&1
|
||||
case ${action} in
|
||||
reboot|poweroff|halt|shutdown) ${action} -f;;
|
||||
*) reboot -f;;
|
||||
esac
|
||||
emergencyShell #Last luck emergency shell after reboot doesn't work; usefull for debugging
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
dev=$1
|
||||
[ "$dev" = "" ] && exit 1
|
||||
|
||||
fs=$(blkid "$dev" | grep -o ' TYPE=".*' | cut -f 2 -d '"')
|
||||
|
||||
case $fs in
|
||||
ext2|ext3|ext4) e2fsck -y $dev ;;
|
||||
vfat|msdos) fsck.fat -y $dev ;;
|
||||
exfat) exfatfsck $dev ;;
|
||||
*) echo "(${dev}) Not supported: $fs" ; exit 1 ;;
|
||||
esac
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user