0
0
mirror of https://github.com/openwrt/packages.git synced 2025-07-19 01:34:47 +00:00
Files
packages/net/csshnpd/files/at_enroll.sh
Chris Swan bd43da7ce5 csshnpd: add new package
Maintainer: @cpswan
Compile tested: x86_64 (snapshot r29619)
Run tested: x86_64 (snapshot r29619)

Description:
A C daemon for NoPorts, which allows TCP connections to be
established without exposing ports to the Internet.

More details at: https://docs.noports.com/

Signed-off-by: Chris Swan <chris@atsign.com>
2025-06-23 13:54:07 +02:00

61 lines
1.4 KiB
Bash

#!/bin/sh
. /lib/functions.sh
enroll_atsign() {
local section="$1"
config_get atsign "$section" "atsign"
if [ -z "$atsign" ]; then
echo "sshnpd: atsign must be configured in /etc/config/sshnpd"
return 1
fi
config_get device "$section" "device"
if [ -z "$device" ]; then
echo "sshnpd: device must be configured in /etc/config/sshnpd"
return 1
fi
config_get otp "$section" "otp"
if [ -z "$otp" ]; then
echo "sshnpd: otp must be configured in /etc/config/sshnpd"
return 1
fi
config_get user "$section" user
if [ -z "$user" ]; then
user='root'
fi
config_get home "$section" home
if [ -z "$home" ]; then
if [ "$user" = "root" ]; then
home='/root'
else
home="/home/${user}"
fi
fi
if [ ! -d "${home}/.atsign/keys" ]; then
mkdir -p "${home}/.atsign/keys"
fi
if [ -f "${home}/.atsign/keys/${atsign}_key.atKeys" ]; then
echo "sshnpd: atsign keys file already present, exiting enrollment"
return 1
fi
echo
echo "To activate this enrollment run the following command line on a"
echo "system where the ${atsign} key has been activated:"
echo
echo "at_activate approve -a ${atsign} --arx noports --drx ${device}"
echo
at_activate enroll -a ${atsign} -s ${otp} -p noports \
-k ${home}/.atsign/keys/${atsign}_key.atKeys -d ${device} \
-n "sshnp:rw,sshrvd:rw"
}
config_load sshnpd
config_foreach enroll_atsign sshnpd