added init scripts
This commit is contained in:
parent
5ad4393d9b
commit
9aad2dadbf
@ -8,5 +8,8 @@ cd build
|
|||||||
|
|
||||||
echo_blue "Starting installation at $ROOT."
|
echo_blue "Starting installation at $ROOT."
|
||||||
|
|
||||||
install_busybox || exit 1
|
install_busybox
|
||||||
|
install_binary $(which modprobe)
|
||||||
|
install_binary $(which switch_root)
|
||||||
|
install_init_script
|
||||||
create_archive
|
create_archive
|
||||||
|
@ -8,13 +8,12 @@ echo_red() {
|
|||||||
echo -e "\033[0;31m$1\033[0m"
|
echo -e "\033[0;31m$1\033[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Installs a library. Expects absolute path.
|
# Installs a library. Expects absolute path.
|
||||||
install_lib() {
|
install_lib() {
|
||||||
local lib="$1"
|
local lib="$1"
|
||||||
[[ -f "$lib" ]] || {
|
[[ -f "$lib" ]] || {
|
||||||
echo "Did not find library at path: $lib"
|
echo "Did not find library at path: $lib"
|
||||||
return 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir -p $(dirname "${ROOT}${lib}")
|
mkdir -p $(dirname "${ROOT}${lib}")
|
||||||
@ -29,7 +28,7 @@ install_binary() {
|
|||||||
local binary="$1" lib=''
|
local binary="$1" lib=''
|
||||||
[[ -f "$binary" ]] || {
|
[[ -f "$binary" ]] || {
|
||||||
echo_red "Did not find binary at path: $binary"
|
echo_red "Did not find binary at path: $binary"
|
||||||
return 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
echo_blue "Adding binary to root: $binary"
|
echo_blue "Adding binary to root: $binary"
|
||||||
@ -50,14 +49,20 @@ install_busybox() {
|
|||||||
[[ -f "$BUSYBOX_PATH" ]] || {
|
[[ -f "$BUSYBOX_PATH" ]] || {
|
||||||
echo_red "Did not find busybox at $BUSYBOX_PATH"
|
echo_red "Did not find busybox at $BUSYBOX_PATH"
|
||||||
echo_red "Please compile or download busybox. You can also change the path."
|
echo_red "Please compile or download busybox. You can also change the path."
|
||||||
return 1
|
exit 1
|
||||||
}
|
}
|
||||||
install_binary "$BUSYBOX_PATH"
|
install_binary "$BUSYBOX_PATH" || return 1
|
||||||
for applet in $(/usr/lib/initcpio/busybox --list); do
|
for applet in $(/usr/lib/initcpio/busybox --list); do
|
||||||
ln -s busybox "${ROOT}/usr/bin/$applet"
|
ln -s busybox "${ROOT}/usr/bin/$applet"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_init_script() {
|
||||||
|
cp ../init.sh ${ROOT}/init
|
||||||
|
cp ../init_functions.sh ${ROOT}/
|
||||||
|
}
|
||||||
|
|
||||||
create_archive() {
|
create_archive() {
|
||||||
|
echo_blue "Creating archive..."
|
||||||
find . | cpio -o -H newc | gzip > detee-$(hostnamectl hostname)-$(uname -r).cpio.gz
|
find . | cpio -o -H newc | gzip > detee-$(hostnamectl hostname)-$(uname -r).cpio.gz
|
||||||
}
|
}
|
||||||
|
5
init.sh
Executable file
5
init.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source /init_functions.sh
|
||||||
|
load_modules
|
||||||
|
mount_root
|
||||||
|
exec switch_root /mnt /sbin/init "$@"
|
38
init_functions.sh
Normal file
38
init_functions.sh
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo_blue() {
|
||||||
|
echo -e "\033[34m$1\033[0m"
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_red() {
|
||||||
|
echo -e "\033[0;31m$1\033[0m"
|
||||||
|
}
|
||||||
|
|
||||||
|
load_modules() {
|
||||||
|
modprobe btrfs msr sev-guest || exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
create_mounts() {
|
||||||
|
mount -t proc proc /proc -o nosuid,noexec,nodev
|
||||||
|
mount -t sysfs sys /sys -o nosuid,noexec,nodev
|
||||||
|
mount -t devtmpfs dev /dev -o mode=0755,nosuid
|
||||||
|
mount -t tmpfs run /run -o nosuid,nodev,mode=0755
|
||||||
|
mkdir -m755 /run/initramfs
|
||||||
|
|
||||||
|
if [ -e /sys/firmware/efi ]; then
|
||||||
|
mount -t efivarfs efivarfs /sys/firmware/efi/efivars -o nosuid,nodev,noexec
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Setup /dev symlinks
|
||||||
|
if [ -e /proc/kcore ]; then
|
||||||
|
ln -sfT /proc/kcore /dev/core
|
||||||
|
fi
|
||||||
|
ln -sfT /proc/self/fd /dev/fd
|
||||||
|
ln -sfT /proc/self/fd/0 /dev/stdin
|
||||||
|
ln -sfT /proc/self/fd/1 /dev/stdout
|
||||||
|
ln -sfT /proc/self/fd/2 /dev/stderr
|
||||||
|
}
|
||||||
|
|
||||||
|
mount_root() {
|
||||||
|
mount /dev/vda1 /mnt
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user