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

Last change on this file since 4914 was 4914, checked in by mabarracus, 2 years ago

Add zenity buttons translations

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