contrib/meshwizard: fix LAN with OLSR and DHCP
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / helpers / setup_ssh.sh
1 #!/bin/sh
2 # Setup ssh. At this point only used to store pubkeys.
3
4 [ ! "$(uci -q get meshwizard.ssh)" == "system" ] && exit
5
6 . /lib/functions.sh
7 . $dir/functions.sh
8 authorized="/etc/dropbear/authorized_keys"
9
10
11 config_load meshwizard
12
13 i=0
14 handle_pubkeys() {
15         local k="$1"
16         ( [ -f "$authorized" ] && grep -q "$k" $authorized) || {
17                 echo "$k" >> $authorized
18                 i=`expr $i + 1`
19         }
20 }
21
22 config_list_foreach ssh pubkey handle_pubkeys
23
24 uci delete meshwizard.ssh
25 uci_commitverbose "Added $i pubkeys to authorized_keys" meshwizard
26