feat(moonraker.sh): custom instance names

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus
2022-05-06 13:09:23 +02:00
parent bb95c0b727
commit e840524fb9
2 changed files with 167 additions and 96 deletions

View File

@@ -607,4 +607,14 @@ function set_hostname(){
echo "127.0.0.1 ${new_hostname}" | sudo tee -a /etc/hosts &>/dev/null
ok_msg "New hostname successfully configured!"
ok_msg "Remember to reboot for the changes to take effect!"
}
function get_instance_name() {
### this function takes in the full path of a systemd service file and returns
### either the instance index or the custom name
### input: /etc/systemd/system/klipper-name.service
### returns: name
local instance=${1} name
name=$(echo "${instance}" | rev | cut -d"/" -f1 | rev | cut -d"-" -f2 | cut -d"." -f1)
echo "${name}"
}