Setup
* -S option * call setup when no conf file present * [general] setup
This commit is contained in:
parent
9bb66ba76c
commit
9cde5ba272
41
atom
41
atom
@ -72,7 +72,7 @@ help() {
|
||||
|
||||
#parse arguments
|
||||
OPTERR=0
|
||||
while getopts ':c:Cl:T:F:hD' opt
|
||||
while getopts ':c:Cl:T:F:ShD' opt
|
||||
do
|
||||
case $opt in
|
||||
c)
|
||||
@ -90,6 +90,9 @@ do
|
||||
F)
|
||||
forceall+=("$OPTARG")
|
||||
;;
|
||||
S)
|
||||
forcesetup=1
|
||||
;;
|
||||
h)
|
||||
help
|
||||
exit 0
|
||||
@ -110,24 +113,38 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
askconf() {
|
||||
read -p"Create one now? [Y/n/q] " createconf
|
||||
case $createconf in
|
||||
''|[yY])
|
||||
setup
|
||||
;;
|
||||
[nNqQ])
|
||||
echo "You need a configuration file. If you" \
|
||||
"want to create it yourself, please" \
|
||||
"read doc/config and doc/example.cfg." >&2
|
||||
exit $ENOCFG
|
||||
;;
|
||||
*)
|
||||
echo "Come again?" >&2
|
||||
askconf
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
if [ ! -f "$cffile" ]
|
||||
then
|
||||
if [ ! -d ~/.atom ]
|
||||
if [ ! -d "${cffile%/*}" ]
|
||||
then
|
||||
mkdir -p ~/.atom
|
||||
mkdir -p "${cffile%/*}"
|
||||
fi
|
||||
sed "s:%HOME%:$HOME:" "$exampleconf" > "$cffile"
|
||||
cat >&2 <<-EOCfgNotice
|
||||
No configuration file found!
|
||||
An example file has been created as "${cffile/$HOME/~}".
|
||||
You should change it to your likings using you favorite editor.
|
||||
|
||||
Bailing out.
|
||||
EOCfgNotice
|
||||
exit $ENOCFG
|
||||
echo "No configuration file found!" >&2
|
||||
askconf
|
||||
fi
|
||||
getConfig
|
||||
|
||||
(( forcesetup )) && setup
|
||||
|
||||
set +H
|
||||
|
||||
# Apply CLI overrides
|
||||
|
||||
@ -19,6 +19,7 @@ getConfig() {
|
||||
context=Destination
|
||||
destination="${key#[}"
|
||||
destination="${destination%]}"
|
||||
destinations+=("${destination%]}")
|
||||
;;
|
||||
*)
|
||||
getConfig$context
|
||||
|
||||
@ -19,7 +19,7 @@ getConfigDestination() {
|
||||
oggencneeded=1
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported destination format: $value" >2&
|
||||
echo "Unsupported destination format: $value" >&2
|
||||
exit $EFORMAT
|
||||
;;
|
||||
esac
|
||||
|
||||
15
lib/setup/setup
Normal file
15
lib/setup/setup
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
setup() {
|
||||
cat <<-EOStartConf
|
||||
You will now be asked (hopefully) simple questions to help you configure AtOM's
|
||||
behavior.
|
||||
|
||||
Completion is available for prompts asking for a paths or filenames.
|
||||
EOStartConf
|
||||
setupGeneral
|
||||
setupSource
|
||||
setupDestinations
|
||||
unset expr
|
||||
exit
|
||||
}
|
||||
132
lib/setup/setupGeneral
Normal file
132
lib/setup/setupGeneral
Normal file
@ -0,0 +1,132 @@
|
||||
#!/bin/bash
|
||||
|
||||
setupGeneral() {
|
||||
cat <<-EODesc
|
||||
|
||||
[General]
|
||||
We will start by setting the general parameters defining the program's
|
||||
behavior.
|
||||
EODesc
|
||||
cat <<-EODesc
|
||||
|
||||
Target load (integer):
|
||||
Defines how parallel processing will behave. AtOM will try to keep the
|
||||
1 minute load average between <load> and <load>+1 by adjusting
|
||||
concurrency. Initial concurrency will be set to half of that value.
|
||||
EODesc
|
||||
expr='^[0-9]*$'
|
||||
comeagain() {
|
||||
read \
|
||||
-e \
|
||||
-p'Target load: (integer) ' \
|
||||
${maxload+-i"$maxload"} \
|
||||
value
|
||||
if [ -n "$value" ] && [[ $value =~ $expr ]]
|
||||
then
|
||||
maxload="$value"
|
||||
else
|
||||
echo "Invalid max-load value: $value" >&2
|
||||
comeagain
|
||||
fi
|
||||
}
|
||||
comeagain
|
||||
cat <<-EODesc
|
||||
|
||||
Load interval (seconds, integer):
|
||||
How often should we check the load average and adjust concurrency. Set
|
||||
this too low, and concurrency may be increased too quickly. Set this
|
||||
too high, and AtOM will not adapt quickly enough to load increase. In
|
||||
both cases, your hard drive will suffer. In my experience, 30 seconds
|
||||
is a good value.
|
||||
EODesc
|
||||
comeagain() {
|
||||
read \
|
||||
-e \
|
||||
-p'Load interval: (integer) ' \
|
||||
-i${loadinterval:-30} \
|
||||
value
|
||||
if [[ $value =~ $expr ]]
|
||||
then
|
||||
loadinterval="$value"
|
||||
else
|
||||
echo "Invalid load-interval value: $value" >&2
|
||||
comeagain
|
||||
fi
|
||||
}
|
||||
comeagain
|
||||
cat <<-EODesc
|
||||
|
||||
Ionice <class> [niceness]:
|
||||
IO-hungry processes will be run with ionice class <class> and niceness
|
||||
[niceness] (if applicable). See man ionice for details.
|
||||
EODesc
|
||||
comeagain() {
|
||||
read \
|
||||
-e \
|
||||
-p'Ionice: <1-3> [0-7] ' \
|
||||
-i"${class:-3} ${niceness}" \
|
||||
class niceness
|
||||
case $class in
|
||||
1)
|
||||
# real-time class, only root can do that
|
||||
if (( UID ))
|
||||
then
|
||||
echo "IO class 'realtime' is"\
|
||||
"not available to unprivileged"\
|
||||
"users" >&2
|
||||
comeagain
|
||||
fi
|
||||
if [ -n "$niceness" ] \
|
||||
&& (( niceness >= 0 && niceness <= 7 ))
|
||||
then
|
||||
ionice="ionice -c1 -n$niceness "
|
||||
else
|
||||
echo "Invalid IO priority"\
|
||||
"'$niceness'" >&2
|
||||
comeagain
|
||||
fi
|
||||
;;
|
||||
2)
|
||||
if [ -n "$niceness" ] \
|
||||
&& (( niceness >= 0 && niceness <= 7 ))
|
||||
then
|
||||
ionice="ionice -c2 -n$niceness "
|
||||
else
|
||||
echo "Invalid IO priority"\
|
||||
"'$niceness'" >&2
|
||||
comeagain
|
||||
fi
|
||||
;;
|
||||
3)
|
||||
ionice="ionice -c3 "
|
||||
;;
|
||||
*)
|
||||
echo "Invalid ionice parameters $value"\
|
||||
>&2
|
||||
comeagain
|
||||
;;
|
||||
esac
|
||||
}
|
||||
comeagain
|
||||
cat <<-EODesc
|
||||
|
||||
Temporary Directory (path):
|
||||
Name speaks for itself: this is where FIFOs (for communicating with
|
||||
sqlite) and temporary WAVE files will be created. Note that debug logs
|
||||
(if enabled) will go there too.
|
||||
EODesc
|
||||
read \
|
||||
-e \
|
||||
-i"${tempdir:-$HOME/.atom/tmp}" \
|
||||
-p'Temporary directory (<TAB> for completion): '\
|
||||
tempdir
|
||||
cat <<-EODesc
|
||||
|
||||
Database (filename):
|
||||
EODesc
|
||||
read \
|
||||
-e \
|
||||
-i"${database:-$HOME/.atom/atom.db}" \
|
||||
-p'Database file (<TAB> for completion): ' \
|
||||
database
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user