6
# Licensed under GPL v2
10
# Documentation Portion
14
# Menu Entry Name for Selector:
17
#*****************************************************************************#
18
#* Configure One-Click Operations *#
20
#* This program will run you through options available and create a *#
21
#* configuration file containing your selected options for later use by *#
22
#* the automated customization process. *#
24
#* This is a very verbose process that will ask many questions. *#
25
#* Try not to get annoyed ;) *#
27
#*****************************************************************************#
32
# $2 -> config already selected? true/false
37
cfgtmp="$croot/program/tmp"
51
# Repeats a given string
52
# $1 -> times to repeat string
53
# $2 -> string to repeat
63
# Archive Configuration for Storage
64
# $1 -> Name for Archive/Config
65
# $2 -> directory with config
68
tar -czf config.tgz config
70
if [ -d customization ]
72
tar -czf customization.tgz customization
75
tar -cf "$1".x10conf *
76
mv "$1".x10conf "$croot/config/"
82
# Extract Configuration for Usage
83
# $1 -> config file to use
85
cp "$croot/config/$1" "$cfgtmp/"
92
if [ -e "customization.tgz" ]
94
tar -xzf "customization.tgz"
95
rm "customization.tgz"
106
echo "###############################################################################
107
# x10 2.1 Customization Configurator #
109
# This will guide you through the Configuration for automated routines. #
110
# You can give these routines their own names. The Program will ask you which #
111
# Configuration file you want to use for the routine, each time. #
112
###############################################################################"
119
cd "$croot/program/bin/"
120
bash ./010_config-selector.sh "$1" "$0" 2> "$croot/local-logs/config-selector-configure.txt"
128
for name in `ls -1d --color=never * | grep -v .x10conf | grep -v customization`
132
printf "$(cat $name/folder-cfg | grep "\#QQ" | sed -e "s_\#QQ\ __")"
133
printf " [yes/no] (default: yes):"
135
if [ "$decision" = "yes" ] || [ "$decision" = "y" ]
138
question="$(cat folder-cfg | grep "\#FQ" | sed -e "s_\#FQ\ __")"
139
for app in `ls -1d --color=never * | grep -v "folder-cfg"`
141
printf "$question $app [yes/no] (default: yes)?: "
143
if [ "$decision" = "yes" ] || [ "$decision" = "y" ]
146
elif [ "$decision" = "no" ] || [ "$decision" = "n" ]
150
echo "Will remove the application from your phone."
151
echo "If you want to change that, re-run the configurator"
152
echo "with the config you're creating right now selected"
153
echo "as base for the new configuration."
157
elif [ "$decision" = "no" ] || [ "$decision" = "n" ]
161
echo "Will remove the default set of applications from your phone."
165
printf "$(cat $name | grep "\#QQQ" | sed -e "s_\#QQQ\ __")"
166
ncf=`cat $name | grep "\#NCF"`
169
printf " [yes/no/keep]: "
175
if [ "$decision" = "yes" ] || [ "$decision" = "y" ]
178
# Check for extra-questions for the case of a positive answer.
179
# @TODO: Make more generic so that stuff aside from positive answers can use it.
181
if [ $(cat $name | grep "\#POQ") ]
183
printf "`cat $name | grep "\#POQ" | sed -e "s_\#POQ\ __"`"
185
sed -i "s/\#POV\ [0-9]*/\#POV\ $input/g" $name
186
printf "Applying Value: `cat $name | grep "\#POV" | sed -e "s_\#POV\ __"`\n"
188
mv $name $(cat $name | grep "\#PAF" | sed -e "s_\#PAF\ __") &> /dev/null
189
elif [ "$decision" = "no" ] || [ "$decision" = "n" ]
191
target=$(cat $name | grep "\#NAF" | sed -e "s_\#NAF\ __")
192
if [ "$target" = "delete" ]
196
mv $name $target &> /dev/null
198
elif [ "$decision" = "keep" ] || [ "$decision" = "k" ] && [ ! -z $ncf ]
200
target=$(cat $name | grep "\#NCF" | sed -e "s_\#NCF\ __")
201
if [ "$target" = "delete" ]
205
mv $name $target &> /dev/null
208
echo "Using default value 'yes'."
209
mv $name $(cat $name | grep "\#PAF" | sed -e "s_\#PAF\ __") &> /dev/null
217
printf "If you want to provide all needed files within the configuration.\nCopy them over into program/tmp/customization now.\n
218
Press Enter to continue"
222
# Set Configuration Name
225
printf "Give the new Configuration a name: "
228
sed -i "s/\#N\ .*/\#N\ $packname/g" config-info
232
# *Disabled for now as only Configurations available. Needs better selection, too.
236
#printf "What kind of Configuration is it? [Case Sensitive!]\n"
237
#printf "Known Types: "
238
#cd "$croot/program/types/"
239
#for ctype in `ls -1 *`;
243
#printf "\nYours is a: "
246
ptype="Configuration"
247
sed -i "s/\#T\ .*/\#T\ $ptype/g" ./config-info
253
printf "Enter what's gonna be the author-name: "
256
sed -i "s/\#A\ .*/\#A\ $authorname/g" ./config-info
263
sed -i "s_\#\*.*__g" ./config-info
264
sed -i '/^$/d' ./config-info
265
echo "#*****************************************************************************#" >> ./config-info
267
printf "Enter a brief description of what your $ptype does:\n"
275
if [ -z "$descline" ]
279
printf "#* $descline `repeat_string $((73-${#descline})) " "`*#\n" >> ./config-info
282
echo "#*****************************************************************************#" >> ./config-info
285
mkcfg "$packname" "$cfgtmp"
286
if [ -e "$croot/config/$packname.x10conf" ]
289
echo "Your Configuration has been created. Find it in the config folder."
290
echo "The filename is: $packname.x10conf"
292
echo "For some reason or another your config did not get created."
293
echo "Look for updates to this program or report the bug. (Please incl. logs)"
298
bash ./selector "$croot"