Skip to content

Commit

Permalink
add version 1.1, also initial commit from local
Browse files Browse the repository at this point in the history
  • Loading branch information
em1lyy committed Aug 10, 2020
1 parent 3d89be2 commit 1132d69
Show file tree
Hide file tree
Showing 13 changed files with 730 additions and 23 deletions.
40 changes: 19 additions & 21 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
MIT License

Copyright (c) 2020 Chiyoko Linux

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Copyright (c) 2020 Jonas Jaguar <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
53 changes: 53 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
include config.mk

INITOBJ = ichirou.o
INITBIN = ichirou

SERVOBJ = kanrisha.o
SERVBIN = kanrisha

CONFS = confs/rc.conf confs/rc.init confs/rc.local confs/rc.postinit confs/rc.shutdown

all: $(INITBIN) $(SERVBIN) confs

$(INITBIN): $(INITOBJ)
$(CC) $(LDFLAGS) -o $@ $(INITOBJ) $(LDLIBS)

$(SERVBIN): $(SERVOBJ)
$(CC) $(LDFLAGS) -o $@ $(SERVOBJ) $(LDLIBS)

$(INITOBJ): config.h
$(SERVOBJ): config.h

confs:
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f $(CONFS) $(DESTDIR)$(PREFIX)/bin

install: all
mkdir -p $(DESTDIR)$(PREFIX)/bin
cp -f $(INITBIN) $(DESTDIR)$(PREFIX)/bin
cp -f $(SERVBIN) $(DESTDIR)$(PREFIX)/bin

uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(INITBIN) $(DESTDIR)$(PREFIX)/bin/$(SERVBIN)

dist: clean
mkdir -p ichirou-$(VERSION)
mkdir -p ichirou-$(VERSION)/confs
cp LICENSE Makefile README config.def.h config.mk ichirou.c kanrisha.c ichirou-$(VERSION)
cp confs/rc.conf confs/rc.init confs/rc.local confs/rc.postinit \
confs/rc.shutdown ichirou-$(VERSION)/confs
tar -cf ichirou-$(VERSION).tar ichirou-$(VERSION)
gzip ichirou-$(VERSION).tar
rm -rf ichirou-$(VERSION)

clean:
rm -f $(INITBIN) $(SERVBIN) $(INITOBJ) $(SERVOBJ) ichirou-$(VERSION).tar.gz

.SUFFIXES: .def.h

.def.h.h:
cp $< $@

.PHONY:
all install uninstall dist clean
5 changes: 5 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ichirou init system
===================

ichirou is a basic init system for linux systems.
it comes with its own service manager, kanrisha.
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

8 changes: 8 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
static char *const rcinitfile[] = { "/bin/rc.init", NULL };
static char *const rcpostinitfile[] = { "/bin/rc.postinit", NULL };
static char *const servstartcmd[] = { "/bin/kanrisha", "start", NULL };
static char *const rcshutdownfile[] = { "/bin/rc.shutdown", NULL };
static char *const servstopcmd[] = { "/bin/kanrisha", "stop", NULL };

#define SIGKILLTIMEOUT 10
#define MAXSERVICES 512
10 changes: 10 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
VERSION = 1.1

PREFIX =
MANPREFIX = $(PREFIX)/share/man

CC = gcc
LD = $(CC)
CPPFLAGS =
CFLAGS = -Wextra -Wall -Os -s
LDFLAGS = -s -static
3 changes: 3 additions & 0 deletions confs/rc.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
HOSTNAME=lfs-live
INTERFACE=eth0
TIMEZONE="Europe/Berlin"
82 changes: 82 additions & 0 deletions confs/rc.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/sh

umask 022

echo
echo "---------------------------------"
echo "| ichirou init system - booting |"
echo "---------------------------------"
echo

echo sourcing config
source /etc/rc.conf

/bin/ctrlaltdel -s

echo mounting system filesystems...
/bin/mount -n -t proc -o nosuid,noexec,nodev proc /proc
/bin/mount -n -t sysfs -o nosuid,noexec,nodev sysfs /sys
/bin/mount -n -t tmpfs -o nosuid,mode=0755 dev /dev
/bin/mkdir -p /dev/pts
/bin/mount -n -t devpts -o gid=5,mode=0620 devpts /dev/pts
/bin/mount -o remount,ro /

/bin/grep -q " verbose" /proc/cmdline && dmesg -n 8 || dmesg -n 3

echo starting udevd
/sbin/udevd -d
/sbin/udevadm trigger --action=add --type=subsystems
/sbin/udevadm trigger --action=add --type=devices
/sbin/udevadm trigger --action=change --type=devices

/bin/ln -sf /proc/self/fd/0 /dev/stdin
/bin/ln -sf /proc/self/fd/1 /dev/stdout
/bin/ln -sf /proc/self/fd/2 /dev/stderr
/bin/ln -sf /proc/self/fd /dev/fd

echo checking filesystems...
/bin/fsck -ATa
if [ $? -eq 1 ]; then
echo CRITICAL: filesystem has errors, dropping into rescue shell
/bin/sh
/bin/halt -r
fi

echo making root writable
/bin/mount -o remount,rw /

echo mounting filesystems...
/bin/mount -a
ln -sf /proc/mounts /etc/mtab

echo setting hostname...
/bin/hostname $HOSTNAME

echo starting loopback
/bin/ip addr add 127.0.0.1/8 dev lo broadcast + scope host
/bin/ip link set lo up

echo setting hwclock
export TZ="$TIMEZONE"
/bin/hwclock -u -s /dev/rtc0
unset TZ

echo directing dmesg output to /var/log/dmesg.log
/bin/dmesg > /var/log/dmesg.log
if [ -e /proc/sys/kernel/dmesg_restrict ] && [ $(/bin/cat /proc/sys/kernel/dmesg_restrict) = "1" ];
then
/bin/chmod 0600 /var/log/dmesg.log
else
/bin/chmod 0644 /var/log/dmesg.log
fi

ulimit -c unlimited

: > /var/run/utmp

echo
echo "-------------------------------------"
echo "| ichirou init system - almost done |"
echo "| starting services now! |"
echo "-------------------------------------"
echo
8 changes: 8 additions & 0 deletions confs/rc.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

echo
echo "----------------------------------"
echo "| ichirou init system - rc.local |"
echo "| place custom init scripts here |"
echo "----------------------------------"
echo
16 changes: 16 additions & 0 deletions confs/rc.postinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

echo running rc.local
/bin/rc.local

echo
echo "-----------------------------------"
echo "| ichirou init system - boot done |"
echo "| starting ttys now! |"
echo "-----------------------------------"
echo

for i in {1..7}
do
/bin/sh -c "/bin/respawn /bin/getty /dev/tty$i linux" &>/dev/null &
done
19 changes: 19 additions & 0 deletions confs/rc.shutdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

echo
echo "---------------------------------"
echo "| ichirou init system - halting |"
echo "---------------------------------"
echo

/bin/hwclock $HWCLOCK_PARAMS /dev/rtc0

echo syncing filesystems
/bin/sync
/bin/sleep 3

echo disabling swap
swapoff -a &>/dev/null

echo unmounting filesystems
/bin/umount -a -r &>/dev/null
Loading

0 comments on commit 1132d69

Please sign in to comment.