Created
February 24, 2025 15:27
-
-
Save koreapyj/72b9651225a9c4757e4b7efaf174e20d to your computer and use it in GitHub Desktop.
OpenVPN user pass auth script for OpenWRT ubus
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
. /usr/share/libubox/jshn.sh | |
userpass=`cat $1` | |
username=`echo $userpass | awk '{print $1}'` | |
password=`echo $userpass | awk '{print $2}'` | |
json_init | |
json_add_string "username" "$username" | |
json_add_string "password" "$password" | |
json_add_int "timeout" "1" | |
json_close_object | |
JSON=`json_dump` | |
if ubus call session login "$JSON"; then | |
exit 0 | |
fi | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment