pmaports/postmarketos-mkinitfs/10-usb-unlock.sh
Oliver Smith fec2e22f49 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 17:32:16 +02:00

28 lines
548 B
Bash

#!/bin/sh
. ./init_functions.sh
TELNET_PORT=23
start_usb_unlock() {
# Only run if we have an encrypted partition
cryptsetup isLuks "$(find_root_partition)" || return
# Set up networking
setup_usb_network
start_udhcpd
# Telnet splash
show_splash /splash1.ppm.gz
# Start the telnet daemon
{
echo '#!/bin/sh'
echo '. /init_functions.sh'
echo 'unlock_root_partition'
echo 'killall cryptsetup telnetd'
} >/telnet_connect.sh
chmod +x /telnet_connect.sh
telnetd -b "${IP}:${TELNET_PORT}" -l /telnet_connect.sh
}
start_usb_unlock