summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorramon <ramongomez@us.es>2009-10-27 16:45:14 +0000
committerramon <ramongomez@us.es>2009-10-27 16:45:14 +0000
commitc7d9af7e6f6a93545647221c2bf7c889f0343006 (patch)
tree7f5831224e27cf2a10573051b5416a45ed45f767
parent0d997c62418b734f80462613ddd8fa4c3b5a2ee9 (diff)
NTFS: formatear; FAT 12/16/32: comprobar y formatear; retoques en scripts.
git-svn-id: https://opengnsys.es/svn/trunk@419 a21b9725-9963-47de-94b9-378ad31fedc9
-rwxr-xr-xclient/engine/Disk.lib6
-rwxr-xr-xclient/engine/File.lib44
-rwxr-xr-xclient/engine/FileSystem.lib26
-rwxr-xr-xclient/nfsexport/bin/dosfsckbin0 -> 47140 bytes
-rwxr-xr-xclient/nfsexport/bin/mkdosfsbin0 -> 26904 bytes
-rwxr-xr-xclient/nfsexport/bin/mkntfsbin0 -> 228336 bytes
-rwxr-xr-xclient/nfsexport/scripts/boot.sh32
-rwxr-xr-xclient/nfsexport/scripts/create-image.sh1
-rwxr-xr-xclient/nfsexport/scripts/restore-image.sh21
9 files changed, 84 insertions, 46 deletions
diff --git a/client/engine/Disk.lib b/client/engine/Disk.lib
index ffa3b02c..d1324481 100755
--- a/client/engine/Disk.lib
+++ b/client/engine/Disk.lib
@@ -614,16 +614,22 @@ PART=`ogDiskToDev $1 $2` || return $?
#/// Elección del tipo de partición.
case "$3" in
EMPTY) ID=0 ;;
+ FAT12) ID=1 ;;
EXTENDED) ID=5 ;;
+ FAT16) ID=6 ;;
NTFS|EXFAT) ID=7 ;;
FAT32) ID=b ;;
+ HFAT12) ID=11 ;;
+ HFAT16) ID=16 ;;
HNTFS) ID=17 ;;
HFAT32) ID=1b ;;
LINUX-SWAP) ID=82 ;;
+ LINUX-LVM) ID=8e ;;
EXT[234]|REISERFS|REISER4|XFS|JFS)
ID=83 ;;
SOLARIS) ID=bf ;;
CACHE) ID=ca ;;
+ LINUX-RAID) ID=fd ;;
*) ogRaiseError $OG_ERR_PARTITION "$TYPE"
return $? ;;
esac
diff --git a/client/engine/File.lib b/client/engine/File.lib
index c1cb5e1f..9134c886 100755
--- a/client/engine/File.lib
+++ b/client/engine/File.lib
@@ -9,7 +9,6 @@
#*/
-##### PRUEBAS
#/**
# ogCopyFile [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target
#@brief Metafunción para copiar un fichero de sistema OpenGNSys a un directorio OpenGNSys.
@@ -46,6 +45,24 @@ cp -p "$SOURCE" "$TARGET" # (definir posible error)
#/**
+# ogDeleteFile [ str_repo | int_ndisk int_npartition ] path_filepath
+#@brief Metafunción que borra un fichero de un dispositivo.
+#@see ogGetPath
+#@version 0.9 - Pruebas con OpenGNSys.
+#@author Ramon Gomez, ETSII Universidad de Sevilla
+#@date 2009-09-29
+#*/
+function ogDeleteFile () {
+# Variables locales.
+local FILE
+#/// Comprobar que existe el fichero y borrarlo.
+FILE=$(ogGetPath "$@")
+[ -n "$FILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || reutrn $?
+rm -f "$FILE" || ogRaiseError $OG_ERR_NOTFOUND "$*" || reutrn $?
+}
+
+
+#/**
# ogDeleteTree [ str_repo | int_ndisk int_npartition ] path_dirpath
#@brief Metafunción que borra todo un subárbol de directorios de un dispositivo.
#@see ogGetPath
@@ -53,11 +70,13 @@ cp -p "$SOURCE" "$TARGET" # (definir posible error)
#@author Ramon Gomez, ETSII Universidad de Sevilla
#@date 2009-09-29
#*/
-# Borrar subárbol de directorio.
function ogDeleteTree () {
+
+# Variables locales.
local DIR
-DIR=$(ogGetPath "$@") || return $?
-[ -z "$DIR" ] && ogRaiseError $OG_ERR_NOTFOUND "$*" && reutrn $?
+#/// Comprobar que existe el directorio y borrarlo con su contenido.
+DIR=$(ogGetPath "$@")
+[ -n "$DIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || reutrn $?
rm -fr "$DIR" || ogRaiseError $OG_ERR_NOTFOUND "$*" || reutrn $?
}
@@ -154,22 +173,6 @@ ogGetPath $PARENT
#/**
-# ogDeleteFile [ str_repo | int_ndisk int_npartition ] path_filepath
-#@brief Metafunción que borra un fichero de un dispositivo.
-#@see ogGetPath
-#@version 0.9 - Pruebas con OpenGNSys.
-#@author Ramon Gomez, ETSII Universidad de Sevilla
-#@date 2009-09-29
-#*/
-function ogDeleteFile () {
-local FILE
-FILE=$(ogGetPath "$@") || return $?
-[ -z "$FILE" ] && ogRaiseError $OG_ERR_NOTFOUND "$*" && reutrn $?
-rm -f "$FILE" || ogRaiseError $OG_ERR_NOTFOUND "$*" || reutrn $?
-}
-
-
-#/**
# ogMakeDir [ str_repo | int_ndisk int_npartition ] path_dirpath
#@brief Metafunción que crea un subdirectorio vacío en un dispositivo.
#@see ogGetParentPath
@@ -181,7 +184,6 @@ function ogMakeDir () {
local PARENT DIR
PARENT=$(ogGetParentPath "$@") || return $?
DIR="$(basename "${!#}")"
-echo mkdir -p "$PARENT/$DIR"
mkdir -p "$PARENT/$DIR" || ogRaiseError $OG_ERR_NOTFOUND "$*" || reutrn $?
}
diff --git a/client/engine/FileSystem.lib b/client/engine/FileSystem.lib
index fa60e5cf..12312159 100755
--- a/client/engine/FileSystem.lib
+++ b/client/engine/FileSystem.lib
@@ -42,9 +42,10 @@ case "$TYPE" in
JFS) PROG="fsck.jfs" ;;
XFS) PROG="fsck.xfs" ;;
NTFS|HNTFS) PROG="ntfsfix" ;;
- FAT32|FAT32) PROG="fsck.vfat" ;;
- FAT16|FAT16) PROG="fsck.msdos" ;;
- *) ogRaiseError $OG_ERR_PARTITION "$1 $2 $TYPE"
+ FAT32|HFAT32) PROG="dosfsck"; PARAMS="-a" ;;
+ FAT16|HFAT16) PROG="dosfsck"; PARAMS="-a" ;;
+ FAT12|HFAT12) PROG="dosfsck"; PARAMS="-a" ;;
+ *) ogRaiseError $OG_ERR_PARTITION "$1, $2, $TYPE"
return $? ;;
esac
#/// Error si el sistema de archivos esta montado o bloqueado.
@@ -192,10 +193,12 @@ case "$3" in
JFS) ID=83; PROG="mkfs.jfs"; PARAMS="<<<\"y\"";;
NTFS) ID=7; PROG="mkntfs"; PARAMS="-f" ;;
HNTFS) ID=17; PROG="mkntfs"; PARAMS="-f" ;;
- FAT32) ID=b; PROG="mkfs.vfat" ;;
- HFAT32) ID=1b; PROG="mkfs.vfat" ;;
- FAT16) ID=6; PROG="mkfs.msdos" ;;
- HFAT16) ID=16; PROG="mkfs.msdos" ;;
+ FAT32) ID=b; PROG="mkdosfs"; PARAMS="-F 32" ;;
+ HFAT32) ID=1b; PROG="mkdosfs"; PARAMS="-F 32" ;;
+ FAT16) ID=6; PROG="mkdosfs"; PARAMS="-F 16" ;;
+ HFAT16) ID=16; PROG="mkdosfs"; PARAMS="-F 16" ;;
+ FAT12) ID=1; PROG="mkdosfs"; PARAMS="-F 12" ;;
+ HFAT12) ID=11; PROG="mkdosfs"; PARAMS="-F 12" ;;
*) LABEL="$3" ;;
esac
#/// Si no se indica explícitamente, detectar el tipo de sistema de archivos.
@@ -209,8 +212,9 @@ if [ -z "$PROG" ]; then
XFS) PROG="mkfs.xfs"; PARAMS="-f" ;;
JFS) PROG="mkfs.jfs"; PARAMS="<<<\"y\"";;
NTFS|HNTFS) PROG="mkntfs"; PARAMS="-f" ;;
- FAT32|HFAT32) PROG="mkfs.vfat" ;;
- FAT16|HFAT16) PROG="mkfs.msdos" ;;
+ FAT32|HFAT32) PROG="mkdosfs"; PARAMS="-F 32" ;;
+ FAT16|HFAT16) PROG="mkdosfs"; PARAMS="-F 16" ;;
+ FAT12|HFAT12) PROG="mkdosfs"; PARAMS="-F 12" ;;
*) ogRaiseError $OG_ERR_PARTITION "$1 $2 $TYPE"
return $? ;;
esac
@@ -588,8 +592,8 @@ case "$(ogGetFsType $1 $2)" in
awk -v B=$BLKS '/minimum size/ {print int($7*B/2048+1000)}')
resize2fs -fp $PART "${SIZE}M" &>/dev/null || ogRaiseError $OG_ERR_PARTITION "$1,$2" || return $?
;;
- REISERFS) # Usar "resize_reiserfs"
- ;;
+# REISERFS) # Usar "resize_reiserfs"
+# ;;
NTFS|HNTFS)
ogDeleteFile $1 $2 pagefile.sys
ogDeleteFile $1 $2 hiberfile.sys
diff --git a/client/nfsexport/bin/dosfsck b/client/nfsexport/bin/dosfsck
new file mode 100755
index 00000000..454b981b
--- /dev/null
+++ b/client/nfsexport/bin/dosfsck
Binary files differ
diff --git a/client/nfsexport/bin/mkdosfs b/client/nfsexport/bin/mkdosfs
new file mode 100755
index 00000000..95ca7390
--- /dev/null
+++ b/client/nfsexport/bin/mkdosfs
Binary files differ
diff --git a/client/nfsexport/bin/mkntfs b/client/nfsexport/bin/mkntfs
new file mode 100755
index 00000000..e3a32f2e
--- /dev/null
+++ b/client/nfsexport/bin/mkntfs
Binary files differ
diff --git a/client/nfsexport/scripts/boot.sh b/client/nfsexport/scripts/boot.sh
index 28f5ea02..594e4ecb 100755
--- a/client/nfsexport/scripts/boot.sh
+++ b/client/nfsexport/scripts/boot.sh
@@ -9,17 +9,35 @@ if [ $# -ne 2 ]; then
fi
# Procesos previos.
-PART=$(ogDiskToDev $1 $2) | exit $?
+PART=$(ogDiskToDev "$1" "$2") || exit $?
+NAME=$(ogGetHostname)
+NAME=${NAME:-"pc"}
# Arrancar.
ogEcho info "$PROG: Desmontar todos los sistemas operativos del disco."
ogUnmountAll $1 | exit $?
-if [ "$(ogGetOsType $1 $2)" = "Windows" ]; then
- ogEcho info "$PROG: Activar partición de Windows $PART."
- ogSetPartitionActive $1 $2
- ogEcho info "$PROG: Comprobar sistema de archivos."
- ogCheckFs $1 $2
-fi
+case "$(ogGetOsType $1 $2)" in
+ Windows)
+ ogEcho info "$PROG: Activar partición de Windows $PART."
+ ogSetPartitionActive $1 $2
+ ogEcho info "$PROG: Comprobar sistema de archivos."
+ ogCheckFs $1 $2
+ NAME=$(ogGetHostname)
+ ogEcho info "$PROG: Asignar nombre Windows \"$NAME\"."
+ ogSetWindowsName $1 $2 "$NAME"
+ ;;
+ Linux)
+ ogEcho info "$PROG: Asignar nombre Linux \"$NAME\"."
+ ETC=$(ogGetPath $1 $2 /etc)
+ [ -d "$ETC" ] && echo "$NAME" >$ETC/hostname 2>/dev/null
+ if [ -f "$ETC/fstab" ]; then
+ ogEcho info "$PROG: Actaualizar fstab con partición raíz \"$PART\"."
+ awk -v P="$PART " '{ if ($2=="/") {sub(/^.*$/, P, $1)}
+ print } ' $ETC/fstab >/tmp/fstab
+ mv /tmp/fstab $ETC/fstab
+ fi
+ ;;
+esac
ogEcho info "$PROG: Arrancar sistema operativo."
ogBoot $1 $2
diff --git a/client/nfsexport/scripts/create-image.sh b/client/nfsexport/scripts/create-image.sh
index 8aeb94df..a2b50497 100755
--- a/client/nfsexport/scripts/create-image.sh
+++ b/client/nfsexport/scripts/create-image.sh
@@ -15,6 +15,7 @@ IMGDIR=$(ogGetParentPath "$3" "$4") || exit $?
IMGFILE="$IMGDIR/$(basename $4).img"
# Renombrar el fichero de imagen si ya existe.
if [ -f "$IMGFILE" ]; then
+ ogEcho info "Renombrar \"$IMGFILE\" por \"$IMGFILE.ant\"."
mv "$IMGFILE" "$IMGFILE.ant"
fi
# Mostrar información.
diff --git a/client/nfsexport/scripts/restore-image.sh b/client/nfsexport/scripts/restore-image.sh
index 6510c201..8c6f5e04 100755
--- a/client/nfsexport/scripts/restore-image.sh
+++ b/client/nfsexport/scripts/restore-image.sh
@@ -10,17 +10,24 @@ if [ $# -ne 4 ]; then
fi
# Procesar parámetros de entrada
+IMGFILE=$(ogGetPath "$1" "$2.img")
if [ "$1" == "CACHE" -o "$1" == "cache" ]; then
- # Si la imagen no está en la caché, copiarla del repositorio.
- IMGDIR=$(ogGetParentPath "$1" "$2") || exit $?
- IMGFILE=$(ogGetPath "$1" "$2")
+ IMGDIR=$(ogGetParentPath "$1" "$2")
+ # Si no existe el directorio de la imagen, crearlo.
+ if [ -z "$IMGDIR"]; then
+ echo "Creando directorio de imagen \"$1, ${2%/*}\"."
+ ogMakeDir "$1" "${2%/*}" || ogRaiseError $OG_ERR_NOTFOUND "$1, ${2%/*}" || exit $?
+ fi
+ IMGDIR=$(ogGetParentPath "$1" "$2") || ogRaiseError $OG_ERR_NOTFOUND "$1, ${2%/*}" || exit $?
if [ -z "$IMGFILE" ]; then
echo "Copiando imagen \"$2\" del repositorio a caché local"
- ogCopyFile "repo" "$2" "$IMGDIR" || exit $?
- IMGFILE=$(ogGetPath "cache" "$2") || exit $?
+ ogCopyFile "repo" "$2.img" "$IMGDIR" || exit $?
+ IMGFILE=$(ogGetPath "cache" "$2.img")
fi
-else
- IMGFILE=$(ogGetPath "$1" "$2") || exit $?
+fi
+if [ -z "$IMGFILE" ]; then
+ ogRaiseError $OG_ERR_NOTFOUND "$1, $2"
+ exit $?
fi
PART=$(ogDiskToDev "$3" "$4") || exit $?