#! /bin/sh

# FIXME: this script should be translatable in a better way than the
# ugly case..esac thing. Note that using gettext at this point -i.e.
# after the DVD has been ejected- is probably too brittle. A possible
# solution would be to turn this script into a .in file, with
# placeholders for translatable string. Translatable strings and their
# translations could be managed by ikiwiki+po, and the placeholders
# could be replaced at boot time -depending on the chosen locale- by
# the appropriate strings. Unfortunately po4a does not support shell
# scripts.

PATH=/sbin:/bin

print_text () {
   echo "$1" > /dev/console
}

print_empty_line () {
   print_text ''
}

### Main

test "x`/bin/cat /sys/kernel/kexec_loaded`y" = "x1y" || exit 0

/bin/stty sane < /dev/console

print_empty_line
print_empty_line
print_text "--------------------------------------------------------------------------------"

# $LANG was set there by the FIXME live-config upstream script
. /etc/default/locale

# Note to translators: any text line must fit on a 80 characters wide screen
case "${LANG}" in
   de_DE.UTF-8)
      print_text "        Sie können nun die Start-DVD oder den Start-USB-Stick entfernen"
      print_empty_line
      print_text "            Der Systemspeicher wird in einigen Sekunden gelöscht..."
      print_empty_line
      print_text "               Die Anzeige könnte anschließend fehlerhaft sein."
      print_empty_line
      print_text "      Falls sich das System in einigen Sekunden nicht selbst ausschaltet,"
      print_text "         bedeutet dies, dass die Speicherlöschung fehlgeschlagen ist."
      ;;
   es_ES.UTF-8)
      print_text "              Puede ahora retirar el DVD o el USB de arranque."
      print_empty_line
      print_text "       Se borrará dentro de pocos segundos la memoria RAM del sistema..."
      print_empty_line
      print_text "Pueden aparecer problemas de visualización en el monitor durante esta operación."
      print_empty_line
      print_text "      If the system does not power off automatically in a few seconds,"
      print_text "                  it may mean the memory wiping has failed."
      ;;
   fr_FR.UTF-8)
      print_text "            Vous pouvez maintenant retirer le DVD / clé USB de boot."
      print_empty_line
      print_text "           La mémoire vive va être effacée dans quelques secondes..."
      print_empty_line
      print_text "   Il est possible que l'affichage soit corrompu au cours de cette opération."
      print_empty_line
      print_text "    Si l'ordinateur ne s'éteint pas automatiquement après quelques secondes,"
      print_text "           il est possible que l'effacement de la mémoire ait échoué."
      ;;
   it*)
      print_text "              Adesso puoi rimuovere il cd o la penna USB."
      print_empty_line
      print_text "       La memoria del computer verra' cancellata tra pochi secondi..."
      print_empty_line
      print_text "        Il display potra' essere corrotto durante questa operazione."
      print_empty_line
      print_text "      Se vostro PC non si spegnera' automaticamente in pochi secondi"
      print_text "        la cancellazione della memoria potrebbe essere incompleta."

      ;;
   *)
      print_text "               You can now remove the boot DVD or USB stick."
      print_empty_line
      print_text "         The system memory is going to be wiped in a few seconds..."
      print_empty_line
      print_text "             Display might be corrupted during this operation."
      print_empty_line
      print_text "      If the system does not power off automatically in a few seconds,"
      print_text "                  it may mean the memory wiping has failed."
      ;;
esac

print_text "--------------------------------------------------------------------------------"
print_empty_line
print_empty_line

/bin/sleep 5
/sbin/kexec -e --reset-vga
