source: lmd/trunk/fuentes/lmd-server.install/usr/sbin/lmd-import-img-non-ui.sh @ 3136

Last change on this file since 3136 was 3136, checked in by kbut, 3 years ago

add script to set search domain

  • Property svn:executable set to *
File size: 3.4 KB
Line 
1#!/bin/bash
2
3##
4
5if [[ ${LANGUAGE} == "ca_ES" ]] || [[ ${LANGUAGE} == "ca_ES@valencia" ]] || [[ ${LANGUAGE} == "ca" ]] || [[ ${LANGUAGE} == "ca@valencia" ]];
6then
7    MSG_INFO_IMPORT="Aneu a importar la imatge: "
8    MSG_EXTRACTING="Extraient la imatge. Espereu un moment... "
9    MSG_CANCELLED="El procés ha estat cancel·lat"
10    MSG_CREATE_SQUASHFS="S'està creant la imatge al servidor."
11    MSG_SUCCESS="La imatge de client lleuger s'ha exportat"
12    MSG_PASS_TITLE="Contrassenya d'administrador"
13    MSG_PASS="Inseriu la contrassenya d'administrador"
14    MSG_EXISTS_CHROOT="Ja existeix una imatge amb este nom. Voleu sobreescriure-la?"
15    MSG_REMOVING="Esborrant la imatge prèvia..."
16elif  [[ ${LANGUAGE} == "es_ES" ]] || [[ ${LANGUAGE} == "es" ]];
17then
18    MSG_INFO_IMPORT="Va a importar la imagen: "
19    MSG_EXTRACTING="Extrayendo imagen. Espere un momento. "
20    MSG_CANCELLED="El proceso se ha cancelado"
21    MSG_CREATE_SQUASHFS="Creando la imagen en el servidor..."
22    MSG_SUCCESS="La imagen de cliente ligero se ha exportado"
23    MSG_PASS_TITLE="Contraseña del administrador"
24    MSG_PASS="Inserte la contraseña de administrador"
25    MSG_EXISTS_CHROOT="¿Ya existe una imagen con este nombre. Desea sobreescribirla?"
26    MSG_REMOVING="Borrando la imagen previa..."
27else
28    MSG_INFO_IMPORT="You are going to import image: "
29    MSG_EXTRACTING="Extracting image. Please wait... "
30    MSG_CANCELLED="Process has been cancelled"
31    MSG_CREATE_SQUASHFS="Creating image in server..."
32    MSG_SUCCESS="Thin client image has been exporported"
33    MSG_PASS_TITLE="Admin Password"
34    MSG_PASS="Insert admin password"
35    MSG_EXISTS_CHROOT="An image with this name alreasy exists. Overwrite it?"
36    MSG_REMOVING="Deleting previous image..."
37fi
38
39
40if [ $# -ne 1 ]; 
41    then echo "USAGE: lmd-import-img-non-ui.sh image.lmdimg" 
42    exit -1;
43fi
44
45# Confirm message
46read -p "${MSG_INFO_IMPORT} ${1} (y/n) " yn
47if [ "${yn}" = "n" ];
48then
49    exit 1
50fi
51
52# Admin Password
53echo -n "${MSG_PASS}"
54read -s PASS
55   
56# Remove previous images in tmp
57echo "[lmd Import] Removing prevous uncompressed images in tmp..."
58
59if [[ -d /tmp/extracted_image ]]
60then
61    rm -r /tmp/extracted_image
62fi
63mkdir /tmp/extracted_image
64
65#### Ubicar dins la llista d'opcions el que hem creat n4d
66
67echo "[lmd Import] Extracting file..."
68tar -xvzf ${1} -C /tmp/extracted_image
69
70# Moving
71extracted_image=`ls /tmp/extracted_image/opt/ltsp/*/*.json | cut -d "/" -f 6`
72extracted_filename=`ls /tmp/extracted_image/opt/ltsp/*/*.json | cut -d "/" -f 7`
73new_imagename="${extracted_filename%.*}"
74
75
76if [ -d /opt/ltsp/${new_imagename} ];
77then
78   
79    read -p "${MSG_EXISTS_CHROOT} ${1} (y/n) " resp
80    if [ "${resp}" = "n" ];
81    then
82        exit 1
83    else
84        rm -r /opt/ltsp/${new_imagename}
85    fi
86fi
87
88echo "moving /tmp/extracted_image/opt/ltsp/${extracted_image} to /opt/ltsp/${new_imagename}"
89echo "moving /opt/ltsp/${new_imagename}/${extracted_filename} to /etc/ltsp/images/"
90
91mv /tmp/extracted_image/opt/ltsp/${extracted_image}  /opt/ltsp/${new_imagename}
92mv /opt/ltsp/${new_imagename}/${extracted_filename}  /etc/ltsp/images/
93
94# Update kernels and regenerate image
95ltsp-update-kernels ${new_imagename}
96ltsp-update-sshkeys
97ltsp-update-image ${new_imagename}
98ltsp-set-domain-search-ltsconf
99
100# Setting image into bootMenu
101n4d-client -c LlxBootManager -m pushToBootList -u ${USER} -p ${PASS} -a ltp_label${new_imagename}
102 
103# Restarting NBD
104invoke-rc.d nbd-server restart
105
106echo "DONE.."
107exit 0
Note: See TracBrowser for help on using the repository browser.