2017-05-26 20:26:25 +00:00
|
|
|
#!/bin/sh
|
2017-08-20 19:45:26 +00:00
|
|
|
# shellcheck disable=SC1091
|
|
|
|
. /etc/deviceinfo
|
2017-05-26 20:26:25 +00:00
|
|
|
. ./init_functions.sh
|
|
|
|
|
|
|
|
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
|
|
|
/bin/busybox --install -s
|
2017-06-07 21:14:24 +00:00
|
|
|
/bin/busybox-extras --install -s
|
2017-05-26 20:26:25 +00:00
|
|
|
|
2017-06-28 16:13:02 +00:00
|
|
|
# Mount everything, set up logging, modules, mdev
|
postmarketos-mkinitfs: Major refactoring
* rewrote find_root_partition to make it compatible with the i9100
again (and added a big description comment about how it works)
* usb network and dhcp server gets started independent of hooks
now. this really makes sense for development now, we can disable
this later (and set up networking via OpenRC, when the usb-shell
hook is not installed)
* telnet splash + unlock telnetd code only runs, when the rootfs
is encrypted
* usb_setup_android wrapped with a generic usb_setup function, so
we can support networking for more device types in a clean way
* the IP of the device is now in init_functions.sh, and init_functions.sh
gets included in all hooks.
* rewrote logging function. it logs all stdout and stderr to
/pmOS_init.log, except when PMOS_NO_OUTPUT_REDIRECT is specified
as kernel command line. This way we can see error output from
all commands.
* used shfmt to format everything, so it looks consistent again
* added automatic shellchecking for init.sh.in and
init_functions.sh
* clear naming scheme for initfs functions, they all start with a
verb now (e.g. setup_usb_network, start_udhcpd, ...)
2017-06-28 15:32:16 +00:00
|
|
|
mount_proc_sys_dev
|
2017-06-28 16:13:02 +00:00
|
|
|
setup_log
|
2017-08-23 17:05:05 +00:00
|
|
|
# shellcheck disable=SC2154,SC2086
|
|
|
|
[ -d /lib/modules ] && modprobe -a ${deviceinfo_modules_initfs} ext4
|
postmarketos-mkinitfs: Major refactoring
* rewrote find_root_partition to make it compatible with the i9100
again (and added a big description comment about how it works)
* usb network and dhcp server gets started independent of hooks
now. this really makes sense for development now, we can disable
this later (and set up networking via OpenRC, when the usb-shell
hook is not installed)
* telnet splash + unlock telnetd code only runs, when the rootfs
is encrypted
* usb_setup_android wrapped with a generic usb_setup function, so
we can support networking for more device types in a clean way
* the IP of the device is now in init_functions.sh, and init_functions.sh
gets included in all hooks.
* rewrote logging function. it logs all stdout and stderr to
/pmOS_init.log, except when PMOS_NO_OUTPUT_REDIRECT is specified
as kernel command line. This way we can see error output from
all commands.
* used shfmt to format everything, so it looks consistent again
* added automatic shellchecking for init.sh.in and
init_functions.sh
* clear naming scheme for initfs functions, they all start with a
verb now (e.g. setup_usb_network, start_udhcpd, ...)
2017-06-28 15:32:16 +00:00
|
|
|
setup_mdev
|
2017-05-26 20:26:25 +00:00
|
|
|
mount_subpartitions
|
|
|
|
|
2017-09-18 19:17:30 +00:00
|
|
|
# Start msm-fb-refresher workaround for qualcomm devices
|
|
|
|
start_msm_refresher
|
|
|
|
|
postmarketos-mkinitfs: Major refactoring
* rewrote find_root_partition to make it compatible with the i9100
again (and added a big description comment about how it works)
* usb network and dhcp server gets started independent of hooks
now. this really makes sense for development now, we can disable
this later (and set up networking via OpenRC, when the usb-shell
hook is not installed)
* telnet splash + unlock telnetd code only runs, when the rootfs
is encrypted
* usb_setup_android wrapped with a generic usb_setup function, so
we can support networking for more device types in a clean way
* the IP of the device is now in init_functions.sh, and init_functions.sh
gets included in all hooks.
* rewrote logging function. it logs all stdout and stderr to
/pmOS_init.log, except when PMOS_NO_OUTPUT_REDIRECT is specified
as kernel command line. This way we can see error output from
all commands.
* used shfmt to format everything, so it looks consistent again
* added automatic shellchecking for init.sh.in and
init_functions.sh
* clear naming scheme for initfs functions, they all start with a
verb now (e.g. setup_usb_network, start_udhcpd, ...)
2017-06-28 15:32:16 +00:00
|
|
|
# Hooks
|
2017-05-26 20:26:25 +00:00
|
|
|
for hook in /etc/postmarketos-mkinitfs/hooks/*.sh; do
|
|
|
|
[ -e "$hook" ] || continue
|
|
|
|
sh "$hook"
|
|
|
|
done
|
|
|
|
|
2017-09-29 15:22:20 +00:00
|
|
|
# Fix for framebuffer drivers, which do not have a default mode
|
|
|
|
set_framebuffer_mode
|
|
|
|
|
2017-08-03 16:01:00 +00:00
|
|
|
show_splash /splash-loading.ppm.gz
|
|
|
|
|
2017-06-29 16:51:24 +00:00
|
|
|
# Always run dhcp daemon/usb networking for now (later this should only
|
|
|
|
# be enabled, when having the usb-shell hook installed for debugging,
|
|
|
|
# or get activated after the initramfs is done with an OpenRC service).
|
|
|
|
setup_usb_network
|
|
|
|
start_udhcpd
|
|
|
|
|
2017-07-28 18:51:21 +00:00
|
|
|
mount_boot_partition
|
|
|
|
extract_initramfs_extra @INITRAMFS_EXTRA@
|
2017-08-03 16:01:00 +00:00
|
|
|
wait_root_partition
|
|
|
|
resize_root_partition
|
2017-05-26 20:26:25 +00:00
|
|
|
unlock_root_partition
|
2017-08-03 16:01:00 +00:00
|
|
|
resize_root_filesystem
|
|
|
|
mount_root_partition
|
2017-05-26 20:26:25 +00:00
|
|
|
|
postmarketos-mkinitfs: Major refactoring
* rewrote find_root_partition to make it compatible with the i9100
again (and added a big description comment about how it works)
* usb network and dhcp server gets started independent of hooks
now. this really makes sense for development now, we can disable
this later (and set up networking via OpenRC, when the usb-shell
hook is not installed)
* telnet splash + unlock telnetd code only runs, when the rootfs
is encrypted
* usb_setup_android wrapped with a generic usb_setup function, so
we can support networking for more device types in a clean way
* the IP of the device is now in init_functions.sh, and init_functions.sh
gets included in all hooks.
* rewrote logging function. it logs all stdout and stderr to
/pmOS_init.log, except when PMOS_NO_OUTPUT_REDIRECT is specified
as kernel command line. This way we can see error output from
all commands.
* used shfmt to format everything, so it looks consistent again
* added automatic shellchecking for init.sh.in and
init_functions.sh
* clear naming scheme for initfs functions, they all start with a
verb now (e.g. setup_usb_network, start_udhcpd, ...)
2017-06-28 15:32:16 +00:00
|
|
|
# Switch root
|
2017-09-18 19:17:30 +00:00
|
|
|
killall telnetd mdev msm-fb-refresher 2>/dev/null
|
2017-07-28 18:51:21 +00:00
|
|
|
umount /boot
|
2017-05-26 20:26:25 +00:00
|
|
|
umount /proc
|
|
|
|
umount /sys
|
|
|
|
umount /dev/pts
|
|
|
|
umount /dev
|
postmarketos-mkinitfs: Major refactoring
* rewrote find_root_partition to make it compatible with the i9100
again (and added a big description comment about how it works)
* usb network and dhcp server gets started independent of hooks
now. this really makes sense for development now, we can disable
this later (and set up networking via OpenRC, when the usb-shell
hook is not installed)
* telnet splash + unlock telnetd code only runs, when the rootfs
is encrypted
* usb_setup_android wrapped with a generic usb_setup function, so
we can support networking for more device types in a clean way
* the IP of the device is now in init_functions.sh, and init_functions.sh
gets included in all hooks.
* rewrote logging function. it logs all stdout and stderr to
/pmOS_init.log, except when PMOS_NO_OUTPUT_REDIRECT is specified
as kernel command line. This way we can see error output from
all commands.
* used shfmt to format everything, so it looks consistent again
* added automatic shellchecking for init.sh.in and
init_functions.sh
* clear naming scheme for initfs functions, they all start with a
verb now (e.g. setup_usb_network, start_udhcpd, ...)
2017-06-28 15:32:16 +00:00
|
|
|
|
|
|
|
# shellcheck disable=SC2093
|
2017-05-26 20:26:25 +00:00
|
|
|
exec switch_root /sysroot /sbin/init
|
postmarketos-mkinitfs: Major refactoring
* rewrote find_root_partition to make it compatible with the i9100
again (and added a big description comment about how it works)
* usb network and dhcp server gets started independent of hooks
now. this really makes sense for development now, we can disable
this later (and set up networking via OpenRC, when the usb-shell
hook is not installed)
* telnet splash + unlock telnetd code only runs, when the rootfs
is encrypted
* usb_setup_android wrapped with a generic usb_setup function, so
we can support networking for more device types in a clean way
* the IP of the device is now in init_functions.sh, and init_functions.sh
gets included in all hooks.
* rewrote logging function. it logs all stdout and stderr to
/pmOS_init.log, except when PMOS_NO_OUTPUT_REDIRECT is specified
as kernel command line. This way we can see error output from
all commands.
* used shfmt to format everything, so it looks consistent again
* added automatic shellchecking for init.sh.in and
init_functions.sh
* clear naming scheme for initfs functions, they all start with a
verb now (e.g. setup_usb_network, start_udhcpd, ...)
2017-06-28 15:32:16 +00:00
|
|
|
|
|
|
|
echo "ERROR: switch_root failed!"
|
|
|
|
echo "Looping forever. Install and use the usb-shell hook to debug this."
|
2017-07-27 18:03:07 +00:00
|
|
|
echo "For more information, see <https://postmarketos.org/usbhook>"
|
2017-07-28 18:51:21 +00:00
|
|
|
loop_forever
|