]> git.ipfire.org Git - people/stevee/network.git/blobdiff - src/functions/functions.config
wpa_supplicant: Drop config helper
[people/stevee/network.git] / src / functions / functions.config
index ab1dadc4a2ab513c3293d2bf33879b3d59578aa2..6a148c7a3bb492ebc31b10b6f27e240a06449edd 100644 (file)
@@ -19,7 +19,7 @@
 #                                                                             #
 ###############################################################################
 
-function config_header() {
+config_header() {
        local what=${1}
        assert isset what
 
@@ -34,7 +34,7 @@ function config_header() {
        echo
 }
 
-function config_hostname() {
+config_hostname() {
        local hostname=${1}
 
        if [ -n "${hostname}" ]; then
@@ -44,10 +44,29 @@ function config_hostname() {
        fi
 }
 
-function config_domainname() {
+config_domainname() {
        local hostname=$(config_hostname)
 
        # Strip off the hostname part and just return
        # the domain part.
        print "${hostname#*.}"
 }
+
+config_get_id_from_config() {
+       # This function returns the id for a given config name
+       # Example 'dhcp.0' => 0
+       assert [ $# -eq 1 ]
+       local config=${1}
+
+       echo "${config##*.}"
+
+}
+
+config_get_hook_from_config() {
+       # This function returns the hook for a given config name
+       # Example 'dhcp.0' => dhcp
+       assert [ $# -eq 1 ]
+       local config=${1}
+
+       echo "${config%%.*[[:digit:]]}"
+}