refactor: sort after find
Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
@@ -125,7 +125,7 @@ function download_fluidd_macros(){
|
||||
log_info "executing: download_fluidd_macros"
|
||||
local fluidd_cfg="https://raw.githubusercontent.com/fluidd-core/FluiddPI/master/src/modules/fluidd/filesystem/home/pi/klipper_config/fluidd.cfg"
|
||||
local configs
|
||||
configs=$(find "${KLIPPER_CONFIG}" -type f -name "printer.cfg")
|
||||
configs=$(find "${KLIPPER_CONFIG}" -type f -name "printer.cfg" | sort)
|
||||
if [ -n "${configs}" ]; then
|
||||
### create a backup of the config folder
|
||||
backup_klipper_config_dir
|
||||
@@ -375,7 +375,7 @@ function select_fluidd_port(){
|
||||
|
||||
function patch_fluidd_update_manager(){
|
||||
local moonraker_configs
|
||||
moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf")
|
||||
moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf" | sort)
|
||||
for conf in ${moonraker_configs}; do
|
||||
if ! grep -Eq "[update_manager fluidd]" "${conf}"; then
|
||||
### add new line to conf if it doesn't end with one
|
||||
|
||||
@@ -97,7 +97,7 @@ function create_example_shell_command() {
|
||||
backup_klipper_config_dir
|
||||
|
||||
local printer_cfgs
|
||||
printer_cfgs=$(find "$(get_klipper_cfg_dir)" -type f -name "printer.cfg")
|
||||
printer_cfgs=$(find "$(get_klipper_cfg_dir)" -type f -name "printer.cfg" | sort)
|
||||
for cfg in ${printer_cfgs}; do
|
||||
path=$(echo "${cfg}" | rev | cut -d"/" -f2- | rev)
|
||||
if [ ! -f "${path}/shell_command.cfg" ]; then
|
||||
|
||||
@@ -18,13 +18,13 @@ set -e
|
||||
### check for existing klipper service installations
|
||||
function klipper_initd() {
|
||||
local services
|
||||
services=$(find "${INITD}" -maxdepth 1 -regextype posix-extended -regex "${INITD}/klipper(-[^0])?[0-9]*")
|
||||
services=$(find "${INITD}" -maxdepth 1 -regextype posix-extended -regex "${INITD}/klipper(-[^0])?[0-9]*" | sort)
|
||||
echo "${services}"
|
||||
}
|
||||
|
||||
function klipper_systemd() {
|
||||
local services
|
||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/klipper(-[^0])?[0-9]*.service")
|
||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/klipper(-[^0])?[0-9]*.service" | sort)
|
||||
echo "${services}"
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ function remove_klipper_systemd() {
|
||||
|
||||
function remove_klipper_logs() {
|
||||
local files
|
||||
files=$(find "${HOME}/klipper_logs" -maxdepth 1 -regextype posix-extended -regex "${HOME}/klipper_logs/klippy(-[^0])?[0-9]*\.log(.*)?")
|
||||
files=$(find "${HOME}/klipper_logs" -maxdepth 1 -regextype posix-extended -regex "${HOME}/klipper_logs/klippy(-[^0])?[0-9]*\.log(.*)?" | sort)
|
||||
if [ -n "${files}" ]; then
|
||||
for file in ${files}; do
|
||||
status_msg "Removing ${file} ..."
|
||||
@@ -283,7 +283,7 @@ function remove_klipper_logs() {
|
||||
|
||||
function remove_klipper_uds() {
|
||||
local files
|
||||
files=$(find /tmp -maxdepth 1 -regextype posix-extended -regex "/tmp/klippy_uds(-[^0])?[0-9]*")
|
||||
files=$(find /tmp -maxdepth 1 -regextype posix-extended -regex "/tmp/klippy_uds(-[^0])?[0-9]*" | sort)
|
||||
if [ -n "${files}" ]; then
|
||||
for file in ${files}; do
|
||||
status_msg "Removing ${file} ..."
|
||||
@@ -295,7 +295,7 @@ function remove_klipper_uds() {
|
||||
|
||||
function remove_klipper_printer() {
|
||||
local files
|
||||
files=$(find /tmp -maxdepth 1 -regextype posix-extended -regex "/tmp/printer(-[^0])?[0-9]*")
|
||||
files=$(find /tmp -maxdepth 1 -regextype posix-extended -regex "/tmp/printer(-[^0])?[0-9]*" | sort)
|
||||
if [ -n "${files}" ]; then
|
||||
for file in ${files}; do
|
||||
status_msg "Removing ${file} ..."
|
||||
|
||||
@@ -187,7 +187,7 @@ function compare_klipperscreen_versions(){
|
||||
|
||||
function patch_klipperscreen_update_manager(){
|
||||
local moonraker_configs
|
||||
moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf")
|
||||
moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf" | sort)
|
||||
for conf in ${moonraker_configs}; do
|
||||
if ! grep -Eq "[update_manager KlipperScreen]" "${conf}"; then
|
||||
### add new line to conf if it doesn't end with one
|
||||
|
||||
@@ -125,7 +125,7 @@ function download_mainsail_macros(){
|
||||
log_info "executing: download_mainsail_macros"
|
||||
local ms_cfg="https://raw.githubusercontent.com/mainsail-crew/MainsailOS/master/src/modules/mainsail/filesystem/home/pi/klipper_config/mainsail.cfg"
|
||||
local configs
|
||||
configs=$(find "${KLIPPER_CONFIG}" -type f -name "printer.cfg")
|
||||
configs=$(find "${KLIPPER_CONFIG}" -type f -name "printer.cfg" | sort)
|
||||
if [ -n "${configs}" ]; then
|
||||
### create a backup of the config folder
|
||||
backup_klipper_config_dir
|
||||
@@ -497,7 +497,7 @@ function enable_mainsail_remotemode(){
|
||||
|
||||
function patch_mainsail_update_manager(){
|
||||
local moonraker_configs
|
||||
moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf")
|
||||
moonraker_configs=$(find "$(get_klipper_cfg_dir)" -type f -name "moonraker.conf" | sort)
|
||||
for conf in ${moonraker_configs}; do
|
||||
if ! grep -Eq "[update_manager mainsail]" "${conf}"; then
|
||||
### add new line to conf if it doesn't end with one
|
||||
|
||||
@@ -17,7 +17,7 @@ set -e
|
||||
|
||||
function telegram_bot_systemd() {
|
||||
local services
|
||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/moonraker-telegram-bot(-[^0])?[0-9]*.service")
|
||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/moonraker-telegram-bot(-[^0])?[0-9]*.service" | sort)
|
||||
echo "${services}"
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ set -e
|
||||
|
||||
function moonraker_systemd() {
|
||||
local services
|
||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/moonraker(-[^0])?[0-9]*.service")
|
||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/moonraker(-[^0])?[0-9]*.service" | sort)
|
||||
echo "${services}"
|
||||
}
|
||||
|
||||
@@ -316,7 +316,7 @@ function remove_moonraker_systemd() {
|
||||
|
||||
function remove_moonraker_logs() {
|
||||
local files
|
||||
files=$(find "${HOME}/klipper_logs" -maxdepth 1 -regextype posix-extended -regex "${HOME}/klipper_logs/moonraker(-[^0])?[0-9]*\.log(.*)?")
|
||||
files=$(find "${HOME}/klipper_logs" -maxdepth 1 -regextype posix-extended -regex "${HOME}/klipper_logs/moonraker(-[^0])?[0-9]*\.log(.*)?" | sort)
|
||||
if [ -n "${files}" ]; then
|
||||
for file in ${files}; do
|
||||
status_msg "Removing ${file} ..."
|
||||
|
||||
@@ -17,7 +17,7 @@ set -e
|
||||
|
||||
function octoprint_systemd() {
|
||||
local services
|
||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/octoprint(-[^0])?[0-9]*.service")
|
||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/octoprint(-[^0])?[0-9]*.service" | sort)
|
||||
echo "${services}"
|
||||
}
|
||||
|
||||
@@ -239,7 +239,7 @@ function remove_octoprint_sudoers(){
|
||||
|
||||
function remove_octoprint_env(){
|
||||
local files
|
||||
files=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/OctoPrint(_[^0])?[0-9]*")
|
||||
files=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/OctoPrint(_[^0])?[0-9]*" | sort)
|
||||
if [ -n "${files}" ]; then
|
||||
for file in ${files}; do
|
||||
status_msg "Removing ${file} ..."
|
||||
@@ -251,7 +251,7 @@ function remove_octoprint_env(){
|
||||
|
||||
function remove_octoprint_dir(){
|
||||
local files
|
||||
files=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/.octoprint(_[^0])?[0-9]*")
|
||||
files=$(find "${HOME}" -maxdepth 1 -regextype posix-extended -regex "${HOME}/.octoprint(_[^0])?[0-9]*" | sort)
|
||||
if [ -n "${files}" ]; then
|
||||
for file in ${files}; do
|
||||
status_msg "Removing ${file} ..."
|
||||
|
||||
@@ -281,7 +281,7 @@ function set_klipper_cfg_path(){
|
||||
fi
|
||||
fi
|
||||
done
|
||||
moonraker_configs=$(find "${new_cfg_loc}" -type f -name "moonraker.conf")
|
||||
moonraker_configs=$(find "${new_cfg_loc}" -type f -name "moonraker.conf" | sort)
|
||||
### replace old file path with new one in moonraker.conf
|
||||
for conf in ${moonraker_configs}; do
|
||||
loc=$(echo "${conf}" | rev | cut -d"/" -f2- | rev)
|
||||
@@ -347,7 +347,7 @@ function set_custom_klipper_repo() {
|
||||
|
||||
function do_action_service(){
|
||||
local action=${1} service=${2}
|
||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/${service}(-[^0])?[0-9]*.service")
|
||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/${service}(-[^0])?[0-9]*.service" | sort)
|
||||
if [ -n "${services}" ]; then
|
||||
for service in ${services}; do
|
||||
service=$(echo "${service}" | rev | cut -d"/" -f1 | rev)
|
||||
|
||||
Reference in New Issue
Block a user