From c7ad0613322f7816dfefbed842677b6cf6cb1d2a Mon Sep 17 00:00:00 2001 From: th33xitus Date: Sun, 17 Apr 2022 20:11:09 +0200 Subject: [PATCH] refactor(octoprint.sh): use utility function for checking tty and dialout usergroup Signed-off-by: Dominik Willner th33xitus@gmail.com --- scripts/octoprint.sh | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/scripts/octoprint.sh b/scripts/octoprint.sh index bcb1838..dac5b2a 100644 --- a/scripts/octoprint.sh +++ b/scripts/octoprint.sh @@ -80,8 +80,8 @@ function octoprint_setup(){ ) dependency_check "${dep[@]}" - ### add user to usergroups and add reboot permissions - add_to_groups + ### check for tty and dialout usergroups and add reboot permissions + check_usergroups add_reboot_permission ### install octoprint @@ -120,17 +120,6 @@ function install_octoprint(){ deactivate } -add_to_groups(){ - if [ ! "$(groups | grep tty)" ]; then - status_msg "Adding user '${USER}' to group 'tty' ..." - sudo usermod -a -G tty "${USER}" && ok_msg "Done!" - fi - if [ ! "$(groups | grep dialout)" ]; then - status_msg "Adding user '${USER}' to group 'dialout' ..." - sudo usermod -a -G dialout "${USER}" && ok_msg "Done!" - fi -} - function create_config_yaml(){ local base_dir=${1} tmp_printer=${2} restart_cmd=${3}