summaryrefslogtreecommitdiff
path: root/custom/overlay/etc/init.d/S49-dropbear-prep
blob: 7cc5ed6687722d00556548652b3ad559e1cfbbfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
#
# Prepares dropbear (external keys).
# Assumes there's a third partition (test for it).
# Assume partition is formatted (however you want).
#
#

set -eu

start() {
	if ! [[ -e /data/ ]] ; then
		mkdir /data/
	fi

	if test -e /dev/mmcblk0p3 && ! grep -sq mmcblk0p3 /proc/mounts ; then
		mount /dev/mmcblk0p3 /data/
	fi

	if grep -sq mmcblk0p3 /proc/mounts && test -d /data/dropbear ; then
		rmdir /etc/dropbear || mv /etc/dropbear /etc/dropbear.bak
		ln -snf /data/dropbear /etc/dropbear
	fi
}

case "$1" in
  start)
  	start
	;;
  stop|restart|reload)
	;;
  *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
esac

exit 0