source: ogLive-Builder-Git/ogclientImg2Sqfs

qndtest
Last change on this file was d34358c, checked in by Irina Gómez <irinagomez@…>, 5 years ago

#847 ogclientSqfs2Img and ogclientImg2Sqfs: Auxiliary file size is increased to fit the content of the second file system.

  • Property mode set to 100755
File size: 1.8 KB
Line 
1#!/bin/bash
2#/**
3#@brief Comprime el fichero ogclient.img en ogclient.sqfs.
4#@param none
5#@exeption 1 No es usuario root
6#@exeption 2 No existe el fichero ogclient.img
7#@date 2013-11.27
8#*/
9PROG="$(basename $0)"
10# Mostrar ayuda: Si se solicita, si faltan parametros o $3 no es SYNC1 o SYNC2.
11if [ "$*" == "help" ]; then
12        echo -e "$PROG: Comprime el fichero ogclient.img en ogclient.sqfs. \n"
13                "       Uso: $PROG (sin parametros)"
14        exit 0
15fi
16
17if [ "$USER" != "root" ]; then
18        echo "$PROG: Error: solo ejecutable por root" >&2
19        exit 1
20fi
21
22
23DATE=$(date +%y-%m-%d)
24OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
25OGCLIENTBASEDIR=$OPENGNSYS/tftpboot/ogclient/;
26OGCLIENTFILE=${OGCLIENTBASEDIR}ogclient.img;
27OGCLIENTSQFS=${OGCLIENTBASEDIR}ogclient.sqfs
28OGCLIENTMOUNT=${OGCLIENTBASEDIR}ogclientmount;
29OGCLIENTSIZEMB=2100;
30OGCLIENTLABEL=ogClient;
31
32# Comprobamos que existe el cliente .sqfs
33! [ -f $OGCLIENTFILE -a -d $OGCLIENTMOUNT ] && echo "No existe $OGCLIENTFILE o $OGCLIENTMOUNT" && exit 3
34# Montamos ogclient.img.
35echo "Montamos ogclient.img."
36mkdir -p $OGCLIENTMOUNT;
37mount | grep $OGCLIENTMOUNT || mount $OGCLIENTFILE $OGCLIENTMOUNT -o loop,offset=32256;
38
39# Si existe ogclient.sqfs hacemos copia de seguridad.
40echo "Si existe ogclient.sqfs hacemos copia de seguridad."
41[ -f ${OGCLIENTSQFS} ] && mv ${OGCLIENTSQFS} ${OGCLIENTSQFS}.$DATE
42
43# Comprimimos el cliente.
44echo "Comprimimos el cliente."
45echo "mksquashfs $OGCLIENTMOUNT  ${OGCLIENTSQFS}"
46mksquashfs $OGCLIENTMOUNT  ${OGCLIENTSQFS}
47
48# Desmontamos el ogclient.img
49echo "Desmontamos el ogclient.img"
50umount $OGCLIENTMOUNT
51
52# Generamos nuevo archivo de suma de comprobación.
53echo "Generamos nuevo archivo de suma de comprobacion."
54mv ${OGCLIENTSQFS}.sum ${OGCLIENTSQFS}.sum.$DATE
55md5sum ${OGCLIENTSQFS} |awk '{print $1}' >${OGCLIENTSQFS}.sum
Note: See TracBrowser for help on using the repository browser.