So i have a custom init that seems to work pretty good but i wanted to add the fish shell to it and make it and interactive place for ZFS based recovery and nfs mounting etc....
i am running into a problem with losing pid 1. I got the fire on my back for getting multiple wiper units deployed with server monitoring to ensure happy clients and iam behind so any help would greatly be appreciated. It seems this issue has been a stepping stone for me for a while.
Anyway i was wondering whats the best way of maintaining PID 1, TTY 1 and environment when jumping from an interactive prompt with /bin/busybox sh to the interactive shell and back to exec switch_root
I didn't post the entire init but i think its obvious what i am doi
Code:
#!/bin/sh
#Rescue Shell
/bin/busybox sleep 1
/bin/busybox mount -t proc nonexec setsid in busybox and keep pid 1 after script execution /proc
/bin/busybox mount -t sysfs none /sys
/bin/busybox mount -t devtmpfs none /dev
/bin/busybox --install -s
/bin/busybox sleep 3
source /etc/profile
hostname Ultimate
ldconfig
if [ $(cat /proc/cmdline | grep -i -o -m1 "breaknow" ) = "breaknow" ]
then
rescue_break
else
echo "$yellow attempting to import pool $nocolor"
fi
exec setsid cttyhack sh (how i get pid 1 now but after but i keep needing to resource the environment in /etc/profile)
Also i was wondering if it might be better to use inittab for this is i was thinking it might but it iam not really sure where to put the init file for init tab.
udev
importpool
example of environment / profile file
Code:
#!/bin/busybox sh
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
SHELL=/bin/busybox sh
HOME=/
red="\e[1;31m"
yellow="\e[1;33m"
orange="\e[0;33m"
green="\e[1;32m"
nocolor="\e[1;m"
LANG="en_US.UTF-8"
LANGUAGE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
TERM="linux"
root=rpool
showcommands() (
echo -e "$green ZFS COMMAND LIST $nocolor"
echo -e "$green export root=zfs:rpool $nocolor sets desired pool to be rootfs note: boo
tfs is dicated by the what the pools bootfs is"
echo -e "$green importpool $nocolor imports pool by looking at the root= kernel command
line"
echo -e "$green mountpool $nocolor mounts imported pool"
echo -e "$green boot $nocolor - boots into primary OS requires pool to be imported and
udev() (
udevd --daemon --resolve-names=never
udevadm trigger --action=add
udevadm settle
)
boot() (
echo -e "$yellow Attempting Boot......:"$nocolor"
"
udevadm control --exit
cd root
mount --move /dev /root/dev
mount --move /sys /root/sys
mount --move /proc /root/proc
nuke /dev
exec switch_root /root /sbin/init
)