GIF89a; EcchiShell v1.0
//proc/self/root/lib/lib/lib//dev/null 2>&1 || : # then the rest udevadm trigger --type=subsystems --action=add >/dev/null 2>&1 udevadm trigger --type=devices --action=add >/dev/null 2>&1 make_trace_mem "hook initqueue" '1:shortmem' '2+:mem' '3+:slab' getarg 'rd.break=initqueue' -d 'rdbreak=initqueue' && emergency_shell -n initqueue "Break before initqueue" RDRETRY=$(getarg rd.retry -d 'rd_retry=') RDRETRY=${RDRETRY:-30} RDRETRY=$(($RDRETRY*2)) export RDRETRY main_loop=0 export main_loop while :; do check_finished && break udevsettle check_finished && break if [ -f $hookdir/initqueue/work ]; then rm -f -- $hookdir/initqueue/work fi for job in $hookdir/initqueue/*.sh; do [ -e "$job" ] || break job=$job . $job check_finished && break 2 done $UDEV_QUEUE_EMPTY >/dev/null 2>&1 || continue for job in $hookdir/initqueue/settled/*.sh; do [ -e "$job" ] || break job=$job . $job check_finished && break 2 done $UDEV_QUEUE_EMPTY >/dev/null 2>&1 || continue # no more udev jobs and queues empty. sleep 0.5 if [ $main_loop -gt $((2*$RDRETRY/3)) ]; then for job in $hookdir/initqueue/timeout/*.sh; do [ -e "$job" ] || break job=$job . $job udevadm settle --timeout=0 >/dev/null 2>&1 || main_loop=0 [ -f $hookdir/initqueue/work ] && main_loop=0 done fi main_loop=$(($main_loop+1)) [ $main_loop -gt $RDRETRY ] \ && { flock -s 9 ; action_on_fail "Could not boot."; } 9>/.console_lock \ && break done unset job unset queuetriggered unset main_loop unset RDRETRY # pre-mount happens before we try to mount the root filesystem, # and happens once. make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab' '4+:komem' getarg 'rd.break=pre-mount' -d 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount" source_hook pre-mount getarg 'rd.break=mount' -d 'rdbreak=mount' && emergency_shell -n mount "Break mount" # mount scripts actually try to mount the root filesystem, and may # be sourced any number of times. As soon as one suceeds, no more are sourced. _i_mount=0 while :; do if ismounted "$NEWROOT"; then usable_root "$NEWROOT" && break; umount "$NEWROOT" fi for f in $hookdir/mount/*.sh; do [ -f "$f" ] && . "$f" if ismounted "$NEWROOT"; then usable_root "$NEWROOT" && break; warn "$NEWROOT has no proper rootfs layout, ignoring and removing offending mount hook" umount "$NEWROOT" rm -f -- "$f" fi done _i_mount=$(($_i_mount+1)) [ $_i_mount -gt 20 ] \ && { flock -s 9 ; action_on_fail "Can't mount root filesystem" && break; } 9>/.console_lock done { printf "Mounted root filesystem " while read dev mp rest || [ -n "$dev" ]; do [ "$mp" = "$NEWROOT" ] && echo $dev; done < /proc/mounts } | vinfo # pre pivot scripts are sourced just before we doing cleanup and switch over # to the new root. make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' '4+:komem' getarg 'rd.break=pre-pivot' -d 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot" source_hook pre-pivot make_trace_mem "hook cleanup" '1:shortmem' '2+:mem' '3+:slab' cleanup_trace_mem # pre pivot cleanup scripts are sourced just before we switch over to the new root. getarg 'rd.break=cleanup' -d 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup" source_hook cleanup # By the time we get here, the root filesystem should be mounted. # Try to find init. for i in "$(getarg real_init=)" "$(getarg init=)" $(getargs rd.distroinit=) /sbin/init; do [ -n "$i" ] || continue __p=$(readlink -f "${NEWROOT}/${i}") if [ -x "$__p" -o -x "${NEWROOT}/${__p}" ]; then INIT="$i" break fi done [ "$INIT" ] || { echo "Cannot find init!" echo "Please check to make sure you passed a valid root filesystem!" action_on_fail } if [ $UDEVVERSION -lt 168 ]; then # stop udev queue before killing it udevadm control --stop-exec-queue HARD="" while pidof udevd >/dev/null 2>&1; do for pid in $(pidof udevd); do kill $HARD $pid >/dev/null 2>&1 done HARD="-9" done else udevadm control --exit udevadm info --cleanup-db fi debug_off # Turn off debugging for this section # unexport some vars export_n root rflags fstype netroot NEWROOT export RD_TIMESTAMP # Clean up the environment for i in $(export -p); do i=${i#declare -x} i=${i#export} strstr "$i" "=" || continue i=${i%%=*} [ -z "$i" ] && continue case $i in root|PATH|HOME|TERM|PS4|RD_*) :;; *) unset "$i";; esac done . /tmp/export.orig 2>/dev/null || : rm -f -- /tmp/export.orig initargs="" read CLINE /dev/null ; then ignoreargs="console BOOT_IMAGE" # only pass arguments after init= to the init CLINE=${CLINE#*init=} set -- $CLINE shift # clear out the rest of the "init=" arg for x in "$@"; do for s in $ignoreargs; do [ "${x%%=*}" = $s ] && continue 2 done initargs="$initargs $x" done unset CLINE else debug_off # Turn off debugging for this section set -- $CLINE for x in "$@"; do case "$x" in [0-9]|s|S|single|emergency|auto ) \ initargs="$initargs $x" ;; esac done fi debug_on if ! [ -d "$NEWROOT"/run ]; then NEWRUN=/dev/.initramfs mkdir -m 0755 "$NEWRUN" mount --rbind /run/initramfs "$NEWRUN" fi wait_for_loginit # remove helper symlink [ -h /dev/root ] && rm -f -- /dev/root getarg rd.break -d rdbreak && emergency_shell -n switch_root "Break before switch_root" info "Switching root" unset PS4 CAPSH=$(command -v capsh) SWITCH_ROOT=$(command -v switch_root) PATH=$OLDPATH export PATH if [ -f /etc/capsdrop ]; then . /etc/capsdrop info "Calling $INIT with capabilities $CAPS_INIT_DROP dropped." unset RD_DEBUG exec $CAPSH --drop="$CAPS_INIT_DROP" -- \ -c "exec switch_root \"$NEWROOT\" \"$INIT\" $initargs" || \ { warn "Command:" warn capsh --drop=$CAPS_INIT_DROP -- -c exec switch_root "$NEWROOT" "$INIT" $initargs warn "failed." action_on_fail } else unset RD_DEBUG exec $SWITCH_ROOT "$NEWROOT" "$INIT" $initargs || { warn "Something went very badly wrong in the initramfs. Please " warn "file a bug against dracut." action_on_fail } fi