comment lib/setup/* (#LLM assisted - Claude Code)
This commit is contained in:
parent
3995e92323
commit
0f13154d6f
@ -1,5 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright © 2012-2026 ScriptFanix
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# A copy of the GNU General Public License v3 is includded in the LICENSE file
|
||||
# at the root of the project.
|
||||
|
||||
setupDestination() {
|
||||
cat <<-EODesc
|
||||
|
||||
|
||||
@ -1,5 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright © 2012-2026 ScriptFanix
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# A copy of the GNU General Public License v3 is includded in the LICENSE file
|
||||
# at the root of the project.
|
||||
|
||||
setupDestinations() {
|
||||
cat <<-EODesc
|
||||
|
||||
|
||||
@ -1,5 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright © 2012-2026 ScriptFanix
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# A copy of the GNU General Public License v3 is includded in the LICENSE file
|
||||
# at the root of the project.
|
||||
|
||||
setupGeneral() {
|
||||
cat <<-EODesc
|
||||
|
||||
@ -14,11 +27,14 @@ setupGeneral() {
|
||||
1 minute load average between <load> and <load>+1 by adjusting
|
||||
concurrency. Initial concurrency will be set to half of that value.
|
||||
EODesc
|
||||
# Check input is an integer
|
||||
# Reused across multiple prompts in this function
|
||||
expr='^[0-9]*$'
|
||||
comeagain() {
|
||||
read \
|
||||
-e \
|
||||
-p'Target load: (integer) ' \
|
||||
# Pre-fill with the existing value when re-running setup
|
||||
${maxload+-i"$maxload"} \
|
||||
value
|
||||
if [ -n "$value" ] && [[ $value =~ $expr ]]
|
||||
@ -26,6 +42,7 @@ setupGeneral() {
|
||||
maxload="$value"
|
||||
else
|
||||
echo "Invalid max-load value: $value" >&2
|
||||
# Recurse until we get a valid value
|
||||
comeagain
|
||||
fi
|
||||
}
|
||||
@ -64,6 +81,7 @@ setupGeneral() {
|
||||
read \
|
||||
-e \
|
||||
-p'Ionice: <1-3> [0-7] ' \
|
||||
# Default to class 3 (idle) when no prior value exists
|
||||
-i"${class:-3} ${niceness}" \
|
||||
class niceness
|
||||
case $class in
|
||||
@ -87,6 +105,7 @@ setupGeneral() {
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
# Best-effort class; niceness 0-7 is mandatory
|
||||
if [ -n "$niceness" ] \
|
||||
&& (( niceness >= 0 && niceness <= 7 ))
|
||||
then
|
||||
@ -98,6 +117,7 @@ setupGeneral() {
|
||||
fi
|
||||
;;
|
||||
3)
|
||||
# Idle class; no niceness level is accepted
|
||||
ionice="ionice -c3 "
|
||||
;;
|
||||
*)
|
||||
@ -115,6 +135,7 @@ setupGeneral() {
|
||||
sqlite) and temporary WAVE files will be created. Note that debug logs
|
||||
(if enabled) will go there too.
|
||||
EODesc
|
||||
# Tab-completion (-e) works here because readline is active
|
||||
read \
|
||||
-e \
|
||||
-i"${tempdir:-$HOME/.atom/tmp}" \
|
||||
|
||||
@ -1,5 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright © 2012-2026 ScriptFanix
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# A copy of the GNU General Public License v3 is includded in the LICENSE file
|
||||
# at the root of the project.
|
||||
|
||||
setupRegen() {
|
||||
(( regen )) && return 0
|
||||
echo "Parameter $1 for destination $destination changed."
|
||||
|
||||
@ -1,5 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright © 2012-2026 ScriptFanix
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# A copy of the GNU General Public License v3 is includded in the LICENSE file
|
||||
# at the root of the project.
|
||||
|
||||
setup() {
|
||||
cat <<-EOStartConf
|
||||
You will now be asked (hopefully) simple questions to help you configure AtOM's
|
||||
@ -7,11 +20,17 @@ behavior.
|
||||
|
||||
Completion is available for prompts asking for a paths or filenames.
|
||||
EOStartConf
|
||||
# Collect all configuration sections in order
|
||||
setupGeneral
|
||||
setupSource
|
||||
setupDestinations
|
||||
# Clear the regex used by validation loops inside setup sub-functions
|
||||
unset expr
|
||||
# Write the newly gathered config to a temp file so the original is
|
||||
# preserved until the user confirms
|
||||
writeConfig >"$cffile".tmp
|
||||
# Unset all config variables so getConfig can repopulate them cleanly
|
||||
# from the temp file; avoids stale values leaking into the review
|
||||
unset \
|
||||
sourcepath \
|
||||
skippeddirectories \
|
||||
@ -37,6 +56,8 @@ Completion is available for prompts asking for a paths or filenames.
|
||||
destinationnoresample \
|
||||
destinationrenamepath \
|
||||
destinationskipmime
|
||||
# Re-declare per-destination variables as associative arrays so
|
||||
# getConfig can populate them with [destinationname]=value entries
|
||||
declare -A \
|
||||
destinationchannels \
|
||||
destinationfat32compat \
|
||||
@ -54,6 +75,8 @@ Completion is available for prompts asking for a paths or filenames.
|
||||
destinationnoresample \
|
||||
destinationrenamepath \
|
||||
destinationskipmime
|
||||
# Point getConfig at the temp file so the review reflects exactly what
|
||||
# would be written, not the old on-disk config
|
||||
oldcffile="$cffile"
|
||||
cffile="$cffile".tmp
|
||||
getConfig
|
||||
@ -61,6 +84,7 @@ Completion is available for prompts asking for a paths or filenames.
|
||||
echo $'Please review your new configuration:\n'
|
||||
printConfig
|
||||
}| less -F -e
|
||||
# Restore the original config path before deciding whether to commit
|
||||
cffile="$oldcffile"
|
||||
read -p'Write config file? [y/N] ' do_write
|
||||
case $do_write in
|
||||
|
||||
@ -1,5 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright © 2012-2026 ScriptFanix
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# A copy of the GNU General Public License v3 is includded in the LICENSE file
|
||||
# at the root of the project.
|
||||
|
||||
setupSource() {
|
||||
cat <<-EODesc
|
||||
|
||||
@ -18,6 +31,7 @@ setupSource() {
|
||||
-i"${sourcepath:-/var/lib/mpd/music}" \
|
||||
-p'Music collection (<TAB> for completion): ' \
|
||||
sourcepath
|
||||
# Reject paths that don't exist; AtOM doesn't create the source
|
||||
if ! [ -d "$sourcepath" ]
|
||||
then
|
||||
echo "$sourcepath does not exist or is not a" \
|
||||
@ -34,12 +48,17 @@ setupSource() {
|
||||
|
||||
This prompt will loop until an empty string is encountered.
|
||||
EODesc
|
||||
# Change into the source directory so readline tab-completion resolves
|
||||
# relative paths correctly while the user types skip entries
|
||||
cd "$sourcepath"
|
||||
# Remember how many skip entries already exist so we know when to stop
|
||||
# re-presenting existing entries vs. treating blanks as "done"
|
||||
count=${#skippeddirectories[@]}
|
||||
for (( i=0 ; 1 ; i++ ))
|
||||
do
|
||||
read \
|
||||
-e \
|
||||
# Pre-fill with the existing entry at this index, if any
|
||||
${skippeddirectories[i]+-i"${skippeddirectories[i]}"}\
|
||||
-p'Skip: ' \
|
||||
value
|
||||
@ -48,11 +67,14 @@ setupSource() {
|
||||
skippeddirectories[i]="$value"
|
||||
elif (( i < count ))
|
||||
then
|
||||
# Blank input on a previously set entry removes it
|
||||
unset skippeddirectories[i]
|
||||
else
|
||||
# Blank input beyond the old list signals end of input
|
||||
break
|
||||
fi
|
||||
done
|
||||
unset count
|
||||
# Return to the prior directory; output suppressed to keep the UI clean
|
||||
cd - >/dev/null
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user