From 082ff35cd5d3b93cf6731525d4c5e273108e9061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Mazurkiewicz?= Date: Tue, 31 Oct 2017 17:14:37 -0400 Subject: [PATCH] Init --- prepare.sh | 81 ++++++++++ src/init | 28 ++++ src/usr/bin/commands | 234 ++++++++++++++++++++++++++++ src/usr/share/livedemo/src/cfdisk | 4 + src/usr/share/livedemo/src/fdisk | 4 + src/usr/share/livedemo/src/func | 57 +++++++ src/usr/share/livedemo/src/rescshri | 10 ++ 7 files changed, 418 insertions(+) create mode 100755 prepare.sh create mode 100755 src/init create mode 100755 src/usr/bin/commands create mode 100755 src/usr/share/livedemo/src/cfdisk create mode 100755 src/usr/share/livedemo/src/fdisk create mode 100755 src/usr/share/livedemo/src/func create mode 100755 src/usr/share/livedemo/src/rescshri diff --git a/prepare.sh b/prepare.sh new file mode 100755 index 0000000..3ff1e36 --- /dev/null +++ b/prepare.sh @@ -0,0 +1,81 @@ +#!/bin/sh + + # ------------------------------------------------------- + # Preparation of the rescshri Linux mini-distribution + # 2017 Jaromaz http://jm.iq.pl + # ------------------------------------------------------- + + VERSION='1.2' + DEMO=0 + CPU=32 + HTTPSERVER='http://jm.iq.pl/rescshri/download' + + # ------------------------------------------------------- + + download_unpack () { + echo "Downloading $CPU-bit version:" + cd ./download + wget $HTTPSERVER/rescshri-$VERSION-$CPU-src.tar.gz + tar zxf rescshri-$VERSION-$CPU-src.tar.gz + rm rescshri-$VERSION-$CPU-src.tar.gz + cd .. + } + + if [ ! -d 'output' ] ; then + mkdir output + fi + + for i in $@ + do + case $i in + 'redownload') + rm -r download + ;; + 'livedemo') + DEMO=1 + ;; + *) + if [ $i -eq 32 -o $i -eq 64 ] ; then + CPU=$i + fi + ;; + esac + done + + if [ ! -d 'download' ] ; then + mkdir download + fi + if [ ! -d "download/$CPU" ] ; then + download_unpack + fi + + # Instalation + rm -r tmp > /dev/null 2>&1 + mkdir tmp + cp -r download/$CPU/* tmp + cp -r src/* tmp + rm -r output > /dev/null 2>&1 + mkdir output + mv tmp/bzImage output + + # Preparation of live demo version + if [ $DEMO -eq 1 ] ; then + mv tmp/usr/share/livedemo/bin/* tmp/usr/bin/ + mv tmp/usr/bin/fdisk tmp/usr/share/livedemo/bin/ + mv tmp/usr/bin/cfdisk tmp/usr/share/livedemo/bin/ + tail +2 tmp/usr/share/livedemo/src/func >> tmp/usr/bin/func + rm tmp/usr/share/livedemo/src/func + tail +3 tmp/usr/bin/rescshri >> tmp/usr/share/livedemo/src/rescshri + mv tmp/usr/share/livedemo/src/* tmp/usr/bin/ + else + rm -r tmp/usr/share/livedemo + fi + + # Initrd cpio archive + cd ./tmp + find . | cpio --create --format='newc' | gzip > ../output/rescshri.img + cd .. + rm -r tmp + + echo "done" + diff --git a/src/init b/src/init new file mode 100755 index 0000000..5b30c40 --- /dev/null +++ b/src/init @@ -0,0 +1,28 @@ +#!/bin/sh +# rescshri 1.2 init + +export HOME=/home +export PATH=/bin:/sbin:/usr/bin + +mountpoint -q proc || mount -t proc proc proc +mountpoint -q sys || mount -t sysfs sys sys + + +if ! mountpoint -q dev +then + mount -t devtmpfs dev dev || mdev -s + mkdir -p dev/pts + mountpoint -q dev/pts || mount -t devpts dev/pts dev/pts +fi + +hostname rescshri + +[ -z "$CONSOLE" ] && + CONSOLE="$(sed -n 's@.* console=\(/dev/\)*\([^ ]*\).*@\2@p' /proc/cmdline)" + +[ -z "$HANDOFF" ] && HANDOFF=/bin/sh && rescshri +[ -z "$CONSOLE" ] && CONSOLE=console + +exec /sbin/oneit -c /dev/"$CONSOLE" $HANDOFF + + diff --git a/src/usr/bin/commands b/src/usr/bin/commands new file mode 100755 index 0000000..2d533d6 --- /dev/null +++ b/src/usr/bin/commands @@ -0,0 +1,234 @@ +#!/bin/sh + +. func + + COMNS="acpi\ + base64\ + basename\ + blkid\ + blockdev\ + bunzip2\ + bunzip2\ + bzcat\ + bzcat\ + -\ + bzip2\ + cal\ + cat\ + catv\ + cfdisk\ + chattr\ + chgrp\ + chmod\ + chown\ + chroot\ + chrt\ + -\ + chvt\ + cksum\ + clear\ + cmp\ + comm\ + commands\ + count\ + cp\ + cpio\ + cut\ + date\ + df\ + -\ + dirname\ + dmesg\ + dos2unix\ + du\ + e2fsck\ + echo\ + egrep\ + eject\ + env\ + expand\ + -\ + factor\ + fallocate\ + false\ + fdisk\ + fgrep\ + file\ + find\ + flock\ + free\ + -\ + freeramdisk\ + fsfreeze\ + fstype\ + fsync\ + grep\ + groups\ + gunzip\ + gzip\ + halt\ + -\ + head\ + help\ + hexedit\ + hostname\ + hush\ + hwclock\ + id\ + ifconfig\ + inotifyd\ + -\ + insmod\ + install\ + ionice\ + iorenice\ + iotop\ + kill\ + killall\ + killall5\ + link\ + -\ + ln\ + login\ + logname\ + losetup\ + ls\ + lsattr\ + lsmod\ + lspci\ + lsusb\ + makedevs\ + -\ + md5sum\ + microcom\ + mix\ + mkdir\ + mkfifo\ + mknod\ + mkpasswd\ + mkswap\ + mktemp\ + -\ + modinfo\ + mount\ + mountpoint\ + mv\ + nbd-client\ + nc\ + netcat\ + netstat\ + nice\ + -\ + nl\ + nohup\ + nproc\ + od\ + oneit\ + partprobe\ + passwd\ + paste\ + patch\ + pgrep\ + -\ + pidof\ + ping\ + pivot_root\ + pkill\ + pmap\ + poweroff\ + printenv\ + printf\ + ps\ + -\ + pwd\ + pwdx\ + readahead\ + readlink\ + realpath\ + reboot\ + renice\ + reset\ + -\ + resize2fs\ + rev\ + rfkill\ + rm\ + rmdir\ + rmmod\ + route\ + sed\ + seq\ + setsid\ + sh\ + -\ + sha1sum\ + shred\ + sleep\ + sort\ + split\ + stat\ + strings\ + su\ + swapoff\ + swapon\ + -\ + switch_root\ + sync\ + sysctl\ + tac\ + tail\ + tar\ + taskset\ + tee\ + time\ + timeout\ + -\ + top\ + touch\ + true\ + truncate\ + tty\ + tunctl\ + tutorial\ + umount\ + uname\ + uniq\ + -\ + unix2dos\ + unlink\ + unxz\ + uptime\ + usleep\ + uudecode\ + uuencode\ + vconfig\ + vi\ + -\ + vmstat\ + w\ + wc\ + wget\ + which\ + who\ + whoami\ + xargs\ + xxd\ + xzcat\ + yes\ + " + + clear + rdwhi "\n\n Currently available commands:\n\n " + rdef + for v in $COMNS + do + if [ $v == "-" ] ; then + printf "\n " + else + rdcya $v + rdef ", " + fi + done + + rdcya 'zcat' + rdef ".\n\n" diff --git a/src/usr/share/livedemo/src/cfdisk b/src/usr/share/livedemo/src/cfdisk new file mode 100755 index 0000000..f5cfcb9 --- /dev/null +++ b/src/usr/share/livedemo/src/cfdisk @@ -0,0 +1,4 @@ +#!/bin/sh +. func +/usr/share/livedemo/bin/cfdisk $@ +resdenit diff --git a/src/usr/share/livedemo/src/fdisk b/src/usr/share/livedemo/src/fdisk new file mode 100755 index 0000000..3034d8a --- /dev/null +++ b/src/usr/share/livedemo/src/fdisk @@ -0,0 +1,4 @@ +#!/bin/sh +. func +/usr/share/livedemo/bin/fdisk $@ +resdenit diff --git a/src/usr/share/livedemo/src/func b/src/usr/share/livedemo/src/func new file mode 100755 index 0000000..d1f96c0 --- /dev/null +++ b/src/usr/share/livedemo/src/func @@ -0,0 +1,57 @@ +#!/bin/sh + + # Livedemo location + LD='/usr/share/livedemo'; + + # Virtual HDD location + FHDD="$LD/hdd/hda.img" + + # Virtual HDD initialization + resinit () { + + losetup --partscan --show --find $FHDD > /dev/null 2>&1 + + # Virtual partitions - maximum 5 + ln -n /dev/loop0 /dev/hda > /dev/null 2>&1 + for i in 1 2 3 4 5 + do + ln -n /dev/loop0p$i /dev/hda$i > /dev/null 2>&1 + done + } + + # Virtual HDD reinitialization + resdenit () { + + # Removing fake hdd + rm /dev/hda > /dev/null 2>&1 + for i in 1 2 3 4 5 + do + rm /dev/hda$i > /dev/null 2>&1 + done + + # Detaching the loop device + losetup -d /dev/loop0 > /dev/null 2>&1 + sleep 1 + + # Resinit call + resinit + } + + + # Image file creation + hdd_image () { + printf "Setting up a virtual hard drive /dev/hda ." + dd if=/dev/zero of=$FHDD bs=1024 count=6144 > /dev/null 2>&1 + printf "." + printf "n\np\n\n\n\nw\n" | $LD/bin/fdisk $FHDD > /dev/null 2>&1 + printf "." + resinit + printf "." + mkfs.ext4 /dev/loop0p1 > /dev/null 2>&1 + printf ". " + resdenit + printf "done.\n" + sleep 1 + } + + diff --git a/src/usr/share/livedemo/src/rescshri b/src/usr/share/livedemo/src/rescshri new file mode 100755 index 0000000..01592e1 --- /dev/null +++ b/src/usr/share/livedemo/src/rescshri @@ -0,0 +1,10 @@ +#!/bin/sh + + . func + if [ ! -f $FHDD ] ; then + dmesg -n 1 + hdd_image + mount /dev/hda1 /mnt + fi + +