Merge pull request #5387 from diizzyy/admin-netdata
[feed/packages.git] / net / netopeer2 / files / netopeer2-keystored-keygen.default
1 #!/bin/sh
2
3 # Warning, problems can occur if the device restarts in the middle of this uci-default script
4
5 if [ -x /bin/sysrepoctl ]; then
6 match=$(sysrepoctl -l | grep "ietf-keystore ")
7 if [ ! "$match" ]; then
8 sysrepoctl --install --yang=/etc/sysrepo/yang/ietf-keystore@2016-10-31.yang -o root:root -p 600
9 if [ -x /bin/sysrepocfg ]; then
10 sysrepocfg -d startup -i /usr/share/netopeer2-keystored/stock_key_config.xml ietf-keystore
11 rm /usr/share/netopeer2-keystored/stock_key_config.xml
12 fi
13
14 #generate ssh keys
15 ssh-keygen -t rsa -f /tmp/ssh_host_rsa_key -N ""
16 openssl rsa -in /tmp/ssh_host_rsa_key -outform pem > /etc/keystored/keys/ssh_host_rsa_key.pem
17 openssl rsa -pubout -in /etc/keystored/keys/ssh_host_rsa_key.pem -out /etc/keystored/keys/ssh_host_rsa_key.pub.pem
18 rm /tmp/ssh_host_rsa_key
19 fi
20 fi
21
22 exit 0