instance_filter funciton

This commit is contained in:
paukstelis
2022-10-24 09:02:55 -04:00
parent 0a19791f1d
commit 9ee613d4fe

View File

@@ -371,9 +371,14 @@ add_camera() {
PS3='Select instance number to add camera to: ' PS3='Select instance number to add camera to: '
readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p') readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p')
options+=("Quit") options+=("Quit")
instance_Filter options
#Not yet check to see if instance already has a camera #Not yet check to see if instance already has a camera
select camopt in "${options[@]}" select camopt in "${options[@]}"
do do
if [ "$camopt" == generic ]; then
main_menu
fi
if [ "$camopt" == generic ]; then if [ "$camopt" == generic ]; then
echo "Don't add cameras to the template instance." echo "Don't add cameras to the template instance."
main_menu main_menu
@@ -489,6 +494,7 @@ remove_instance() {
PS3='Select instance number to remove: ' PS3='Select instance number to remove: '
readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) port:.*/\1/p') readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) port:.*/\1/p')
options+=("Quit") options+=("Quit")
instance_filter options
select opt in "${options[@]}" select opt in "${options[@]}"
do do
if [ "$opt" == Quit ] || [ "$opt" == generic ]; then if [ "$opt" == Quit ] || [ "$opt" == generic ]; then
@@ -853,7 +859,7 @@ prepare () {
#this restart seems necessary in some cases #this restart seems necessary in some cases
systemctl restart octoprint_default.service systemctl restart octoprint_default.service
fi fi
#echo 'instance:generic port:5000' > /etc/octoprint_instances echo 'instance:generic port:5000' > /etc/octoprint_instances
touch /etc/octoprint_instances touch /etc/octoprint_instances
echo 'Adding camera port records' echo 'Adding camera port records'
touch /etc/camera_ports touch /etc/camera_ports
@@ -1002,6 +1008,7 @@ create_menu() {
restart_all() { restart_all() {
get_settings get_settings
readarray -t instances < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p') readarray -t instances < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p')
instance_filter instances
for instance in "${instances[@]}"; do for instance in "${instances[@]}"; do
if [ "$instance" == generic ]; then if [ "$instance" == generic ]; then
continue continue
@@ -1087,6 +1094,7 @@ restore() {
back_up_all() { back_up_all() {
get_settings get_settings
readarray -t instances < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p') readarray -t instances < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p')
instance_filter instances
for instance in "${instances[@]}"; do for instance in "${instances[@]}"; do
if [ "$instance" == generic ]; then if [ "$instance" == generic ]; then
continue continue
@@ -1104,6 +1112,7 @@ replace_id() {
PS3='Select instance to change serial ID: ' PS3='Select instance to change serial ID: '
readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p') readarray -t options < <(cat /etc/octoprint_instances | sed -n -e 's/^instance:\([[:graph:]]*\) .*/\1/p')
options+=("Quit") options+=("Quit")
instance_filter options
select opt in "${options[@]}" select opt in "${options[@]}"
do do
if [ "$opt" == Quit ] || [ "$opt" == generic ]; then if [ "$opt" == Quit ] || [ "$opt" == generic ]; then
@@ -1132,6 +1141,12 @@ octo_deploy_update() {
exit exit
} }
instance_filter() {
local input_array=$1
unset 'input_array[0]'
eval $input_array
}
main_menu() { main_menu() {
VERSION=0.1.6 VERSION=0.1.6
#reset #reset