Skip to content

Commit 7679d89

Browse files
committed
Prepare updater for YAML configuration style
1 parent 360bd88 commit 7679d89

1 file changed

Lines changed: 49 additions & 1 deletion

File tree

scripts/updater.sh

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,62 @@
11
#!/bin/bash --login
2-
2+
33
INPUT=/tmp/menu.sh.$$
44
OUTPUT=/tmp/output.sh.$$
5+
YAML_UPDATE_DONE="$HOME/src/.update_to_yaml_done"
56
trap "rm $OUTPUT; rm $INPUT; exit" SIGHUP SIGINT SIGTERM
67

78
if [ ! -f "$(which dialog 2>/dev/null)" ]; then
89
echo -en "\n\nYou must install \"dialog\" on your system in order to use this updater.\n"
910
exit 1
1011
fi
1112

13+
# Check whether this installation is one with deprecated ruby configuration files.
14+
# If so display a big warning that a manual update must be done for the configuration file of the bot.
15+
function upgrade_to_yaml() {
16+
if [ -f $HOME/src/bot1_conf.yml ] && [ -f "${YAML_UPDATE_DONE}" ];
17+
then
18+
# Update was already done and new YAML config beside the old .rb config was created
19+
# Nothing to do ...
20+
echo -en "\n\n\nWARNING: REMOVE the old ruby style configuration file \"$HOME/src/bot1_conf.rb\".\n\n"
21+
echo -en "The updater won't run as long as this file was not removed.\n\n"
22+
exit 15
23+
else
24+
# Neither the new overwrite config bot1_conf.yml does exist nor the YAML_UPDAT_DONE file.
25+
26+
# Check whether we have an installation that already has YAML configuration files.
27+
if [ -f $HOME/src/mumble-ruby-pluginbot/pluginbot_conf.yml ];
28+
then
29+
# This installation already has a YAML config file, so it was updated.
30+
31+
# Create a new overwrite config beside the old .rb config but make sure not to overwrite an existing one.
32+
if [ ! -f $HOME/src/bot1_conf.rb ];
33+
then
34+
cp $HOME/src/mumble-ruby-pluginbot/scripts/overwrite_conf.yml $HOME/src/bot1_conf.yml
35+
touch "${YAML_UPDATE_DONE}" # To know later that we already did this ... :)
36+
fi
37+
38+
cat<<EOF
39+
40+
WARNING: The format for configuration files has been changed from ruby style to YAML style.
41+
42+
You need to manually adapt the changes from
43+
$HOME/src/bot1_conf.rb
44+
into
45+
$HOME/src/bot1_conf.yml
46+
47+
When you finished that please remove the file $HOME/src/bot1_conf.rb or rename it.
48+
49+
Do the same for every additional bot in your installation.
50+
51+
Then run this updater again and then restart your bot or the complete system.
52+
EOF
53+
exit 15
54+
fi
55+
fi
56+
}
57+
58+
upgrade_to_yaml
59+
1260
function update_error() {
1361
echo -ne "\n\n\nERROR: Something went wrong, please verify the updates via the commandline.\n\n\n\n"
1462
echo -ne "\nThe error occured while updating \"${1}\\n\n"

0 commit comments

Comments
 (0)