source: client/shared/scripts/configureOs @ 11364a6

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
Last change on this file since 11364a6 was f05d952, checked in by ramon <ramongomez@…>, 9 years ago

#718: Nueva función ogConfigureOsAgent para configurar el servicio del nuevo agente para sistemas operativos; llamada a la función en el script configureOs.

git-svn-id: https://opengnsys.es/svn/branches/version1.1@4990 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 6.8 KB
Line 
1#!/bin/bash
2
3#/**
4#         configureOs
5#@brief   Scirpt para realizar la configuracion del sistema operativo restaurado.
6#@param 1 disco
7#@param 2 particion
8#@return 
9#@TODO  comprobar que el tipo de particion corresponde con el sistema de archivos.
10#@exception OG_ERR_FORMAT     # 1 formato incorrecto.
11#@version 1.0.1 - Integracion cambio de nombre, extender fs, chequear particion activa
12#@author 
13#@date   2011-05-11
14#@version 1.0.1 - Configura el sector de la particion y el gestor de windows para iniciarse desde cualquier particion. 
15#@author Antonio J. Doblas Viso.    Universidad de Malaga.
16#@date   2011-05-20
17#@version 1.0.2 - Configura el sector de la particion y el gestor de linux para iniciarse desde cualquier particion. 
18#@author Antonio J. Doblas Viso.    Universidad de Malaga.
19#@date   2011-11-22
20#@version 1.0.3 - Configura el chkdisk en el arranque de windows, segun variable OGWINCHKDISK del engine.cfg. 
21#@author Antonio J. Doblas Viso.    Universidad de Malaga.
22#@date   2011-12-23
23#@version 1.0.4 - Inyecta el cliente para gestión del sistema operativo.
24#@author Ramon Gomez, ETSII Universidad de Sevilla
25#@date   2012-04-11
26#@version 1.0.5 - Postconfiguración para Mac OS X.
27#@author Ramon Gomez, ETSII Universidad de Sevilla
28#@date   2013-10-11
29#@version 1.1.0 - Postconfiguración para agente de sistema operativo basado en REST.
30#@author Ramon Gomez, ETSII Universidad de Sevilla
31#@date   2016-08-16
32#*/ ##
33
34# Carga el configurador del engine y los parámetros de red.
35[ -z $OGENGINECONFIGURATE ] && source /opt/opengnsys/etc/engine.cfg
36[ -f $DEVICECFG ] && source $DEVICECFG
37
38# Si el sistema de archivos no esta extendido, ampliarlo al tamaño de su partición.
39PARTSIZE=$(ogGetPartitionSize $1 $2) || exit $?
40FSSIZE=$(ogGetFsSize $1 $2)
41if [ $FSSIZE -lt $PARTSIZE ]; then
42    echo "Extender sistema de archivos."
43    ogExtendFs $1 $2
44fi
45
46# Si no existe partición activa, activar este sistema.
47FLAGACTIVE=$(ogGetPartitionActive $1)
48[ -z $FLAGACTIVE ] && ogSetPartitionActive $1 $2
49
50# Si el sistema de archivos es de solo lectura, no hacer la post-configuración.
51MNTDIR=$(ogMount $1 $2)
52if ! ogIsWritable $1 $2; then
53    echo "AVISO: sistema de archivos de solo lectura, no se ejecuta postconfiguración."
54    exit
55fi
56
57# Nombre del cliente.
58HOST="$(ogGetHostname)"
59
60# Post-configuración personalizada para cada tipo de sistema operativo.
61OSTYPE="$(ogGetOsType $1 $2)"
62case "$OSTYPE" in
63    Windows)    # Postconfiguración de Windows.
64        # Cambiar nombre en sistemas Windows.
65        HOST=${HOST:-"pc"}
66        ogSetWindowsName $1 $2 "$HOST"
67        # Descomentar la siguiente línea para cambiar usuario de inicio.
68        #ogSetWinlogonUser $1 $2 " "
69        # Configurar el boot sector de la partición Windows.
70        ogFixBootSector $1 $2
71        # Configurar el gestor de arranque de Windows XP/Vista/7.
72        ogWindowsBootParameters $1 $2
73        # Registrar en Windows que la partición indicada es su nueva unidad C:\
74        ogWindowsRegisterPartition $1 $2 C $1 $2
75        #ogLoadHiveWindows $1 $2; ogSetWindowsChkdisk $OGWINCHKDISK; ogUpdateHiveWindows
76        # Instalar nuevo agente de sistema operativo o el antiguo cliente para Windows.
77        if [ "${INSTALLOSAGENT^^}" == "TRUE" ]; then
78                ogConfigureOsAgent $1 $2
79        elif [ "${INSTALLOSCLIENT^^}" == "TRUE" ]; then
80                ogInstallMiniSetup $1 $2 postconf.cmd
81                ogInstallWindowsClient $1 $2 postconf.cmd
82        fi
83        ;;
84    Linux)      # Postconfiguración de GNU/Linux.
85        ## Install and Configure Grub based on OS installed and Grub 1st stage location.
86        ogGrubInstallPartition $1 $2
87        # Instalar nuevo agente de sistema operativo o el antiguo cliente para GNU/Linux.
88        if [ "${INSTALLOSAGENT^^}" == "TRUE" ]; then
89                ogConfigureOsAgent $1 $2
90        elif [ "${INSTALLOSCLIENT^^}" == "TRUE" ]; then
91                ogInstallLinuxClient $1 $2
92        fi
93        ;;
94    MacOS)      # Postconfiguración de Mac OS X.
95        # Fichero indicador de activación de postconfiguración.
96        touch $MNTDIR/osxpostconf
97
98        # Crear fichero de configuración del servicio de arranque.
99        cat << EOT >$MNTDIR/Library/LaunchDaemons/es.opengnsys.postconfd.plist
100<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
101<plist version="1.0">
102        <dict>
103                <key>Label</key>
104                <string>es.opengnsys.postconfd.sh</string>
105                <key>ProgramArguments</key>
106                <array>
107                        <string>/var/root/postconfd.sh</string>
108                </array>
109                <key>RunAtLoad</key>
110                <true/>
111                <key>StandardOutPath</key>
112                <string>/var/log/postconfd.log</string>
113                <key>StandardErrorPath</key>
114                <string>/var/log/postconfd.err</string>
115                <key>Debug</key>
116                <true/>
117        </dict>
118</plist>
119EOT
120
121        # Programa de inicio que será ejecutado en el arranque de Mac OS X.
122        cat << EOT >$MNTDIR/var/root/postconfd.sh
123#!/bin/bash
124# postconfd - ejecución de scripts de inicio.
125
126# Ejecutar postconfiguración si existe el fichero indicador.
127if [ -e /osxpostconf ]; then
128        ### NOTA: descomentar las opciones deseadas.
129        # Activar Journaling en HFS+ (no usar si el cliente continua en OpenGnsys).
130        #diskutil enableJournal disk$[$1-1]s$2
131        # Pedir usuario y clave en pantalla de conexión.
132        #defaults write /Library/Preferences/com.apple.loginwindow SHOWFULLNAME -bool yes
133        # No mostrar botón de cambio rápido de usuario.
134        #defaults write /Library/Preferences/.GlobalPreferences MultipleSessionEnabled -bool NO
135        # Bloquear escritorio, fondo, dock, etc del usuario "usuario".
136        #chflags uchange /Users/usuario/Library/Preferences/com.apple.desktop.plist
137        #chflags uchange /Users/usuario/Library/Preferences/com.apple.dock.plist
138        #chflags uchange /Users/usuario/Desktop
139        # Añadir usuario "usuario" a la lista de desarrolladores de Xcode.
140        #DevToolsSecurity --enable
141        #dscl . -append /Groups/_developer GroupMembership usuario
142        # Bajar volumen (valor entre 0 y 7).
143        #osascript -e 'set volume 1'
144        # Tomar nombre del equipo.
145        HOST="$HOST"
146        if [ -z "\$HOST" ]; then
147                # Si no hay nombre asociado, activar la red para obtener datos del DHCP.
148                source /etc/rc.common
149                CheckForNetwork
150                while [ "\$NETWORKUP" != "-YES-" ]; do
151                        sleep 5
152                        NETWORKUP=
153                        CheckForNetwork
154                done
155                # Componer nombre del equipo a partir de datos del DHCP.
156                IP=\$(ifconfig en0 inet | awk '{if (\$1=="inet") print \$2}')
157                HOST="mac-\$(echo \${IP//./-} | cut -f3-4 -d-)"
158        fi
159        # Asignar nombre del equipo.
160        scutil --set ComputerName "\$HOST"
161        scutil --set LocalHostName "\$HOST"
162        scutil --set HostName "\$HOST"
163        hostname "\$HOST"
164        # Descromprimir ficheros de versión para obtener inventario de aplicaciones.
165        find /Applications -type d -name "*.app" -prune -exec \
166             ditto --nopreserveHFSCompression "{}/Contents/version.plist" "{}/Contents/version.plist.uncompress"
167        # Borrar fichero indicador de psotconfiguración
168        rm -f /osxpostconf
169fi
170EOT
171        # Dar permiso de ejecución.
172        chmod 700 $MNTDIR/var/root/postconfd.sh
173        ;;
174esac
175
Note: See TracBrowser for help on using the repository browser.