source: lmd/trunk/fuentes/lmd-server.install/usr/sbin/lmd-import-img.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.8 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.sh image.lmdimg" 
42    exit -1;
43fi
44
45# Confirm message
46zenity --question --text "${MSG_INFO_IMPORT} ${1}"
47if [ $? -eq 1 ];
48then
49    exit 1
50fi
51
52# Admin Password
53PASS=`zenity --password --text "${MSG_PASS}" --title "${MSG_PASS_TITLE}"`
54   
55# Remove previous images in tmp
56echo "[lmd Import] Removing prevous uncompressed images in tmp..."
57
58if [[ -d /tmp/extracted_image ]]
59then
60    rm -r /tmp/extracted_image
61fi
62mkdir /tmp/extracted_image
63
64#### Ubicar dins la llista d'opcions el que hem creat n4d
65
66echo "[lmd Import] Extracting file..."
67tar -xvzf ${1} -C /tmp/extracted_image | zenity --progress --pulsate --auto-close --text "${MSG_EXTRACTING}" 
68
69if [ $? -ne 0 ] ; then
70zenity --error --text "${MSG_CANCELLED}"
71exit -1
72fi
73
74# Moving
75extracted_image=`ls /tmp/extracted_image/opt/ltsp/*/*.json | cut -d "/" -f 6`
76extracted_filename=`ls /tmp/extracted_image/opt/ltsp/*/*.json | cut -d "/" -f 7`
77new_imagename="${extracted_filename%.*}"
78
79
80if [ -d /opt/ltsp/${new_imagename} ];
81then
82    zenity --question --text "${MSG_EXISTS_CHROOT}"
83    if [ $? -eq  1 ]; then
84        exit -1
85    else
86        rm -r /opt/ltsp/${new_imagename} | zenity --progress --auto-close --pulsate --text "${MSG_REMOVING}"
87    fi
88fi
89
90
91echo "moving /tmp/extracted_image/opt/ltsp/${extracted_image} to /opt/ltsp/${new_imagename}"
92echo "moving /opt/ltsp/${new_imagename}/${extracted_filename} to /etc/ltsp/images/"
93
94mv /tmp/extracted_image/opt/ltsp/${extracted_image}  /opt/ltsp/${new_imagename}
95mv /opt/ltsp/${new_imagename}/${extracted_filename}  /etc/ltsp/images/
96
97# Update kernels and regenerate image
98ltsp-update-kernels ${new_imagename}
99ltsp-update-sshkeys
100ltsp-update-image ${new_imagename} | zenity --progress --pulsate --text "${MSG_CREATE_SQUASHFS}"
101lmd-server.install/usr/sbin/lmd-import-img.sh
102
103if [ $? -ne 0 ] ; then
104zenity --error --text "${MSG_CANCELLED}"
105exit -1
106fi
107
108# Setting image into bootMenu
109n4d-client -c LlxBootManager -m pushToBootList -u ${USER} -p ${PASS} -a ltp_label${new_imagename}
110 
111# Restarting NBD
112invoke-rc.d nbd-server restart
113
114zenity --info --text "${MSG_SUCCESS}"
115exit 0
Note: See TracBrowser for help on using the repository browser.