close
Warning:
Failed to sync with repository "ogBrowser-Git": (1366, "Incorrect string value: '\\xF0\\x9F\\x93\\xA6 I...' for column 'message' at row 1"); repository information may be out of date. Look in the Trac log for more information including mitigation strategies.
918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
| Line | |
|---|
| 1 | #!/bin/bash |
|---|
| 2 | # Script de ejemplo para reiniciar un ordenador |
|---|
| 3 | # Nota: se usa como base para el programa de reinicio de OpenGnsys Admin. |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | # Registrar ejecución manual de script. |
|---|
| 7 | case "$(ogGetCaller)" in |
|---|
| 8 | browser|bash) ogEcho log info "Script: $0" ;; |
|---|
| 9 | esac |
|---|
| 10 | |
|---|
| 11 | # Cargamos el valor por defecto del tiempo de sleep |
|---|
| 12 | [ -z $OGSLEEP ] && source /opt/opengnsys/etc/engine.cfg |
|---|
| 13 | |
|---|
| 14 | # Si se recibe un parametro sera el tiempo de sleep antes de realizar el reboot |
|---|
| 15 | if [ $# == 1 ] && [ "${1//[^0-9]/}" == "$1" ] |
|---|
| 16 | then |
|---|
| 17 | TIME=$1 |
|---|
| 18 | echo "[5] Se ha introducido un retardo de $TIME segundos para reiniciar" |
|---|
| 19 | else |
|---|
| 20 | # Sin parámetros, o el parámetro introducido no es un número |
|---|
| 21 | TIME=${OGSLEEP:-5} |
|---|
| 22 | echo "[5] No se ha introducido un retardo, $TIME segundos para reiniciar" |
|---|
| 23 | fi |
|---|
| 24 | |
|---|
| 25 | # No registrar errores. |
|---|
| 26 | export DEBUG="no" |
|---|
| 27 | |
|---|
| 28 | # Desmontar los sistemas de archivos y la caché local. |
|---|
| 29 | echo "[10] Desmontar todos los sistemas de archivos." |
|---|
| 30 | sync |
|---|
| 31 | for (( i=1; i <= $(ogDiskToDev | wc -w); i++ )); do |
|---|
| 32 | ogUnmountAll $i &>/dev/null |
|---|
| 33 | done |
|---|
| 34 | echo "[50] Desmontar cache local." |
|---|
| 35 | ogUnmountCache &>/dev/null |
|---|
| 36 | |
|---|
| 37 | # Volver a registrar errores. |
|---|
| 38 | unset DEBUG |
|---|
| 39 | |
|---|
| 40 | echo "[90] Reiniciar el equipo." |
|---|
| 41 | # Estado correcto de Wake-On-Lan antes de reiniciar. |
|---|
| 42 | ethtool -s $DEVICE wol g 2>/dev/null |
|---|
| 43 | # Detectar Busybox. |
|---|
| 44 | BUSYBOX=$(which busyboxOLD) |
|---|
| 45 | BUSYBOX=${BUSYBOX:-"busybox"} |
|---|
| 46 | |
|---|
| 47 | # Retardo para dar lugar al registro en cola de acciones. |
|---|
| 48 | sleep $TIME |
|---|
| 49 | # Parar Browser para evitar "cuelgues". |
|---|
| 50 | [ "$ogstatus" == "offline" ] || pkill browser |
|---|
| 51 | # Reiniciar. |
|---|
| 52 | $BUSYBOX reboot |
|---|
| 53 | |
|---|
| 54 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.