contrib/meshwizard: Allow to setup dropbear autorized_keys
authorManuel Munz <freifunk@somakoma.de>
Thu, 26 Jul 2012 09:45:48 +0000 (09:45 +0000)
committerManuel Munz <freifunk@somakoma.de>
Thu, 26 Jul 2012 09:45:48 +0000 (09:45 +0000)
contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_ssh.sh [new file with mode: 0755]
contrib/package/meshwizard/files/usr/bin/meshwizard/wizard.sh

diff --git a/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_ssh.sh b/contrib/package/meshwizard/files/usr/bin/meshwizard/helpers/setup_ssh.sh
new file mode 100755 (executable)
index 0000000..38b331e
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Setup ssh. At this point only used to store pubkeys.
+
+[ ! "$(uci -q get meshwizard.ssh)" == "system" ] && exit
+
+. /lib/functions.sh
+. $dir/functions.sh
+authorized="/etc/dropbear/authorized_keys"
+
+
+config_load meshwizard
+
+i=0
+handle_pubkeys() {
+       local k="$1"
+       ( [ -f "$authorized" ] && grep -q "$k" $authorized) || {
+               echo "$k" >> $authorized
+               i=`expr $i + 1`
+       }
+}
+
+config_list_foreach ssh pubkey handle_pubkeys
+
+uci delete meshwizard.ssh
+uci_commitverbose "Added $i pubkeys to authorized_keys" meshwizard
+
index eae4de87e6ef5c5dd12b48daa188486da6cb0037..b45c83987c620d1963e644d0e0be3c8ac6b117af 100755 (executable)
@@ -59,6 +59,7 @@ $dir/helpers/setup_dnsmasq.sh
 $dir/helpers/setup_system.sh
 $dir/helpers/setup_olsrd.sh
 $dir/helpers/setup_firewall.sh
+$dir/helpers/setup_ssh.sh
 
 if [ "$wan_proto" == "static" ] && [ -n "$wan_ip4addr" ] && [ -n "$wan_netmask" ]; then
        $dir/helpers/setup_wan_static.sh