From 01e4adbf08b5d196ab53f7a852e1e8edc96918e6 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Thu, 10 Oct 2024 08:06:35 +0200 Subject: [PATCH] Move change hostname function from JSON file --- lib/armbian-configng/config.ng.jobs.json | 5 +---- lib/armbian-configng/config.ng.system.sh | 16 ++++++++++++++++ tools/json/config.localisation.json | 5 +---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/armbian-configng/config.ng.jobs.json b/lib/armbian-configng/config.ng.jobs.json index 62675dd9b..45ecb1b13 100644 --- a/lib/armbian-configng/config.ng.jobs.json +++ b/lib/armbian-configng/config.ng.jobs.json @@ -562,10 +562,7 @@ { "id": "L04", "description": "Change System Hostname", - "command": [ - "NEW_HOSTNAME=$($DIALOG --title \"Enter new hostnane\" --inputbox \"\" 7 50 3>&1 1>&2 2>&3)", - "[ $? -eq 0 ] && [ -n \"${NEW_HOSTNAME}\" ] && hostnamectl set-hostname \"${NEW_HOSTNAME}\"" - ], + "command": [ "change_system_hostname" ], "status": "Preview", "author": "" } diff --git a/lib/armbian-configng/config.ng.system.sh b/lib/armbian-configng/config.ng.system.sh index 5c6571541..ec51c2dfd 100644 --- a/lib/armbian-configng/config.ng.system.sh +++ b/lib/armbian-configng/config.ng.system.sh @@ -21,6 +21,22 @@ function apt_install_wrapper() { fi } +module_options+=( + ["change_system_hostname,author"]="igorpecovnik" + ["change_system_hostname,ref_link"]="" + ["change_system_hostname,feature"]="Change hostname" + ["change_system_hostname,desc"]="change_system_hostname" + ["change_system_hostname,example"]="change_system_hostname" + ["change_system_hostname,status"]="Active" +) +# +# @description Change system hostname +# +function change_system_hostname() { + local new_hostname=$($DIALOG --title "Enter new hostnane" --inputbox "" 7 50 3>&1 1>&2 2>&3) + [ $? -eq 0 ] && [ -n "${new_hostname}" ] && hostnamectl set-hostname "${new_hostname}" +} + module_options+=( ["release_upgrade,author"]="Igor Pecovnik" ["release_upgrade,ref_link"]="" diff --git a/tools/json/config.localisation.json b/tools/json/config.localisation.json index d05486bf8..7bfaf88b0 100644 --- a/tools/json/config.localisation.json +++ b/tools/json/config.localisation.json @@ -53,10 +53,7 @@ { "id": "L04", "description": "Change System Hostname", - "command": [ - "NEW_HOSTNAME=$(whiptail --title \"Enter new hostnane\" --inputbox \"\" 7 50 3>&1 1>&2 2>&3)", - "[ $? -eq 0 ] && [ -n \"${NEW_HOSTNAME}\" ] && hostnamectl set-hostname \"${NEW_HOSTNAME}\"" - ], + "command": [ "change_system_hostname" ], "status": "Preview", "author": "" }