|
1 | 1 | #!/bin/bash --login |
2 | | - |
| 2 | + |
3 | 3 | INPUT=/tmp/menu.sh.$$ |
4 | 4 | OUTPUT=/tmp/output.sh.$$ |
| 5 | +YAML_UPDATE_DONE="$HOME/src/.update_to_yaml_done" |
5 | 6 | trap "rm $OUTPUT; rm $INPUT; exit" SIGHUP SIGINT SIGTERM |
6 | 7 |
|
7 | 8 | if [ ! -f "$(which dialog 2>/dev/null)" ]; then |
8 | 9 | echo -en "\n\nYou must install \"dialog\" on your system in order to use this updater.\n" |
9 | 10 | exit 1 |
10 | 11 | fi |
11 | 12 |
|
| 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 | + |
12 | 60 | function update_error() { |
13 | 61 | echo -ne "\n\n\nERROR: Something went wrong, please verify the updates via the commandline.\n\n\n\n" |
14 | 62 | echo -ne "\nThe error occured while updating \"${1}\\n\n" |
|
0 commit comments