Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
|
961d84db86 | |
|
631c3093c5 | |
|
8daaefffd1 | |
|
ae48530b95 | |
|
ab552d571d | |
|
9a0a3c2223 |
18
CHANGELOG.md
18
CHANGELOG.md
|
@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.7.3] - 2025-10-13
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed doxygen comments
|
||||
|
||||
## [1.7.2] - 2025-10-02
|
||||
|
||||
### Fixed
|
||||
|
||||
- Improve detection of BCD files for the menu entries
|
||||
|
||||
## [1.7.1] - 2025-10-02
|
||||
|
||||
### Fixed
|
||||
|
||||
- Allow to create images in regular ogLive (not ogLiveAdmin)
|
||||
|
||||
## [1.7.0] - 2025-09-29
|
||||
|
||||
### Added
|
||||
|
|
|
@ -0,0 +1,439 @@
|
|||
# Doxyfile 1.9.8
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME = "My Project"
|
||||
PROJECT_NUMBER =
|
||||
PROJECT_BRIEF =
|
||||
PROJECT_LOGO =
|
||||
OUTPUT_DIRECTORY =
|
||||
CREATE_SUBDIRS = NO
|
||||
CREATE_SUBDIRS_LEVEL = 8
|
||||
ALLOW_UNICODE_NAMES = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class" \
|
||||
"The $name widget" \
|
||||
"The $name file" \
|
||||
is \
|
||||
provides \
|
||||
specifies \
|
||||
contains \
|
||||
represents \
|
||||
a \
|
||||
an \
|
||||
the
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
JAVADOC_BANNER = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
PYTHON_DOCSTRING = YES
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 4
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = YES
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
OPTIMIZE_OUTPUT_SLICE = NO
|
||||
EXTENSION_MAPPING =
|
||||
MARKDOWN_SUPPORT = YES
|
||||
TOC_INCLUDE_HEADINGS = 5
|
||||
MARKDOWN_ID_STYLE = DOXYGEN
|
||||
AUTOLINK_SUPPORT = YES
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
IDL_PROPERTY_SUPPORT = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
GROUP_NESTED_COMPOUNDS = NO
|
||||
SUBGROUPING = YES
|
||||
INLINE_GROUPED_CLASSES = NO
|
||||
INLINE_SIMPLE_STRUCTS = NO
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
LOOKUP_CACHE_SIZE = 0
|
||||
NUM_PROC_THREADS = 1
|
||||
TIMESTAMP = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = NO
|
||||
EXTRACT_PRIV_VIRTUAL = NO
|
||||
EXTRACT_PACKAGE = NO
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
RESOLVE_UNNAMED_PARAMS = YES
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = SYSTEM
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
HIDE_COMPOUND_REFERENCE= NO
|
||||
SHOW_HEADERFILE = YES
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
SHOW_GROUPED_MEMB_INC = NO
|
||||
FORCE_LOCAL_INCLUDES = NO
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_MEMBERS_CTORS_1ST = NO
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
STRICT_PROTO_MATCHING = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
LAYOUT_FILE =
|
||||
CITE_BIB_FILES =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_IF_INCOMPLETE_DOC = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_IF_UNDOC_ENUM_VAL = NO
|
||||
WARN_AS_ERROR = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LINE_FORMAT = "at line $line of file $file"
|
||||
WARN_LOGFILE =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
INPUT = ./ogclient
|
||||
INPUT_ENCODING = UTF-8
|
||||
INPUT_FILE_ENCODING =
|
||||
FILE_PATTERNS = *.c \
|
||||
*.cc \
|
||||
*.cxx \
|
||||
*.cxxm \
|
||||
*.cpp \
|
||||
*.cppm \
|
||||
*.c++ \
|
||||
*.c++m \
|
||||
*.java \
|
||||
*.ii \
|
||||
*.ixx \
|
||||
*.ipp \
|
||||
*.i++ \
|
||||
*.inl \
|
||||
*.idl \
|
||||
*.ddl \
|
||||
*.odl \
|
||||
*.h \
|
||||
*.hh \
|
||||
*.hxx \
|
||||
*.hpp \
|
||||
*.h++ \
|
||||
*.ixx \
|
||||
*.l \
|
||||
*.cs \
|
||||
*.d \
|
||||
*.php \
|
||||
*.php4 \
|
||||
*.php5 \
|
||||
*.phtml \
|
||||
*.inc \
|
||||
*.m \
|
||||
*.markdown \
|
||||
*.md \
|
||||
*.mm \
|
||||
*.dox \
|
||||
*.py \
|
||||
*.pyw \
|
||||
*.f90 \
|
||||
*.f95 \
|
||||
*.f03 \
|
||||
*.f08 \
|
||||
*.f18 \
|
||||
*.f \
|
||||
*.for \
|
||||
*.vhd \
|
||||
*.vhdl \
|
||||
*.ucf \
|
||||
*.qsf \
|
||||
*.ice
|
||||
RECURSIVE = YES
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
FILTER_SOURCE_PATTERNS =
|
||||
USE_MDFILE_AS_MAINPAGE =
|
||||
FORTRAN_COMMENT_AFTER = 72
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
SOURCE_TOOLTIPS = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
CLANG_ASSISTED_PARSING = NO
|
||||
CLANG_ADD_INC_PATHS = YES
|
||||
CLANG_OPTIONS =
|
||||
CLANG_DATABASE_PATH =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
ALPHABETICAL_INDEX = YES
|
||||
IGNORE_PREFIX =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_EXTRA_STYLESHEET =
|
||||
HTML_EXTRA_FILES =
|
||||
HTML_COLORSTYLE = AUTO_LIGHT
|
||||
HTML_COLORSTYLE_HUE = 220
|
||||
HTML_COLORSTYLE_SAT = 100
|
||||
HTML_COLORSTYLE_GAMMA = 80
|
||||
HTML_DYNAMIC_MENUS = YES
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
HTML_CODE_FOLDING = YES
|
||||
HTML_INDEX_NUM_ENTRIES = 100
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
DOCSET_FEEDURL =
|
||||
DOCSET_BUNDLE_ID = org.doxygen.Project
|
||||
DOCSET_PUBLISHER_ID = org.doxygen.Publisher
|
||||
DOCSET_PUBLISHER_NAME = Publisher
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
CHM_INDEX_ENCODING =
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
SITEMAP_URL =
|
||||
GENERATE_QHP = NO
|
||||
QCH_FILE =
|
||||
QHP_NAMESPACE = org.doxygen.Project
|
||||
QHP_VIRTUAL_FOLDER = doc
|
||||
QHP_CUST_FILTER_NAME =
|
||||
QHP_CUST_FILTER_ATTRS =
|
||||
QHP_SECT_FILTER_ATTRS =
|
||||
QHG_LOCATION =
|
||||
GENERATE_ECLIPSEHELP = NO
|
||||
ECLIPSE_DOC_ID = org.doxygen.Project
|
||||
DISABLE_INDEX = NO
|
||||
GENERATE_TREEVIEW = NO
|
||||
FULL_SIDEBAR = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
TREEVIEW_WIDTH = 250
|
||||
EXT_LINKS_IN_WINDOW = NO
|
||||
OBFUSCATE_EMAILS = YES
|
||||
HTML_FORMULA_FORMAT = png
|
||||
FORMULA_FONTSIZE = 10
|
||||
FORMULA_MACROFILE =
|
||||
USE_MATHJAX = NO
|
||||
MATHJAX_VERSION = MathJax_2
|
||||
MATHJAX_FORMAT = HTML-CSS
|
||||
MATHJAX_RELPATH =
|
||||
MATHJAX_EXTENSIONS =
|
||||
MATHJAX_CODEFILE =
|
||||
SEARCHENGINE = YES
|
||||
SERVER_BASED_SEARCH = NO
|
||||
EXTERNAL_SEARCH = NO
|
||||
SEARCHENGINE_URL =
|
||||
SEARCHDATA_FILE = searchdata.xml
|
||||
EXTERNAL_SEARCH_ID =
|
||||
EXTRA_SEARCH_MAPPINGS =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_LATEX = YES
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME =
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
LATEX_MAKEINDEX_CMD = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
LATEX_FOOTER =
|
||||
LATEX_EXTRA_STYLESHEET =
|
||||
LATEX_EXTRA_FILES =
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
LATEX_BIB_STYLE = plain
|
||||
LATEX_EMOJI_DIRECTORY =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_SUBDIR =
|
||||
MAN_LINKS = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_PROGRAMLISTING = YES
|
||||
XML_NS_MEMB_FILE_SCOPE = NO
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the DOCBOOK output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_DOCBOOK = NO
|
||||
DOCBOOK_OUTPUT = docbook
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
GENERATE_SQLITE3 = NO
|
||||
SQLITE3_OUTPUT = sqlite3
|
||||
SQLITE3_RECREATE_DB = YES
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
EXTERNAL_PAGES = YES
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to diagram generator tools
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = YES
|
||||
DOT_NUM_THREADS = 0
|
||||
DOT_COMMON_ATTR = "fontname=Helvetica,fontsize=10"
|
||||
DOT_EDGE_ATTR = "labelfontname=Helvetica,labelfontsize=10"
|
||||
DOT_NODE_ATTR = "shape=box,height=0.2,width=0.4"
|
||||
DOT_FONTPATH =
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
UML_LIMIT_NUM_FIELDS = 10
|
||||
DOT_UML_DETAILS = NO
|
||||
DOT_WRAP_THRESHOLD = 17
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DIR_GRAPH_MAX_DEPTH = 1
|
||||
DOT_IMAGE_FORMAT = png
|
||||
INTERACTIVE_SVG = NO
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
DIA_PATH =
|
||||
DIAFILE_DIRS =
|
||||
PLANTUML_JAR_PATH =
|
||||
PLANTUML_CFG_FILE =
|
||||
PLANTUML_INCLUDE_PATH =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
MSCGEN_TOOL =
|
||||
MSCFILE_DIRS =
|
|
@ -73,7 +73,7 @@ if 'REPO' == repo or ogCheckIpAddress (repo):
|
|||
sys.exit (1)
|
||||
|
||||
# Si el destino es REPO y el cliente no está en modo "admin"; activar repositorio para escritura,
|
||||
if 'REPO' == repo and 'admin' != env_boot:
|
||||
if 'admin' != env_boot:
|
||||
retval = subprocess.run ([f'{dirname}/CambiarAcceso', 'admin']).returncode
|
||||
if retval:
|
||||
sys.exit (retval)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,439 +0,0 @@
|
|||
#!/bin/bash
|
||||
#/**
|
||||
#@file Cache.lib
|
||||
#@brief Librería o clase Cache
|
||||
#@class Cache
|
||||
#@brief Funciones para gestión de la caché local de disco.
|
||||
#@version 1.1.1
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
|
||||
#/**
|
||||
# ogCreateCache [int_ndisk] int_partsize
|
||||
#@brief Define la caché local, por defecto en partición 4 del disco 1.
|
||||
#@param int_ndisk numero de disco donde crear la cache, si no se indica es el 1 por defecto
|
||||
#@param int_npart número de partición (opcional, 4 por defecto)
|
||||
#@param int_partsize tamaño de la partición (en KB)
|
||||
#@return (nada, por determinar)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@note Requisitos: sfdisk, parted, awk, sed
|
||||
#@warning El tamaño de caché debe estar entre 50 MB y la mitad del disco.
|
||||
#@warning La caché no puede solaparse con las particiones de datos.
|
||||
#@version 0.9.1 - Definición de caché local.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010/03/09
|
||||
#@version 0.9.2 - Corrección definición de límites.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010/06/01
|
||||
#@version 1.0.4 - Soporte para discos GPT.
|
||||
#@author Universidad de Huelva
|
||||
#@date 2012/03/13
|
||||
#@version 1.0.5 - Posibilidad de crear la cache en cualquier disco duro
|
||||
#@author Universidad de Huelva
|
||||
#@date 2012/09/18
|
||||
#@version 1.1.0 - Posibilidad de crear la caché en cualquier partición.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2016/05/25
|
||||
#@version 1.1.0 - Soporte discos con sectores de 4k
|
||||
#@date 2017/01/09
|
||||
#@version 1.0.6b - Al crear las particiones ordenamos los dispositivos en el fichero auxiliar.
|
||||
#@author Irina Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2017/01/09
|
||||
#*/ ##
|
||||
function ogCreateCache ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FINDCACHE IOSIZE NDSK SIZECACHE PART DISK START END ENDPREVPART SIZE MINSIZE MAXSIZE
|
||||
local PTTYPE ID TMPFILE NVME_PREFIX
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [int_ndisk [int_npart]] int_partsize" \
|
||||
"$FUNCNAME 10000000" "$FUNCNAME 1 10000000" "$FUNCNAME 1 4 10000000"
|
||||
return
|
||||
fi
|
||||
# Si se recibe un parametro, sera el tamano de la cache
|
||||
case $# in
|
||||
1) # Error, si no es un entero positivo
|
||||
[[ $1 =~ ^[1-9][0-9]*$ ]] || ogRaiseError $OG_ERR_FORMAT "$1" || return $?
|
||||
NDSK=1
|
||||
PART=4
|
||||
SIZECACHE=$1
|
||||
;;
|
||||
2) # Error, si no son enteros positivos
|
||||
[[ $1 =~ ^[1-9][0-9]*$ ]] || ogRaiseError $OG_ERR_FORMAT "$1" || return $?
|
||||
[[ $2 =~ ^[1-9][0-9]*$ ]] || ogRaiseError $OG_ERR_FORMAT "$2" || return $?
|
||||
NDSK=$1
|
||||
PART=4
|
||||
SIZECACHE=$2
|
||||
;;
|
||||
3) # Error, si no son enteros positivos
|
||||
[[ $1 =~ ^[1-9][0-9]*$ ]] || ogRaiseError $OG_ERR_FORMAT "$1" || return $?
|
||||
[[ $2 =~ ^[1-9][0-9]*$ ]] || ogRaiseError $OG_ERR_FORMAT "$2" || return $?
|
||||
[[ $3 =~ ^[1-9][0-9]*$ ]] || ogRaiseError $OG_ERR_FORMAT "$3" || return $?
|
||||
NDSK=$1
|
||||
PART=$2
|
||||
SIZECACHE=$3
|
||||
;;
|
||||
*) ogRaiseError $OG_ERR_FORMAT
|
||||
return $?
|
||||
;;
|
||||
esac
|
||||
|
||||
TMPFILE=/tmp/sfdisk$$
|
||||
DISK=$(ogDiskToDev $NDSK) || return $?
|
||||
|
||||
# PATCH Para discos nvme la particion debe ser p1, p2, etc...en lugar de 1,2, sino falla sfdisk
|
||||
NVME_PREFIX=""
|
||||
if [[ $DISK == *"nvme"* ]]; then
|
||||
NVME_PREFIX="p"
|
||||
fi
|
||||
|
||||
|
||||
END=$[$(ogGetLastSector $NDSK 2>/dev/null)] # Sector final del disco.
|
||||
SIZE=$[$SIZECACHE*2] # Tamaño en sectores de 512 B.
|
||||
# Inicio partición cache según el disco tenga sectores de 4k o menores
|
||||
IOSIZE=$(fdisk -l $DISK | awk '/I\/O/ {print $4}')
|
||||
if [ $IOSIZE -eq 4096 ]; then
|
||||
END=$[$END-8192]
|
||||
START=$[END-SIZE+2048-(END-SIZE)%2048]
|
||||
else
|
||||
START=$[END-SIZE+1]
|
||||
fi
|
||||
ENDPREVPART=$[$(ogGetLastSector $NDSK $[PART-1] 2>/dev/null)]
|
||||
# Error si tamaño no está entre límites permitidos o si se solapa con la partición anterior.
|
||||
MINSIZE=25000 # Error de formateo si tamaño < 50 MB.
|
||||
MAXSIZE=$END # Para restringir tamaño > mitad del disco: MAXSIZE=$[END/2]
|
||||
if [ $SIZE -lt $MINSIZE -o $SIZE -gt $MAXSIZE -o $START -le $ENDPREVPART ]; then
|
||||
ogRaiseError $OG_ERR_FORMAT "$1" || return $?
|
||||
fi
|
||||
|
||||
# Desmontar todos los sistemas de archivos del disco.
|
||||
ogUnmountAll $NDSK 2>/dev/null
|
||||
# Definir particiones y notificar al kernel.
|
||||
# En el caso de ser disco GPT, de momento se borra la particion y se vuelve a crear,
|
||||
# por lo que se pierden los datos.
|
||||
PTTYPE=$(ogGetPartitionTableType $NDSK)
|
||||
if [ -z "$PTTYPE" ]; then
|
||||
PTTYPE="MSDOS" # Por defecto para discos vacíos.
|
||||
ogCreatePartitionTable $NDSK $PTTYPE
|
||||
fi
|
||||
case "$(ogGetPartitionTableType $NDSK)" in
|
||||
GPT)
|
||||
# Si la tabla de particiones no es valida, volver a generarla.
|
||||
[ ! $(sgdisk -p $DISK &>/dev/null) ] || echo -e "2\nw\nY\n" | gdisk $DISK
|
||||
# Si existe la cache se borra previamente
|
||||
[ -n "$(ogFindCache)" ] && ogDeleteCache
|
||||
# Capturamos el codigo de particion GPT para cache
|
||||
# PATCH - Cuando es GPT, la particion con codigo CACHE (CA00) no existe y no puede crearse, se cambia por LINUX (8300)
|
||||
ID=$(ogTypeToId LINUX GPT)
|
||||
sgdisk $DISK -n$PART:$START:$END -c$PART:CACHE -t$PART:$ID 2>/dev/null
|
||||
;;
|
||||
MSDOS)
|
||||
# Si la tabla de particiones no es valida, volver a generarla.
|
||||
parted -s $DISK print &>/dev/null || fdisk $DISK <<< "w"
|
||||
# Definir particiones y notificar al kernel.
|
||||
ID=$(ogTypeToId CACHE MSDOS)
|
||||
# Salvamos la configuración de las particiones e incluimos la cache.
|
||||
trap "rm -f $TMPFILE" 1 2 3 9 15
|
||||
sfdisk --dump $DISK | grep -v $DISK$PART > $TMPFILE
|
||||
echo "$DISK$NVME_PREFIX$PART : start= $START, size= $SIZE, Id=$ID" >> $TMPFILE
|
||||
# Ordenamos las líneas de los dispositivos
|
||||
UNIT=$(grep unit $TMPFILE)
|
||||
grep ^/dev $TMPFILE|sort -o $TMPFILE
|
||||
sed -i "1i $UNIT\n" $TMPFILE
|
||||
# Guardamos nueva configuración en el disco.
|
||||
sfdisk --no-reread $DISK < $TMPFILE
|
||||
rm -f $TMPFILE
|
||||
;;
|
||||
esac
|
||||
# Actualiza la tabla de particiones en el kernel.
|
||||
ogUpdatePartitionTable
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogDeleteCache
|
||||
#@brief Elimina la partición de caché local.
|
||||
#@return (nada, por determinar)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@note Requisitos: fdisk, sgdisk, partprobe
|
||||
#@version 0.91 - Definición de caché local.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010/03/11
|
||||
#@version 1.0.4 - Soporte para discos GPT.
|
||||
#@author Universidad de Huelva
|
||||
#@date 2012/03/13
|
||||
#@version 1.0.6b - llamada correcta a ogUpdatePartitionTable
|
||||
#@author Antonio Doblas Universidad de Málaga
|
||||
#@date 2016/11/16
|
||||
#@version 1.1.0 - Sustituir "sfdisk" por "fdisk" para discos MSDOS.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2016/05/25
|
||||
#*/ ##
|
||||
function ogDeleteCache ()
|
||||
{
|
||||
# Variables locales.
|
||||
local NDISK NPART DISK
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME"
|
||||
return
|
||||
fi
|
||||
# Error si no se encuentra partición de caché.
|
||||
read NDISK NPART <<<"$(ogFindCache)"
|
||||
[ -n "$NDISK" -a -n "$NPART" ] || ogRaiseError $OG_ERR_PARTITION "$MSG_NOCACHE" || return $?
|
||||
DISK=$(ogDiskToDev $NDISK)
|
||||
|
||||
# Desmontar todos los sistemas de archivos del disco.
|
||||
ogUnmountAll $NDISK 2>/dev/null
|
||||
case "$(ogGetPartitionTableType $NDISK)" in
|
||||
GPT)
|
||||
# Si la tabla de particiones no es valida, volver a generarla.
|
||||
[ ! $(sgdisk -p $DISK 2>&1 >/dev/null) ] || echo -e "2\nw\nY\n" | gdisk $DISK
|
||||
sgdisk $DISK -d$NPART 2>/dev/null
|
||||
;;
|
||||
MSDOS)
|
||||
# Si la tabla de particiones no es valida, volver a generarla.
|
||||
parted -s $DISK print &>/dev/null || fdisk $DISK <<< "w"
|
||||
# Eliminar la partición de caché.
|
||||
echo -e "d\n$NPART\nw" | fdisk $DISK 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
# Borrar etiqueta de la caché.
|
||||
rm -f /dev/disk/by-label/CACHE
|
||||
#Actualiza la tabla de particiones en el kernel.
|
||||
ogUpdatePartitionTable $NDISK
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogFindCache
|
||||
#@brief Detecta la partición caché local.
|
||||
#@param No requiere parametros
|
||||
#@return int_ndisk int_npart - devuelve el par nº de disco-nº de partición .
|
||||
#@warning Si no hay cache no devuelve nada
|
||||
#@version 0.1 - Integracion para Opengnsys - EAC: FindCache() en ATA.lib - HIDRA: DetectarCache.sh
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@Date 2008/06/19
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#@Date 2008/10/27
|
||||
#@version 0.91 - Adaptacion a la cache local de OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010/03/16
|
||||
#@version 1.0.5 - Obtener caché en discos GPT.
|
||||
#@author Alberto García, Universidad de Málaga y Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2014/05/28
|
||||
#*/ ##
|
||||
function ogFindCache ()
|
||||
{
|
||||
# Variables locales
|
||||
local DISK PART
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 1 4"
|
||||
return
|
||||
fi
|
||||
# Obtener el dispositivo del sistema de archivos etiquetado como "CACHE".
|
||||
PART=$(blkid -L "CACHE")
|
||||
# En discos nvme con particiones GPT la partición se detecta usando el tag PARTLABEL
|
||||
PART=${PART:-$(blkid -t PARTLABEL=CACHE | awk -F: '{print $1}')}
|
||||
# Si no se detecta, obtener particiones marcadas de tipo caché en discos MSDOS.
|
||||
PART=${PART:-$(sfdisk -l 2>/dev/null | awk '$6~/ca|a7/ {print $1}')}
|
||||
|
||||
# Por último revisar todos los discos GPT y obtener las particiones etiquetadas como caché.
|
||||
if [ -z "$PART" ]; then
|
||||
for DISK in $(ogDiskToDev); do
|
||||
# Nota: se añade espacio separador solo si existe valor previo.
|
||||
PART="${PART:+"$PART "}$(sgdisk -p $DISK 2>/dev/null | awk -v d=$DISK '$7~/CACHE/ {printf "%s%s",d,$1;}')"
|
||||
done
|
||||
fi
|
||||
|
||||
# Devolver número de disco y número de partición de la 1ª partición encontrada.
|
||||
ogDevToDisk ${PART%% *} 2>/dev/null
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogFormatCache
|
||||
#@brief Formatea el sistema de ficheros para la caché local.
|
||||
#@return (por determinar)
|
||||
#@warning Prueba con formato Reiser.
|
||||
#@attention
|
||||
#@note El sistema de archivos de la caché se queda montado.
|
||||
#@version 0.1 - Integracion para Opengnsys - EAC: FormatCache() en ATA.lib
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#@date 2008/10/27
|
||||
#@version 0.91 - Creacion cache local.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010-03-11
|
||||
#@version 1.1.0 - llamada a updateBootCache.
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#@date 2018-01-21
|
||||
|
||||
#*/ ##
|
||||
function ogFormatCache ()
|
||||
{
|
||||
# Variables locales.
|
||||
local DEV MNTDIR OPTIONS
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME"
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no hay definida partición de caché.
|
||||
DEV=$(ogFindCache) || ogRaiseError $OG_ERR_PARTITION "$MSG_NOCACHE" || return $?
|
||||
DEV=$(ogDiskToDev $DEV) || return $?
|
||||
|
||||
# Formatear sistema de ficheros.
|
||||
ogUnmountCache 2>/dev/null
|
||||
OPTIONS="extent,large_file"
|
||||
[[ $(uname -r) =~ ^5 ]] && OPTIONS+=",uninit_bg,^metadata_csum,^64bit"
|
||||
mkfs.ext4 -q -F $DEV -L "CACHE" -O "$OPTIONS" 2>/dev/null || ogRaiseError $OG_ERR_PARTITION "CACHE" || return $?
|
||||
|
||||
# Crear estructura básica.
|
||||
MNTDIR=$(ogMountCache)
|
||||
mkdir -p $MNTDIR/$OGIMG
|
||||
|
||||
# Incluir kernel e Initrd del ogLive
|
||||
updateBootCache 2>&1>/dev/null
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetCacheSize
|
||||
#@brief Devuelve el tamaño definido para la partición de caché.
|
||||
#@return int_partsize tamaño de la partición (en KB)
|
||||
#@exception OG_ERR_PARTITION No existe partición de caché.
|
||||
#@version 0.1 - Integracion para Opengnsys - EAC: InfoCache() en FileSystem.lib
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#@date 2008/10/27
|
||||
#@version 0.91 - Definicion de cache local.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010/03/09
|
||||
#*/ ##
|
||||
function ogGetCacheSize ()
|
||||
{
|
||||
# Variables locales
|
||||
local PART
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 10000000"
|
||||
return
|
||||
fi
|
||||
# Error si no se encuentra partición de caché.
|
||||
PART=$(ogFindCache) || ogRaiseError $OG_ERR_PARTITION "$MSG_NOCACHE" || return $?
|
||||
|
||||
# Devuelve tamaño de la partición de caché.
|
||||
ogGetPartitionSize $PART
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetCacheSpace
|
||||
#@brief Devuelve el espacio de disco disponible para la partición de caché.
|
||||
#@return int_size tamaño disponible (en KB)
|
||||
#@note El espacio disponible es el que hay entre el límite superior de la partición 3 del disco 1 y el final de dicho disco, y no puede ser superior a la mitad de dicho disco.
|
||||
#@version 0.1 - Integracion para Opengnsys - EAC: InfoCache() en FileSystem.lib
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#@date 2008/10/27
|
||||
#@version 0.91 - Definicion de cache local.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010/03/09
|
||||
#@version 1.0.5 - Uso de ogFindCache para detectar disco y particion
|
||||
#@author Universidad de Huelva
|
||||
#@date 2012/09/18
|
||||
#*/ ##
|
||||
function ogGetCacheSpace ()
|
||||
{
|
||||
# Variables locales.
|
||||
local NDISK DISK NPART SECTORS CYLS ENDPART3
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 23165386"
|
||||
return
|
||||
fi
|
||||
# Parche UHU para usar ogFindCache en lugar de 1
|
||||
# Error si no se encuentra partición de caché.
|
||||
read NDISK NPART <<<"$(ogFindCache)"
|
||||
[ -n "$NDISK" -a -n "$NPART" ] || ogRaiseError $OG_ERR_PARTITION "$MSG_NOCACHE" || return $?
|
||||
DISK=$(ogDiskToDev $NDISK) || return $?
|
||||
|
||||
SECTORS=$(awk -v D=${DISK#/dev/} '{if ($4==D) {print $3*2}}' /proc/partitions)
|
||||
CYLS=$(sfdisk -g $DISK | cut -f2 -d" ")
|
||||
SECTORS=$[SECTORS/CYLS*CYLS-1]
|
||||
ENDPART3=$(sfdisk -uS -l $DISK | awk -v P="${DISK}3" '{if ($1==P) print $3}')
|
||||
# Mostrar espacio libre en KB (1 KB = 2 sectores)
|
||||
if [ $ENDPART3 -gt $[SECTORS/2] ]; then
|
||||
echo $[(SECTORS-ENDPART3)/2]
|
||||
else
|
||||
echo $[SECTORS/4]
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogMountCache
|
||||
#@brief Monta la partición Cache y exporta la variable $OGCAC
|
||||
#@param sin parametros
|
||||
#@return path_mountpoint - Punto de montaje del sistema de archivos de cache.
|
||||
#@warning Salidas de errores no determinada
|
||||
#@version 0.1 - Integracion para Opengnsys - EAC: MountCache() en FileSystem.lib - HIDRA: MontarCache.sh
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2008/06/19
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#@Date 2008/10/27
|
||||
#@version 0.91 - Adaptacion a la cache local de OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010/03/16
|
||||
#@version 1.0 - Correccion multiples montajes de cache.
|
||||
#@author Antonio J. Doblas Viso, Universidad de Malaga
|
||||
#@date 2011/02/24
|
||||
#*/ ##
|
||||
function ogMountCache ()
|
||||
{
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME ==> /mnt/sda4"
|
||||
return
|
||||
fi
|
||||
|
||||
ogMountFs $(ogFindCache) 2>/dev/null || ogRaiseError $OG_ERR_PARTITION "$MSG_NOCACHE" || return $?
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogUnmountCache
|
||||
#@brief Desmonta la particion Cache y elimina la variable $OGCAC
|
||||
#@param sin parametros
|
||||
#@return nada
|
||||
#@warning Salidas de errores no determinada
|
||||
#@version 0.1 - Integracion para Opengnsys - EAC: UmountCache() en FileSystem.lib
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#@Date 2008/10/27
|
||||
#@version 0.91 - Adaptacion a la cache local de OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010/03/16
|
||||
#@version 1.0 - Correccion multiples montajes de cache.
|
||||
#@author Antonio J. Doblas Viso, Universidad de Malaga
|
||||
#@date 2011/02/24
|
||||
#*/ ##
|
||||
function ogUnmountCache ()
|
||||
{
|
||||
# Variables locales.
|
||||
local CACHE
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME"
|
||||
return
|
||||
fi
|
||||
|
||||
CACHE=$(ogFindCache) || ogRaiseError $OG_ERR_PARTITION "$MSG_NOCACHE"
|
||||
ogIsMounted $CACHE || return 0
|
||||
ogUnmountFs $CACHE
|
||||
# Borrar enlace simbólico de /mnt/ParticiónCache.
|
||||
rm -f $(ogDiskToDev $CACHE | sed 's/dev/mnt/')
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,422 +0,0 @@
|
|||
#!/bin/bash
|
||||
#/**
|
||||
#@file File.lib
|
||||
#@brief Librería o clase File
|
||||
#@class File
|
||||
#@brief Funciones para gestión de archivos y directorios.
|
||||
#@version 1.0.4
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
|
||||
#/**
|
||||
# ogCalculateChecksum [ str_repo | int_ndisk int_npart ] path_filepath
|
||||
#@brief Devuelve la suma de comprobación (checksum) de un fichero.
|
||||
#@param path_filepath camino del fichero (independiente de mayúsculas)
|
||||
#@param str_repo repositorio de ficheros
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@return hex_checksum Checksum del fichero
|
||||
#@version 0.9.2 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010-07-24
|
||||
#@version 1.0.4 - Calcula solo el checksum del último MB del fichero.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2012-03-16
|
||||
#*/ ##
|
||||
function ogCalculateChecksum ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FILE
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \
|
||||
"$FUNCNAME REPO ubuntu.img ==> ef899299caf8b517ce36f1157a93d8bf"
|
||||
return
|
||||
fi
|
||||
|
||||
# Comprobar que existe el fichero y devolver sus datos.
|
||||
FILE=$(ogGetPath "$@")
|
||||
[ -n "$FILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $?
|
||||
tail -c1M "$FILE" | md5sum -b 2>&1 | cut -f1 -d" "
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogCompareChecksumFiles [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target
|
||||
#@brief Metafunción que compara las sumas de comprobación almacenadas de 2 ficheros.
|
||||
#@return bool_compare Valor de comparación.
|
||||
#@warning No es necesario especificar la extensión ".sum".
|
||||
#@version 0.9.2 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010-07-24
|
||||
#*/ ##
|
||||
function ogCompareChecksumFiles ()
|
||||
{
|
||||
# Variables locales.
|
||||
local ARGS SOURCE TARGET
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \
|
||||
"if $FUNCNAME REPO ubuntu.img CACHE ubuntu.img; then ...; fi"
|
||||
return
|
||||
fi
|
||||
|
||||
ARGS="$@"
|
||||
case "$1" in
|
||||
/*) # Camino completo. */ (Comentrio Doxygen)
|
||||
SOURCE=$(ogGetPath "$1")
|
||||
shift ;;
|
||||
[1-9]*) # ndisco npartición.
|
||||
SOURCE=$(ogGetPath "$1" "$2" "$3")
|
||||
shift 3 ;;
|
||||
*) # Otros: repo, cache, cdrom (no se permiten caminos relativos).
|
||||
SOURCE=$(ogGetPath "$1" "$2")
|
||||
shift 2 ;;
|
||||
esac
|
||||
TARGET=$(ogGetPath "$@")
|
||||
|
||||
# Comparar los ficheros de checksum.
|
||||
test "$(cat "$SOURCE.sum" 2>/dev/null)" == "$(cat "$TARGET.sum" 2>/dev/null)"
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogCalculateFullChecksum [ str_repo | int_ndisk int_npart ] path_filepath
|
||||
#@brief Devuelve la suma COMPLETA de comprobación (checksum) de un fichero.
|
||||
#@param path_filepath camino del fichero (independiente de mayúsculas)
|
||||
#@param str_repo repositorio de ficheros
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@return hex_checksum Checksum del fichero
|
||||
#@version 1.0.5 - Primera versión para OpenGnSys.
|
||||
#@author Antonio Doblas Viso, EVLT Universidad de Málaga
|
||||
#@date 2014-07-09
|
||||
#*/ ##
|
||||
function ogCalculateFullChecksum ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FILE
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \
|
||||
"$FUNCNAME REPO ubuntu.img ==> ef899299caf8b517ce36f1157a93d8bf"
|
||||
return
|
||||
fi
|
||||
|
||||
# Comprobar que existe el fichero y devolver sus datos.
|
||||
FILE=$(ogGetPath "$@")
|
||||
[ -n "$FILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $?
|
||||
#ADV
|
||||
md5sum "$FILE" -b 2>&1 | cut -f1 -d" "
|
||||
# tail -c1M "$FILE" | md5sum -b 2>&1 | cut -f1 -d" "
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#/**
|
||||
# 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.
|
||||
#@see ogGetPath
|
||||
#@return Progreso de la copia.
|
||||
#@warning Deben existir tanto el fichero origen como el directorio destino.
|
||||
#@version 0.9 - Pruebas con OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-10-20
|
||||
#@version 1.0.4 - Copiar usando rsync.
|
||||
#@author Universidad de Huelva
|
||||
#@date 2012-07-06
|
||||
#*/ ##
|
||||
function ogCopyFile ()
|
||||
{
|
||||
# Variables locales.
|
||||
local ARGS SOURCE TARGET
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_source [ str_repo | int_ndisk int_npartition ] path_target" \
|
||||
"$FUNCNAME REPO newfile.txt 1 2 /tmp/newfile.txt"
|
||||
return
|
||||
fi
|
||||
|
||||
ARGS="$@"
|
||||
case "$1" in
|
||||
/*) # Camino completo. */ (Comentrio Doxygen)
|
||||
SOURCE="$(ogGetPath "$1")"
|
||||
shift ;;
|
||||
[1-9]*) # ndisco npartición.
|
||||
SOURCE="$(ogGetPath "$1" "$2" "$3")"
|
||||
shift 3 ;;
|
||||
*) # Otros: repo, cache, cdrom (no se permiten caminos relativos).
|
||||
SOURCE="$(ogGetPath "$1" "$2")"
|
||||
shift 2 ;;
|
||||
esac
|
||||
# Comprobar fichero origen y directorio destino.
|
||||
[ -n "$SOURCE" ] || ogRaiseError $OG_ERR_NOTFOUND "${ARGS% $*}" || return $?
|
||||
TARGET="$(ogGetPath "$@")"
|
||||
[ -n "$TARGET" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $?
|
||||
# Copiar fichero (para evitar problemas de comunicaciones las copias se hacen con rsync en vez de cp).
|
||||
rsync --progress --inplace -avh "$SOURCE" "$TARGET"
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# 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
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_file" \
|
||||
"$FUNCNAME 1 2 /tmp/newfile.txt"
|
||||
return
|
||||
fi
|
||||
|
||||
# Comprobar que existe el fichero y borrarlo.
|
||||
FILE="$(ogGetPath "$@")"
|
||||
[ -n "$FILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $?
|
||||
rm -f "$FILE" || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $?
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# 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
|
||||
#@version 0.9 - Pruebas con OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-09-29
|
||||
#*/ ##
|
||||
function ogDeleteTree ()
|
||||
{
|
||||
# Variables locales.
|
||||
local DIR
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_dir" \
|
||||
"$FUNCNAME 1 2 /tmp/newdir"
|
||||
return
|
||||
fi
|
||||
|
||||
# Comprobar que existe el directorio y borrarlo con su contenido.
|
||||
DIR="$(ogGetPath "$@")"
|
||||
[ -n "$DIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $?
|
||||
rm -fr "$DIR" || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $?
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetPath [ str_repo | int_ndisk int_npartition ] path_filepath
|
||||
#@brief Inicia el proceso de arranque de un sistema de archivos.
|
||||
#@param path_filepath camino del fichero (independiente de mayúsculas)
|
||||
#@param str_repo repositorio de ficheros
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@return path_file - camino completo real del fichero.
|
||||
#@note repo = { REPO, CACHE, CDROM }
|
||||
#@note Requisitos: \c grep \c sed
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero o dispositivo no encontrado.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#@warning En caso de error, sólo devuelve el código y no da mensajes.
|
||||
#@todo Terminar de definir parámetros para acceso a repositorios.
|
||||
#@version 0.1 - Integracion para Opengnsys - HIDRA: CaminoWindows.sh; EAC: GetPath(), FormatSintaxSpacePath(), FormatSintaxBackSlashPath (), en FileSystem.lib
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@Date 2008/10/10
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#@date 2008/10/27
|
||||
#@version 0.9 - Pruebas con OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-09-15
|
||||
#@version 1.1.1 - Correccion comentarios autodocumentacion doxygen .
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#@date 2018-07-05
|
||||
#*/ ##
|
||||
|
||||
function ogGetPath ()
|
||||
{
|
||||
# Variables locales.
|
||||
local MNTDIR FILE PREVFILE FILEPATH CURRENTDIR
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \
|
||||
"$FUNCNAME \"/mnt/sda1/windows/system32\" ==> /mnt/sda1/WINDOWS/System32" \
|
||||
"$FUNCNAME REPO /etc/fstab ==> /opt/opengnsys/images/etc/fstab" \
|
||||
"$FUNCNAME 1 1 \"/windows/system32\" ==> /mnt/sda1/WINDOWS/System32"
|
||||
return
|
||||
fi
|
||||
|
||||
# Procesar camino según el número de parámetros.
|
||||
case $# in
|
||||
1) FILE="$1" ;;
|
||||
2) case "${1^^}" in
|
||||
REPO)
|
||||
FILE="$OGIMG/$2" ;;
|
||||
CACHE)
|
||||
MNTDIR="$(ogMountCache)" || return $?
|
||||
FILE="$MNTDIR/$OGIMG/$2" ;;
|
||||
CDROM)
|
||||
MNTDIR="$(ogMountCdrom)" || return $?
|
||||
FILE="$MNTDIR/$2" ;;
|
||||
*) ogRaiseError $OG_ERR_FORMAT
|
||||
return $? ;;
|
||||
esac ;;
|
||||
3) MNTDIR="$(ogMount $1 $2)" || return $?
|
||||
FILE="$MNTDIR/$3" ;;
|
||||
*) ogRaiseError $OG_ERR_FORMAT
|
||||
return $? ;;
|
||||
esac
|
||||
|
||||
# Eliminar caracteres \c / duplicados y finales.
|
||||
|
||||
FILE="$(echo $FILE|sed -e 's/\(\/\)*\1/\//g; s/\/$//')"
|
||||
# Comprobar si existe el fichero para reducir tiempos.
|
||||
if [ -e "$FILE" ]; then
|
||||
FILEPATH="$FILE"
|
||||
else
|
||||
# Buscar el nombre correcto en cada subdirectorio del camino.
|
||||
FILEPATH="/"
|
||||
|
||||
while [ "$FILE" != "$PREVFILE" ]; do
|
||||
FILEPATH="$(ls -d "${FILEPATH%/}/${FILE%%/*}" 2>/dev/null || find "$FILEPATH" -maxdepth 1 -iname "${FILE%%/*}" -print 2>/dev/null)" #*/ (Comentario Doxygen)
|
||||
PREVFILE="$FILE"
|
||||
FILE="${FILE#*/}"
|
||||
done
|
||||
|
||||
fi
|
||||
[ -n "$FILEPATH" ] && echo "$FILEPATH"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetParentPath [ str_repo | int_ndisk int_npartition ] path_filepath
|
||||
#@brief Metafunción que devuelve el camino del directorio padre.
|
||||
#@see ogGetPath
|
||||
#@version 0.9 - Pruebas con OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-09-29
|
||||
#*/ ##
|
||||
|
||||
function ogGetParentPath ()
|
||||
{
|
||||
local PARENT
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \
|
||||
"$FUNCNAME \"/mnt/sda1/windows/system32\" ==> /mnt/sda1/WINDOWS" \
|
||||
"$FUNCNAME REPO /etc/fstab ==> /opt/opengnsys/images/etc" \
|
||||
"$FUNCNAME 1 1 \"/windows/system32\" ==> /mnt/sda1/WINDOWS"
|
||||
return
|
||||
fi
|
||||
|
||||
case $# in
|
||||
1) PARENT="$(dirname "$1")" ;;
|
||||
2) PARENT="$1 $(dirname "/$2")" ;;
|
||||
3) PARENT="$1 $2 $(dirname "/$3")" ;;
|
||||
*) ogRaiseError $OG_ERR_FORMAT
|
||||
return $? ;;
|
||||
esac
|
||||
ogGetPath $PARENT
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogIsNewerFile [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target
|
||||
#@brief Metafunción que indica se un fichero es más nuevo que otro.
|
||||
#@see ogGetPath
|
||||
#@return Código de salida: 0 - nuevo, 1 - antiguo o error
|
||||
#@warning Deben existir tanto el fichero origen como el destino.
|
||||
#@version 0.9.2 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010-07-24
|
||||
#@version 1.0.1 - Devolver falso en caso de error.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-05-18
|
||||
#*/ ##
|
||||
function ogIsNewerFile ()
|
||||
{
|
||||
# Variables locales.
|
||||
local ARGS SOURCE TARGET
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_source [ str_repo | int_ndisk int_npartition ] path_target" \
|
||||
"if $FUNCNAME REPO ubuntu.img CACHE ubuntu.img; then ... fi"
|
||||
return
|
||||
fi
|
||||
|
||||
ARGS="$@"
|
||||
case "$1" in
|
||||
/*) # Camino completo. */ (Comentrio Doxygen)
|
||||
SOURCE="$(ogGetPath "$1")"
|
||||
shift ;;
|
||||
[1-9]*) # ndisco npartición.
|
||||
SOURCE="$(ogGetPath "$1" "$2" "$3")"
|
||||
shift 3 ;;
|
||||
*) # Otros: repo, cache, cdrom (no se permiten caminos relativos).
|
||||
SOURCE="$(ogGetPath "$1" "$2")"
|
||||
shift 2 ;;
|
||||
esac
|
||||
# Comprobar que existen los ficheros origen y destino.
|
||||
[ -n "$SOURCE" ] || ogRaiseError $OG_ERR_NOTFOUND "${ARGS% $*}" || return 1
|
||||
TARGET=$(ogGetPath "$@")
|
||||
[ -n "$TARGET" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return 1
|
||||
# Devolver si el primer fichero se ha modificado después que el segundo.
|
||||
test "$SOURCE" -nt "$TARGET"
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogMakeChecksumFile [ str_repo | int_ndisk int_npart ] path_filepath
|
||||
#@brief Metafunción que guarda el valor de comprobación de un fichero.
|
||||
#@see ogCalculateChecksum
|
||||
#@warning Genera un fichero con extensión ".sum".
|
||||
#@version 0.9.2 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010-07-24
|
||||
#*/ ##
|
||||
function ogMakeChecksumFile ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FILE
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_filepath" \
|
||||
"$FUNCNAME REPO ubuntu.img"
|
||||
return
|
||||
fi
|
||||
|
||||
# Comprobar que existe el fichero y guardar su checksum.
|
||||
FILE="$(ogGetPath "$@")"
|
||||
[ -n "$FILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $?
|
||||
ogCalculateChecksum "$FILE" > "$FILE.sum"
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogMakeDir [ str_repo | int_ndisk int_npartition ] path_dirpath
|
||||
#@brief Metafunción que crea un subdirectorio vacío en un dispositivo.
|
||||
#@see ogGetParentPath
|
||||
#@version 0.1 - Integracion para Opengnsys - HIDRA: CrearDirectorio.sh, EAC: MkdirPath() en FileSystem.lib
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@Date 2008/10/10
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#@date 2008/10/27
|
||||
#@version 0.9 - Pruebas con OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-09-29
|
||||
#*/ ##
|
||||
function ogMakeDir ()
|
||||
{
|
||||
local PARENT DIR
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ str_repo | int_ndisk int_npartition ] path_dir" \
|
||||
"$FUNCNAME 1 2 /tmp/newdir"
|
||||
return
|
||||
fi
|
||||
|
||||
PARENT="$(ogGetParentPath "$@")" || return $?
|
||||
DIR="$(basename "${!#}")"
|
||||
mkdir -p "$PARENT/$DIR" || ogRaiseError $OG_ERR_NOTFOUND "$*" || return $?
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,528 +0,0 @@
|
|||
#!/bin/bash
|
||||
#/**
|
||||
#@file Inventory.lib
|
||||
#@brief Librería o clase Inventory
|
||||
#@class Inventory
|
||||
#@brief Funciones para recogida de datos de inventario de hardware y software de los clientes.
|
||||
#@version 1.1.0
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetArch
|
||||
#@brief Devuelve el tipo de arquitectura del cliente.
|
||||
#@return str_arch - Arquitectura (i386 para 32 bits, x86_64 para 64 bits).
|
||||
#@version 0.9.2 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010-07-17
|
||||
#*/
|
||||
function ogGetArch ()
|
||||
{
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => x86_64"
|
||||
return
|
||||
fi
|
||||
|
||||
[ -d /lib64 ] && echo "x86_64" || echo "i386"
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetOsType int_ndisk int_npartition
|
||||
#@brief Devuelve el tipo del sistema operativo instalado.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@return OSType - Tipo de sistema operativo.
|
||||
#@see ogGetOsVersion
|
||||
#*/ ##
|
||||
function ogGetOsType ()
|
||||
{
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition" \
|
||||
"$FUNCNAME 1 2 => Linux"
|
||||
return
|
||||
fi
|
||||
ogGetOsVersion "$@" | cut -sf1 -d:
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetOsUuid int_ndisk int_nfilesys
|
||||
#@brief Devuelve el UUID del sistema operativo instalado en un sistema de archivos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden de la partición
|
||||
#@return str_uuid - UUID del sistema operativo.
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositiv
|
||||
#@version 1.1.0 - Primera versión para OpenGnsys
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2015-09-09
|
||||
#*/ ##
|
||||
function ogGetOsUuid ()
|
||||
{
|
||||
# Variables locales.
|
||||
local MNTDIR
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_nfilesys" \
|
||||
"$FUNCNAME 1 2 => 540e47c6-8e78-4178-aa46-042e4803fb16"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 2 parametros.
|
||||
[ $# = 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
|
||||
# Montar la particion, si no lo estaba previamente.
|
||||
MNTDIR=$(ogMount $1 $2) || return $?
|
||||
|
||||
# Obtener UUID según el tipo de sistema operativo.
|
||||
case "$(ogGetOsType $1 $2)" in
|
||||
Linux)
|
||||
# Leer el UUID del sistema de ficheros raíz o el fichero de identificador.
|
||||
findmnt -no UUID $MNTDIR 2>/dev/null || cat $MNTDIR/etc/machine-id 2>/dev/null
|
||||
;;
|
||||
Windows)
|
||||
# Leer identificador en clave de registro.
|
||||
ogGetRegistryValue $MNTDIR SOFTWARE '\Microsoft\Cryptography\MachineGuid' 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetSerialNumber
|
||||
#@brief Obtiene el nº de serie del cliente.
|
||||
#@version 1.1.0 - Primeras versión con OpenGnsys
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2015-06-08
|
||||
#*/ ##
|
||||
function ogGetSerialNumber ()
|
||||
{
|
||||
# Variables locales.
|
||||
local SERIALNO
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 123456"
|
||||
return
|
||||
fi
|
||||
|
||||
# Obtener nº de serie (ignorar los no especificados).
|
||||
SERIALNO=$(dmidecode -s system-serial-number | egrep -vi "(^[ 0]+$|not specified|to be filled|invalid entry|default string)")
|
||||
# Quitar espacios y truncar cadena si >25 caracteres.
|
||||
SERIALNO="${SERIALNO// /}"
|
||||
[ ${#SERIALNO} -gt 25 ] && SERIALNO="${SERIALNO:0:22}..."
|
||||
[ -n "$SERIALNO" ] && echo "$SERIALNO"
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogIsEfiActive
|
||||
#@brief Comprueba si el sistema tiene activo el arranque EFI.
|
||||
#*/ ##
|
||||
function ogIsEfiActive ()
|
||||
{
|
||||
test -d /sys/firmware/efi
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogListHardwareInfo
|
||||
#@brief Lista el inventario de hardware de la máquina cliente.
|
||||
#@return TipoDispositivo:Modelo (por determinar)
|
||||
#@warning Se ignoran los parámetros de entrada.
|
||||
#@note TipoDispositivo = { bio, boa, bus, cha, cdr, cpu, dis, fir, mem, mod, mul, net, sto, usb, vga }
|
||||
#@note Requisitos: dmidecode, lshw, awk
|
||||
#@version 0.1 - Primeras pruebas con OpenGnSys
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-07-28
|
||||
#@version 1.1.0 - Incluir nuevos componentes al inventario.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2014-04-23
|
||||
#*/ ##
|
||||
function ogListHardwareInfo ()
|
||||
{
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME"
|
||||
return
|
||||
fi
|
||||
|
||||
# Recopilación de dispositivos procesando la salida de \c lshw
|
||||
ogEcho info "$MSG_HARDWAREINVENTORY}"
|
||||
echo "cha=$(dmidecode -s chassis-type)" | grep -v "Other"
|
||||
[ -e /sys/firmware/efi ] && echo "boo=UEFI" || echo "boo=BIOS"
|
||||
lshw | awk 'BEGIN {type="mod";}
|
||||
/product:/ {sub(/ *product: */,""); prod=$0;}
|
||||
/vendor:/ {sub(/ *vendor: */,""); vend=$0;}
|
||||
/version:/ {sub(/ *version: */,"v.");vers=$0;}
|
||||
/size:/ {size=$2;}
|
||||
/clock:/ {clock=$2;}
|
||||
/slot:/ {sub(/ *slot: */,""); slot=$0;}
|
||||
/\*-/ {if (type=="mem"){
|
||||
if (size!=""){
|
||||
numbank++;
|
||||
print type"="vend,prod,size,clock" ("slot")";}
|
||||
}else{
|
||||
if (type=="totalmem"){
|
||||
if (size!=""){
|
||||
totalmemory="mem="size;}
|
||||
}else{
|
||||
if (type!="" && prod!=""){
|
||||
if (prod=="v."vers)
|
||||
vers="";
|
||||
print type"="vend,prod,size,vers;} }
|
||||
}
|
||||
type=prod=vend=vers=size=clock=slot="";}
|
||||
$1~/-core/ {type="boa";}
|
||||
$1~/-firmware/ {type="bio";}
|
||||
$1~/-cpu/ {type="cpu";}
|
||||
$1~/-bank/ {type="mem";}
|
||||
$1~/-memory/ {type="totalmem";}
|
||||
$1~/-ide/ {type="ide";}
|
||||
$1~/-storage/ {type="sto";}
|
||||
$1~/-disk/ {type="dis";}
|
||||
$1~/-cdrom/ {type="cdr";}
|
||||
$1~/-display/ {type="vga";}
|
||||
$1~/-network/ {type="net";}
|
||||
$1~/-multimedia/ {type="mul";}
|
||||
$1~/-usb/ {type="usb";}
|
||||
$1~/-firewire/ {type="fir";}
|
||||
$1~/-serial/ {type="bus";}
|
||||
END {if (type!="" && prod!="")
|
||||
print type"="vend,prod,size,vers;
|
||||
if (length(numbank)==0 && length(totalmemory)>=4)
|
||||
print totalmemory; }
|
||||
'
|
||||
# */ (comentario para Doxygen)
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogListSoftware int_ndisk int_npartition
|
||||
#@brief Lista el inventario de software instalado en un sistema operativo.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@return programa versión ...
|
||||
#@warning Se ignoran los parámetros de entrada.
|
||||
#@note Requisitos: ...
|
||||
#@todo Detectar software en Linux
|
||||
#@version 0.1 - Primeras pruebas con OpenGnSys
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-09-23
|
||||
#@version 1.0.5 - Aproximación para inventario de software de Mac OS.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2013-10-08
|
||||
#@version 1.0.6 - Proceso depende del tipo de SO y soporte para FreeBSD.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2014-11-13
|
||||
#@version 1.1.0 - Se muestra el sistema operativo en la primera línea de la salida
|
||||
#@author Irina Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2016-04-26
|
||||
#*/ ##
|
||||
function ogListSoftware ()
|
||||
{
|
||||
# Variables locales.
|
||||
local APPS HIVE k KEYS KEYS32 MNTDIR PKGDIR PROG VERS TMPFILE TYPE
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME 1 1"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 2 parametros.
|
||||
[ $# = 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
|
||||
# Obtener tipo de sistema de archivos y montarlo.
|
||||
MNTDIR=$(ogMount $1 $2) || return $?
|
||||
TYPE=$(ogGetOsType $1 $2) || return $?
|
||||
|
||||
# Ficheros temporales.
|
||||
APPS=$(mktemp /tmp/apps.XXXXX)
|
||||
TMPFILE=$(mktemp /tmp/tmp.XXXXX)
|
||||
trap "rm -f $APPS $TMPFILE" 1 2 3 9 15
|
||||
|
||||
case "$TYPE" in
|
||||
Linux) # Software de GNU/Linux.
|
||||
# Procesar paquetes dpkg.
|
||||
PKGDIR="${MNTDIR}/var/lib/dpkg"
|
||||
if [ -r $PKGDIR ]; then
|
||||
# Proceso de fichero en sistemas de 64 bits.
|
||||
awk '/Package:/ {if (pack!="") print pack,vers;
|
||||
sub(/-dev$/,"",$2);
|
||||
pack=$2}
|
||||
/Version:/ {sub(/^.*:/,"",$2); sub(/-.*$/,"",$2);
|
||||
vers=$2}
|
||||
/Status:/ {if ($2!="install") pack=vers=""}
|
||||
END {if (pack!="") print pack,vers}
|
||||
' $PKGDIR/status > $APPS
|
||||
fi
|
||||
# Procesar paquetes RPM.
|
||||
PKGDIR="${MNTDIR}/var/lib/rpm"
|
||||
if [ -r $PKGDIR ]; then
|
||||
# Listar si está instalado el paquete "rpm" en el cliente.
|
||||
if which rpm &>/dev/null; then
|
||||
rm -f ${PKGDIR}/__db.*
|
||||
rpm --dbpath $PKGDIR -qa --qf "%{NAME} %{VERSION}\n" 2>/dev/null | \
|
||||
awk '$1!~/-devel$/ {sub(/-.*$/,"",$2); print $0}' > $APPS
|
||||
rm -f ${PKGDIR}/__db.*
|
||||
else
|
||||
# Obtener el nombre de cada paquete en la BD de RPM.
|
||||
python <<<"
|
||||
import re;
|
||||
import bsddb;
|
||||
db=bsddb.hashopen('$PKGDIR/Name','r');
|
||||
for k in db.keys():
|
||||
print re.sub('-devel$','',k);" > $APPS
|
||||
fi
|
||||
fi
|
||||
# Procesar paquetes pacman.
|
||||
PKGDIR="${MNTDIR}/var/lib/pacman/local"
|
||||
if [ -r $PKGDIR ]; then
|
||||
ls $PKGDIR | awk -F- '/-/ {print gensub(/-/, " ", NF-2);}' > $APPS
|
||||
fi
|
||||
# Procesar aplicaciones Snappy.
|
||||
PKGDIR="${MNTDIR}/snap"
|
||||
find $PKGDIR/*/current/meta -name snap.yaml -exec \
|
||||
awk '/name:/ {pack=$2}
|
||||
/version:/ {vers=$2}
|
||||
END {if (pack!="") print pack,"(snap)",vers}' {} 2>/dev/null \; >> $APPS
|
||||
# Procesar aplicaciones Flatpak.
|
||||
PKGDIR="${MNTDIR}/var/lib/flatpak"
|
||||
ls -1 $PKGDIR/app/*/current/active/deploy 2> /dev/null | python -c "
|
||||
import sys
|
||||
for f in sys.stdin:
|
||||
p = open(f.strip()).read().split('\0')
|
||||
try:
|
||||
if(p[0] != 'flathub'):
|
||||
raise ValueError
|
||||
print('{} (flatpak) {}'.format(p[p.index('appdata-name') + 4], p[p.index('appdata-version') + 1]))
|
||||
except ValueError:
|
||||
pass
|
||||
" >> $APPS
|
||||
;;
|
||||
Windows) # Software de Windows.
|
||||
# Comprobar tipo de proceso del registro de Windows.
|
||||
if which hivexregedit &>/dev/null; then
|
||||
# Nuevo proceso más rápido basado en "hivexregedit".
|
||||
HIVE=$(ogGetHivePath $MNTDIR software 2>/dev/null)
|
||||
if [ -n "$HIVE" ]; then
|
||||
# Claves de registro para programas instalados.
|
||||
hivexregedit --unsafe-printable-strings --export "$HIVE" '\Microsoft\Windows\CurrentVersion\Uninstall' > $TMPFILE 2>/dev/null
|
||||
hivexregedit --unsafe-printable-strings --export "$HIVE" '\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' >> $TMPFILE 2>/dev/null
|
||||
# Mostrar los valores "DisplayName" y "DisplayVersion" para cada clave.
|
||||
awk -F\" '$1~/^\[/ {n=""}
|
||||
$2~/DisplayName/ {n=$4}
|
||||
$2~/DisplayVersion/ {print n,$4}
|
||||
' $TMPFILE > $APPS
|
||||
fi
|
||||
else
|
||||
# Compatibilidad con clientes ogLive antiguos.
|
||||
# Claves de registro para programas instalados: formato "{clave}".
|
||||
KEYS=$(ogListRegistryKeys $MNTDIR software '\Microsoft\Windows\CurrentVersion\Uninstall')
|
||||
KEYS32=$(ogListRegistryKeys $MNTDIR software '\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall')
|
||||
# Mostrar los valores "DisplayName" y "DisplayVersion" para cada clave.
|
||||
for k in $KEYS; do
|
||||
PROG=$(ogGetRegistryValue $MNTDIR software "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayName")
|
||||
if [ -n "$PROG" ]; then
|
||||
VERS=$(ogGetRegistryValue $MNTDIR software "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayVersion")
|
||||
echo "$PROG $VERS"
|
||||
fi
|
||||
done > $APPS
|
||||
for k in $KEYS32; do
|
||||
PROG=$(ogGetRegistryValue $MNTDIR software "\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayName")
|
||||
if [ -n "$PROG" ]; then
|
||||
VERS=$(ogGetRegistryValue $MNTDIR software "\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayVersion")
|
||||
echo "$PROG $VERS"
|
||||
fi
|
||||
done >> $APPS
|
||||
fi
|
||||
;;
|
||||
MacOS) # Software de Mac OS.
|
||||
# Listar directorios de aplicaciones e intentar obtener la versión del fichero .plist (tanto original como descomprimido).
|
||||
find "${MNTDIR}/Applications" -type d -name "*.app" -prune -print | \
|
||||
while read k; do
|
||||
FILE="$k/Contents/version.plist"
|
||||
[ -s "$FILE" ] || FILE="$k/Contents/version.plist.uncompress"
|
||||
[ -s "$FILE" ] && VERSION=$(awk -F"[<>]" '/ShortVersionString/ {getline;v=$3}
|
||||
END {print v}' "$FILE")
|
||||
echo "$(basename "$k" .app) $VERSION"
|
||||
done > $APPS
|
||||
;;
|
||||
BSD) # Software de FreeBSD.
|
||||
sqlite3 $MNTDIR/var/db/pkg/local.sqlite <<<"SELECT name FROM pkg_search;" 2>/dev/null | \
|
||||
sed 's/\(.*\)-\(.*\)/\1 \2/g' > $APPS
|
||||
;;
|
||||
*) ogRaiseError $OG_ERR_NOTOS "$1, $2 ${TYPE+($TYPE)}"
|
||||
return $? ;;
|
||||
esac
|
||||
|
||||
# Mostrar sistema Operativo y aplicaciones.
|
||||
ogGetOsVersion $1 $2 | awk -F: '{print $2}'
|
||||
sort $APPS | uniq | iconv -ct utf-8
|
||||
rm -f $APPS $TMPFILE
|
||||
}
|
||||
|
||||
#/**
|
||||
# ogGetOsVersion int_ndisk int_nfilesys
|
||||
#@brief Devuelve la versión del sistema operativo instalado en un sistema de archivos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden de la partición
|
||||
#@return OSType:OSVersion - tipo y versión del sistema operativo.
|
||||
#@note OSType = { Android, BSD, GrubLoader, Hurd, Linux, MacOS, Solaris, Windows, WinLoader }
|
||||
#@note Requisitos: awk, head, chroot
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositiv
|
||||
#@exception OG_ERR_PARTITION Fallo al montar el sistema de archivos.
|
||||
#@version 0.9 - Primera versión para OpenGnSys
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-09-15
|
||||
#@version 1.0.4 - Incluir tipos BSD, MacOS y Solaris.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2012-06-29
|
||||
#@version 1.0.5 - Incluir tipos GrubLoader, Hurd y WinLoader, leer por defecto fichero /etc/os-release.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2013-10-07
|
||||
#@version 1.0.6 - Detectar GrubLoader al final y sistemas basados en EFI.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2014-08-27
|
||||
#*/ ##
|
||||
function ogGetOsVersion ()
|
||||
{
|
||||
# Variables locales.
|
||||
local MNTDIR TYPE DISTRIB VERSION IS64BIT FILE
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_nfilesys" \
|
||||
"$FUNCNAME 1 2 => Linux:Ubuntu precise (12.04 LTS) 64 bits"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 2 parametros.
|
||||
[ $# = 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
|
||||
# Montar la particion, si no lo estaba previamente.
|
||||
MNTDIR=$(ogMount $1 $2) || return $?
|
||||
|
||||
# Buscar tipo de sistema operativo.
|
||||
# Para GNU/Linux: leer descripción.
|
||||
TYPE="Linux"
|
||||
FILE="$MNTDIR/etc/os-release"
|
||||
[ -r $FILE ] && VERSION="$(awk -F= '$1~/PRETTY_NAME/ {gsub(/\"/,"",$2); print $2}' $FILE)"
|
||||
# Si no se puede obtener, buscar en ficheros del sistema.
|
||||
if [ -z "$VERSION" ]; then
|
||||
FILE="$MNTDIR/etc/lsb-release"
|
||||
[ -r $FILE ] && VERSION="$(awk -F= '$1~/DESCRIPTION/ {gsub(/\"/,"",$2); print $2}' $FILE)"
|
||||
for DISTRIB in redhat SuSE mandrake gentoo; do
|
||||
FILE="$MNTDIR/etc/${DISTRIB}-release"
|
||||
[ -r $FILE ] && VERSION="$(head -1 $FILE)"
|
||||
done
|
||||
FILE="$MNTDIR/etc/arch-release"
|
||||
[ -r $FILE ] && VERSION="Arch Linux"
|
||||
FILE="$MNTDIR/etc/slackware-version"
|
||||
[ -r $FILE ] && VERSION="Slackware $(cat $FILE)"
|
||||
fi
|
||||
# Si no se encuentra, intentar ejecutar "lsb_release".
|
||||
[ -z "$VERSION" ] && VERSION=$(chroot $MNTDIR lsb_release -d 2>/dev/null | awk -F":\t" '{print $2}')
|
||||
# Comprobar Linux de 64 bits.
|
||||
[ -n "$VERSION" ] && [ -e $MNTDIR/lib64 ] && IS64BIT="$MSG_64BIT"
|
||||
# Para Android, leer fichero de propiedades.
|
||||
if [ -z "$VERSION" ]; then
|
||||
TYPE="Android"
|
||||
FILE="$MNTDIR/android*/system/build.prop"
|
||||
[ -r $FILE ] && VERSION="Android $(awk -F= '$1~/(product.brand|build.version.release)/ {print $2}' $FILE | tr '\n' ' ')"
|
||||
[ -e $MNTDIR/lib64 ] && IS64BIT="$MSG_64BIT"
|
||||
fi
|
||||
# Para GNU/Hurd, comprobar fichero de inicio (basado en os-prober).
|
||||
if [ -z "$VERSION" ]; then
|
||||
TYPE="Hurd"
|
||||
FILE="$MNTDIR/hurd/init"
|
||||
[ -r $FILE ] && VERSION="GNU/Hurd"
|
||||
fi
|
||||
# Para Windows: leer la version del registro.
|
||||
if [ -z "$VERSION" ]; then
|
||||
TYPE="Windows"
|
||||
FILE="$(ogGetHivePath $MNTDIR SOFTWARE)"
|
||||
if [ -n "$FILE" ]; then
|
||||
# Nuevo método más rápido para acceder al registro de Windows..
|
||||
VERSION=$(echo $(hivexsh << EOT 2>/dev/null
|
||||
load $FILE
|
||||
cd \Microsoft\Windows NT\CurrentVersion
|
||||
lsval ProductName
|
||||
lsval ReleaseId
|
||||
EOT
|
||||
))
|
||||
[ -n "$(reglookup -H -p "Microsoft/Windows/CurrentVersion/ProgramW6432Dir" "$FILE" 2>/dev/null)" ] && IS64BIT="$MSG_64BIT"
|
||||
if [ -z "$VERSION" ]; then
|
||||
# Compatibilidad con métrodo antiguo y más lento de acceder al registro.
|
||||
VERSION=$(ogGetRegistryValue $MNTDIR software '\Microsoft\Windows NT\CurrentVersion\ProductName' 2>/dev/null)
|
||||
[ -n "$(ogGetRegistryValue $MNTDIR software '\Microsoft\Windows\CurrentVersion\ProgramW6432Dir' 2>/dev/null)" ] && IS64BIT="$MSG_64BIT"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# Para cargador Windows: buscar versión en fichero BCD (basado en os-prober).
|
||||
if [ -z "$VERSION" ]; then
|
||||
TYPE="WinLoader"
|
||||
FILE="$(ogGetPath $MNTDIR/boot/bcd)"
|
||||
[ -z "$FILE" ] && FILE="$(ogGetPath $MNTDIR/EFI/Microsoft/boot/bcd)"
|
||||
if [ -n "$FILE" ]; then
|
||||
for DISTRIB in "Windows Recovery" "Windows Boot"; do
|
||||
if grep -aqs "$(echo "$DISTRIB" | sed 's/./&./g')" $FILE; then
|
||||
VERSION="$DISTRIB loader"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
# Para macOS: detectar kernel y completar con fichero plist de información del sistema.
|
||||
if [ -z "$VERSION" ]; then
|
||||
TYPE="MacOS"
|
||||
# Kernel de Mac OS (no debe ser fichero de texto).
|
||||
FILE="$MNTDIR/mach_kernel"
|
||||
if [ -z "$(file -b $FILE | grep 'text')" ]; then
|
||||
# Obtener tipo de kernel.
|
||||
[ -n "$(file -b $FILE | grep 'Mach-O')" ] && VERSION="macOS"
|
||||
[ -n "$(file -b $FILE | grep 'Mach-O 64-bit')" ] && IS64BIT="$MSG_64BIT"
|
||||
# Datos de configuración de versión de Mac OS.
|
||||
FILE="$MNTDIR/System/Library/CoreServices/SystemVersion.plist"
|
||||
[ -r $FILE ] && VERSION=$(awk -F"[<>]" '
|
||||
/ProductName/ {getline;s=$3}
|
||||
/ProductVersion/ {getline;v=$3}
|
||||
END {print s,v}' $FILE)
|
||||
# Datos de recuperación de macOS.
|
||||
FILE="$MNTDIR/com.apple.recovery.boot"
|
||||
[ -r $FILE -a -n "$VERSION" ] && VERSION="$VERSION recovery"
|
||||
fi
|
||||
fi
|
||||
# Para FreeBSD: obtener datos del Kernel.
|
||||
### TODO Revisar solución.
|
||||
if [ -z "$VERSION" ]; then
|
||||
TYPE="BSD"
|
||||
FILE="$MNTDIR/boot/kernel/kernel"
|
||||
if [ -r $FILE ]; then
|
||||
VERSION="$(strings $FILE|awk '/@.*RELEASE/ {sub(/@\(#\)/,""); print $1,$2}')"
|
||||
[ -n "$(file -b $FILE | grep 'x86-64')" ] && IS64BIT="$MSG_64BIT"
|
||||
fi
|
||||
fi
|
||||
# Para Solaris: leer el fichero de versión.
|
||||
### TODO Revisar solución.
|
||||
if [ -z "$VERSION" ]; then
|
||||
TYPE="Solaris"
|
||||
FILE="$MNTDIR/etc/release"
|
||||
[ -r $FILE ] && VERSION="$(head -1 $FILE)"
|
||||
fi
|
||||
# Para cargador GRUB, comprobar fichero de configuración.
|
||||
if [ -z "$VERSION" ]; then
|
||||
TYPE="GrubLoader"
|
||||
for FILE in $MNTDIR/{,boot/}grub/menu.lst; do
|
||||
[ -r $FILE ] && VERSION="GRUB Loader"
|
||||
done
|
||||
#/* (comentario Doxygen)
|
||||
for FILE in $MNTDIR/{,boot/}{grub{,2},EFI/*}/grub.cfg; do
|
||||
[ -r $FILE ] && VERSION="GRUB2 Loader"
|
||||
done
|
||||
fi
|
||||
#*/ (Comentario Doxygen)
|
||||
# Mostrar resultado y salir sin errores.
|
||||
[ -n "$VERSION" ] && echo "$TYPE:$VERSION $IS64BIT"
|
||||
return 0
|
||||
}
|
|
@ -1,345 +0,0 @@
|
|||
#!/bin/bash
|
||||
#/**
|
||||
#@file Net.lib
|
||||
#@brief Librería o clase Net
|
||||
#@class Net
|
||||
#@brief Funciones básicas de red.
|
||||
#@version 1.0.6
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
|
||||
#/**
|
||||
# ogChangeRepo IPREPO [ OgUnit ]
|
||||
#@brief Cambia el repositorio para el recurso remoto images.
|
||||
#@param 1 Ip Repositorio
|
||||
#@param 2 Abreviatura Unidad Organizativa
|
||||
#@return Cambio recurso remoto en OGIMG.
|
||||
#@version 1.1 - Primera versión para OpenGnSys.
|
||||
#@author Irina Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2015-06-16
|
||||
#*/
|
||||
function ogChangeRepo ()
|
||||
{
|
||||
local SRCIMG NEWREPO REPO OGUNIT
|
||||
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME IPREPO [ OgUnit ]" \
|
||||
"$FUNCNAME 10.1.120.3" \
|
||||
"$FUNCNAME 10.1.120.3 cdc"
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
ogRaiseError $OG_ERR_FORMAT "$MSG_FORMAT: $FUNCNAME IPREPO [ OgUnit ]"
|
||||
return $?
|
||||
fi
|
||||
|
||||
|
||||
# Opciones de montaje: lectura o escritura
|
||||
mount |grep "ogimages.*rw," &>/dev/null && RW=",rw" || RW=",ro"
|
||||
|
||||
# Si REPO tomamos el repositorio y la unidad organizativa actual
|
||||
REPO=$(ogGetRepoIp)
|
||||
OGUNIT="$(df | awk -F " " '/ogimages/ {sub("//.*/ogimages","",$1); sub("/","",$1); print $1}')"
|
||||
|
||||
# Parametros de entrada. Si $1 = "REPO" dejo el repositorio actual
|
||||
[ "${1^^}" == "REPO" ] && NEWREPO="$REPO" || NEWREPO="${1}"
|
||||
|
||||
# Si $1 y $2 son el repositorio y la OU actual me salgo
|
||||
[ "$NEWREPO" == "$REPO" ] && [ "$2" == "$OGUNIT" ] && return 0
|
||||
|
||||
source /scripts/functions
|
||||
source /scripts/ogfunctions
|
||||
umount $OGIMG
|
||||
[ "$2" == "" ] && SRCIMG="ogimages" || SRCIMG="ogimages/$2"
|
||||
eval $(grep "OPTIONS=" /scripts/ogfunctions)
|
||||
|
||||
ogEcho session log "$MSG_HELP_ogChangeRepo $NEWREPO ${2%/}"
|
||||
ogConnect $NEWREPO $ogprotocol $SRCIMG $OGIMG $RW
|
||||
|
||||
# Si da error volvemos a montar el inicial
|
||||
if [ $? -ne 0 ]; then
|
||||
ogConnect $REPO $ogprotocol $SRCIMG $OGIMG $RW
|
||||
ogRaiseError session $OG_ERR_REPO "$NEWREPO"
|
||||
return $?
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetGroupDir [ str_repo ]
|
||||
#@brief Devuelve el camino del directorio para el grupo del cliente.
|
||||
#@param str_repo repositorio de imágenes (opcional)
|
||||
#@return path_dir - Camino al directorio del grupo.
|
||||
#@note repo = { REPO, CACHE } REPO por defecto
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@version 1.0.2 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-10-03
|
||||
#*/
|
||||
function ogGetGroupDir ()
|
||||
{
|
||||
local REPO DIR GROUP
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME str_repo" \
|
||||
"$FUNCNAME REPO ==> /opt/opengnsys/images/groups/Grupo1"
|
||||
return
|
||||
fi
|
||||
# Error si se recibe más de 1 parámetro.
|
||||
case $# in
|
||||
0) REPO="REPO" ;;
|
||||
1) REPO="$1" ;;
|
||||
*) ogRaiseError $OG_ERR_FORMAT "$*"
|
||||
return $? ;;
|
||||
esac
|
||||
|
||||
GROUP="$(ogGetGroupName)"
|
||||
if [ -n "$GROUP" ]; then
|
||||
DIR=$(ogGetPath "$REPO" "/groups/$GROUP" 2>/dev/null)
|
||||
[ -d "$DIR" ] && echo "$DIR"
|
||||
fi
|
||||
# Para que no haya error al fallar la condición anterior
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetGroupName
|
||||
#@brief Devuelve el nombre del grupo al que pertenece el cliente.
|
||||
#@return str_group - Nombre de grupo.
|
||||
#@version 1.0.2 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-10-03
|
||||
#*/
|
||||
function ogGetGroupName ()
|
||||
{
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => Grupo1"
|
||||
return
|
||||
fi
|
||||
[ -n "$group" ] && echo "$group"
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetHostname
|
||||
#@brief Muestra el nombre del cliente.
|
||||
#@return str_host - nombre de máquina
|
||||
#@version 0.10 - Integración en OpenGnSys 0.10
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010-02-11
|
||||
#*/ ##
|
||||
function ogGetHostname ()
|
||||
{
|
||||
local HOST
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => pc1"
|
||||
return
|
||||
fi
|
||||
# Tomar nombre de la variable HOSTNAME
|
||||
HOST="$HOSTNAME"
|
||||
# Si no, tomar del DHCP, opción host-name /* (comentario para Doxygen)
|
||||
[ -z "$HOST" ] && HOST=$(awk -F\" '/option host-name/ {gsub(/;/,""); host=$2}
|
||||
END {print host}
|
||||
' /var/lib/dhcp3/dhclient.leases)
|
||||
# Si no, leer el parámetro del kernel hostname (comentario para Doxygen) */
|
||||
[ -z "$HOST" ] && HOST=$(awk 'BEGIN {RS=""; FS="="}
|
||||
$1~/hostname/ {print $2}' /proc/cmdline)
|
||||
[ "$HOSTNAME" != "$HOST" ] && export HOSTNAME="$HOST"
|
||||
[ -n "$HOST" ] && echo $HOST
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetIpAddress
|
||||
#@brief Muestra la dirección IP del sistema
|
||||
#@return str_ip - Dirección IP
|
||||
#@version 0.10 - Integración en OpenGnSys 0.10
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010-02-11
|
||||
#@version 1.0 - Integración OpenGnSys 0.10 Opengnsys 0.10-testing
|
||||
#@note Usa las variables utilizadas por el initrd "/etc/net-ethX.conf
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
||||
#@date 2011-02-24
|
||||
#@version 1.0.2 - Soporte para varias tarjetas de red
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-06-17
|
||||
#*/ ##
|
||||
function ogGetIpAddress ()
|
||||
{
|
||||
local IP
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 192.168.0.10"
|
||||
return
|
||||
fi
|
||||
if [ -n "$IPV4ADDR" ]; then
|
||||
IP="$IPV4ADDR"
|
||||
else
|
||||
# Obtener direcciones IP.
|
||||
if [ -n "$DEVICE" ]; then
|
||||
IP=$(ip -o address show up dev "$DEVICE" 2>/dev/null | awk '{if ($3~/inet$/) {printf ("%s ", $4)}}')
|
||||
else
|
||||
IP=$(ip -o address show up | awk '$2!~/lo/ {if ($3~/inet$/) {printf ("%s ", $4)}}')
|
||||
fi
|
||||
fi
|
||||
# Mostrar solo la primera.
|
||||
echo "${IP%%/*}" # (comentario para Doxygen) */
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetMacAddress
|
||||
#@brief Muestra la dirección Ethernet del cliente.
|
||||
#@return str_ether - Dirección Ethernet
|
||||
#@version 0.10 - Integración en OpenGnSys 0.10
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2010-02-11
|
||||
#@version 1.0.2 - Soporte para varias tarjetas de red
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-06-17
|
||||
#*/ ##
|
||||
function ogGetMacAddress ()
|
||||
{
|
||||
local MAC
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 00:11:22:33:44:55"
|
||||
return
|
||||
fi
|
||||
# Obtener direcciones Ethernet.
|
||||
if [ -n "$DEVICE" ]; then
|
||||
MAC=$(ip -o link show up dev "$DEVICE" 2>/dev/null | awk '{sub (/.*\\/, ""); if ($1~/ether/) printf ("%s ", toupper($2));}')
|
||||
else
|
||||
MAC=$(ip -o link show up | awk '$2!~/lo/ {sub (/.*\\/, ""); if ($1~/ether/) printf ("%s ", toupper($2));}')
|
||||
fi
|
||||
# Mostrar sólo la primera.
|
||||
echo ${MAC%% *}
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetNetInterface
|
||||
#@brief Muestra la interfaz de red del sistema
|
||||
#@return str_interface - interfaz de red
|
||||
#@version 1.0 - Integración OpenGnSys 0.10 Opengnsys 0.10-testing
|
||||
#@note Usa las variables utilizadas por el initrd "/etc/net-ethX.conf
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
||||
#@date 2011-02-24
|
||||
#*/ ##
|
||||
function ogGetNetInterface ()
|
||||
{
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => eth0"
|
||||
return
|
||||
fi
|
||||
[ -n "$DEVICE" ] && echo "$DEVICE"
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetRepoIp
|
||||
#@brief Muestra la dirección IP del repositorio de datos.
|
||||
#@return str_ip - Dirección IP
|
||||
#@version 0.10 - Integración en OpenGnSys 0.10
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-01-13
|
||||
#@version 1.0 - Integración OpenGnSys 0.10 Opengnsys 0.10-testing
|
||||
#@note Comprobacion segun protocolo de conexion al Repo
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
||||
#@date 2011-02-24
|
||||
#@version 1.0.6 - Obtener datos del punto de montaje, evitando fallo si $ogprotocol está vacía.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2014-08-27
|
||||
#*/ ##
|
||||
function ogGetRepoIp ()
|
||||
{
|
||||
# Variables locales.
|
||||
local SOURCE FSTYPE
|
||||
|
||||
# Mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 192.168.0.2"
|
||||
return
|
||||
fi
|
||||
|
||||
# Obtener direcciones IP, según el tipo de montaje.
|
||||
eval $(findmnt -P -o SOURCE,FSTYPE $OGIMG)
|
||||
case "$FSTYPE" in
|
||||
nfs) echo "$SOURCE" | cut -f1 -d: ;;
|
||||
cifs) echo "$SOURCE" | cut -f3 -d/ ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetServerIp
|
||||
#@brief Muestra la dirección IP del Servidor de OpenGnSys.
|
||||
#@return str_ip - Dirección IP
|
||||
#@version 0.10 - Integración en OpenGnSys 0.10
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-01-13
|
||||
#@version 1.0 - Integración OpenGnSys 0.10 Opengnsys 0.10-testing
|
||||
#@note Comprobacion segun protocolo de conexion al Repo
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga.
|
||||
#@date 2011-02-24
|
||||
#@version 1.0.6 - Obtener datos del punto de montaje, evitando fallo si $ogprotocol está vacía.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2014-08-27
|
||||
#*/ ##
|
||||
function ogGetServerIp ()
|
||||
{
|
||||
# Variables locales.
|
||||
local SOURCE FSTYPE
|
||||
|
||||
# Mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "$FUNCNAME => 192.168.0.2"
|
||||
return
|
||||
fi
|
||||
|
||||
# Obtener direcciones IP, según el tipo de montaje.
|
||||
eval $(findmnt -P -o SOURCE,FSTYPE $OPENGNSYS)
|
||||
case "$FSTYPE" in
|
||||
nfs) echo "$SOURCE" | cut -f1 -d: ;;
|
||||
cifs) echo "$SOURCE" | cut -f3 -d/ ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogMakeGroupDir [ str_repo ]
|
||||
#@brief Crea el directorio para el grupo del cliente.
|
||||
#@param str_repo repositorio de imágenes (opcional)
|
||||
#@return (nada)
|
||||
#@note repo = { REPO, CACHE } REPO por defecto
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@version 1.0.5 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2013-09-26
|
||||
#*/
|
||||
function ogMakeGroupDir ()
|
||||
{
|
||||
local REPO DIR GROUP
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME str_repo" \
|
||||
"$FUNCNAME" "$FUNCNAME REPO"
|
||||
return
|
||||
fi
|
||||
# Error si se recibe más de 1 parámetro.
|
||||
case $# in
|
||||
0) REPO="REPO" ;;
|
||||
1) REPO="$1" ;;
|
||||
*) ogRaiseError $OG_ERR_FORMAT "$*"
|
||||
return $? ;;
|
||||
esac
|
||||
# Comprobar tipo de repositorio.
|
||||
DIR=$(ogGetPath "$REPO" / 2>/dev/null)
|
||||
[ -n "$DIR" ] || ogRaiseError $OG_ERR_FORMAT "$1"
|
||||
GROUP="$(ogGetGroupName)"
|
||||
if [ -n "$GROUP" ]; then
|
||||
mkdir -p "$DIR/groups/$GROUP" 2>/dev/null
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,543 +0,0 @@
|
|||
#!/bin/bash
|
||||
#/**
|
||||
#@file PostConf.lib
|
||||
#@brief Librería o clase PostConf
|
||||
#@class PostConf
|
||||
#@brief Funciones para la postconfiguración de sistemas operativos.
|
||||
#@version 1.1.0
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
|
||||
#/**
|
||||
# ogCleanOs int_ndisk int_nfilesys
|
||||
#@brief Elimina los archivos que no son necesarios en el sistema operativo.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@exception OG_ERR_PARTITION Partición desconocida o no accesible.
|
||||
#@note Antes incluido en la funcion ogReduceFs
|
||||
#@author Irina Gomez. Universidad de Sevilla.
|
||||
#@return (nada)
|
||||
#@date 2014-10-27
|
||||
#*/ ##
|
||||
function ogCleanOs ()
|
||||
{
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_nfilesys" \
|
||||
"$FUNCNAME 1 1"
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se reciben 2 parámetros.
|
||||
[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_ndisk int_nfilesys" || return $?
|
||||
|
||||
case "$(ogGetOsType $1 $2)" in
|
||||
Linux)
|
||||
# Borramos los ficheros de dispositivos y los temporales.
|
||||
ogCleanLinuxDevices $1 $2
|
||||
rm -rf $(ogMount $1 $2)/tmp/* #*/ Comentario Doxygen
|
||||
;;
|
||||
Windows)
|
||||
# Borrar ficheros de hibernación y paginación de Windows.
|
||||
[ -n "$(ogGetPath $1 $2 pagefile.sys)" ] && ogDeleteFile $1 $2 pagefile.sys
|
||||
[ -n "$(ogGetPath $1 $2 hiberfil.sys)" ] && ogDeleteFile $1 $2 hiberfil.sys
|
||||
[ -n "$(ogGetPath $1 $2 swapfile.sys)" ] && ogDeleteFile $1 $2 swapfile.sys
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#/**
|
||||
# ogInstallMiniSetup int_ndisk int_npartition str_filename [str_admuser str_admpassword bool_autologin [str_autouser str_autopassword] ]
|
||||
#@brief Metafunción para instalar archivo que se ejecutará en el arranque de Windows.
|
||||
#@see ogInstallFirstBoot ogInstallRunonce
|
||||
#*/ ##
|
||||
function ogInstallMiniSetup ()
|
||||
{
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$MSG_SEE ogInstallFirstBoot ogInstallRunonce"
|
||||
return
|
||||
fi
|
||||
case $# in
|
||||
3) # Ejecución en el primer arranque de la máquina.
|
||||
ogInstallFirstBoot "$@" ;;
|
||||
6|8) # Ejecución en el "runonce".
|
||||
ogInstallRunonce "$@" ;;
|
||||
*) ogRaiseError $OG_ERR_FORMAT
|
||||
return $? ;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogInstallFirstBoot int_ndisk int_npartition str_filename
|
||||
#@brief Crea unas claves del registro y el archivo cmd que se ejecutara en el primer arranque estando la maquina en un estado bloqueado
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@param str_filename nombre del archivo .cmd a ejecutar en el arranque
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@note El archivo estará en system32 y será visible por el sistema.
|
||||
#@version 1.0.2 - Nueva función
|
||||
#@author Jonathan Alonso Martinez - Universidad Autonoma de Barcelona
|
||||
#@date 2011-06-29
|
||||
#@version 1.0.4 - Heredada de antigua función ogInstallMiniSetup.
|
||||
#@author Jonathan Alonso Martinez - Universidad Autonoma de Barcelona
|
||||
#@date 2012-04-16
|
||||
#*/ ##
|
||||
function ogInstallFirstBoot ()
|
||||
{
|
||||
local MNTDIR DIR CMDDIR CMDFILE
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition str_filename" \
|
||||
"$FUNCNAME 1 1 filename.cmd"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 3 parámetros.
|
||||
[ $# == 3 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
|
||||
# Comprobar que existe el directorio del fichero de comandos.
|
||||
MNTDIR=$(ogMount "$1" "$2") || return $?
|
||||
for i in winnt windows; do
|
||||
DIR=$(ogGetPath $MNTDIR/$i/system32)
|
||||
[ -n "$DIR" ] && CMDDIR=$DIR
|
||||
done
|
||||
[ -n "$CMDDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$MNTDIR/windows/system32" || return $?
|
||||
CMDFILE="$CMDDIR/$3"
|
||||
|
||||
# Creamos el archivo cmd y creamos un par de comandos para que una vez acabe la
|
||||
# postconfiguracion resetee el mini setup, sino lo haria en cada arranque.
|
||||
cat > "$CMDFILE" << EOF
|
||||
REG ADD HKLM\System\Setup /v SystemSetupInProgress /t REG_DWORD /d 0 /f
|
||||
REG ADD HKLM\System\Setup /v CmdLine /t REG_SZ /d "" /f
|
||||
EOF
|
||||
|
||||
# Crear los valores de registro necesarios para que se haga la ejecución del .cmd al aranque.
|
||||
ogSetRegistryValue "$MNTDIR" SYSTEM "\Setup\SystemSetupInProgress" 1
|
||||
ogSetRegistryValue "$MNTDIR" SYSTEM "\Setup\SetupType" 4
|
||||
#ogDeleteRegistryValue "$MNTDIR" SYSTEM "\Setup\CmdLine"
|
||||
ogAddRegistryValue "$MNTDIR" SYSTEM "\Setup\CmdLine"
|
||||
ogSetRegistryValue "$MNTDIR" SYSTEM "\Setup\CmdLine" "cmd.exe /c $(basename $CMDFILE)"
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogInstallRunonce int_ndisk int_npartition str_filename str_adm_user str_adm_password bool_autologin [str_auto_user str_auto_password]
|
||||
#@brief Crea el archivo cmd que se ejecutara en el runonce de un usuario administrador
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@param str_filename nombre del archivo .cmd a ejecutar en el arranque (estara en system32 y sera visible por el sistema)
|
||||
#@param str_adm_user usuario administrador para hacer autologin y ejecutar el runonce
|
||||
#@param str_adm_password password del usuario administrador
|
||||
#@param bool_autologin si despues de la postconfiguracion queremos que la maquina haga autologin (0 o 1)
|
||||
#@param str_auto_user Usuario con el que queremos que haga autologin despues de la postconfiguracion
|
||||
#@param str_auto_password Password del usuario que hara autologin
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@version 1.0.2 - Nueva función
|
||||
#@author Jonathan Alonso Martinez - Universidad Autonoma de Barcelona
|
||||
#@date 2011-06-29
|
||||
#@version 1.0.4 - Heredado de antigua función ogInstallMiniSetup
|
||||
#@author Jonathan Alonso Martinez - Universidad Autonoma de Barcelona
|
||||
#@date 2012-04-16
|
||||
#@version 1.1.0 - Resuelve problemas a partir de Windows 10
|
||||
#@author Carmelo Cabezuelo Aguilar - Universidad Politécnica de Valencia
|
||||
#@date 2018-02-20
|
||||
#*/ ##
|
||||
function ogInstallRunonce ()
|
||||
{
|
||||
local MOUNTPOINT DIR CMDDIR CMDFILE
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition str_filename str_adm_user str_adm_password bool_autologin [str_auto_user str_auto_password]" \
|
||||
"$FUNCNAME 1 1 filename.cmd administrator passadmin 1 userauto passuserauto" \
|
||||
"$FUNCNAME 1 1 filename.cmd administrator passadmin 0"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 6 u 8 parámetros.
|
||||
[ $# == 6 -o $# == 8 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
|
||||
# Punto de montaje.
|
||||
MOUNTPOINT="$(ogGetPath "$1" "$2" /)"
|
||||
# Comprobar que existe el directorio del fichero de comandos.
|
||||
for i in winnt windows; do
|
||||
DIR=$(ogGetPath $MOUNTPOINT/$i/system32)
|
||||
[ -n "$DIR" ] && CMDDIR=$DIR
|
||||
done
|
||||
[ -n "$CMDDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$MOUNTPOINT/Windows/System32" || return $?
|
||||
CMDFILE="$CMDDIR/$3"
|
||||
|
||||
if [ $6 == 0 ]; then
|
||||
# Si no queremos hacer autologin despues de la postconfiguracion lo indicamos en las claves de registro
|
||||
cat > "$CMDFILE" << EOF
|
||||
DEL C:\ogboot.*
|
||||
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 0 /f
|
||||
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d "" /f
|
||||
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /f
|
||||
EOF
|
||||
else
|
||||
# Si queremos hacer autologin despues de la postconfiguracion introducimos la informacion en las claves de registro
|
||||
cat > "$CMDFILE" << EOF
|
||||
DEL C:\ogboot.*
|
||||
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v AutoAdminLogon /t REG_SZ /d 1 /f
|
||||
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultUserName /t REG_SZ /d "$7" /f
|
||||
REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v DefaultPassword /t REG_SZ /d "$8" /f
|
||||
EOF
|
||||
fi
|
||||
#Creamos las claves de registro necesarias para que meter el cmd en el runonce del usuario y este haga autologin
|
||||
ogAddRegistryValue $MOUNTPOINT software '\Microsoft\Windows\CurrentVersion\RunOnce\PostConfiguracion' 2>/dev/null
|
||||
ogSetRegistryValue $MOUNTPOINT software '\Microsoft\Windows\CurrentVersion\RunOnce\PostConfiguracion' "C:\windows\system32\\$3" 2>/dev/null
|
||||
ogAddRegistryValue $MOUNTPOINT software '\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon' 2>/dev/null
|
||||
ogSetRegistryValue $MOUNTPOINT software '\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoAdminLogon' 1 2>/dev/null
|
||||
ogAddRegistryValue $MOUNTPOINT software '\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName' 2>/dev/null
|
||||
ogSetRegistryValue $MOUNTPOINT software '\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName' "$4" 2>/dev/null
|
||||
ogAddRegistryValue $MOUNTPOINT software '\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName' 2>/dev/null
|
||||
ogSetRegistryValue $MOUNTPOINT software '\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName' ".\\" 2>/dev/null
|
||||
ogAddRegistryValue $MOUNTPOINT software '\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword' 2>/dev/null
|
||||
ogSetRegistryValue $MOUNTPOINT software '\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultPassword' "$5" 2>/dev/null
|
||||
ogDeleteRegistryValue $MOUNTPOINT software '\Microsoft\Windows NT\CurrentVersion\Winlogon\ForceAutoLockOnLogon' 2>/dev/null
|
||||
ogDeleteRegistryValue $MOUNTPOINT software '\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoLogonCount' 2>/dev/null
|
||||
}
|
||||
|
||||
#/**
|
||||
# ogAddCmd int_ndisk int_npartition str_filename str_commands
|
||||
#@brief Añade comandos al cmd creado por ogInstalMiniSetup
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@param str_filename nombre del fichero cmd (siempre se guardara en windows\system32\para que sea visible por el sistema
|
||||
#@param str_commands comando o comandos que se añadiran al fichero
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#@version 1.0.2 - Nueva función
|
||||
#@author Jonathan Alonso Martinez - Universidad Autonoma de Barcelona
|
||||
#@date 2011-06-29
|
||||
#@version 1.0.4 - Cambios en los parametros de entrada de la funcion
|
||||
#@author Jonathan Alonso Martinez - Universidad Autonoma de Barcelona
|
||||
#@date 2012-04-16
|
||||
#*/ ##
|
||||
function ogAddCmd ()
|
||||
{
|
||||
local MOUNTPOINT CMDFILE
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_npartition str_filename str_commands" \
|
||||
"$FUNCNAME 1 1 filename.cmd command"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 4 parámetros.
|
||||
[ $# == 4 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
|
||||
# Punto de montaje
|
||||
MOUNTPOINT="$(ogMount "$1" "$2")" || return $?
|
||||
# Crear fichero de comandos, si no existe.
|
||||
CMDFILE="$(ogGetPath "$MOUNTPOINT/windows/system32")/$3"
|
||||
[ -n "$CMDFILE" ] || ogInstallMiniSetup "$1" "$2" "$3"
|
||||
[ -n "$CMDFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$MOUNTPOINT/windows/system32/$3" || return $?
|
||||
|
||||
# Concatenamos el comando en el fichero de comandos
|
||||
cat >> "$CMDFILE" << EOF
|
||||
$4
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogDomainScript int_ndisk int_npartition str_domain str_user str_password
|
||||
#@brief Crea un script .vbs para unir al dominio una maquina windows y el comando adequado en el archivo cmd creado por ogInstallMiniSetup
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@param str_filename nombre del fichero cmd donde deberemos introducir el comando de ejecutar el script vbs
|
||||
#@param str_domain dominio donde se quiere conectar
|
||||
#@param str_user usuario con privilegios para unir al dominio
|
||||
#@param str_password password del usuario con privilegios
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@version 1.0.2 - Nueva función
|
||||
#@author Jonathan Alonso Martinez - Universidad Autonoma de Barcelona
|
||||
#@date 2011-06-29
|
||||
#@version 1.0.4 - Cambios en los parametros de entrada de la funcion
|
||||
#@author Jonathan Alonso Martinez - Universidad Autonoma de Barcelona
|
||||
#@date 2012-04-16
|
||||
#*/ ##
|
||||
function ogDomainScript ()
|
||||
{
|
||||
local CMDDIR
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" \
|
||||
"$FUNCNAME int_ndisk int_npartition str_filename str_domain str_user str_password" \
|
||||
"$FUNCNAME 1 1 filename.cmd domain user password_user"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 6 parámetros.
|
||||
[ $# == 6 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
|
||||
# Punto de montaje
|
||||
MOUNTPOINT="$(ogMount "$1" "$2")" || return $?
|
||||
# Comprobar que existe el directorio de comandos.
|
||||
CMDDIR=$(ogGetPath "$MOUNTPOINT/windows/system32")
|
||||
[ -n "$CMDDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$1/windows/system32" || return $?
|
||||
|
||||
# Añadimos en el cmd que se ejecutara al arranque, el comando de ejecutar el script que añade al dominio.
|
||||
ogAddCmd $1 $2 "$3" "CSCRIPT joindomain.vbs"
|
||||
# Eliminamos el script porque tiene el usuario de administrador de dominio en claro
|
||||
ogAddCmd $1 $2 "$3" "DEL /Q C:\Windows\System32\joindomain.vbs"
|
||||
# Metemos unas claves de registro para que el dominio salga seleccionado por defecto
|
||||
ogAddCmd $1 $2 "$3" "REG ADD \"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\" /v DefaultDomainName /t REG_SZ /d \"$4\" /f"
|
||||
|
||||
# Creamos el archivo joindomain.vbs que nos introduce la maquina en el dominio
|
||||
cat > "$CMDDIR/joindomain.vbs" << EOF
|
||||
Const JOIN_DOMAIN = 1
|
||||
Const ACCT_CREATE = 2
|
||||
Const ACCT_DELETE = 4
|
||||
Const WIN9X_UPGRADE = 16
|
||||
Const DOMAIN_JOIN_IF_JOINED = 32
|
||||
Const JOIN_UNSECURE = 64
|
||||
Const MACHINE_PASSWORD_PASSED = 128
|
||||
Const DEFERRED_SPN_SET = 256
|
||||
Const INSTALL_INVOCATION = 262144
|
||||
|
||||
strDomain = "$4"
|
||||
strUser = "$5"
|
||||
strPassword = "$6"
|
||||
|
||||
Set objNetwork = CreateObject("WScript.Network")
|
||||
strComputer = objNetwork.ComputerName
|
||||
|
||||
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\\" & _
|
||||
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
|
||||
|
||||
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, _
|
||||
strDomain & "\" & strUser, NULL, JOIN_DOMAIN + ACCT_CREATE)
|
||||
EOF
|
||||
|
||||
#*/ " (comentario Doxygen)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
### PRUEBAS.
|
||||
|
||||
#/**
|
||||
# ogConfigureOgagent int_ndisk int_filesys
|
||||
#@brief Modifica el fichero de configuración del nuevo agente OGAent para sistemas operativos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_filesys nº de orden del sistema de archivos
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero o dispositivo no encontrado.
|
||||
#@exception OG_ERR_LOCKED Sistema de archivos bloqueado.
|
||||
#@version 1.1.0 - Primera adaptación para OpenGnsys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2016-07-15
|
||||
#*/ ##
|
||||
function ogConfigureOgagent ()
|
||||
{
|
||||
# Variables locales.
|
||||
local MNTDIR AGENTDIR CFGFILE
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_filesys" \
|
||||
"$FUNCNAME 1 1"
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se reciben 2 parámetros.
|
||||
[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
# Obtener sistema de archvios.
|
||||
MNTDIR=$(ogMount $1 $2) || return $?
|
||||
|
||||
# Comprobar si existe el fichero de configuración de OGAgent.
|
||||
for AGENTDIR in usr/share/OGAgent "Program Files/OGAgent" "Program Files (x86)/OGAgent" Applications/OGAgent.app; do
|
||||
CFGFILE=$(ogGetPath "$MNTDIR/$AGENTDIR/cfg/ogagent.cfg")
|
||||
[ -n "$CFGFILE" ] && break
|
||||
done
|
||||
[ -n "$CFGFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "ogagent.cfg" || return $?
|
||||
# Parchear dirección del servidor OpenGnsys en el fichero de configuración de OGAgent.
|
||||
sed -i "0,/remote=/ s,remote=.*,remote=https://$(ogGetServerIp):8443/opengnsys/rest/," "$CFGFILE"
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogInstallLaunchDaemon int_ndisk int_nfilesys str_filename
|
||||
#@brief Instala archivo que se ejecutará en el arranque de macOS.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@param str_filename nombre del script
|
||||
#return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero o directorio no encontrado.
|
||||
#@npte Crea ficheros de configuración /Library/LaunchDaemon/es.opengnsys.Script.plist.
|
||||
#@version 1.0.6 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2014-10-06
|
||||
#*/ ##
|
||||
function ogInstallLaunchDaemon ()
|
||||
{
|
||||
# Variables locales.
|
||||
local LAUNCHDIR SCRIPTDIR
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_filesys str_scriptname" \
|
||||
"$FUNCNAME 1 2 postconf"
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se reciben 3 parámetros.
|
||||
[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
# Comprobar directorios.
|
||||
LAUNCHDIR=$(ogGetPath $1 $2 /Library/LaunchDaemons)
|
||||
[ -n "$LAUNCHDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 /Library/LaunchDaemons" || return $?
|
||||
SCRIPTDIR=$(ogGetPath $1 $2 /usr/share)
|
||||
[ -n "$SCRIPTDIR" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 /usr/share" || return $?
|
||||
|
||||
# Crear fichero de configuración del servicio de arranque.
|
||||
cat << EOT $LAUNCHDIR/es.opengnsys.$3.plist
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>es.opengnsys.$3</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>$SCRIPTDIR/$3.sh</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
<key>StandardOutPath</key>
|
||||
<string>/var/log/$3.log</string>
|
||||
<key>StandardErrorPath</key>
|
||||
<string>/var/log/$3.err</string>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
EOT
|
||||
|
||||
# Crear un fichero de script vacío.
|
||||
rm -f $SCRIPTDIR/$3.sh
|
||||
touch $SCRIPTDIR/$3.sh
|
||||
chmod +x $SCRIPTDIR/$3.sh
|
||||
}
|
||||
|
||||
|
||||
### PRUEBAS.
|
||||
|
||||
#/**
|
||||
# ogAddToLaunchDaemon int_ndisk int_nfilesys str_filename str_commands
|
||||
#@brief Añade comandos al script creado por ogInstalLaunchDaemon.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@param str_filename nombre del script (siempre se guardará en /usr/share para que sea visible por el sistema
|
||||
#@param str_commands comando o comandos que se añadiran al fichero
|
||||
#return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero o directorio no encontrado.
|
||||
#@version 1.0.6 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2014-10-06
|
||||
#*/ ##
|
||||
function ogAddToLaunchDaemon ()
|
||||
{
|
||||
# Variables locales.
|
||||
local SCRIPTFILE
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_filesys str_scriptname" \
|
||||
"$FUNCNAME 1 2 postconf \"diskutil enableJournal disk0s2\""
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se reciben 4 parámetros.
|
||||
[ $# == 4 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
# Comprobar que existe el fichero de comandos.
|
||||
SCRIPTFILE=$(ogGetPath $1 $2 "/usr/share/$3.sh")
|
||||
[ -n "$SCRIPTFILE" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2 /usr/share/$3" || return $?
|
||||
|
||||
# Concatenamos el comando en el fichero de comandos
|
||||
cat >> "$SCRIPTFILE" << EOT
|
||||
$4
|
||||
EOT
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogUninstallLinuxClient int_ndisk int_filesys
|
||||
#@brief Desinstala el cliente OpenGnSys para sistemas operativos GNU/Linux.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_filesys nº de orden del sistema de archivos
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Paritición o sistema de archivos incorrectos.
|
||||
#@exception OG_ERR_LOCKED Sistema de archivos bloqueado.
|
||||
#@version 1.1.0 - Primera adaptación para OpenGnsys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2016-08-22
|
||||
#*/ ##
|
||||
function ogUninstallLinuxClient ()
|
||||
{
|
||||
# Variables locales.
|
||||
local MNTDIR
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_filesys" \
|
||||
"$FUNCNAME 1 1"
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se reciben 2 parámetros.
|
||||
[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
# Obtener sistema de archvios.
|
||||
MNTDIR=$(ogMount $1 $2) || return $?
|
||||
|
||||
# Borrar ficheros y quitar llamada al cliente durante el proceso de inicio.
|
||||
rm -f $MNTDIR/{usr/sbin,sbin,usr/local/sbin}/ogAdmLnxClient
|
||||
rm -f $MNTDIR/{etc,usr/local/etc}/ogAdmLnxClient.cfg
|
||||
sed -i -e '/ogAdmLnxClient/ d' $MNTDIR/{etc,usr/local/etc}/{rc.local,rc.d/rc.local} 2>/dev/null
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogUninstallWindowsClient int_ndisk int_filesys str_filename
|
||||
#@brief Desinstala el cliente OpenGnSys para sistemas operativos Windows.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@param str_filename nombre del fichero cmd donde deberemos introducir el comando de ejecutar el script vbs
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Paritición o sistema de archivos incorrectos.
|
||||
#@exception OG_ERR_LOCKED Sistema de archivos bloqueado.
|
||||
#@version 1.1.0 - Primera adaptación para OpenGnsys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2016-08-22
|
||||
#*/ ##
|
||||
|
||||
function ogUninstallWindowsClient ()
|
||||
{
|
||||
# Variables locales.
|
||||
local MNTDIR
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_filesys str_filename" \
|
||||
"$FUNCNAME 1 1 filename.cmd"
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se reciben 3 parámetros.
|
||||
[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
# Obtener sistema de archvios.
|
||||
MNTDIR=$(ogMount "$1" "$2") || return $?
|
||||
|
||||
# Crear órdenes para desinstalar servicio y borrar ejecutable del cliente.
|
||||
if [ -n "$(ogGetPath $MNTDIR/windows/ogAdmWinClient.exe)" -o -n "$(ogGetPath $MNTDIR/winnt/ogAdmWinClient.exe)" ]; then
|
||||
ogAddCmd $1 $2 "$3" 'ogAdmWinClient -remove'
|
||||
ogAddCmd $1 $2 "$3" 'DEL C:\Windows\ogAdmWinClient.exe'
|
||||
ogAddCmd $1 $2 "$3" 'DEL C:\Winnt\ogAdmWinClient.exe'
|
||||
fi
|
||||
}
|
||||
|
|
@ -1,699 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# ogLoadHiveWindows int_ndisk int_partiton
|
||||
#@brief Localiza los hive del registro de windows (de sistema y usuarios)
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_partition nº de particion
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#@version 0.9 - Adaptación a OpenGNSys.
|
||||
#@author Antonio J. Doblas Viso. Universidad de Málaga
|
||||
#@date 2009-09-24
|
||||
#*/ ##
|
||||
|
||||
|
||||
function ogLoadHiveWindows () {
|
||||
# Variables locales.
|
||||
local PART DISK
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition" \
|
||||
"$FUNCNAME 1 1 "
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se reciben 2 parámetros.
|
||||
[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
|
||||
|
||||
DISK=$1; PART=$2;
|
||||
|
||||
#Comprobaciones redundantes: borrar"
|
||||
#ogDiskToDev $DISK $PART || return $(ogRaiseError $OG_ERR_PARTITION "particion de windows no detectada"; echo $?)
|
||||
#ogGetOsType $DISK $PART | grep "Windows" || return $(ogRaiseError $OG_ERR_NOTOS "no es windows"; echo $?)
|
||||
#VERSION=$(ogGetOsVersion $DISK $PART)
|
||||
#Fin Comprobaciones redundantes: borrar"
|
||||
|
||||
|
||||
# primera fase, carga de los hive del sistema
|
||||
if ogGetPath $DISK $PART WINDOWS
|
||||
then
|
||||
SYSTEMROOT="Windows"
|
||||
elif ogGetPath $DISK $PART WINNT
|
||||
then
|
||||
SYSTEMROOT="winnt"
|
||||
else
|
||||
return $(ogRaiseError $OG_ERR_NOTOS "version windows no detectada"; echo $?)
|
||||
fi
|
||||
|
||||
hiveSAM=$(ogGetPath $DISK $PART /${SYSTEMROOT}/system32/config/SAM)
|
||||
[ -n "$hiveSAM" ] && export hiveSAM || return $(ogRaiseError $OG_ERR_NOTOS " hive SAM no detectada"; echo $?)
|
||||
hiveSYSTEM=$(ogGetPath $DISK $PART /${SYSTEMROOT}/system32/config/system)
|
||||
[ -n "$hiveSYSTEM" ] && export hiveSYSTEM || return $(ogRaiseError $OG_ERR_NOTOS "hive SYSTEM no detectada"; echo $?)
|
||||
hiveSOFTWARE=$(ogGetPath $DISK $PART /${SYSTEMROOT}/system32/config/software)
|
||||
[ -n "$hiveSOFTWARE" ] && export hiveSOFTWARE || return $(ogRaiseError $OG_ERR_NOTOS "hive SOFTWARE no detectada"; echo $?)
|
||||
export TEMPhive=/tmp/tmpregistry
|
||||
|
||||
# segunda fase, carga de los hive de usuarios windows.
|
||||
declare -i COUNT
|
||||
COUNT=3
|
||||
#TODO WINDOWS XP WINDOWS7
|
||||
BASEHOMEDIR=$(ogGetPath $DISK $PART /"Documents and Settings")
|
||||
TMPUSERFILE="/tmp/WuserRegAndDAT.tmp"
|
||||
find "$BASEHOMEDIR/" -type f -name NTUSER.DAT > $TMPUSERFILE
|
||||
LISTUSERS=$(drbl-chntpw -l $hiveSAM | grep RID | awk -F"<" '{print $2}' | awk -F">" '{print $1}')
|
||||
#echo "$BASEHOMEDIR" $LISTUSERS
|
||||
for user in $LISTUSERS
|
||||
do
|
||||
# Comprobamos que el usuario registrado tiene .DAT
|
||||
if HOMEDIR=$(cat $TMPUSERFILE | grep -w $user)
|
||||
then
|
||||
#echo "$user exportamos los usuarios de windows como variables, y como valor hiveUSERX; donde la X es 3 4 5 6 ... X"
|
||||
export `echo $user=hiveUSER$COUNT`
|
||||
#echo "$user exportamos la variable hiveUSERX con el valor del home de la variable-usuario_windows"
|
||||
##export `echo hiveUSER$COUNT`="$(echo $HOMEDIR | sed -e 's/ /\\ /'g | sed -e 's/\\/\\\\/g')"
|
||||
export `echo hiveUSER$COUNT`="$(echo $HOMEDIR)"
|
||||
#echo " estas variables \$USUARIO -> Identificador del HIVE ; \${!USUARIO} -> path del HIVE "
|
||||
COUNT=${COUNT}+1
|
||||
fi
|
||||
|
||||
done
|
||||
COUNT=0
|
||||
}
|
||||
|
||||
|
||||
# ogUpdateHiveWindows
|
||||
#@brief Actualiza los hive de windows.
|
||||
#@param int_ndisk
|
||||
#@param int_partition
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#@version 0.9 - Adaptación a OpenGNSys.
|
||||
#@author Antonio J. Doblas Viso. Universidad de Málaga
|
||||
#@date 2009-09-24
|
||||
#*/ ##
|
||||
|
||||
|
||||
function ogUpdateHiveWindows (){
|
||||
# Variables locales.
|
||||
local PART DISK FILE
|
||||
|
||||
#TODO detectar llamada a ogLoadHiveWindows
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME " \
|
||||
"$FUNCNAME "
|
||||
return
|
||||
fi
|
||||
|
||||
echo drbl-chntpw -f $TEMPhive $hiveSAM $hiveSYSTEM $hiveSOFTWARE \"${hiveUSER3}\" \"${hiveUSER4}\" \"${hiveUSER5}\" \"${hiveUSER6}\" \"${hiveUSER7}\" \"${hiveUSER8}\" \"${hiveUSER9}\" > /tmp/run.sh
|
||||
cat /tmp/run.sh; sh /tmp/run.sh; rm -fr $TEMPhive; rm /tmp/run.sh
|
||||
|
||||
unset hiveSAM hiveSYSTEM hiveSOFTWARE TEMPhive hiveUSER3 hiveUSER4 hiveUSER5 hiveUSER6 hiveUSER7 hiveUSER8 hiveUSER9
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function ogHiveNTRunMachine () {
|
||||
#echo sintaxis: PathScripts idScripts
|
||||
#echo ejemplo: c:\\\\WINDOSWS\\\\crearusuarios.bat scripts1
|
||||
#echo IMPORTANTE: el path debe llevar dos barras \\, pero como se deben 'escapar' debes poner cuatro \\\\
|
||||
#echo "identifica 0=$hiveSAM 1=$hiveSystem 2=$hiveSoftware 3=$HiveUser3"
|
||||
|
||||
local PART DISK FILE
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME PathScripts|command keyName " \
|
||||
"$FUNCNAME c:\\\\Windows\\\\crearusuarios.cmd scripts_crearUsuarios "\
|
||||
"$FUNCNAME "cmd /c del c:\ogboot.*" ogcleanboot "\
|
||||
"$FUNCNAME Requiere la previa ejecución de ogLoadHive int_disk int_part"\
|
||||
"$FUNCNAME Despues requiere el ogUpdateHive"
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
# Error si no se reciben al menos 1 parámetros.
|
||||
[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
|
||||
|
||||
|
||||
cat >> $TEMPhive << EOF
|
||||
h 2
|
||||
cd \Microsoft\Windows\CurrentVersion\Run
|
||||
nv 1 $2
|
||||
ed $2
|
||||
$1
|
||||
EOF
|
||||
#ogGetRegistryValue /mnt/sda1 software '\Microsoft\Windows\CurrentVersion\Run\og3'
|
||||
}
|
||||
|
||||
function ogNTPolUserOn () {
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME id_hive_user " \
|
||||
"$FUNCNAME NombreUsuario"\
|
||||
"$FUNCNAME "
|
||||
return
|
||||
fi
|
||||
|
||||
# TODO: error si no se ha llamado previamente a ogLoadHiveWindows
|
||||
[ -n $hiveSAM ] || return $(ogRaiseError $OG_ERR_FORMAT "se debe utilizar primero la utilidad ogLoadHiveWindows"; echo $?)
|
||||
|
||||
# TODO: error si el usuario no tiene cuenta en windows.
|
||||
drbl-chntpw -l $hiveSAM | grep RID | grep -w $1 || return $(ogRaiseError $OG_ERR_FORMAT "el usuario $1 no tiene cuenta en este windows: Compruebe mayusculas o minusculas"; echo $?)
|
||||
|
||||
# TODO: error si no el usario no no tiene HIVE asociado.
|
||||
[ -n "${!1}" ] || return $(ogRaiseError $OG_ERR_FORMAT "el usuario no tiene hive creado"; echo $?)
|
||||
|
||||
|
||||
HIVEID=$(echo ${!1} | tr -d "hiveUSER")
|
||||
|
||||
|
||||
#echo "IMPORTANTE: la variable HiveUser3=/mnt/windows/Document/\ and/\ Seeting\alumnmos\NTUSER.dat"
|
||||
echo $HIVEID
|
||||
#cp /var/EAC/admin/utilswin/Fondo.BMP ${particion}/WINDOWS/
|
||||
|
||||
cat >> $TEMPhive << EOF
|
||||
h $HIVEID
|
||||
cd \Control Panel\Desktop
|
||||
ed Wallpaper
|
||||
C:\\WINDOWS\\fondo.bmp
|
||||
|
||||
cd \Software\Microsoft\Windows\CurrentVersion\Policies
|
||||
nk Explorer
|
||||
cd Explorer
|
||||
|
||||
nv 4 NoDesktop
|
||||
ed NoDesktop
|
||||
1
|
||||
|
||||
nv 4 NoSimpleStartMenu
|
||||
ed NoSimpleStartMenu
|
||||
1
|
||||
nv 4 NoWindowsUpdate
|
||||
ed NoWindowsUpdate
|
||||
1
|
||||
|
||||
nv 4 NoSMConfigurePrograms
|
||||
ed NoSMConfigurePrograms
|
||||
1
|
||||
|
||||
nv 4 NoChangeStartMenu
|
||||
ed NoChangeStartMenu
|
||||
1
|
||||
|
||||
nv 4 Intellimenus
|
||||
ed Intellimenus
|
||||
1
|
||||
|
||||
nv 4 NoRun
|
||||
ed NoRun
|
||||
1
|
||||
|
||||
nv 4 NoRecentDocsHistory
|
||||
ed NoRecentDocsHistory
|
||||
1
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##########################################################
|
||||
##########################################################
|
||||
#####librerias de PostConfiguracion v0.1para Advanced Deploy enViorenment###########
|
||||
# Liberado bajo licencia GPL <http://www.gnu.org/licenses/gpl.html>################
|
||||
############# 2008 Antonio Jes<65>s Doblas Viso adv@uma.es ##########################
|
||||
########### Universidad de Malaga (Spain)############################
|
||||
##########################################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function NTChangeName () {
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
echo sintaxis: NTChangeNAME str_$var
|
||||
echo ejemplos: NTCHangeName adi${IPcuatro}-xp
|
||||
fi
|
||||
cat >> $temporal << EOF
|
||||
h 1
|
||||
ed ControlSet001\Control\ComputerName\ComputerName\ComputerName
|
||||
$1
|
||||
ed ControlSet001\Services\Tcpip\Parameters\Hostname
|
||||
$1
|
||||
ed ControlSet001\Services\Tcpip\Parameters\NV Hostname
|
||||
$1
|
||||
h 2
|
||||
cd \Microsoft\Windows NT\CurrentVersion\Winlogon
|
||||
ed DefaultDomainName
|
||||
$1
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
|
||||
function NTSetGroupName () {
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
echo sintaxis: NTSetGroupName str_$var
|
||||
echo ejemplos: NTSetGroupName adi
|
||||
fi
|
||||
cat >> $temporal << EOF
|
||||
h 2
|
||||
ed \Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultDomainName
|
||||
$1
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
function NTSetOwner (){
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
echo sintaxis: NtSetOwner str_propietario str_organizacion
|
||||
echo ejemplos: NTSetOwner eu\ politecnica universidad\ de\ malaga
|
||||
fi
|
||||
cat >> $temporal << EOF
|
||||
h 2
|
||||
ed \Microsoft\Windows NT\CurrentVersion\RegisteredOwner
|
||||
$1
|
||||
ed \Microsoft\Windows NT\CurrentVersion\RegisteredOrganization
|
||||
$2
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
function NTAutoLogon (){
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
echo sintaxis: Int_Activar Int_nves str_usuario str_passwd str_equipo
|
||||
echo ejemplos: 1 2 administrador 3451 $equipo
|
||||
echo IMPORTANTE: cuando AutoLogonCount llegue a 0, activa el AutoAdminLogon a 0. Pero no borra los valores de DefaultPassword
|
||||
return 2
|
||||
fi
|
||||
#echo la pass es $4
|
||||
export temporal=/tmp/tmpregistry
|
||||
cat >> $temporal << EOF
|
||||
hive 2
|
||||
cd \Microsoft\Windows NT\CurrentVersion\Winlogon
|
||||
nv 1 AutoAdminLogon
|
||||
ed AutoAdminLogon
|
||||
$1
|
||||
nv 1 AutoLogonCount
|
||||
ed AutoLogonCount
|
||||
$2
|
||||
nv 1 DefaultUserName
|
||||
ed DefaultUserName
|
||||
$3
|
||||
nv 1 DefaultDomainName
|
||||
ed DefaultDomainName
|
||||
$5
|
||||
EOF
|
||||
if [ "$4" == none ]
|
||||
then
|
||||
echo "debe aparecer done" $4
|
||||
cat >> $temporal << EOF
|
||||
dv DefaultPassword
|
||||
|
||||
|
||||
EOF
|
||||
else
|
||||
cat >> $temporal << EOF
|
||||
nv 1 DefaultPassword
|
||||
ed DefaultPassword
|
||||
$4
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
function NTStatusRatonTeclado (){
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
echo sintaxis: Int-StatusRaton Int-StatusTeclado
|
||||
echo ejemplos: int=1 activo int=4 desactivado
|
||||
return 2
|
||||
fi
|
||||
cat >> $temporal << EOF
|
||||
hive 1
|
||||
cd \ControlSet001\Services\Mouclass
|
||||
ed Start
|
||||
$1
|
||||
cd \ControlSet001\Services\Kbdclass
|
||||
ed Start
|
||||
$2
|
||||
EOF
|
||||
}
|
||||
|
||||
function NTRunOnceMachine () {
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
echo sintaxis: PathScripts idScripts
|
||||
echo "ejemplo: c:\\\\WINDOSWS\\\\crearusuarios.bat scripts1"
|
||||
echo "IMPORTANTE: el path debe llevar dos barras \\, pero como se deben 'escapar' debes poner cuatro \\\\"
|
||||
return 2
|
||||
fi
|
||||
export temporal=/tmp/tmpregistry
|
||||
cat >> $temporal << EOF
|
||||
h 2
|
||||
cd \Microsoft\Windows\CurrentVersion\RunOnce
|
||||
nv 1 $2
|
||||
ed $2
|
||||
$1
|
||||
EOF
|
||||
}
|
||||
|
||||
function NTRunMachine () {
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
echo sintaxis: PathScripts idScripts
|
||||
echo ejemplo: c:\\\\WINDOSWS\\\\crearusuarios.bat scripts1
|
||||
echo IMPORTANTE: el path debe llevar dos barras \\, pero como se deben 'escapar' debes poner cuatro \\\\
|
||||
return 2
|
||||
fi
|
||||
export temporal=/tmp/tmpregistry
|
||||
cat >> $temporal << EOF
|
||||
h 2
|
||||
cd \Microsoft\Windows\CurrentVersion\Run
|
||||
nv 1 $2
|
||||
ed $2
|
||||
$1
|
||||
EOF
|
||||
}
|
||||
|
||||
function NTRunUser () {
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
echo sintaxis: str_PathWINScripts str_idScripts Int_hive||\$usuario
|
||||
echo ejemplo: c:\\\\WINDOSWS\\\\crearusuarios.bat scripts1 3
|
||||
echo IMPORTANTE: el pathWIN debe llevar dos barras \\, pero como se deben 'escapar' debes poner cuatro \\\\
|
||||
echo IMPORTANTE: el pathLinux si lleva espacios debe escaparse con una barra \\
|
||||
echo IMPORTANTE Int_hive: 3 para el primer usuario, 4 para el segundo usuario
|
||||
echo requiere export un HiveUser3=/mnt/windows/Document\ and\ Seeting\alumnmos\NTUSER.dat
|
||||
return 2
|
||||
fi
|
||||
cat >> $temporal << EOF
|
||||
h $3
|
||||
cd \Software\Microsoft\Windows\CurrentVersion\Run
|
||||
nv 1 $2
|
||||
ed $2
|
||||
$1
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
|
||||
function NTPolUserOn () {
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
Msg "requiere LoadRegistryUser str_user1 str_user2..." orange
|
||||
echo "sintaxis: Int_hive"
|
||||
echo "ejemplo: NTPolUserOn 3"
|
||||
echo "IMPORTANTE: la variable HiveUser3=/mnt/windows/Document/\ and/\ Seeting\alumnmos\NTUSER.dat"
|
||||
return 2
|
||||
fi
|
||||
cp /var/EAC/admin/utilswin/Fondo.BMP ${particion}/WINDOWS/
|
||||
cat >> $temporal << EOF
|
||||
h $1
|
||||
cd \Control Panel\Desktop
|
||||
ed Wallpaper
|
||||
C:\\WINDOWS\\fondo.bmp
|
||||
|
||||
cd \Software\Microsoft\Windows\CurrentVersion\Policies
|
||||
nk Explorer
|
||||
cd Explorer
|
||||
|
||||
nv 4 NoDesktop
|
||||
ed NoDesktop
|
||||
1
|
||||
|
||||
nv 4 NoSimpleStartMenu
|
||||
ed NoSimpleStartMenu
|
||||
1
|
||||
nv 4 NoWindowsUpdate
|
||||
ed NoWindowsUpdate
|
||||
1
|
||||
|
||||
nv 4 NoSMConfigurePrograms
|
||||
ed NoSMConfigurePrograms
|
||||
1
|
||||
|
||||
nv 4 NoChangeStartMenu
|
||||
ed NoChangeStartMenu
|
||||
1
|
||||
|
||||
nv 4 Intellimenus
|
||||
ed Intellimenus
|
||||
1
|
||||
|
||||
nv 4 NoRun
|
||||
ed NoRun
|
||||
1
|
||||
|
||||
nv 4 NoRecentDocsHistory
|
||||
ed NoRecentDocsHistory
|
||||
1
|
||||
EOF
|
||||
}
|
||||
|
||||
function NTPolUserOFF () {
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
Msg "requiere LoadRegistryUser str_user1 str_user2..." orange
|
||||
echo "sintaxis: Int_hive"
|
||||
echo "ejemplo: NTPolUserOFF 3"
|
||||
echo "IMPORTANTE: la variable HiveUser3=/mnt/windows/Document/\ and/\ Seeting\alumnmos\NTUSER.dat"
|
||||
return 2
|
||||
fi
|
||||
cat >> $temporal << EOF
|
||||
h $1
|
||||
cd \Control Panel\Desktop
|
||||
ed Wallpaper
|
||||
C:\\WINDOWS\\web\\wallpaper\\Felicidad.bmp
|
||||
|
||||
cd \Software\Microsoft\Windows\CurrentVersion\
|
||||
rdel Policies
|
||||
nk Policies
|
||||
1
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
function ogSetWindowsChkdisk() {
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
echo sintaxis: true|TRUE|0 false|false|1
|
||||
echo ejemplos: int=0 desactivado int=1 activado
|
||||
return 2
|
||||
fi
|
||||
case $1 in
|
||||
0|true|TRUE)
|
||||
valor="autocheck autochk *";;
|
||||
1|false|FALSE)
|
||||
valor="none";;
|
||||
*)
|
||||
return 0 ;;
|
||||
esac
|
||||
|
||||
cat >> $TEMPhive << EOF
|
||||
hive 1
|
||||
cd \ControlSet001\Control\Session Manager
|
||||
ed BootExecute
|
||||
$valor
|
||||
--n
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
|
||||
### FASE DE PRUEBAS NO FUNCIONA
|
||||
function NTStartRecovery () {
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
echo sintaxis: Int-Status
|
||||
echo ejemplos: int=0 desactivado int=1 activado
|
||||
return 2
|
||||
fi
|
||||
|
||||
[ $1 = 0 ] && valor="none"
|
||||
[ $1 = 1 ] && valor="00000000"
|
||||
|
||||
|
||||
cat >> $TEMPhive << EOF
|
||||
hive 2
|
||||
#cd \Policies\Microsoft\Windows\WinRE
|
||||
#ed DisableSetup
|
||||
cd \Policies\Microsoft\Windows
|
||||
nk WinRE
|
||||
nv 4 DisableSetup
|
||||
ed DisableSetup
|
||||
$valor
|
||||
--n
|
||||
EOF
|
||||
|
||||
|
||||
#Activado
|
||||
#[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WinRE]
|
||||
#"DisableSetup"=-
|
||||
|
||||
# Desactivado
|
||||
#[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WinRE]
|
||||
#"DisableSetup"=dword:00000000
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function ogSchrootLinux () {
|
||||
|
||||
# Variables locales.
|
||||
local PART DISK DIRCONF SCHROOTDEVICE
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_partition" \
|
||||
"$FUNCNAME 1 1 "
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se reciben 2 parámetros.
|
||||
[ $# == 2 ] || return $(ogRaiseError $OG_ERR_FORMAT; echo $?)
|
||||
|
||||
DISK=$1; PART=$2; DIRCONF="/etc/schroot"
|
||||
|
||||
|
||||
VERSION=$(ogGetOsVersion $DISK $PART)
|
||||
echo $VERSION | grep "Linux" || return $(ogRaiseError $OG_ERR_NOTOS "no es linux"; echo $?)
|
||||
|
||||
ogUnmount $DISK $PART || return $(ogRaiseError $OG_ERR_NOTOS "no es linux"; echo $?)
|
||||
|
||||
SCHROOTDEVICE=$(ogDiskToDev $DISK $PART)
|
||||
|
||||
|
||||
rm ${DIRCONF}/mount-defaults
|
||||
rm ${DIRCONF}/schroot.conf
|
||||
|
||||
cat >> ${DIRCONF}/mount-defaults << EOF
|
||||
# <file system> <mount point> <type> <options> <dump> <pass>
|
||||
proc /proc proc defaults 0 0
|
||||
/dev /dev none rw,bind 0 0
|
||||
/dev/pts /dev/pts none rw,bind 0 0
|
||||
/dev/shm /dev/shm none rw,bind 0 0
|
||||
EOF
|
||||
|
||||
|
||||
cat >> ${DIRCONF}/schroot.conf << EOF
|
||||
[linux]
|
||||
description=$VERSION
|
||||
type=block-device
|
||||
device=$SCHROOTDEVICE
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
|
||||
schroot -c linux
|
||||
|
||||
schroot -end-sessiona --all-sessions
|
||||
}
|
||||
|
||||
|
||||
#/** @function ogDiskToRelativeDev: @brief Traduce los ID de discos o particiones EAC a ID Linux relativos, es decir 1 1 => sda1
|
||||
#@param Admite 1 parametro: $1 int_numdisk
|
||||
#@param Admite 2 parametro: $1 int_numdisk $2 int_partition
|
||||
#@return Para 1 parametros traduce Discos Duros: Devuelve la ruta relativa linux del disco duro indicado con nomenclatura EAC.........ejemplo: IdPartition 1 => sda
|
||||
#@return Para 2 parametros traduce Particiones: Devuelve la ruta relativa linux de la particion indicado con nomenclatura EAC........... ejemplo: IdPartition 2 1 => sdb1
|
||||
#@warning No definidas
|
||||
#@attention
|
||||
#@note Notas sin especificar
|
||||
#@version 0.1 - Integracion para Opengnsys - EAC: IdPartition en ATA.lib
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#@date 27/10/2008
|
||||
#*/
|
||||
function ogDiskToRelativeDev () {
|
||||
if [ $# = 0 ]
|
||||
then
|
||||
Msg "Info: Traduce el identificador del dispositivo EAC a dispositivo linux \n" info
|
||||
Msg "Sintaxis1: IdPartition int_disk -----------------Ejemplo1: IdPartition 1 -> sda " example
|
||||
Msg "Sintaxis2: IdPartition int_disk int_partition --Ejemplo2: IdPartition 1 2 -> sda2 " example
|
||||
|
||||
return
|
||||
fi
|
||||
#PART="$(Disk|cut -f$1 -d' ')$2" # se comenta esta linea porque doxygen no reconoce la funcion disk y no crea los enlaces y referencias correctas.
|
||||
PART=$(ogDiskToDev|cut -f$1 -d' ')$2
|
||||
echo $PART | cut -f3 -d \/
|
||||
}
|
||||
|
||||
|
||||
#/** @function ogDeletePartitionsLabels: @brief Elimina la informacion que tiene el kernel del cliente og sobre los labels de los sistemas de archivos
|
||||
#@param No requiere
|
||||
#@return Nada
|
||||
#@warning
|
||||
#@attention Requisitos: comando interno linux rm
|
||||
#@note
|
||||
#@version 0.1 - Integracion para Opengnsys - EAC: DeletePartitionTable() en ATA.lib
|
||||
#@author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#@date 27/10/2008
|
||||
#*/
|
||||
function ogDeletePartitionsLabels () {
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME " \
|
||||
"$FUNCNAME "
|
||||
return
|
||||
fi
|
||||
|
||||
rm /dev/disk/by-label/* # */ COMENTARIO OBLIGATORIO PARA DOXYGEN
|
||||
}
|
||||
|
||||
|
||||
#/** @function ogInfoCache: @brief muestra la informacion de la CACHE.
|
||||
#@param sin parametros
|
||||
#@return texto que se almacena en $IP.-InfoCache. punto_montaje, tama?oTotal, TamanioOcupado, TaminioLibre, imagenes dentro de la cahce
|
||||
#@warning Salidas de errores no determinada
|
||||
#@warning printf no soportado por busybox
|
||||
#@attention
|
||||
#@version 0.1 Date: 27/10/2008 Author Antonio J. Doblas Viso. Universidad de Malaga
|
||||
#*/
|
||||
function ogInfoCache ()
|
||||
{
|
||||
local info infoFilesystem infoSize infoUsed infoUsedPorcet infoMountedOn content
|
||||
if ogMountCache
|
||||
then
|
||||
info=`df -h | grep $OGCAC`
|
||||
infoFilesystem=`echo $info | cut -f1 -d" "`
|
||||
infoSize=`echo $info | cut -f2 -d" "`
|
||||
infoUsed=`echo $info | cut -f3 -d" "`
|
||||
infoAvail=`echo $info | cut -f4 -d" "`
|
||||
infoUsedPorcet=`echo $info | cut -f5 -d" "`
|
||||
infoMountedOn=`echo $info | cut -f2 -d" "`
|
||||
if `ls ${OGCAC}$OGIMG > /dev/null 2>&1`
|
||||
then
|
||||
cd ${OGCAC}${OPENGNSYS}
|
||||
#content=`find images/ -type f -printf "%h/ %f %s \n"` busybox no soporta printf
|
||||
content=`find images/ -type f`
|
||||
cd /
|
||||
echo $info
|
||||
echo -ne $content
|
||||
echo " "
|
||||
#echo "$info" > ${OGLOG}/${IP}-InfoCache
|
||||
#echo "$content" >> {$OGLOG}/${IP}-InfoCache
|
||||
else
|
||||
echo $info
|
||||
#echo "$info" > {$OGLOG}/${IP}-InfoCache
|
||||
fi
|
||||
ogUnmountCache
|
||||
else
|
||||
echo " "
|
||||
#echo " " > {$OGLOG}/${IP}-InfoCache
|
||||
|
||||
fi
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,455 +0,0 @@
|
|||
#!/bin/bash
|
||||
#/**
|
||||
#@file Registry.lib
|
||||
#@brief Librería o clase Registry
|
||||
#@class Boot
|
||||
#@brief Funciones para gestión del registro de Windows.
|
||||
#@version 1.1.0
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
|
||||
# Función ficticia para lanzar chntpw con timeout de 5 s., evitando cuelgues del programa.
|
||||
function chntpw ()
|
||||
{
|
||||
local CHNTPW
|
||||
CHNTPW=$(which drbl-chntpw)
|
||||
CHNTPW=${CHNTPW:-$(which chntpw)}
|
||||
timeout --foreground 5s $CHNTPW -e "$@"
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogAddRegistryKey path_mountpoint str_hive str_keyname
|
||||
#@brief Añade una nueva clave al registro de Windows.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
#@param str_keyname nombre de la clave
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero de registro no encontrado.
|
||||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw
|
||||
#@warning El sistema de archivos de Windows debe estar montada previamente.
|
||||
#@version 1.0.1 - Nueva función
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-05-25
|
||||
#*/ ##
|
||||
function ogAddRegistryKey ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FILE
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" \
|
||||
"$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey'"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 3 parámetros.
|
||||
[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
# Camino del fichero de registro.
|
||||
FILE=$(ogGetHivePath "$1" "$2") || return $?
|
||||
|
||||
# Añadir nueva clave.
|
||||
chntpw "$FILE" << EOT &> /dev/null
|
||||
cd ${3%\\*}
|
||||
nk ${3##*\\}
|
||||
q
|
||||
y
|
||||
EOT
|
||||
}
|
||||
|
||||
#/**
|
||||
# ogAddRegistryValue path_mountpoint str_hive str_valuename [str_valuetype]
|
||||
#@brief Añade un nuevo valor al registro de Windows, indicando su tipo de datos.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
#@param str_valuename nombre del valor
|
||||
#@param str_valuetype tipo de datos del valor (opcional)
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero de registro no encontrado.
|
||||
#@note hive = { DEFAULT, SAM, SECURITY, SOFTWARE, SYSTEM, COMPONENTS }
|
||||
#@note valuetype = { STRING, BINARY, DWORD }, por defecto: STRING
|
||||
#@warning Requisitos: chntpw
|
||||
#@warning El sistema de archivos de Windows debe estar montada previamente.
|
||||
#@version 1.0.1 - Nueva función
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-05-25
|
||||
#*/ ##
|
||||
function ogAddRegistryValue ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FILE TYPE
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename [str_valuetype]" \
|
||||
"$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1'" \
|
||||
"$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1' DWORD"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 3 o 4 parámetros.
|
||||
[ $# == 3 -o $# == 4 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
# Camino del fichero de registro.
|
||||
FILE=$(ogGetHivePath "$1" "$2") || return $?
|
||||
case "${4^^}" in
|
||||
STRING|"") TYPE=1 ;;
|
||||
BINARY) TYPE=3 ;;
|
||||
DWORD) TYPE=4 ;;
|
||||
*) ogRaiseError $OG_ERR_OUTOFLIMIT "$4"
|
||||
return $? ;;
|
||||
esac
|
||||
|
||||
# Devolver el dato del valor de registro.
|
||||
# /* (comentario Doxygen)
|
||||
chntpw "$FILE" << EOT &> /dev/null
|
||||
cd ${3%\\*}
|
||||
nv $TYPE ${3##*\\}
|
||||
q
|
||||
y
|
||||
EOT
|
||||
# (comentario Doxygen) */
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogDeleteRegistryKey path_mountpoint str_hive str_keyname
|
||||
#@brief Elimina una clave del registro de Windows con todo su contenido.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
#@param str_keyname nombre de la clave
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero de registro no encontrado.
|
||||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw
|
||||
#@warning El sistema de archivos de Windows debe estar montada previamente.
|
||||
#@warning La clave debe estar vacía para poder ser borrada.
|
||||
#@version 1.0.1 - Nueva función
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-05-25
|
||||
#*/ ##
|
||||
function ogDeleteRegistryKey ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FILE
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" \
|
||||
"$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey'"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 3 parámetros.
|
||||
[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
# Camino del fichero de registro.
|
||||
FILE=$(ogGetHivePath "$1" "$2") || return $?
|
||||
|
||||
# Añadir nueva clave.
|
||||
chntpw "$FILE" << EOT &> /dev/null
|
||||
cd ${3%\\*}
|
||||
dk ${3##*\\}
|
||||
q
|
||||
y
|
||||
EOT
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogDeleteRegistryValue path_mountpoint str_hive str_valuename
|
||||
#@brief Elimina un valor del registro de Windows.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
#@param str_valuename nombre del valor
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero de registro no encontrado.
|
||||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw
|
||||
#@warning El sistema de archivos de Windows debe estar montada previamente.
|
||||
#@version 1.0.1 - Nueva función
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-05-25
|
||||
#*/ ##
|
||||
function ogDeleteRegistryValue ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FILE
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename" \
|
||||
"$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1'"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 3 parámetros.
|
||||
[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
# Camino del fichero de registro.
|
||||
FILE=$(ogGetHivePath "$1" "$2") || return $?
|
||||
|
||||
# Devolver el dato del valor de registro.
|
||||
# /* (comentario Doxygen)
|
||||
chntpw "$FILE" << EOT &> /dev/null
|
||||
cd ${3%\\*}
|
||||
dv ${3##*\\}
|
||||
q
|
||||
y
|
||||
EOT
|
||||
# (comentario Doxygen) */
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetHivePath path_mountpoint [str_hive|str_user]
|
||||
#@brief Función básica que devuelve el camino del fichero con una sección del registro.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
#@return str_path - camino del fichero de registro
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero de registro no encontrado.
|
||||
#@note hive = { DEFAULT, SAM, SECURITY, SOFTWARE, SYSTEM, COMPONENTS, NombreDeUsuario }
|
||||
#@warning El sistema de archivos de Windows debe estar montada previamente.
|
||||
#@version 1.0.1 - Nueva función
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-05-18
|
||||
#@version 1.1.0 - Soportar registro de un usuario local.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2015-10-14
|
||||
#*/ ##
|
||||
function ogGetHivePath ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FILE HIVE
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint [str_hive|str_user]" \
|
||||
"$FUNCNAME /mnt/sda1 SOFTWARE => /mnt/sda1/WINDOWS/System32/config/SOFTWARE" \
|
||||
"$FUNCNAME /mnt/sda1 user1 => /mnt/sda1/Users/user1/NTUSER.DAT"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 2 parámetros.
|
||||
[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
|
||||
# Camino del fichero de registro de usuario o de sistema (de menor a mayor prioridad).
|
||||
FILE="$(ogGetPath "/$1/Windows/System32/config/$2")"
|
||||
[ -z "$FILE" ] && FILE="$(ogGetPath "/$1/Users/$2/NTUSER.DAT")"
|
||||
[ -z "$FILE" ] && FILE="$(ogGetPath "/$1/winnt/system32/config/$2")"
|
||||
[ -z "$FILE" ] && FILE="$(ogGetPath "/$1/Documents and Settings/$2/NTUSER.DAT")"
|
||||
[ -f "$FILE" ] && echo "$FILE" || ogRaiseError $OG_ERR_NOTFOUND "$1 $2" || return $?
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetRegistryValue path_mountpoint str_hive str_valuename
|
||||
#@brief Devuelve el dato de un valor del registro de Windows.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
#@param str_valuename nombre del valor
|
||||
#@return str_valuedata - datos del valor.
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero de registro no encontrado.
|
||||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw, awk
|
||||
#@warning El sistema de archivos de Windows debe estar montado previamente.
|
||||
#@version 0.9 - Adaptación para OpenGNSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-09-11
|
||||
#@version 1.1.0 - Soportar tipos BINARY (parejas hexadecimales separadas por espacio).
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2015-09-28
|
||||
#*/ ##
|
||||
function ogGetRegistryValue ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FILE
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename" \
|
||||
"$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\NewKey\Value1' ==> 1"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 3 parámetros.
|
||||
[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
# Camino del fichero de registro.
|
||||
FILE=$(ogGetHivePath "$1" "$2") || return $?
|
||||
|
||||
# Devolver el dato del valor de registro.
|
||||
# /* (comentario Doxygen)
|
||||
chntpw "$FILE" << EOT 2> /dev/null | awk '/> Value/ {if (index($0, "REG_BINARY") > 0)
|
||||
{data=""}
|
||||
else
|
||||
{getline; data=$0;} }
|
||||
/^:[0-9A-F]+ / {data=data""substr($0, 9, 48);}
|
||||
END {print data;}'
|
||||
cd ${3%\\*}
|
||||
cat ${3##*\\}
|
||||
q
|
||||
EOT
|
||||
# (comentario Doxygen) */
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogListRegistryKeys path_mountpoint str_hive str_key
|
||||
#@brief Lista los nombres de subclaves de una determinada clave del registro de Windows.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
#@param str_key clave de registro
|
||||
#@return str_subkey ... - lista de subclaves
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero de registro no encontrado.
|
||||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw, awk
|
||||
#@warning El sistema de archivos de Windows debe estar montado previamente.
|
||||
#@version 0.9 - Adaptación para OpenGNSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-09-23
|
||||
#*/ ##
|
||||
function ogListRegistryKeys ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FILE
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" \
|
||||
"$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\Windows\CurrentVersion'"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 3 parámetros.
|
||||
[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
|
||||
# Camino del fichero de registro.
|
||||
FILE=$(ogGetHivePath "$1" "$2") || return $?
|
||||
|
||||
# Devolver la lista de claves de registro.
|
||||
chntpw "$FILE" << EOT 2> /dev/null | awk 'BEGIN {FS="[<>]"} $1~/^ $/ {print $2}'
|
||||
ls $3
|
||||
q
|
||||
EOT
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogListRegistryValues path_mountpoint str_hive str_key
|
||||
#@brief Lista los nombres de valores de una determinada clave del registro de Windows.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
#@param str_key clave de registro
|
||||
#@return str_value ... - lista de valores
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero de registro no encontrado.
|
||||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw, awk
|
||||
#@warning El sistema de archivos de Windows debe estar montado previamente.
|
||||
#@version 1.0.1 - Nueva función.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-05-26
|
||||
#*/ ##
|
||||
function ogListRegistryValues ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FILE
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key" \
|
||||
"$FUNCNAME /mnt/sda1 SOFTWARE '\Microsoft\Windows\CurrentVersion'"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 3 parámetros.
|
||||
[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
# Camino del fichero de registro.
|
||||
FILE=$(ogGetHivePath "$1" "$2") || return $?
|
||||
|
||||
# Devolver la lista de claves de registro.
|
||||
chntpw "$FILE" << EOT 2> /dev/null | awk 'BEGIN {FS="[<>]"} $1~/REG_/ {print $2}'
|
||||
ls $3
|
||||
q
|
||||
EOT
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogSetRegistryValue path_mountpoint str_hive str_valuename str_valuedata
|
||||
#@brief Establece el dato asociado a un valor del registro de Windows.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
#@param str_valuename nombre del valor de registro
|
||||
#@param str_valuedata dato del valor de registro
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero de registro no encontrado.
|
||||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw
|
||||
#@warning El sistema de archivos de Windows debe estar montado previamente.
|
||||
#@version 0.9 - Adaptación para OpenGNSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-09-24
|
||||
#@version 1.1.0 - Soportar tipos BINARY (parejas hexadecimales separadas por espacio).
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2015-09-28
|
||||
#*/ ##
|
||||
function ogSetRegistryValue ()
|
||||
{
|
||||
# Variables locales.
|
||||
local FILE i n tmpfile
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename str_data" \
|
||||
"$FUNCNAME /mnt/sda1 SOFTWARE '\Key\SubKey\StringValue' \"Abcde Fghij\"" \
|
||||
"$FUNCNAME /mnt/sda1 SOFTWARE '\Key\SubKey\DwordValue' 1" \
|
||||
"$FUNCNAME /mnt/sda1 SOFTWARE '\Key\SubKey\BinaryValue' \"04 08 0C 10\""
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 4 parámetros.
|
||||
[ $# == 4 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
# Camino del fichero de registro.
|
||||
FILE=$(ogGetHivePath "$1" "$2") || return $?
|
||||
|
||||
# Fichero temporal para componer la entrada al comando "chntpw".
|
||||
tmpfile=/tmp/chntpw$$
|
||||
trap "rm -f $tmpfile" 1 2 3 9 15
|
||||
|
||||
# Comprobar tipo de datos del valor del registro.
|
||||
cat << EOT >$tmpfile
|
||||
ls ${3%\\*}
|
||||
q
|
||||
EOT
|
||||
if [ -n "$(chntpw "$FILE" < $tmpfile 2> /dev/null | grep "BINARY.*<${3##*\\}>")" ]; then
|
||||
# Procesar tipo binario (incluir nº de bytes y líneas de 16 parejas hexadecimales).
|
||||
[[ "$4 " =~ ^([0-9A-F]{2} )*$ ]] || ogRaiseError $OG_ERR_FORMAT "\"$4\"" || return $?
|
||||
let n=${#4}+1
|
||||
cat << EOT >$tmpfile
|
||||
cd ${3%\\*}
|
||||
ed ${3##*\\}
|
||||
$[n/3]
|
||||
EOT
|
||||
# Formato de líneas hexadecimales: :OFFSET XX YY ZZ ... (hasta 16 parejas).
|
||||
for (( i=0; i<n; i+=48 )); do
|
||||
printf ":%05x %s\n" $[i/3] "${4:$i:48}" >> $tmpfile
|
||||
done
|
||||
echo -e "s\nq\ny" >> $tmpfile
|
||||
else
|
||||
# Cambiar el dato del valor de registro para cadenas y bytes.
|
||||
cat << EOT >$tmpfile
|
||||
cd ${3%\\*}
|
||||
ed ${3##*\\}
|
||||
$4
|
||||
q
|
||||
y
|
||||
EOT
|
||||
|
||||
fi
|
||||
|
||||
# Aplicar cambios.
|
||||
chntpw "$FILE" < $tmpfile &> /dev/null
|
||||
rm -f $tmpfile
|
||||
}
|
||||
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
#/**
|
||||
# ogCheckStringInGroup
|
||||
#@brief Función para determinar si el elemento pertenece a un conjunto
|
||||
#@param 1 elemento a comprobar
|
||||
#@param 2 grupo de elementos para comprobar tipo "valor1 valor2 valor3"
|
||||
#@return 0 si pertenece al grupo
|
||||
#@return 1 si NO pertenece al grupo
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@note
|
||||
#@todo
|
||||
#@version 0.91 - Definición de
|
||||
#@author Antonio Doblas Viso, Universidad de Málaga
|
||||
#@date 2010/05/09
|
||||
#*/ ##
|
||||
|
||||
function ogCheckStringInGroup ()
|
||||
{
|
||||
local i
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME str_elemento str_grupo" \
|
||||
"$FUNCNAME full-duplex \"full-duplex half-duplex broadcast\" "
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se recibe 2 parámetro.
|
||||
[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
|
||||
|
||||
for i in `echo $2`
|
||||
do
|
||||
if [ "$1" == "$i" ]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
#/**
|
||||
# ogCheckStringInReg
|
||||
#@brief Función para determinar si el elemento contiene una "expresión regular"
|
||||
#@param 1 elemento a comprobar
|
||||
#@param 2 expresión regular"
|
||||
#@return 0 si coincide con la expresión
|
||||
#@return 1 si NO coincide con la expresión
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@note
|
||||
#@todo
|
||||
#@version 0.91 - Definición de
|
||||
#@author Antonio Doblas Viso, Universidad de Málaga
|
||||
#@date 2010/05/09
|
||||
#*/ ##
|
||||
|
||||
function ogCheckStringInReg()
|
||||
{
|
||||
|
||||
local REG
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME str_elemento str_expresión_regular" \
|
||||
"$FUNCNAME 50M \"^[0-9]{1,2}\M$\" "
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se recibe 2 parámetro.
|
||||
[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
|
||||
REG=$2
|
||||
[[ $1 =~ $REG ]] && return 0 || return 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
#/**
|
||||
# ogCheckIpAddress
|
||||
#@brief Función para determinar si una cadena es una dirección ipv4 válida
|
||||
#@param 1 string de la ip a comprobar
|
||||
#@return 0 si es una dirección válida
|
||||
#@return 1 si NO es una dirección válida
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@note
|
||||
#@todo
|
||||
#@version 0.91 - Definición de
|
||||
#@author Antonio Doblas Viso, Universidad de Málaga
|
||||
#@date 2010/05/09
|
||||
#*/ ##
|
||||
|
||||
function ogCheckIpAddress()
|
||||
{
|
||||
local REG IP arrIP
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME str_IpAddressToCheck" \
|
||||
"$FUNCNAME 192.18.35.3"
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se recibe 1 parámetro.
|
||||
[ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
|
||||
|
||||
IP=$1
|
||||
REG="^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$"
|
||||
if [[ "$IP" =~ $REG ]]
|
||||
then
|
||||
OIFS=$IFS;
|
||||
IFS='.' ;
|
||||
arrIP=($IP)
|
||||
IFS=$OIFS
|
||||
if [[ ${arrIP[0]} -le 255 && ${arrIP[1]} -le 255 && ${arrIP[2]} -le 255 && ${arrIP[3]} -le 255 ]]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
|
@ -1,339 +0,0 @@
|
|||
#!/bin/bash
|
||||
#/**
|
||||
#@file System.lib
|
||||
#@brief Librería o clase System
|
||||
#@class System
|
||||
#@brief Funciones básicas del sistema.
|
||||
#@version 1.1.0
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
|
||||
#/**
|
||||
# ogEcho [str_logtype ...] [str_loglevel] "str_message" ...
|
||||
#@brief Muestra mensajes en consola y lo registra en fichero de incidencias.
|
||||
#@param str_logtype tipo de registro de incidencias.
|
||||
#@param str_loglevel nivel de registro de incidencias.
|
||||
#@param str_message mensaje (puede recibir más de 1 parámetro.
|
||||
#@return Mensaje mostrado.
|
||||
#@warning Si no se indica nivel de registro, solo muestra mensaje en pantalla.
|
||||
#@warning Si DEBUG="no", no se registran mensajes de error.
|
||||
#@note logfile = { log, command, session }; usa "log" si se indica nivel de registro.
|
||||
#@note loglevel = { help, info, warning, error }
|
||||
#@note El nivel de ayuda \c (help) no se registra en el fichero de incidencias.
|
||||
#@version 0.9 - Primera versión para OpenGnSys
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-07-23
|
||||
#@version 1.0.5 - Elegir fichero de log.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2014-03-17
|
||||
#@version 1.1.0 - Posibilidad de no registrar mensajes en ficheros.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2015-11-10
|
||||
#*/
|
||||
function ogEcho () {
|
||||
|
||||
# Variables locales
|
||||
local CONT=1 LOGS LOGLEVEL DATETIME
|
||||
|
||||
# Selección de ficheros de rgistro de incidencias.
|
||||
while [ $CONT ]; do
|
||||
case "${1,,}" in
|
||||
log) LOGS="$LOGS $OGLOGFILE"; shift ;;
|
||||
command) LOGS="$LOGS $OGLOGCOMMAND"; shift ;;
|
||||
session) LOGS="$LOGS $OGLOGSESSION"; shift ;;
|
||||
*) CONT= ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Selección del nivel de registro (opcional).
|
||||
case "${1,,}" in
|
||||
help) shift ;;
|
||||
info) LOGLEVEL="$1"; shift ;;
|
||||
warning) LOGLEVEL="$1"; shift ;;
|
||||
error) LOGLEVEL="$1"; shift ;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
if [ -n "$LOGLEVEL" ]; then
|
||||
DATETIME=$(date +"%F %T")
|
||||
# Registrar mensajes en fichero de log si la depuración no está desactivada.
|
||||
[ "${DEBUG,,}" != "no" ] && LOGS="$OGLOGFILE $LOGS"
|
||||
echo "OpenGnsys $LOGLEVEL" "$DATETIME $*" 2>&1 | tee -a $LOGS
|
||||
else
|
||||
echo "$*" | tee -a $LOGS
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogExecAndLog str_logfile ... str_command ...
|
||||
#@brief Ejecuta un comando y guarda su salida en fichero de registro.
|
||||
#@param str_logfile fichero de registro (pueden ser varios).
|
||||
#@param str_command comando y comandos a ejecutar.
|
||||
#@return Salida de ejecución del comando.
|
||||
#@note str_logfile = { LOG, SESSION, COMMAND }
|
||||
#@version 1.0.6 - Primera versión para OpenGnSys
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2013-07-02
|
||||
#*/
|
||||
function ogExecAndLog () {
|
||||
|
||||
# Variables locales
|
||||
local ISCOMMAND ISLOG ISSESSION COMMAND CONTINUE=1 FILES REDIREC
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME str_logfile ... str_command ..." \
|
||||
"$FUNCNAME COMMAND ls -al /"
|
||||
return
|
||||
fi
|
||||
|
||||
# Procesar parámetros.
|
||||
while [ $CONTINUE ]; do
|
||||
case "${1,,}" in
|
||||
command) ISCOMMAND=1; shift ;;
|
||||
log) ISLOG=1; shift ;;
|
||||
session) ISSESSION=1; shift ;;
|
||||
*) COMMAND="$@"
|
||||
CONTINUE= ;;
|
||||
esac
|
||||
done
|
||||
# Error si no se recibe un comando que ejecutar.
|
||||
[ -n "$COMMAND" ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
|
||||
# Componer lista de ficheros de registro.
|
||||
if [ $ISCOMMAND ]; then
|
||||
FILES="$OGLOGCOMMAND"
|
||||
> $FILES
|
||||
REDIREC="2>&1"
|
||||
fi
|
||||
[ $ISLOG ] && FILES="$FILES $OGLOGFILE"
|
||||
[ $ISSESSION ] && FILES="$FILES $OGLOGSESSION"
|
||||
|
||||
# Ejecutar comando.
|
||||
eval $COMMAND $REDIREC | tee -a $FILES
|
||||
# Salida de error del comando ejecutado.
|
||||
return ${PIPESTATUS[0]}
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetCaller
|
||||
#@brief Devuelve nombre del programa o script ejecutor (padre).
|
||||
#@param No.
|
||||
#@return str_name - Nombre del programa ejecutor.
|
||||
#@version 0.10 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-01-17
|
||||
#*/
|
||||
function ogGetCaller () {
|
||||
|
||||
# Obtener el nombre del programa o del script que ha llamado al proceso actual.
|
||||
basename "$(COLUMNS=200 ps hp $PPID -o args | \
|
||||
awk '{if ($1~/bash/ && $2!="") { print $2; }
|
||||
else { sub(/^-/,"",$1); print $1; } }')"
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogHelp ["str_function" ["str_format" ["str_example" ... ]]]
|
||||
#@brief Muestra mensaje de ayuda para una función determinda.
|
||||
#@param str_function Nombre de la función.
|
||||
#@param str_format Formato de ejecución de la función.
|
||||
#@param str_example Ejemplo de ejecución de la función.
|
||||
#@return str_help - Salida de ayuda.
|
||||
#@note Si no se indican parámetros, la función se toma de la variable \c $FUNCNAME
|
||||
#@note La descripción de la función se toma de la variable compuesta por \c MSG_FUNC_$función incluida en el fichero de idiomas.
|
||||
#@note Pueden especificarse varios mensajes con ejemplos.
|
||||
#@version 0.9 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-07-27
|
||||
#*/
|
||||
function ogHelp () {
|
||||
|
||||
# Variables locales.
|
||||
local FUNC MSG
|
||||
|
||||
# Mostrar función, descripción y formato.
|
||||
FUNC="${1:-${FUNCNAME[${#FUNCNAME[*]}-1]}}"
|
||||
MSG="MSG_HELP_$FUNC"
|
||||
ogEcho help "$MSG_FUNCTION $FUNC: ${!MSG}"
|
||||
[ -n "$2" ] && ogEcho help " $MSG_FORMAT: $2"
|
||||
# Mostrar ejemplos (si existen).
|
||||
shift 2
|
||||
while [ $# -gt 0 ]; do
|
||||
ogEcho help " $MSG_EXAMPLE: $1"
|
||||
shift
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogRaiseError [str_logtype ...] int_errcode ["str_errmessage" ...]
|
||||
#@brief Devuelve el mensaje y el código de error correspondiente.
|
||||
#@param str_logtype tipo de registro de incidencias.
|
||||
#@param int_errcode código de error.
|
||||
#@param str_errmessage mensajes complementarios de error.
|
||||
#@return str_message - Mensaje de error, incluyendo las funciones relacionadas.
|
||||
#@warning No definidas
|
||||
#@note Mensajes internacionales del fichero de idiomas.
|
||||
#@version 0.9 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2009-07-21
|
||||
#@version 1.0.5 - Muestra en el mensaje todas las funciones relacionadas (separadas por <-).
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2014-03-17
|
||||
#*/
|
||||
function ogRaiseError () {
|
||||
|
||||
# Variables locales
|
||||
local CONT=1 LOGS MSG CODE FUNCS
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [str_logfile ...] int_errorcode str_errormessage"
|
||||
return
|
||||
fi
|
||||
|
||||
# Selección de rgistros de incidencias.
|
||||
while [ $CONT ]; do
|
||||
case "${1,,}" in
|
||||
log|command|session) LOGS="$LOGS $1"; shift ;;
|
||||
*) CONT= ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Obtener código y mensaje de error.
|
||||
CODE="$1"
|
||||
case "$CODE" in
|
||||
$OG_ERR_FORMAT) MSG="$MSG_ERR_FORMAT \"$2\"" ;;
|
||||
$OG_ERR_NOTFOUND) MSG="$MSG_ERR_NOTFOUND \"$2\"" ;;
|
||||
$OG_ERR_OUTOFLIMIT) MSG="$MSG_ERR_OUTOFLIMIT \"$2\"" ;;
|
||||
$OG_ERR_PARTITION) MSG="$MSG_ERR_PARTITION \"$2\"" ;;
|
||||
$OG_ERR_LOCKED) MSG="$MSG_ERR_LOCKED \"$2\"" ;;
|
||||
$OG_ERR_CACHE) MSG="$MSG_ERR_CACHE \"$2\"" ;;
|
||||
$OG_ERR_NOGPT) MSG="$MSG_ERR_NOGPT \"$2\"" ;;
|
||||
$OG_ERR_REPO) MSG="$MSG_ERR_REPO \"$2\"" ;;
|
||||
$OG_ERR_FILESYS) MSG="$MSG_ERR_FILESYS \"$2\"" ;;
|
||||
$OG_ERR_IMAGE) MSG="$MSG_ERR_IMAGE \"$2\"" ;;
|
||||
$OG_ERR_NOTOS) MSG="$MSG_ERR_NOTOS \"$2\"" ;;
|
||||
$OG_ERR_NOTEXEC) MSG="$MSG_ERR_NOTEXEC \"$2\"" ;;
|
||||
$OG_ERR_NOTWRITE) MSG="$MSG_ERR_NOTWRITE \"$2\"" ;;
|
||||
$OG_ERR_NOTCACHE) MSG="$MSG_ERR_NOTCACHE \"$2\"" ;;
|
||||
$OG_ERR_CACHESIZE) MSG="$MSG_ERR_CACHESIZE \"$2\"" ;;
|
||||
$OG_ERR_REDUCEFS) MSG="$MSG_ERR_REDUCEFS \"$2\"" ;;
|
||||
$OG_ERR_EXTENDFS) MSG="$MSG_ERR_EXTENDFS \"$2\"" ;;
|
||||
$OG_ERR_IMGSIZEPARTITION) MSG="$MSG_ERR_IMGSIZEPARTITION \"$2\"" ;;
|
||||
$OG_ERR_UPDATECACHE) MSG="$MSG_ERR_UPDATECACHE \"$2\"" ;;
|
||||
$OG_ERR_DONTFORMAT) MSG="$MSG_ERR_DONTFORMAT \"$2\"" ;;
|
||||
$OG_ERR_IMAGEFILE) MSG="$MSG_ERR_IMAGEFILE \"$2\"" ;;
|
||||
$OG_ERR_UCASTSYNTAXT) MSG="$MSG_ERR_UCASTSYNTAXT \"$2\"" ;;
|
||||
$OG_ERR_UCASTSENDPARTITION) MSG="$MSG_ERR_UCASTSENDPARTITION \"$2\"" ;;
|
||||
$OG_ERR_UCASTSENDFILE) MSG="$MSG_ERR_UCASTSENDFILE \"$2\"" ;;
|
||||
$OG_ERR_UCASTRECEIVERPARTITION) MSG="$MSG_ERR_UCASTRECEIVERPARTITION \"$2\"" ;;
|
||||
$OG_ERR_UCASTRECEIVERFILE) MSG="$MSG_ERR_UCASTRECEIVERFILE \"$2\"" ;;
|
||||
$OG_ERR_MCASTSYNTAXT) MSG="$MSG_ERR_MCASTSYNTAXT \"$2\"" ;;
|
||||
$OG_ERR_MCASTSENDFILE) MSG="$MSG_ERR_MCASTSENDFILE \"$2\"" ;;
|
||||
$OG_ERR_MCASTRECEIVERFILE) MSG="$MSG_ERR_MCASTRECEIVERFILE \"$2\"" ;;
|
||||
$OG_ERR_MCASTSENDPARTITION) MSG="$MSG_ERR_MCASTSENDPARTITION \"$2\"" ;;
|
||||
$OG_ERR_MCASTRECEIVERPARTITION) MSG="$MSG_ERR_MCASTRECEIVERPARTITION \"$2\"" ;;
|
||||
$OG_ERR_PROTOCOLJOINMASTER) MSG="$MSG_ERR_PROTOCOLJOINMASTER \"$2\"" ;;
|
||||
$OG_ERR_DONTMOUNT_IMAGE) MSG="$MSG_ERR_DONTMOUNT_IMAGE \"$2\"" ;;
|
||||
$OG_ERR_DONTUNMOUNT_IMAGE) MSG="$MSG_ERR_DONTUNMOUNT_IMAGE \"$2\"" ;;
|
||||
$OG_ERR_DONTSYNC_IMAGE) MSG="$MSG_ERR_DONTSYNC_IMAGE \"$2\"" ;;
|
||||
$OG_ERR_NOTDIFFERENT) MSG="$MSG_ERR_NOTDIFFERENT \"$2\"" ;;
|
||||
$OG_ERR_SYNCHRONIZING) MSG="$MSG_ERR_SYNCHRONIZING \"$2\"" ;;
|
||||
$OG_ERR_NOTUEFI) MSG="$MSG_ERR_NOTUEFI \"$2\"" ;;
|
||||
$OG_ERR_NOMSDOS) MSG="$MSG_ERR_NOMSDOS \"$2\"" ;;
|
||||
$OG_ERR_NOTBIOS) MSG="$MSG_ERR_NOTBIOS \"$2\"" ;;
|
||||
*) MSG="$MSG_ERR_GENERIC"; CODE=$OG_ERR_GENERIC ;;
|
||||
esac
|
||||
|
||||
# Obtener lista de funciones afectadas, incluyendo el script que las llama.
|
||||
FUNCS="${FUNCNAME[@]:1}"
|
||||
FUNCS="${FUNCS/main/$(basename $0 2>/dev/null)}"
|
||||
|
||||
# Mostrar mensaje de error si es función depurable y salir con el código indicado.
|
||||
if [ $CODE == $OG_ERR_FORMAT ] || ogCheckStringInGroup "$FUNCS" "$NODEBUGFUNCTIONS" || ! ogCheckStringInGroup "${FUNCS%% *}" "$NODEBUGFUNCTIONS"; then
|
||||
ogEcho $LOGS error "${FUNCS// /<-}: $MSG" >&2
|
||||
fi
|
||||
return $CODE
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogIsRepoLocked
|
||||
#@brief Comprueba si el repositorio está siendo usado (tiene ficheros abiertos).
|
||||
#@param No.
|
||||
#@return Código de salida: 0 - bloqueado, 1 - sin bloquear o error.
|
||||
#@version 0.10 - Primera versión para OpenGnSys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-01-17
|
||||
#@version 1.0.1 - Devolver falso en caso de error.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2011-05-18
|
||||
#*/
|
||||
function ogIsRepoLocked ()
|
||||
{
|
||||
# Variables locales.
|
||||
local f FILES
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" "if $FUNCNAME; then ...; fi"
|
||||
return
|
||||
fi
|
||||
|
||||
# No hacer nada, si no está definido el punto de montaje del repositorio.
|
||||
[ -z "$OGIMG" ] && return 1
|
||||
|
||||
# Comprobar si alguno de los ficheros abiertos por los procesos activos está en el
|
||||
# punto de montaje del repositorio de imágenes.
|
||||
FILES=$(for f in /proc/[0-9]*/fd/*; do readlink -f "$f"; done | grep "^$OGIMG") # */ (comentario Doxygen)
|
||||
test -n "$FILES"
|
||||
}
|
||||
|
||||
|
||||
function ogCheckProgram ()
|
||||
{
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME \"str_program ...\"" \
|
||||
"$FUNCNAME \"partimage partclone mbuffer\""
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se recibe 1 parámetro.
|
||||
[ $# == 1 ] || ogRaiseError $OG_ERR_FORMAT || return $?
|
||||
|
||||
local PERROR PLOG i
|
||||
PERROR=0
|
||||
PLOG=" "
|
||||
for i in `echo $1`
|
||||
do
|
||||
if [ ! `which $i` ]
|
||||
then
|
||||
PERROR=1
|
||||
PLOG="$PLOG $i"
|
||||
fi
|
||||
done
|
||||
if [ "$PERROR" == "1" ]
|
||||
then
|
||||
ogRaiseError $OG_ERR_NOTEXEC "$PLOG" || return $?
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
#### PRUEBA
|
||||
function ogIsVirtualMachine() {
|
||||
case "$(dmidecode -s system-product-name)" in
|
||||
KVM|VirtualBox)
|
||||
return 1 ;;
|
||||
*) return 0 ;;
|
||||
esac
|
||||
}
|
||||
|
|
@ -1,679 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Libreria provisional para uso de UEFI
|
||||
# Las funciones se incluirán las librerías ya existentes
|
||||
|
||||
#/**
|
||||
# ogNvramActiveEntry
|
||||
#@brief Activa entrada de la NVRAM identificada por la etiqueta o el orden
|
||||
#@param Num_order_entry | Label_entry Número de orden o la etiqueta de la entrada a borrar.
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#*/ ##
|
||||
function ogNvramActiveEntry () {
|
||||
local NUMENTRY
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ Num_order_entry | Label_entry ] " \
|
||||
"$FUNCNAME 2" \
|
||||
"$FUNCNAME \"Windows Boot Manager\""
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se recibe 1 parámetro.
|
||||
[ $# -eq 1 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME [ Num_order_entry | Label_entry ]" || return $?
|
||||
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
# Distingo si es número de orden o etiqueta
|
||||
if [[ $1 =~ ^([0-9a-fA-F]+)$ ]]; then
|
||||
NUMENTRY=$( efibootmgr |awk -v NUM="$(printf %04x 0x$1|tr '[:lower:]' '[:upper:]')" '{ if($1~NUM) print substr($1,5,4)}')
|
||||
else
|
||||
NUMENTRY=$(efibootmgr |awk -v LABEL="$1" '{ if(substr($0, index($0,$2))==LABEL) print substr($1,5,4)}')
|
||||
fi
|
||||
|
||||
[ "$NUMENTRY" == "" ] && return $(ogRaiseError $OG_ERR_NOTFOUND "NVRAM entry '$1'")
|
||||
|
||||
efibootmgr -a -b $NUMENTRY &>/dev/null
|
||||
}
|
||||
|
||||
#/**
|
||||
# ogNvramAddEntry
|
||||
#@brief Crea nueva entrada en el gestor de arranque (NVRAM), opcionalmente la incluye al final del orden de arranque.
|
||||
#@param Str_Label_entry Número de disco o etiqueta de la entrada a crear.
|
||||
#@param Str_BootLoader Número de partición o cargador de arranque.
|
||||
#@param Bool_Incluir_Arranque Incluir en el orden de arranque (por defecto FALSE) (opcional)
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#*/ ##
|
||||
function ogNvramAddEntry () {
|
||||
local EFIDISK EFIPART BOOTLABEL BOOTLOADER ADDORDER
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME Str_label_entry Str_boot_loader [ Bool_add_bootorder ]" \
|
||||
"$FUNCNAME 1 2 TRUE" \
|
||||
"$FUNCNAME grub /EFI/grub/grubx64.efi TRUE" \
|
||||
"$FUNCNAME Windows /EFI/Microsoft/Boot/bootmgfw.efi"
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se recibe 1 parámetro.
|
||||
[ $# -ge 2 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME Str_label_entry Str_boot_locader" || return $?
|
||||
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
read -e EFIDISK EFIPART <<<"$(ogGetEsp)"
|
||||
[ -n "$EFIPART" ] || ogRaiseError $OG_ERR_NOTFOUND "ESP" || return $?
|
||||
|
||||
# Recogemos parámetros
|
||||
# Distinguimos si es disco/partición o etiqueta/cargador
|
||||
if [[ "$1$2" =~ ^([0-9]+)$ ]]; then
|
||||
BOOTLABEL=$(printf "Part-%02d-%02d" $1 $2)
|
||||
BOOTLOADER="/EFI/$BOOTLABEL/Boot/ogloader.efi"
|
||||
else
|
||||
BOOTLABEL="$1"
|
||||
BOOTLOADER="$2"
|
||||
fi
|
||||
|
||||
|
||||
# Si existe entrada con la misma etiqueta la borramos
|
||||
ogNvramDeleteEntry "$BOOTLABEL" 2>/dev/null
|
||||
|
||||
efibootmgr -C -d $(ogDiskToDev $EFIDISK) -p $EFIPART -L "$BOOTLABEL" -l "$BOOTLOADER" &>/dev/null
|
||||
|
||||
# Incluimos la entrada en el orden de arranque (opcional)
|
||||
if [ "${3^^}" == "TRUE" ]; then
|
||||
NUMENTRY=$(efibootmgr |awk -v LABEL="$BOOTLABEL" '{ if(substr($0, index($0,$2))==LABEL) print substr($1,5,4)}')
|
||||
ogNvramSetOrder $(ogNvramGetOrder |tr , " ") $NUMENTRY
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogCopyEfiBootLoader int_ndisk str_repo path_image
|
||||
#@brief Copia el cargador de arranque desde la partición EFI a la de sistema.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_part nº de partición
|
||||
#@return (nada, por determinar)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#@note Si existe el cargador en la partición de sistema no es válido
|
||||
#*/ ##
|
||||
function ogCopyEfiBootLoader () {
|
||||
# Variables locales
|
||||
local MNTDIR EFIDIR BOOTLABEL OSVERSION LOADER f
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_part" \
|
||||
"$FUNCNAME 1 2"
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se reciben 2 arámetros.
|
||||
[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_ndisk int_part" || return $?
|
||||
|
||||
# Comprobamos que exista partición de sistema y la ESP
|
||||
MNTDIR=$(ogMount $1 $2) || ogRaiseError $OG_ERR_PARTITION "$DISK $PART" || return $?
|
||||
EFIDIR=$(ogMount $(ogGetEsp)) || ogRaiseError $OG_ERR_PARTITION "ESP" || return $?
|
||||
|
||||
# Comprobamos que exista el cargador
|
||||
BOOTLABEL=$(printf "Part-%02d-%02d" $1 $2)
|
||||
OSVERSION=$(ogGetOsVersion $1 $2)
|
||||
case $OSVERSION in
|
||||
*Windows\ 10*)
|
||||
for f in $EFIDIR/EFI/{Microsoft,$BOOTLABEL}/Boot/bootmgfw.efi; do
|
||||
[ -r $f ] && LOADER=$f
|
||||
done
|
||||
[ -n "$LOADER" ] || ogRaiseError $OG_ERR_NOTOS "$1 $2 ($OSVERSION, EFI)" || return $?
|
||||
# Si existe el directorio Boot lo borramos
|
||||
[ -d $MNTDIR/ogBoot ] && rm -rf $MNTDIR/ogBoot
|
||||
DIRLOADER=$(realpath "${LOADER%/*}/..")
|
||||
cp -r ${DIRLOADER}/Boot $MNTDIR/ogBoot
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramDeleteEntry
|
||||
#@brief Borra entrada de la NVRAM identificada por la etiqueta o el orden
|
||||
#@param Num_order_entry | Label_entry Número de orden o la etiqueta de la entrada a borrar.
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado (entrada en NVRAM).
|
||||
#*/ ##
|
||||
function ogNvramDeleteEntry () {
|
||||
local NUMENTRY n
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ Num_order_entry | Label_entry ] " \
|
||||
"$FUNCNAME 2" \
|
||||
"$FUNCNAME \"Windows Boot Manager\""
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se recibe 1 parámetro.
|
||||
[ $# -eq 1 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME [ Num_order_entry | Label_entry ]" || return $?
|
||||
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
# Distingo si es número de orden o etiqueta
|
||||
if [[ $1 =~ ^([0-9a-fA-F]+)$ ]]; then
|
||||
NUMENTRY=$( efibootmgr |awk -v NUM="$(printf %04x 0x$1|tr '[:lower:]' '[:upper:]')" '{ if($1~NUM) print substr($1,5,4)}')
|
||||
else
|
||||
NUMENTRY=$(efibootmgr |awk -v LABEL="$1" '{ if(substr($0, index($0,$2))==LABEL) print substr($1,5,4)}')
|
||||
fi
|
||||
|
||||
[ "$NUMENTRY" == "" ] && return $(ogRaiseError $OG_ERR_NOTFOUND "NVRAM entry '$1'")
|
||||
|
||||
for n in $NUMENTRY; do
|
||||
efibootmgr -B -b $n &>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramGetCurrent
|
||||
#@brief Muestra la entrada del gestor de arranque (NVRAM) que ha iniciado el equipo.
|
||||
#@return Entrada con la que se ha iniciado el equipo
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
function ogNvramGetCurrent () {
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" \
|
||||
"$FUNCNAME"
|
||||
return
|
||||
fi
|
||||
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
efibootmgr| awk -v bootentry=99999 '{if ($1~/BootCurrent/) bootentry=$2; if ($1~bootentry) printf "%s %s %s\n", gensub(/^0{1,3}/,"",1,substr($1,5,4))," ", substr($0, index($0,$2))}'
|
||||
}
|
||||
|
||||
|
||||
# ogNvramGetNext
|
||||
#@brief Muestra la entrada del gestor de arranque (NVRAM) que se utilizará en el próximo arranque.
|
||||
#@return Entrada que se utilizará en el próximo arranque
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
function ogNvramGetNext () {
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" \
|
||||
"$FUNCNAME"
|
||||
return
|
||||
fi
|
||||
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
efibootmgr|awk '{ if ($1 == "BootNext:") print $2}'
|
||||
}
|
||||
|
||||
|
||||
# ogNvramGetOrder
|
||||
#@brief Muestra el orden de las entradas del gestor de arranque (NVRAM)
|
||||
#@return Orden de las entradas
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
function ogNvramGetOrder () {
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" \
|
||||
"$FUNCNAME"
|
||||
return
|
||||
fi
|
||||
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
efibootmgr|awk '{ if ($1 == "BootOrder:") print $2}'
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramGetTimeout
|
||||
#@brief Muestra el tiempo de espera del gestor de arranque (NVRAM)
|
||||
#@return Timeout de la NVRAM
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
function ogNvramGetTimeout () {
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" \
|
||||
"$FUNCNAME"
|
||||
return
|
||||
fi
|
||||
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
efibootmgr|awk '{ if ($1 == "Timeout:") print substr($0, index($0,$2))}'
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogGrubUefiConf int_ndisk int_part str_dir_grub
|
||||
#@brief Genera el fichero grub.cfg de la ESP
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_part nº de partición
|
||||
#@param str_dir_grub prefijo del directorio de grub en la partición de sistema. ej: /boot/grubPARTITION
|
||||
#@return (nada, por determinar)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#@TODO Confirmar si el fichero "$EFIDIR/EFI/$BOOTLABEL/grub.cfg" es necesario.
|
||||
#*/ ##
|
||||
function ogGrubUefiConf () {
|
||||
local EFIDIR BOOTLABEL GRUBEFI UUID DEVICE PREFIXSECONDSTAGE EFIGRUBDIR
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_part [ str_dir_grub ]" \
|
||||
"$FUNCNAME 1 2" \
|
||||
"$FUNCNAME 1 3 /boot/grubPARTITION"
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se reciben al menos 2 parámetros.
|
||||
[ $# -ge 2 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_ndisk int_part [ str_dir_grub ]" || return $?
|
||||
|
||||
# Directorio del grub en la partición de sistema
|
||||
PREFIXSECONDSTAGE="$3"
|
||||
|
||||
EFIDIR=$(ogMount $(ogGetEsp)) || ogRaiseError $OG_ERR_PARTITION "ESP" || return $?
|
||||
BOOTLABEL=$(printf "Part-%02d-%02d" $1 $2)
|
||||
EFIGRUBDIR="$EFIDIR/EFI/$BOOTLABEL/boot/grub"
|
||||
# Comprobamos que existe directorio
|
||||
[ -d "$EFIGRUBDIR" ] || mkdir -p "$EFIGRUBDIR"
|
||||
# Parcheamos uuid y particion en grub.cfg
|
||||
UUID=$(blkid -o value -s UUID $(ogDiskToDev $1 $2))
|
||||
DEVICE="hd$(expr $1 - 1 ),gpt$2"
|
||||
|
||||
cat << EOT > $EFIGRUBDIR/grub.cfg
|
||||
set root='$DEVICE'
|
||||
set prefix=(\$root)'${PREFIXSECONDSTAGE}/boot/grub'
|
||||
configfile \$prefix/grub.cfg
|
||||
EOT
|
||||
|
||||
# Provisional: confirmar si el segundo archivo se utiliza
|
||||
cp $EFIGRUBDIR/grub.cfg "$EFIDIR/EFI/$BOOTLABEL/grub.cfg"
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramInactiveEntry
|
||||
#@brief Inactiva entrada de la NVRAM identificada por la etiqueta o el orden
|
||||
#@param Num_order_entry | Label_entry Número de orden o la etiqueta de la entrada a borrar.
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
function ogNvramInactiveEntry () {
|
||||
local NUMENTRY
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ Num_order_entry | Label_entry ] " \
|
||||
"$FUNCNAME 2" \
|
||||
"$FUNCNAME \"Windows Boot Manager\""
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se recibe 1 parámetro.
|
||||
[ $# -eq 1 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME [ Num_order_entry | Label_entry ]" || return $?
|
||||
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
# Distingo si es número de orden o etiqueta
|
||||
if [[ $1 =~ ^([0-9a-fA-F]+)$ ]]; then
|
||||
NUMENTRY=$( efibootmgr |awk -v NUM="$(printf %04x 0x$1|tr '[:lower:]' '[:upper:]')" '{ if($1~NUM) print substr($1,5,4)}')
|
||||
else
|
||||
NUMENTRY=$(efibootmgr |awk -v LABEL="$1" '{ if(substr($0, index($0,$2))==LABEL) print substr($1,5,4)}')
|
||||
fi
|
||||
|
||||
[ "$NUMENTRY" == "" ] && return $(ogRaiseError $OG_ERR_NOTFOUND "NVRAM entry '$1'")
|
||||
|
||||
efibootmgr -A -b $NUMENTRY &>/dev/null
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramList
|
||||
#@brief Lista las entradas de la NVRAN (sólo equipos UEFI)
|
||||
#@return Entradas de la NVRAM con el formato: orden etiqueta [* (si está activa) ]
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
function ogNvramList () {
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" \
|
||||
"$FUNCNAME"
|
||||
return
|
||||
fi
|
||||
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
efibootmgr |awk '{if($1~/Boot[[:digit:]]/) ; active="" ;if ($1~/*/) active="*"; if($1~/Boot[[:digit:]]/) printf "%4s %s %s %s\n", gensub(/^0{1,3}/,"",1,substr($1,5,4))," ", substr($0, index($0,$2)), active}'
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramPxeFirstEntry
|
||||
#@brief Sitúa la entrada de la tarjeta de red en el primer lugar en la NVRAM.
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
function ogNvramPxeFirstEntry (){
|
||||
local NUMENTRY ORDER
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME" \
|
||||
"$FUNCNAME"
|
||||
return
|
||||
fi
|
||||
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
NUMENTRY=$(printf %04X 0x$(efibootmgr|awk '/IP[vV]{0,1}4/ {print gensub(/^0{1,3}/,"",1,substr($1,5,4))}'))
|
||||
|
||||
# Si la entrada es la primera nos salimos.
|
||||
[[ $(ogNvramGetOrder) =~ ^$NUMENTRY ]] && return
|
||||
|
||||
# Si la entrada ya existe la borramos.
|
||||
ORDER="$NUMENTRY $(ogNvramGetOrder| sed -e s/$NUMENTRY//g -e s/,/' '/g)"
|
||||
|
||||
ogNvramSetOrder $ORDER
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogRestoreEfiBootLoader int_ndisk str_repo
|
||||
#@brief Copia el cargador de arranque de la partición de sistema a la partición EFI.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_part nº de partición
|
||||
#@return (nada, por determinar)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado (partición de sistema o EFI).
|
||||
#@exception OG_ERR_NOTOS sin sistema operativo.
|
||||
#*/ ##
|
||||
function ogRestoreEfiBootLoader () {
|
||||
# Variables locales
|
||||
local MNTDIR EFIDIR BOOTLABEL OSVERSION LOADER f UUID DEVICE
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_part" \
|
||||
"$FUNCNAME 1 2"
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se reciben 2 arámetros.
|
||||
[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_ndisk int_part" || return $?
|
||||
|
||||
# Comprobamos que exista partición de sistema y la ESP
|
||||
MNTDIR=$(ogMount $1 $2) || ogRaiseError $OG_ERR_PARTITION "$DISK $PART" || return $?
|
||||
EFIDIR=$(ogMount $(ogGetEsp))
|
||||
if [ "$EFIDIR" == "" ]; then
|
||||
ogFormat $(ogGetEsp) FAT32
|
||||
EFIDIR=$(ogMount $(ogGetEsp)) || ogRaiseError $OG_ERR_PARTITION "ESP" || return $?
|
||||
fi
|
||||
|
||||
# Comprobamos que exista el cargador
|
||||
#BOOTLABEL=$(printf "Part-%02d-%02d" $1 $2)
|
||||
OSVERSION=$(ogGetOsVersion $1 $2)
|
||||
case $OSVERSION in
|
||||
*Windows\ 10*)
|
||||
BOOTLABEL=$(printf "Part-%02d-%02d" $1 $2)
|
||||
LOADER=$(ogGetPath $MNTDIR/ogBoot/bootmgfw.efi)
|
||||
[ -n "$LOADER" ] || ogRaiseError $OG_ERR_NOTOS "$1 $2 ($OSVERSION, EFI)" || return $?
|
||||
[ -r $EFIDIR/EFI/$BOOTLABEL ] && rm -rf $EFIDIR/EFI/$BOOTLABEL
|
||||
mkdir -p $EFIDIR/EFI/$BOOTLABEL
|
||||
cp -r "${LOADER%/*}" $EFIDIR/EFI/$BOOTLABEL/Boot
|
||||
# Nombre OpenGnsys para cargador
|
||||
cp $LOADER $EFIDIR/EFI/$BOOTLABEL/Boot/ogloader.efi
|
||||
|
||||
# Si existe subcarpeta Microsoft en la partición EFI la renombramos
|
||||
[ "$(ogGetPath $EFIDIR/EFI/Microsoft)" == "" ] || mv $EFIDIR/EFI/{Microsoft,Microsoft.backup.og}
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogRestoreUuidPartitions
|
||||
#@brief Restaura los uuid de las particiones y la tabla de particiones
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@param REPO|CACHE repositorio
|
||||
#@param str_imgname nombre de la imagen
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND No encontrado fichero de información de la imagen (con uuid)
|
||||
#*/ ##
|
||||
function ogRestoreUuidPartitions () {
|
||||
local DISK PART IMGNAME INFOFILE DEVICE DATA GUID UUID IMGGUID
|
||||
local EFIDEVICE EFIDATA EFIGUID EFIUUID EFIUUID IMGEFIGUID
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME REPO|CACHE str_imgname int_ndisk int_npart" \
|
||||
"$FUNCNAME REPO Windows 1 2"
|
||||
return
|
||||
fi
|
||||
# Error si no se reciben 4 parámetros.
|
||||
[ $# -eq 4 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME REPO|CACHE str_imgname int_ndisk int_npart" || return $?
|
||||
|
||||
# Sólo se ejecuta si es UEFI
|
||||
ogIsEfiActive || return
|
||||
|
||||
# Parámetros de entrada
|
||||
IMGNAME="$2"
|
||||
INFOFILE="$OGIMG/.$IMGNAME.img.json"
|
||||
[ "${1^^}" == "CACHE" ] && INFOFILE="$OGCAC$INFOFILE"
|
||||
# TODO: que la función getPath soporte archivos ocultos
|
||||
ls $INFOFILE &>/dev/null || ogRaiseError $OG_ERR_NOTFOUND "$INFOFILE" || return $?
|
||||
DISK=$3
|
||||
PART=$4
|
||||
|
||||
DEVICE=$(ogDiskToDev $DISK)
|
||||
read -e EFIDISK EFIPART <<<"$(ogGetEsp)"
|
||||
|
||||
# Datos de la imagen
|
||||
IMGGUID=$(jq .guid $INFOFILE|tr -d \")
|
||||
IMGEFIGUID=$(jq .espguid $INFOFILE|tr -d \")
|
||||
|
||||
# Datos actuales
|
||||
DATA=$(sfdisk -J $DEVICE)
|
||||
GUID=$(echo $DATA|jq ".partitiontable|.id"|tr -d \")
|
||||
|
||||
if [ "$IMGGUID" != "$GUID" ]; then
|
||||
echo sgdisk -U "$IMGGUID" "$DEVICE"
|
||||
sgdisk -U "$IMGGUID" "$DEVICE"
|
||||
partprobe
|
||||
fi
|
||||
|
||||
if [ $DISK -eq $EFIDISK ]; then
|
||||
EFIDATA=$DATA
|
||||
EFIDEVICE=$DEVICE
|
||||
else
|
||||
EFIDEVICE=$(ogDiskToDev $EFIDISK) || return $?
|
||||
EFIDATA=$(sfdisk -J $EFIDEVICE)
|
||||
EFIGUID=$(echo $EFIDATA|jq ".partitiontable|.id"|tr -d \")
|
||||
if [ "$IMGEFIGUID" != "$EFIGUID" ]; then
|
||||
echo sgdisk -U "$IMGEFIGUID" "$EFIDEVICE"
|
||||
sgdisk -U "$IMGEFIGUID" "$EFIDEVICE"
|
||||
partprobe
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramSetNext
|
||||
#@brief Configura el próximo arranque con la entrada del gestor de arranque (NVRAM) identificada por la etiqueta o el orden.
|
||||
#@param Num_order_entry | Label_entry Número de orden o la etiqueta de la entrada a borrar.
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#*/ ##
|
||||
function ogNvramSetNext () {
|
||||
local NUMENTRY
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME [ Num_order_entry | Label_entry ] " \
|
||||
"$FUNCNAME 2" \
|
||||
"$FUNCNAME \"Windows Boot Manager\""
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se recibe 1 parámetro.
|
||||
[ $# -eq 1 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME [ Num_order_entry | Label_entry ]" || return $?
|
||||
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
# Distingo si es número de orden o etiqueta
|
||||
if [[ $1 =~ ^([0-9a-fA-F]+)$ ]]; then
|
||||
NUMENTRY=$( efibootmgr |awk -v NUM="$(printf %04x 0x$1|tr '[:lower:]' '[:upper:]')" '{ if($1~NUM) print substr($1,5,4)}')
|
||||
else
|
||||
NUMENTRY=$(efibootmgr | awk -v LABEL="$1" '$0 ~ LABEL { print substr($1,5,4) }')
|
||||
fi
|
||||
|
||||
[ "$NUMENTRY" == "" ] && return $(ogRaiseError $OG_ERR_NOTFOUND "NVRAM entry '$1'")
|
||||
|
||||
efibootmgr -n $NUMENTRY &>/dev/null
|
||||
}
|
||||
|
||||
#/**
|
||||
# ogNvramSetOrder
|
||||
#@brief Configura el orden de las entradas de la NVRAM
|
||||
#@param Orden de las entradas separadas por espacios
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado (entrada NVRAM).
|
||||
#*/ ##
|
||||
function ogNvramSetOrder () {
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME Num_order1 [ Num_order2 ] ... " \
|
||||
"$FUNCNAME 1 3"
|
||||
return
|
||||
fi
|
||||
#
|
||||
# Error si no se recibe al menos 1 parámetro.
|
||||
[ $# -ge 1 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME Num_order1 [ Num_order2 ] ..." || return $?
|
||||
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
# Comprobamos que sean números
|
||||
[[ "$@" =~ ^([0-9a-fA-F ]+)$ ]] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME Num_order1 [ Num_order2 ] ..." || return $?
|
||||
|
||||
# Entradas de la NVRAM actuales
|
||||
NUMENTRYS=$(efibootmgr|awk '{ if ($1~/Boot[0-9a-fA-F]{4}/) printf "0%s ", substr($1,5,4)}')
|
||||
|
||||
ORDER=""
|
||||
for ARG in $@; do
|
||||
# Si no existe la entrada me salgo
|
||||
ARG=$(printf %04X 0x$ARG)
|
||||
echo $NUMENTRYS | grep "$ARG" &>/dev/null || ogRaiseError $OG_ERR_NOTFOUND "NVRAM entry order \"$ARG\"" || return $?
|
||||
ORDER=${ORDER},$ARG
|
||||
done
|
||||
|
||||
# Cambiamos el orden
|
||||
efibootmgr -o ${ORDER#,} &>/dev/null
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramSetTimeout
|
||||
#@brief Configura el tiempo de espera de la NVRAM
|
||||
#@param Orden de las entradas separadas por espacios
|
||||
#@return (nada)
|
||||
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#*/ ##
|
||||
function ogNvramSetTimeout () {
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_Timeout (seg)" \
|
||||
"$FUNCNAME 2"
|
||||
return
|
||||
fi
|
||||
#
|
||||
# Si no es equipo UEFI salir con error
|
||||
ogIsEfiActive || ogRaiseError $OG_ERR_NOTUEFI || return $?
|
||||
|
||||
# Error si no se recibe 1 parámetro.
|
||||
[ $# -eq 1 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_Timeout (seg)" || return $?
|
||||
|
||||
# Comprobamos que sea un número
|
||||
[[ "$1" =~ ^([0-9 ]+)*$ ]] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_Timeout (seg)" || return $?
|
||||
|
||||
# Cambiamos el orden
|
||||
efibootmgr -t $1 &>/dev/null
|
||||
}
|
||||
|
||||
|
||||
#/**
|
||||
# ogUuidChange int_ndisk str_repo
|
||||
#@brief Reemplaza el UUID de un sistema de ficheros.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_part nº de partición
|
||||
#@return (nada, por determinar)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#*/ ##
|
||||
function ogUuidChange () {
|
||||
local MNTDIR DEVICE UUID NEWUUID f
|
||||
|
||||
# Si se solicita, mostrar ayuda.
|
||||
if [ "$*" == "help" ]; then
|
||||
ogHelp "$FUNCNAME" "$FUNCNAME int_ndisk int_part" \
|
||||
"$FUNCNAME 1 2"
|
||||
return
|
||||
fi
|
||||
|
||||
# Error si no se reciben al menos 2 parámetros.
|
||||
[ $# -eq 2 ] || ogRaiseError $OG_ERR_FORMAT "$FUNCNAME int_ndisk int_part" || return $?
|
||||
|
||||
# Comprobamos que exista la partición
|
||||
MNTDIR=$(ogMount $1 $2) || ogRaiseError $OG_ERR_NOTFOUND "Device $1 $2" || return $?
|
||||
DEVICE=$(ogDiskToDev $1 $2)
|
||||
UUID=$(blkid -o value -s UUID $DEVICE)
|
||||
NEWUUID=$(cat /proc/sys/kernel/random/uuid)
|
||||
|
||||
# Cambiamos UUID a la partición
|
||||
ogUnmount $1 $2
|
||||
tune2fs $DEVICE -U $NEWUUID
|
||||
|
||||
# Cambiamos UUID en la configuración (fstab y grub)
|
||||
ogMount $1 $2
|
||||
for f in $MNTDIR/etc/fstab $MNTDIR/{,boot/}{{grubMBR,grubPARTITION}/boot/,}{grub{,2},{,efi/}EFI/*}/{menu.lst,grub.cfg}; do
|
||||
[ -r $f ] && sed -i s/$UUID/$NEWUUID/g $f
|
||||
done
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
Test de comprobacion de la librería Cache.lib y los script relacionados
|
||||
=======================================================================
|
||||
Este test destruye la cache
|
||||
Necesita que las particiones sean tres como máximo
|
||||
=================================================
|
||||
|
||||
$ ogUnmountCache 2>/dev/null ; df|grep cache
|
||||
|
||||
|
||||
$ ogCreateCache 10000000 1>/dev/null 2>&1
|
||||
|
||||
$ AUX=$(ogListPartitions 1) ; echo ${AUX##*CACHE:} | sed s/\ .*\$//g
|
||||
10000000
|
||||
|
||||
# Comprobamos que no esta formateada
|
||||
$ ogCheckFs 1 4
|
||||
OpenGnsys error: ogCheckFs: "1, 4, CACHE"
|
||||
|
||||
$ ogFormatCache|tail -1
|
||||
ReiserFS is successfully created on /dev/sda4.
|
||||
|
||||
$ ogMountCache
|
||||
/opt/opengnsys/cache
|
||||
|
||||
$ echo $OGCAC
|
||||
/opt/opengnsys/cache
|
||||
|
||||
$ touch $OGCAC$OGIMG/lll
|
||||
$ ls $OGCAC$OGIMG
|
||||
lll
|
||||
|
||||
$ rm $OGCAC$OGIMG/lll
|
||||
|
||||
$ ogFindCache
|
||||
1 4
|
||||
|
||||
$ ogGetCacheSize
|
||||
10000000
|
||||
|
||||
|
||||
$ ogDeleteCache >/dev/null 2>&1
|
||||
$ ogFindCache
|
||||
|
||||
$ initCache 2000000 1>/dev/null 2>&1
|
||||
$ touch $OGCAC$OGIMG/lll
|
||||
$ ls $OGCAC$OGIMG
|
||||
lll
|
||||
|
||||
$ rm $OGCAC$OGIMG/lll
|
||||
|
||||
#################################################33
|
||||
# No permite unicast
|
||||
#################################################33
|
||||
#$ echo ooo > $OGCAC$OGIMG/_test_.img
|
||||
#$ echo jjjjjjjjjjjjjjjjjjjjjjjjjjjjjj > $OGIMG/_test_.img
|
||||
#$ touch $OGIMG/_test_.torrent
|
||||
#$ updateCache REPO _test_ UNICAST
|
||||
|
||||
|
||||
Comprobamos los errores de las entradas de datos
|
||||
================================================
|
||||
$ ogCreateCache
|
||||
OpenGnsys error: ogCreateCache: ""
|
||||
|
||||
$ ogCreateCache -1
|
||||
OpenGnsys error: ogCreateCache: "-1"
|
||||
|
||||
$ ogCreateCache 0
|
||||
OpenGnsys error: ogCreateCache: "0"
|
||||
|
||||
# cuando se está usando la cuarta partitión no debe crearse la cache
|
||||
#$ ogCreatePartition 1 NTFS:200000 EXT3:2000000 EXT3:2000000 NTFS:30000000
|
||||
#$ ogListPartitions 1
|
||||
#NTFS:200000 EXT3:2000000 EXT3:2000000 EXTENDED:20000000 LINUX-SWAP:199999
|
||||
#$ ogCreateCache 1000000
|
||||
#$ ogFindCache
|
||||
|
||||
|
||||
# si hay cache no podemos
|
||||
$ ogDeleteCache 1>/dev/null 2>&1
|
||||
$ ogCreatePartitions 1 NTFS:200000 EXT3:2000000 EXT3:2000000 1>/dev/null 2>&1
|
||||
$ ogCreateCache 1000000 1>/dev/null 2>&1
|
||||
$ ogCreatePartitions 1 NTFS:200000 EXT2:2000000 EXT2:2000000 LINUX-SWAP:200000 1>/dev/null 2>&1; echo $?
|
||||
1
|
||||
|
||||
FALTA
|
||||
====
|
||||
ogGetCacheSpace
|
||||
updateCache
|
||||
|
||||
Error
|
||||
=====
|
||||
Al crear la cache no se comprueba si existe una cuarta particion. La machaca
|
|
@ -1,75 +0,0 @@
|
|||
Test de compribación de la libreria File No modifica nada
|
||||
========================================
|
||||
Este test NECESITA LA CACHE
|
||||
|
||||
Comprobamos que existe CACHE
|
||||
$ ls -d $OGCAC$OGIMG # Este test NECESITA LA CACHE ##############################
|
||||
/opt/opengnsys/cache/opt/opengnsys/images
|
||||
|
||||
|
||||
$ ogMakeDir CACHE prueba
|
||||
$ ls -d $OGCAC$OGIMG/prueba
|
||||
/opt/opengnsys/cache/opt/opengnsys/images/prueba
|
||||
|
||||
$ touch $OGCAC$OGIMG/fichero_prueba
|
||||
$ ogCopyFile CACHE fichero_prueba CACHE prueba
|
||||
$ ls $OGCAC$OGIMG/prueba
|
||||
fichero_prueba
|
||||
|
||||
$ ogGetPath CACHE fichero_prueba
|
||||
/opt/opengnsys/cache/opt/opengnsys/images/fichero_prueba
|
||||
|
||||
# Si no existe el fichero
|
||||
$ ogGetPath CACHE fichero_prueba3; echo $?
|
||||
1
|
||||
|
||||
$ ogGetParentPath CACHE fichero_prueba
|
||||
/opt/opengnsys/cache/opt/opengnsys/images
|
||||
|
||||
# si el fichero no existe
|
||||
$ ogGetParentPath CACHE prueba/fichero_prueba3q23
|
||||
/opt/opengnsys/cache/opt/opengnsys/images/prueba
|
||||
|
||||
# Si dir padre no existe
|
||||
$ ogGetParentPath CACHE pruebaNO/fichero_prueba3; echo $?
|
||||
1
|
||||
|
||||
$ AUX=$(ogCalculateChecksum $OGCAC$OGIMG/fichero_prueba); AUX2=$(md5sum $OGCAC$OGIMG/fichero_prueba| cut -f1 -d\ ); if [ "$AUX" == "$AUX2" ]; then echo si; else echo no; fi
|
||||
si
|
||||
|
||||
$ ogCompareChecksumFiles CACHE fichero_prueba CACHE prueba/fichero_prueba; echo $?
|
||||
0
|
||||
|
||||
$ echo 333 >> $OGCAC$OGIMG/fichero_prueba2
|
||||
$ ogMakeChecksumFile CACHE fichero_prueba2
|
||||
$ ls $OGCAC$OGIMG/fichero_prueba2.sum
|
||||
/opt/opengnsys/cache/opt/opengnsys/images/fichero_prueba2.sum
|
||||
|
||||
$ ogMakeChecksumFile CACHE prueba/fichero_prueba
|
||||
$ ogCompareChecksumFiles CACHE fichero_prueba2 CACHE prueba/fichero_prueba; echo $?
|
||||
1
|
||||
|
||||
$ ogIsNewerFile CACHE fichero_prueba2 CACHE prueba/fichero_prueba; echo $?
|
||||
0
|
||||
|
||||
$ ogIsNewerFile CACHE prueba/fichero_prueba CACHE fichero_prueba2; echo $?
|
||||
1
|
||||
|
||||
$ ogIsNewerFile CACHE fichero_prueba CACHE prueba/fichero_prueba; echo $?
|
||||
1
|
||||
|
||||
$ ogDeleteTree CACHE prueba
|
||||
$ ls -d $OGCAC$OGIMG/prueba
|
||||
ls: cannot access /opt/opengnsys/cache/opt/opengnsys/images/prueba: No such file or directory
|
||||
|
||||
$ ogDeleteFile CACHE fichero_prueba
|
||||
$ ls $OGCAC$OGIMG/fichero_prueba
|
||||
ls: cannot access /opt/opengnsys/cache/opt/opengnsys/images/fichero_prueba: No such file or directory
|
||||
|
||||
# Limpiamos el directorio
|
||||
$ rm -rf $OGCAC$OGIMG/fichero_prueba2* $OGCAC$OGIMG/prueba2
|
||||
|
||||
|
||||
MEJORAS
|
||||
=======
|
||||
ogCompareChecksumFiles -> si no existen los ficheros de Checksum da verdadero. Deberia dar falso
|
|
@ -1,85 +0,0 @@
|
|||
€jemplo de test de funciones de bloqueo de particiones e imagenes
|
||||
=================================================================
|
||||
# Funciones de bloqueo
|
||||
|
||||
$ ogLock 1 1
|
||||
$ ls /var/lock/lock-dev-sda1
|
||||
/var/lock/lock-dev-sda1
|
||||
|
||||
$ if ogIsLocked 1 1; then echo si; else echo no; fi
|
||||
si
|
||||
|
||||
$ ls /var/lock/lock-dev-sda1
|
||||
/var/lock/lock-dev-sda1
|
||||
|
||||
$ ogUnlock 1 1
|
||||
$ if ogIsLocked 1 1; then echo si; else echo no; fi
|
||||
no
|
||||
|
||||
$ ogLockPartition 1 1
|
||||
$ if ogIsLocked 1 1; then echo si; else echo no; fi
|
||||
si
|
||||
|
||||
$ ogUnlockPartition 1 1
|
||||
$ if ogIsLocked 1 1; then echo si; else echo no; fi
|
||||
no
|
||||
|
||||
|
||||
|
||||
|
||||
# Es necesario desmontar para probar ogCheck
|
||||
$ ogUnmount 1 1 >/dev/null 2>&1
|
||||
|
||||
$ ogLock 1 1
|
||||
|
||||
$ ogCheckFs 1 1
|
||||
OpenGnsys error: ogCheckFs: "1 1"
|
||||
|
||||
$ ogUnlock 1 1
|
||||
|
||||
$ ogCheckFs 1 1 >/dev/null 2>&1; echo $?
|
||||
0
|
||||
|
||||
|
||||
# Bloqueo del repositorio
|
||||
|
||||
$ ogIsRepoLocked; echo $?
|
||||
1
|
||||
|
||||
# FALTA: test bloqueo repo cuando esta bloqueado
|
||||
|
||||
# bloqueo de imagenes
|
||||
|
||||
|
||||
|
||||
# Creo una imagen ficticia
|
||||
$ touch $OGIMG/_test_.img
|
||||
|
||||
$ ogLockImage REPO _test_
|
||||
$ ls $OGIMG/_test_.lock
|
||||
/opt/opengnsys/images/_test_.lock
|
||||
|
||||
$ if ogIsImageLocked REPO _test_ ; then echo si; else echo no; fi
|
||||
si
|
||||
|
||||
$ ogUnlockImage REPO _test_
|
||||
$ if ogIsImageLocked REPO _test_ ; then echo si; else echo no; fi
|
||||
no
|
||||
|
||||
$ rm $OGIMG/_test_.*
|
||||
|
||||
# Comprobando los errores (FALTA)
|
||||
$ ogLock
|
||||
OpenGnsys error: ogLockPartition: ""
|
||||
|
||||
|
||||
$ ogLock 1 10
|
||||
OpenGnsys error: ogDiskToDev: ""
|
||||
|
||||
|
||||
$ ogIsLocked
|
||||
OpenGnsys error: ogIsLocked: ""
|
||||
|
||||
$ ogIsLocked 1 10
|
||||
OpenGnsys error: ogDiskToDev: ""
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
Test para la librería Net.lib No modifica
|
||||
=========================================
|
||||
$ if [ "$(ogGetHostname)" == "$(hostname)" ] ; then echo si; else echo no; fi
|
||||
si
|
||||
|
||||
$ if [ "$(ogGetNetInterface)" == "$(ifconfig|head -1|cut -d\ -f1 )" ]; then echo si; else echo no; fi
|
||||
si
|
||||
|
||||
$ AUX=$(ifconfig eth0|grep 'inet addr'|cut -dB -f1|sed s/\ //g); if [ "$(ogGetIpAddress)" == "${AUX#*:}" ]; then echo si; else echo no; fi
|
||||
si
|
||||
|
||||
$ AUX=$(ifconfig |head -1|sed s/\ //g| tr '[a-z]' '[A-Z]'); if [ "$(ogGetMacAddress)" == "${AUX##*HWADDR}" ]; then echo si; else echo no; fi
|
||||
si
|
||||
|
||||
$ AUX=$(df|grep $OGIMG); if [ "//$(ogGetRepoIp)" == "${AUX%/ogimages*}" ]; then echo si; else echo no; fi
|
||||
si
|
||||
|
||||
$ AUX=$(df|grep $OGIMG); if [ "//$(ogGetServerIp)" == "${AUX%/ogimages*}" ]; then echo si; else echo no; fi
|
||||
si
|
||||
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
Separamos los test que no modifican el cliente y los que sí lo hacen (pueden modificar la partitiones, imagenes, etc) en dos directorios distintos.
|
||||
|
||||
Ademas los numeramos diferentes por si los queremos mover de sitio:
|
||||
Los test acabados en 1x no modifican nada
|
||||
Los test acabados en 2x modifican el cliente
|
||||
|
|
@ -1,160 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Descripcion: Crea un test no destructivo de la libreria Disk.lib conficurandolo
|
||||
# para un cliente concreto.
|
||||
# Se ejecuta en el servidor y el test creado se utiliza en el cliente
|
||||
# Los datos los toma de la base de administración.
|
||||
# Uso: creaTestDisk1 NombreCliente
|
||||
#
|
||||
# Falta: la bd no tiene información de las particiones lógicas (el script sí esta preparado para ellas)
|
||||
# la bd no tiene datos del tamaño del disco
|
||||
|
||||
|
||||
# Variables.
|
||||
PROG=$(basename $0)
|
||||
OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
|
||||
SERVERCONF=$OPENGNSYS/etc/ogAdmServer.cfg
|
||||
TESTDIR="$OPENGNSYS/client/lib/engine/tests/NoModify"
|
||||
TESTFILE="$TESTDIR/Disk1-$1.shtest "
|
||||
# Control básico de errores.
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "$PROG: Error de ejecución"
|
||||
echo "Formato: $PROG NOMBRE_PC"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Obtener datos de acceso a la Base de datos.
|
||||
source $SERVERCONF
|
||||
|
||||
# Comprobar si se recibe nombre de aula o de equipo.
|
||||
PARTICIONES=$(mysql -u "$USUARIO" -p"$PASSWORD" -D "$CATALOG" -N -e \
|
||||
"SELECT ordenadores_particiones.numpar, tipospar.tipopar, ordenadores_particiones.tamano
|
||||
FROM tipospar INNER JOIN ordenadores_particiones INNER JOIN ordenadores
|
||||
WHERE tipospar.codpar=ordenadores_particiones.codpar
|
||||
AND ordenadores.idordenador=ordenadores_particiones.idordenador
|
||||
AND nombreordenador='$1'
|
||||
ORDER By ordenadores_particiones.numpar;")
|
||||
# Si la cadena esta vacia, error
|
||||
if [ -z "$PARTICIONES" ]; then
|
||||
echo "El equipo $1 no existe en la base de datos"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Ejemplo para añadir partitiones lógicas
|
||||
#PARTICIONES="$PARTICIONES 5 LINUX-SWAP 1999999"
|
||||
PRI=$( echo ${PARTICIONES%%\ 5\ *}|awk '{print $2"_"$3" "$5"_"$6" "$8"_"$9" "$11"_"$12}' |sed s/\ _//g |sed s/\ //g)
|
||||
|
||||
if $(echo $PARTICIONES |grep " 5 " >/dev/null); then
|
||||
LOG=$( echo ${PARTICIONES##*\ 5\ }|awk '{print $1"_"$2" "$4"_"$5" "$7"_"$8" "$10"_"$11" "}' |sed s/\ _//g |sed s/\ //g)
|
||||
else
|
||||
LOG=""
|
||||
fi
|
||||
AUX=$(echo $PARTICIONES| wc -w)
|
||||
let NUMPART=AUX/3
|
||||
P1SIZE=$(echo $PARTICIONES|cut -d\ -f3)
|
||||
P1TYPE=$(echo $PARTICIONES|cut -d\ -f2)
|
||||
case "$P1TYPE" in
|
||||
EMPTY) P1ID=0 ;;
|
||||
FAT12) P1ID=1 ;;
|
||||
EXTENDED) P1ID=5 ;;
|
||||
FAT16) P1ID=6 ;;
|
||||
NTFS|EXFAT) P1ID=7 ;;
|
||||
FAT32) P1ID=b ;;
|
||||
HFAT12) P1ID=11 ;;
|
||||
HFAT16) P1ID=16 ;;
|
||||
HNTFS) P1ID=17 ;;
|
||||
HFAT32) P1ID=1b ;;
|
||||
LINUX-SWAP) P1ID=82 ;;
|
||||
EXT[234]|REISERFS|REISER4|XFS|JFS)
|
||||
P1ID=83 ;;
|
||||
LINUX-LVM) P1ID=8e ;;
|
||||
SOLARIS) P1ID=bf ;;
|
||||
CACHE) P1ID=ca ;;
|
||||
LINUX-RAP1ID) P1ID=fd ;;
|
||||
*) P1ID="" ;;
|
||||
esac
|
||||
|
||||
cat > $TESTFILE << EOF
|
||||
Ejemplo de test funciones de particionado no destrutivo
|
||||
=======================================================
|
||||
|
||||
# Desmontamos antes de empezar
|
||||
$ ogUnmountAll 1 2>/dev/null
|
||||
|
||||
$ ogUnmountCache 2>/dev/null
|
||||
|
||||
# Cambio de formato
|
||||
|
||||
$ ogDevToDisk /dev/sda
|
||||
1
|
||||
|
||||
$ ogDevToDisk /dev/sda1
|
||||
1 1
|
||||
|
||||
$ ogDiskToDev
|
||||
/dev/sda
|
||||
|
||||
$ ogDiskToDev 1
|
||||
/dev/sda
|
||||
|
||||
$ ogDiskToDev 1 1
|
||||
/dev/sda1
|
||||
|
||||
$ ogTypeToId NTFS
|
||||
7
|
||||
|
||||
$ ogTypeToId LINUX
|
||||
83
|
||||
|
||||
$ ogTypeToId LINUX GPT
|
||||
8300
|
||||
|
||||
|
||||
# Tamaño de disco (cuando haya informacion en la base de datos)
|
||||
|
||||
#$ ogGetDiskSize 1
|
||||
#312571224
|
||||
|
||||
# Tamaño de la particion
|
||||
|
||||
$ ogGetPartitionSize 1 1
|
||||
$P1SIZE
|
||||
|
||||
# Información de las particiones
|
||||
$ ogListPartitions 1 | tr : _ | sed s/EXT[234]/LINUX/g | sed s/\ //g
|
||||
$PRI$LOG
|
||||
$ ogListPrimaryPartitions 1 | tr : _ | sed s/EXT[234]/LINUX/g | sed s/\ //g
|
||||
$PRI
|
||||
|
||||
$ ogListLogicalPartitions 1 | tr : _ | sed s/EXT[234]/LINUX/g
|
||||
$LOG
|
||||
|
||||
$ ogGetPartitionsNumber
|
||||
$NUMPART
|
||||
|
||||
# Partición activa
|
||||
|
||||
$ ogSetPartitionActive 1 2 >/dev/null
|
||||
$ ogGetPartitionActive 1
|
||||
2
|
||||
|
||||
$ ogSetPartitionActive 1 1 >/dev/null
|
||||
$ ogGetPartitionActive 1
|
||||
1
|
||||
|
||||
|
||||
# Tipo de particiones
|
||||
|
||||
$ ogGetPartitionId 1 1
|
||||
$P1ID
|
||||
|
||||
|
||||
# Montamos la cache al final
|
||||
$ ogMountCache >/dev/null 2>&1
|
||||
|
||||
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
echo "Test creado en $TESTFILE"
|
||||
echo "Las particiones logicas hay que incluirlas a mano, porque no hay información de las mismas en la base de datos."
|
|
@ -1,82 +0,0 @@
|
|||
#!/bin/bash
|
||||
# Descripcion: Crea un test DESTRUCTIVO de los bloqueos de particiones y de imagenes
|
||||
# Se ejecuta en el servidor y el test creado se utiliza en el cliente
|
||||
# La imagen de prueba puede sufrir daños
|
||||
# Uso: creaTestLock2 NombreImagen
|
||||
|
||||
# Variables.
|
||||
PROG=$(basename $0)
|
||||
OPENGNSYS=${OPENGNSYS:-"/opt/opengnsys"}
|
||||
SERVERCONF=$OPENGNSYS/etc/ogAdmServer.cfg
|
||||
TESTDIR="$OPENGNSYS/client/lib/engine/tests/Modify"
|
||||
TESTFILE="$TESTDIR/Lock2-img$1.shtest "
|
||||
# Control básico de errores.
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "$PROG: Error de ejecución"
|
||||
echo "Formato: $PROG NOMBRE_IMAGEN"
|
||||
echo " La imagen de prueba puede sufrir daños"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
IMG=$1
|
||||
|
||||
cat > $TESTFILE << EOF
|
||||
Test de bloqueos Destructivos
|
||||
=============================================================================
|
||||
# Bloqueo de particiones
|
||||
$ ogUnmountAll 1 2>/dev/null
|
||||
|
||||
$ ogLock 1 1
|
||||
|
||||
$ ogExtendFs 1 1
|
||||
OpenGnsys error: ogExtendFs: "1 1"
|
||||
|
||||
|
||||
$ ogFormatFs 1 1
|
||||
OpenGnsys error: ogFormatFs: "1 1"
|
||||
|
||||
#############################################################################
|
||||
# Los dos comandos siguientes dan error. Los comentamos por ahora
|
||||
#############################################################################
|
||||
#$ ogMount 1 1
|
||||
|
||||
#$ ogUnmount 1 1; df|grep sda1
|
||||
|
||||
$ ogUnlock 1 1
|
||||
|
||||
$ ogExtendFs 1 1 >/dev/null 2>&1; echo $?
|
||||
0
|
||||
|
||||
$ ogFormatFs 1 1 >/dev/null 2>&1; echo $?
|
||||
0
|
||||
|
||||
$ ogMount 1 1
|
||||
/mnt/sda1
|
||||
|
||||
$ ogUnmount 1 1; df|grep sda1
|
||||
|
||||
# Bloqueo de imagenes
|
||||
#############################################################################
|
||||
# Los tres comandos siguientes dan error. Los comentamos por ahora
|
||||
#############################################################################
|
||||
#$ ogLockImage REPO $IMG
|
||||
|
||||
#$ ogRestoreImage REPO $IMG 1 1 >/dev/null 2>&1; echo $?
|
||||
|
||||
#$ ogCreateImage 1 1 REPO $IMG >/dev/null 2>&1; echo $?
|
||||
|
||||
|
||||
$ ogUnlockImage REPO $IMG
|
||||
|
||||
# Lo mismo con la imagen desbloqueada.
|
||||
|
||||
$ ogRestoreImage REPO $IMG 1 1 >/dev/null 2>&1; echo $?
|
||||
0
|
||||
|
||||
$ ogCreateImage 1 1 REPO $IMG >/dev/null 2>&1; echo $?
|
||||
0
|
||||
EOF
|
||||
|
||||
echo "Test creado en $TESTFILE"
|
||||
echo " La imagen de $IMG prueba puede quedar dañada despues de realizar el test"
|
||||
echo " Hay cinco comandos comentados porque por ahora dan error"
|
|
@ -1,10 +1,8 @@
|
|||
#/**
|
||||
#@file BootLib.py
|
||||
##@file BootLib.py
|
||||
#@brief Librería o clase Boot
|
||||
#@class Boot
|
||||
#@brief Funciones para arranque y post-configuración de sistemas de archivos.
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
import os
|
||||
import re
|
||||
|
@ -24,8 +22,7 @@ import FileLib
|
|||
import UEFILib
|
||||
import CacheLib
|
||||
|
||||
#/**
|
||||
# ogBoot int_ndisk int_nfilesys [ NVRAMPERM ] [str_kernel str_initrd str_krnlparams]
|
||||
## ogBoot int_ndisk int_nfilesys [ NVRAMPERM ] [str_kernel str_initrd str_krnlparams]
|
||||
#@brief Inicia el proceso de arranque de un sistema de archivos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -38,7 +35,6 @@ import CacheLib
|
|||
#@exception OG_ERR_NOTOS La partición no tiene instalado un sistema operativo.
|
||||
#@note En Linux, si no se indican los parámetros de arranque se detectan de la opción por defecto del cargador GRUB.
|
||||
#@note En Linux, debe arrancarse la partición del directorio \c /boot
|
||||
#*/ ##
|
||||
def ogBoot (disk, par, nvramperm=False, params=''):
|
||||
# Detectar tipo de sistema de archivos y montarlo.
|
||||
part = DiskLib.ogDiskToDev (disk, par)
|
||||
|
@ -228,8 +224,7 @@ def ogBoot (disk, par, nvramperm=False, params=''):
|
|||
return None
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetWindowsName int_ndisk int_nfilesys
|
||||
## ogGetWindowsName int_ndisk int_nfilesys
|
||||
#@brief Muestra el nombre del equipo en el registro de Windows.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -237,7 +232,6 @@ def ogBoot (disk, par, nvramperm=False, params=''):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#*/ ##
|
||||
def ogGetWindowsName (disk, par):
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
if not mntdir: return None
|
||||
|
@ -246,8 +240,7 @@ def ogGetWindowsName (disk, par):
|
|||
return RegistryLib.ogGetRegistryValue (mntdir, 'system', r'\ControlSet001\Control\ComputerName\ComputerName\ComputerName')
|
||||
|
||||
|
||||
#/**
|
||||
# ogLinuxBootParameters int_ndisk int_nfilesys
|
||||
## ogLinuxBootParameters int_ndisk int_nfilesys
|
||||
#@brief Muestra los parámetros de arranque de un sistema de archivos Linux.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -256,7 +249,6 @@ def ogGetWindowsName (disk, par):
|
|||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#@warning Función básica usada por \c ogBoot
|
||||
#*/ ##
|
||||
def ogLinuxBootParameters (disk, par):
|
||||
# Detectar id. de tipo de partición y codificar al mnemonico.
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
|
@ -305,8 +297,7 @@ def ogLinuxBootParameters (disk, par):
|
|||
return awk_out
|
||||
|
||||
|
||||
#/**
|
||||
# ogSetWindowsName int_ndisk int_nfilesys str_name
|
||||
## ogSetWindowsName int_ndisk int_nfilesys str_name
|
||||
#@brief Establece el nombre del equipo en el registro de Windows.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -316,7 +307,6 @@ def ogLinuxBootParameters (disk, par):
|
|||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#@exception OG_ERR_OUTOFLIMIT Nombre Netbios con más de 15 caracteres.
|
||||
#*/ ##
|
||||
def ogSetWindowsName (disk, par, name):
|
||||
if len (name) > 15:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_OUTOFLIMIT, f'"{name[0:15]}..."')
|
||||
|
@ -335,8 +325,7 @@ def ogSetWindowsName (disk, par, name):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogSetWinlogonUser int_ndisk int_npartition str_username
|
||||
## ogSetWinlogonUser int_ndisk int_npartition str_username
|
||||
#@brief Establece el nombre de usuario por defecto en la entrada de Windows.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -345,37 +334,30 @@ def ogSetWindowsName (disk, par, name):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#*/ ##
|
||||
def ogSetWinlogonUser (disk, par, username):
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
if not mntdir: return None
|
||||
RegistryLib.ogSetRegistryValue (mntdir, 'SOFTWARE', r'\Microsoft\Windows NT\CurrentVersion\Winlogon\DefaultUserName', username)
|
||||
|
||||
|
||||
#/**
|
||||
# ogBootMbrXP int_ndisk
|
||||
## ogBootMbrXP int_ndisk
|
||||
#@brief Genera un nuevo Master Boot Record en el disco duro indicado, compatible con los SO tipo Windows
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return salida del programa my-sys
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#*/ ##
|
||||
|
||||
def ogBootMbrXP (disk):
|
||||
DISK = DiskLib.ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
subprocess.run (['ms-sys', '-z', '-f', DISK])
|
||||
subprocess.run (['ms-sys', '-m', '-f', DISK])
|
||||
|
||||
#/**
|
||||
# ogBootMbrGeneric int_ndisk
|
||||
## ogBootMbrGeneric int_ndisk
|
||||
#@brief Genera un nuevo Codigo de arranque en el MBR del disco indicado, compatible con los SO tipo Windows, Linux.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return salida del programa my-sys
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Tipo de partición desconocido o no se puede montar.
|
||||
#*/ ##
|
||||
|
||||
def ogBootMbrGeneric (disk):
|
||||
DISK = DiskLib.ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
|
@ -390,15 +372,12 @@ def ogBootMbrGeneric (disk):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogFixBootSector int_ndisk int_parition
|
||||
## ogFixBootSector int_ndisk int_parition
|
||||
#@brief Corrige el boot sector de una particion activa para MS windows/dos -fat-ntfs
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_partition nº de particion
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#*/ ##
|
||||
def ogFixBootSector (disk, par):
|
||||
partype = DiskLib.ogGetPartitionId (disk, par)
|
||||
if partype not in [ '1', '4', '6', '7', 'b', 'c', 'e', 'f', '17', '700', 'EF00' ]:
|
||||
|
@ -422,29 +401,23 @@ fix_first_sector=yes
|
|||
os.remove (tmpfile)
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetBootMbr int_ndisk
|
||||
## ogGetBootMbr int_ndisk
|
||||
#@brief Obtiene el contenido del sector de arranque de un disco.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return str_MBR Descripción del contenido del MBR.
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Dispositivo de disco no encontrado.
|
||||
#*/ ##
|
||||
def ogGetBootMbr (disk):
|
||||
DISK = DiskLib.ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
subprocess.run (['ms-sys', '-f', DISK])
|
||||
|
||||
#/**
|
||||
# ogWindowsBootParameters int_ndisk int_parition
|
||||
## ogWindowsBootParameters int_ndisk int_parition
|
||||
#@brief Configura el gestor de arranque de windows 7 / vista / XP / 2000
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_partition nº de particion
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#*/ ##
|
||||
|
||||
def ogWindowsBootParameters (disk, par):
|
||||
if not DiskLib.ogDiskToDev (disk, par):
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_PARTITION, '')
|
||||
|
@ -498,7 +471,7 @@ def ogWindowsBootParameters (disk, par):
|
|||
return
|
||||
|
||||
|
||||
#Preparando instruccion Windows Resume Application
|
||||
#Preparando instruccion Windows Resume Application
|
||||
with open (tmpfile, 'w') as fd:
|
||||
fd.write (f"""boot_disk={bootdisk}
|
||||
boot_main_part={bootpar}
|
||||
|
@ -510,7 +483,7 @@ boot_entry=Windows Resume Application
|
|||
subprocess.run (['timeout', '--foreground', '--signal=SIGKILL', '5s', 'spartlnx.run', '-cui', '-nm', '-w', '-f', tmpfile], stdin=subprocess.DEVNULL)
|
||||
|
||||
|
||||
#Preparando instruccion tipo windows
|
||||
#Preparando instruccion tipo windows
|
||||
with open (tmpfile, 'w') as fd:
|
||||
fd.write (f"""boot_disk={bootdisk}
|
||||
boot_main_part={bootpar}
|
||||
|
@ -521,7 +494,7 @@ boot_entry={winver}
|
|||
""")
|
||||
subprocess.run (['timeout', '--foreground', '--signal=SIGKILL', '5s', 'spartlnx.run', '-cui', '-nm', '-w', '-f', tmpfile], stdin=subprocess.DEVNULL)
|
||||
|
||||
##Preparando instruccion Ramdisk Options
|
||||
##Preparando instruccion Ramdisk Options
|
||||
with open (tmpfile, 'w') as fd:
|
||||
fd.write (f"""boot_disk={bootdisk}
|
||||
boot_main_part={bootpar}
|
||||
|
@ -532,7 +505,7 @@ boot_entry=Ramdisk Options
|
|||
""")
|
||||
subprocess.run (['timeout', '--foreground', '--signal=SIGKILL', '5s', 'spartlnx.run', '-cui', '-nm', '-w', '-f', tmpfile], stdin=subprocess.DEVNULL)
|
||||
|
||||
##Preparando instruccion Recovery Environment
|
||||
##Preparando instruccion Recovery Environment
|
||||
with open (tmpfile, 'w') as fd:
|
||||
fd.write (f"""boot_disk={bootdisk}
|
||||
boot_main_part={bootpar}
|
||||
|
@ -543,7 +516,7 @@ boot_entry=Windows Recovery Environment
|
|||
""")
|
||||
subprocess.run (['timeout', '--foreground', '--signal=SIGKILL', '5s', 'spartlnx.run', '-cui', '-nm', '-w', '-f', tmpfile], stdin=subprocess.DEVNULL)
|
||||
|
||||
##Preparando instruccion Recovery
|
||||
##Preparando instruccion Recovery
|
||||
with open (tmpfile, 'w') as fd:
|
||||
fd.write (f"""boot_disk={bootdisk}
|
||||
boot_main_part={bootpar}
|
||||
|
@ -554,7 +527,7 @@ boot_entry=Windows Recovery
|
|||
""")
|
||||
subprocess.run (['timeout', '--foreground', '--signal=SIGKILL', '5s', 'spartlnx.run', '-cui', '-nm', '-w', '-f', tmpfile], stdin=subprocess.DEVNULL)
|
||||
|
||||
#Preparando instruccion Windows Boot Manager
|
||||
#Preparando instruccion Windows Boot Manager
|
||||
with open (tmpfile, 'w') as fd:
|
||||
fd.write (f"""boot_disk={bootdisk}
|
||||
boot_main_part={bootpar}
|
||||
|
@ -565,7 +538,7 @@ boot_entry=Windows Boot Manager
|
|||
""")
|
||||
subprocess.run (['timeout', '--foreground', '--signal=SIGKILL', '5s', 'spartlnx.run', '-cui', '-nm', '-w', '-f', tmpfile], stdin=subprocess.DEVNULL)
|
||||
|
||||
#Preparando instruccion Herramienta de diagnóstico de memoria de Windows
|
||||
#Preparando instruccion Herramienta de diagnóstico de memoria de Windows
|
||||
with open (tmpfile, 'w') as fd:
|
||||
fd.write (f"""boot_disk={bootdisk}
|
||||
boot_main_part={bootpar}
|
||||
|
@ -576,7 +549,7 @@ boot_entry=Herramienta de diagnóstico de memoria de Windows
|
|||
""")
|
||||
subprocess.run (['timeout', '--foreground', '--signal=SIGKILL', '5s', 'spartlnx.run', '-cui', '-nm', '-w', '-f', tmpfile], stdin=subprocess.DEVNULL)
|
||||
|
||||
#Preparando instruccion Herramienta de diagnóstico de memoria de Windows
|
||||
#Preparando instruccion Herramienta de diagnóstico de memoria de Windows
|
||||
with open (tmpfile, 'w') as fd:
|
||||
fd.write (f"""boot_disk={bootdisk}
|
||||
boot_main_part={bootpar}
|
||||
|
@ -591,20 +564,17 @@ boot_entry=Herramienta de diagn<f3>stico de memoria de Windows
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogWindowsRegisterPartition int_ndisk int_partiton str_volume int_disk int_partition
|
||||
## ogWindowsRegisterPartition int_ndisk int_partiton str_volume int_disk int_partition
|
||||
#@brief Registra una partición en windows con un determinado volumen.
|
||||
#@param int_ndisk nº de orden del disco a registrar
|
||||
#@param int_partition nº de particion a registrar
|
||||
#@param str_volumen volumen a resgistar
|
||||
#@param int_ndisk_windows nº de orden del disco donde esta windows
|
||||
#@param int_partition_windows nº de particion donde esta windows
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#*/ ##
|
||||
#ogWindowsRegisterPartition ("1", "1", "c:", "1", "1")
|
||||
def ogWindowsRegisterPartition (registered_disk, registered_par, registered_vol, disk, par):
|
||||
#ogWindowsRegisterPartition ("1", "1", "c:", "1", "1")
|
||||
registered_vol = registered_vol[0].upper()
|
||||
tmpfile = tempfile.NamedTemporaryFile (prefix='ogWRP-', mode='w').name
|
||||
|
||||
|
@ -649,19 +619,15 @@ part_letter={registered_vol}
|
|||
os.remove (tmpfile)
|
||||
|
||||
|
||||
#/**
|
||||
# ogGrubInstallMbr int_disk_GRUBCFG int_partition_GRUBCFG
|
||||
## ogGrubInstallMbr int_disk_GRUBCFG int_partition_GRUBCFG
|
||||
#@brief Instala el grub el el MBR del primer disco duro (FIRSTSTAGE). El fichero de configuración grub.cfg ubicado según parametros disk y part(SECONDSTAGE). Admite sistemas Windows.
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default]
|
||||
#@return
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default]
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#*/ ##
|
||||
|
||||
#ogGrubInstallMbr ('1', '1', 'FALSE')
|
||||
#ogGrubInstallMbr ('1', '1', 'TRUE', 'nomodeset irqpoll pci=noacpi quiet splash')
|
||||
def ogGrubInstallMbr (disk, par, checkos='FALSE', kernelparam=''):
|
||||
#ogGrubInstallMbr ('1', '1', 'FALSE')
|
||||
#ogGrubInstallMbr ('1', '1', 'TRUE', 'nomodeset irqpoll pci=noacpi quiet splash')
|
||||
backupname = '.backup.og'
|
||||
|
||||
#error si no es linux.
|
||||
|
@ -764,20 +730,16 @@ def ogGrubInstallMbr (disk, par, checkos='FALSE', kernelparam=''):
|
|||
return not eval ## negate shell success code
|
||||
|
||||
|
||||
#/**
|
||||
# ogGrubInstallPartition int_disk_SECONDSTAGE int_partition_SECONDSTAGE bolean_Check_Os_installed_and_Configure_2ndStage
|
||||
## ogGrubInstallPartition int_disk_SECONDSTAGE int_partition_SECONDSTAGE bolean_Check_Os_installed_and_Configure_2ndStage
|
||||
#@brief Instala y actualiza el gestor grub en el bootsector de la particion indicada
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default]
|
||||
#@param str "kernel param "
|
||||
#@return
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default]
|
||||
#@param str "kernel param "
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#*/ ##
|
||||
|
||||
#ogGrubInstallPartition ('1', '1', 'FALSE')
|
||||
#ogGrubInstallPartition ('1', '1', 'TRUE', 'nomodeset irqpoll pci=noacpi quiet splash')
|
||||
def ogGrubInstallPartition (disk, par, checkos='FALSE', kernelparam=''):
|
||||
#ogGrubInstallPartition ('1', '1', 'FALSE')
|
||||
#ogGrubInstallPartition ('1', '1', 'TRUE', 'nomodeset irqpoll pci=noacpi quiet splash')
|
||||
backupname = '.backup.og'
|
||||
|
||||
#error si no es linux.
|
||||
|
@ -843,7 +805,7 @@ def ogGrubInstallPartition (disk, par, checkos='FALSE', kernelparam=''):
|
|||
with open (f'{secondstage}{prefixsecondstage}/boot/grub/grub.cfg', 'a') as fd:
|
||||
fd.write (out + '\n')
|
||||
|
||||
#Instalar el grub
|
||||
#Instalar el grub
|
||||
eval = subprocess.run (['grub-install', '--force'] + efioptgrub + [f'--root-directory={secondstage}{prefixsecondstage}', firststage]).returncode
|
||||
|
||||
# Movemos el grubx64.efi
|
||||
|
@ -860,16 +822,14 @@ def ogGrubInstallPartition (disk, par, checkos='FALSE', kernelparam=''):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogConfigureFstab int_ndisk int_nfilesys
|
||||
#@brief Configura el fstab según particiones existentes
|
||||
## ogConfigureFstab int_ndisk int_nfilesys
|
||||
#@brief Configura el fstab según particiones existentes
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND No se encuentra el fichero fstab a procesar.
|
||||
#@warning Puede haber un error si hay más de 1 partición swap.
|
||||
#*/ ##
|
||||
def ogConfigureFstab (disk, par):
|
||||
fstab = FileLib.ogGetPath (src=f'{disk} {par}', file='/etc/fstab')
|
||||
if not fstab:
|
||||
|
@ -927,8 +887,7 @@ def ogConfigureFstab (disk, par):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogSetLinuxName int_ndisk int_nfilesys [str_name]
|
||||
## ogSetLinuxName int_ndisk int_nfilesys [str_name]
|
||||
#@brief Establece el nombre del equipo en los ficheros hostname y hosts.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -938,7 +897,6 @@ def ogConfigureFstab (disk, par):
|
|||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#@note Si no se indica nombre, se asigna un valor por defecto.
|
||||
#*/ ##
|
||||
def ogSetLinuxName (disk, par, hostname='pc'):
|
||||
# Montar el sistema de archivos.
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
|
@ -947,12 +905,12 @@ def ogSetLinuxName (disk, par, hostname='pc'):
|
|||
etc = FileLib.ogGetPath (src=f'{disk} {par}', file='/etc')
|
||||
|
||||
if os.path.isdir (etc):
|
||||
#cambio de nombre en hostname
|
||||
#cambio de nombre en hostname
|
||||
with open (f'{etc}/hostname', 'w') as fd:
|
||||
fd.write (f'{hostname}\n')
|
||||
#Opcion A para cambio de nombre en hosts
|
||||
#sed "/127.0.1.1/ c\127.0.1.1 \t $HOSTNAME" $ETC/hosts > /tmp/hosts && cp /tmp/hosts $ETC/ && rm /tmp/hosts
|
||||
#Opcion B componer fichero de hosts
|
||||
#Opcion A para cambio de nombre en hosts
|
||||
#sed "/127.0.1.1/ c\127.0.1.1 \t $HOSTNAME" $ETC/hosts > /tmp/hosts && cp /tmp/hosts $ETC/ && rm /tmp/hosts
|
||||
#Opcion B componer fichero de hosts
|
||||
with open (f'{etc}/hosts', 'w') as fd:
|
||||
fd.write ('127.0.0.1 localhost\n')
|
||||
fd.write (f'127.0.1.1 {hostname}\n')
|
||||
|
@ -966,8 +924,7 @@ def ogSetLinuxName (disk, par, hostname='pc'):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogCleanLinuxDevices int_ndisk int_nfilesys
|
||||
## ogCleanLinuxDevices int_ndisk int_nfilesys
|
||||
#@brief Limpia los dispositivos del equipo de referencia. Interfaz de red ...
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -975,9 +932,8 @@ def ogSetLinuxName (disk, par, hostname='pc'):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#*/ ##
|
||||
#ogCleanLinuxDevices (1, 1)
|
||||
def ogCleanLinuxDevices (disk, par):
|
||||
#ogCleanLinuxDevices (1, 1)
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
if not mntdir: return None
|
||||
|
||||
|
@ -988,8 +944,7 @@ def ogCleanLinuxDevices (disk, par):
|
|||
if os.path.exists (f'{mntdir}/etc/initramfs-tools/conf.d/resume'):
|
||||
os.unlink ( f'{mntdir}/etc/initramfs-tools/conf.d/resume')
|
||||
|
||||
#/**
|
||||
# ogGrubAddOgLive num_disk num_part [ timeout ] [ offline ]
|
||||
## ogGrubAddOgLive num_disk num_part [ timeout ] [ offline ]
|
||||
#@brief Crea entrada de menu grub para ogclient, tomando como paramentros del kernel los actuales del cliente.
|
||||
#@param 1 Numero de disco
|
||||
#@param 2 Numero de particion
|
||||
|
@ -1000,9 +955,6 @@ def ogCleanLinuxDevices (disk, par):
|
|||
#@exception OG_ERR_NOTFOUND No existe kernel o initrd en cache.
|
||||
#@exception OG_ERR_NOTFOUND No existe archivo de configuracion del grub.
|
||||
# /// FIXME: Solo para el grub instalado en MBR por Opengnsys, ampliar para más casos.
|
||||
#*/ ##
|
||||
|
||||
|
||||
def ogGrubAddOgLive (disk, par, timeout=None, offline=''):
|
||||
oglivedir = os.environ.get ('oglivedir', 'ogLive')
|
||||
# Error si no existe el kernel y el initrd en la cache.
|
||||
|
@ -1078,16 +1030,13 @@ def ogGrubAddOgLive (disk, par, timeout=None, offline=''):
|
|||
if timeout:
|
||||
subprocess.run (['sed', '-i', f's/timeout=.*$/timeout={timeout}/g', grubcfg])
|
||||
|
||||
#/**
|
||||
# ogGrubHidePartitions num_disk num_part
|
||||
## ogGrubHidePartitions num_disk num_part
|
||||
#@brief ver ogBootLoaderHidePartitions
|
||||
#@see ogBootLoaderHidePartitions
|
||||
#*/ ##
|
||||
def ogGrubHidePartitions (disk, par, datadisk=None, datapar=None):
|
||||
return ogBootLoaderHidePartitions (disk, par, datadisk, datapar)
|
||||
|
||||
#/**
|
||||
# ogBootLoaderHidePartitions num_disk num_part
|
||||
## ogBootLoaderHidePartitions num_disk num_part
|
||||
#@brief Configura el grub/burg para que oculte las particiones de windows que no se esten iniciando.
|
||||
#@param 1 Numero de disco
|
||||
#@param 2 Numero de particion
|
||||
|
@ -1096,8 +1045,6 @@ def ogGrubHidePartitions (disk, par, datadisk=None, datapar=None):
|
|||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception No existe archivo de configuracion del grub/burg.
|
||||
#*/
|
||||
|
||||
def ogBootLoaderHidePartitions (disk, par, datadisk=None, datapar=None):
|
||||
# Nombre de la función que llama a esta.
|
||||
func = inspect.stack()[1][3]
|
||||
|
@ -1174,16 +1121,14 @@ def ogBootLoaderHidePartitions (disk, par, datadisk=None, datapar=None):
|
|||
subprocess.run (['sed', '-i', f'{line}a\\ {text}', cfgfile])
|
||||
# Activamos la particion que se inicia en todas las entradas de windows.
|
||||
subprocess.run (['sed', '-i', '/chainloader/i\\\tparttool ${root} boot+', cfgfile])
|
||||
#/**
|
||||
# ogGrubDeleteEntry num_disk num_part num_disk_delete num_part_delete
|
||||
|
||||
## ogGrubDeleteEntry num_disk num_part num_disk_delete num_part_delete
|
||||
#@brief ver ogBootLoaderDeleteEntry
|
||||
#@see ogBootLoaderDeleteEntry
|
||||
#*/
|
||||
#@see ogBootLoaderDeleteEntry
|
||||
def ogGrubDeleteEntry (disk, par, diskdel, pardel):
|
||||
return ogBootLoaderDeleteEntry (disk, par, diskdel, pardel)
|
||||
|
||||
#/**
|
||||
# ogBootLoaderDeleteEntry num_disk num_part num_part_delete
|
||||
## ogBootLoaderDeleteEntry num_disk num_part num_part_delete
|
||||
#@brief Borra en el grub las entradas para el inicio en una particion.
|
||||
#@param 1 Numero de disco donde esta el grub
|
||||
#@param 2 Numero de particion donde esta el grub
|
||||
|
@ -1194,8 +1139,6 @@ def ogGrubDeleteEntry (disk, par, diskdel, pardel):
|
|||
#@exception OG_ERR_FORMAT Use ogGrubDeleteEntry
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND No existe archivo de configuracion del grub.
|
||||
#*/ ##
|
||||
|
||||
def ogBootLoaderDeleteEntry (disk, par, diskdel, pardel):
|
||||
# Nombre de la función que llama a esta.
|
||||
func = inspect.stack()[1][3]
|
||||
|
@ -1249,27 +1192,23 @@ def ogBootLoaderDeleteEntry (disk, par, diskdel, pardel):
|
|||
subprocess.run (['sed', '-i', '-e', f'{entry},{endentry}d', cfgfile])
|
||||
# Guardamos el número de línea de la entrada, que sera el final de la siguiente.
|
||||
endentry = entry
|
||||
#/**
|
||||
# ogGrubDefaultEntry int_disk_GRUGCFG int_partition_GRUBCFG int_disk_default_entry int_npartition_default_entry
|
||||
|
||||
## ogGrubDefaultEntry int_disk_GRUGCFG int_partition_GRUBCFG int_disk_default_entry int_npartition_default_entry
|
||||
#@brief ver ogBootLoaderDefaultEntry
|
||||
#@see ogBootLoaderDefaultEntry
|
||||
#*/ ##
|
||||
def ogGrubDefaultEntry (disk, par, diskdefault, pardefault):
|
||||
return ogBootLoaderDefaultEntry (disk, par, diskdefault, pardefault)
|
||||
|
||||
#/**
|
||||
# ogBootLoaderDefaultEntry int_disk_CFG int_partition_CFG int_disk_default_entry int_npartition_default_entry
|
||||
## ogBootLoaderDefaultEntry int_disk_CFG int_partition_CFG int_disk_default_entry int_npartition_default_entry
|
||||
#@brief Configura la entrada por defecto de Burg
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@param int_disk_default_entry
|
||||
#@param int_part_default_entry
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||
#@exception OG_ERR_OUTOFLIMIT Param $3 no es entero.
|
||||
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: burg.cfg.
|
||||
#*/ ##
|
||||
def ogBootLoaderDefaultEntry (disk, par, diskdefault, pardefault):
|
||||
# Nombre de la función que llama a esta.
|
||||
func = inspect.stack()[1][3]
|
||||
|
@ -1321,26 +1260,20 @@ def ogBootLoaderDefaultEntry (disk, par, diskdefault, pardefault):
|
|||
print (f'{MSG}: {disk} {par} {diskdefault} {pardefault}')
|
||||
return True
|
||||
|
||||
#/**
|
||||
# ogGrubOgliveDefaultEntry num_disk num_part
|
||||
## ogGrubOgliveDefaultEntry num_disk num_part
|
||||
#@brief ver ogBootLoaderOgliveDefaultEntry
|
||||
#@see ogBootLoaderOgliveDefaultEntry
|
||||
#*/ ##
|
||||
def ogGrubOgliveDefaultEntry (disk, par):
|
||||
return ogBootLoaderOgliveDefaultEntry (disk, par)
|
||||
|
||||
|
||||
#/**
|
||||
# ogBootLoaderOgliveDefaultEntry
|
||||
## ogBootLoaderOgliveDefaultEntry
|
||||
#@brief Configura la entrada de ogLive como la entrada por defecto de Burg.
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@return
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: burg.cfg.
|
||||
#@exception OG_ERR_NOTFOUND Entrada de OgLive no encontrada en burg.cfg.
|
||||
#*/ ##
|
||||
def ogBootLoaderOgliveDefaultEntry (disk, par):
|
||||
# Nombre de la función que llama a esta.
|
||||
func = inspect.stack()[1][3]
|
||||
|
@ -1386,8 +1319,7 @@ def ogBootLoaderOgliveDefaultEntry (disk, par):
|
|||
return True
|
||||
|
||||
|
||||
#/**
|
||||
# ogGrubSecurity int_disk_GRUBCFG int_partition_GRUBCFG [user] [password]
|
||||
## ogGrubSecurity int_disk_GRUBCFG int_partition_GRUBCFG [user] [password]
|
||||
#@brief Configura grub.cfg para que sólo permita editar entrada o acceder a línea de comandos al usuario especificado
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
|
@ -1397,7 +1329,6 @@ def ogBootLoaderOgliveDefaultEntry (disk, par):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar (ogMount).
|
||||
#@exception OG_ERR_NOTFOUND No encuentra archivo de configuración del grub.
|
||||
#*/ ##
|
||||
def ogGrubSecurity (disk, par, user='root', passwd=''):
|
||||
#localizar disco segunda etapa del grub
|
||||
secondstage = FileSystemLib.ogMount (disk, par)
|
||||
|
@ -1438,71 +1369,21 @@ def ogGrubSecurity (disk, par, user='root', passwd=''):
|
|||
subprocess.run (['sed', '-i', '/menuentry /s/{/--unrestricted {/', file])
|
||||
|
||||
|
||||
#/**
|
||||
# ogGrubSetTheme num_disk num_part str_theme
|
||||
#@brief ver ogBootLoaderSetTheme
|
||||
#@see ogBootLoaderSetTheme
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogBootLoaderSetTheme
|
||||
#@brief asigna un tema al BURG
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@param str_theme_name
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg refind.conf.
|
||||
#@exception OG_ERR_NOTFOUND Entrada deltema no encontrada en burg.cfg.
|
||||
#@exception OG_ERR_NOTFOUND Fichero de configuración del tema no encontrado: theme.conf (sólo refind).
|
||||
#@note El tema debe situarse en OGLIB/BOOTLOADER/themes
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogGrubSetAdminKeys num_disk num_part str_theme
|
||||
#@brief ver ogBootLoaderSetTheme
|
||||
#@see ogBootLoaderSetTheme
|
||||
#*/ ##
|
||||
|
||||
|
||||
|
||||
#/**
|
||||
# ogBootLoaderSetAdminKeys
|
||||
#@brief Activa/Desactica las teclas de administracion
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@param Boolean TRUE/FALSE
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg.
|
||||
#@exception OG_ERR_NOTFOUND Entrada deltema no encontrada en burg.cfg.
|
||||
#*/ ##
|
||||
|
||||
|
||||
|
||||
#/**
|
||||
# ogGrubSetTimeOut num_disk num_part int_timeout_seconds
|
||||
## ogGrubSetTimeOut num_disk num_part int_timeout_seconds
|
||||
#@brief ver ogBootLoaderSetTimeOut
|
||||
#@see ogBootLoaderSetTimeOut
|
||||
#*/ ##
|
||||
def ogGrubSetTimeOut (disk, par, timeout):
|
||||
return ogBootLoaderSetTimeOut (disk, par, timeout)
|
||||
|
||||
#/**
|
||||
# ogBootLoaderSetTimeOut
|
||||
#@brief Define el tiempo (segundos) que se muestran las opciones de inicio
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@param int_timeout_seconds
|
||||
#@return
|
||||
## ogBootLoaderSetTimeOut
|
||||
#@brief Define el tiempo (segundos) que se muestran las opciones de inicio
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@param int_timeout_seconds
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg.
|
||||
#@exception OG_ERR_NOTFOUND Entrada deltema no encontrada en burg.cfg.
|
||||
#*/ ##
|
||||
def ogBootLoaderSetTimeOut (disk, par, timeout):
|
||||
# Nombre de la función que llama a esta.
|
||||
func = inspect.stack()[1][3]
|
||||
|
@ -1528,53 +1409,16 @@ def ogBootLoaderSetTimeOut (disk, par, timeout):
|
|||
subprocess.run (['sed', '-i', f's/timeout=.*$/timeout={timeout}/g', cfgfile])
|
||||
|
||||
|
||||
#/**
|
||||
# ogGrubSetResolution num_disk num_part int_resolution
|
||||
#@brief ver ogBootLoaderSetResolution
|
||||
#@see ogBootLoaderSetResolution
|
||||
#*/ ##
|
||||
|
||||
|
||||
|
||||
#/**
|
||||
# ogBootLoaderSetResolution
|
||||
#@brief Define la resolucion que usuara el thema del gestor de arranque
|
||||
#@param int_disk_SecondStage
|
||||
#@param int_part_SecondStage
|
||||
#@param str_resolution (Opcional)
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg.
|
||||
#*/ ##
|
||||
|
||||
|
||||
|
||||
|
||||
#/**
|
||||
# ogBootLoaderSetResolution
|
||||
#@brief Define la resolucion que usuara el thema del gestor de arranque
|
||||
#@param int_resolution1
|
||||
#@param int_resolution2 (Opcional)
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg.
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogGrub4dosInstallMbr int_ndisk
|
||||
## ogGrub4dosInstallMbr int_ndisk
|
||||
#@brief Genera un nuevo Codigo de arranque en el MBR del disco indicado, compatible con los SO tipo Windows, Linux.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_ndisk nº de orden del particion
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Tipo de partición desconocido o no se puede montar.
|
||||
#@exception OG_ERR_NOTBIOS Equipo no firmware BIOS legacy
|
||||
#@exception OG_ERR_NOMSDOS Disco duro no particioniado en modo msdos
|
||||
#@exception OG_ERR_NOTWRITE Particion no modificable.
|
||||
#*/ ##
|
||||
|
||||
def ogGrub4dosInstallMbr (disk, par):
|
||||
#Controlar existencia de disco y particion
|
||||
device = DiskLib.ogDiskToDev (disk)
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
##@file CacheLib.py
|
||||
#@brief Librería o clase Cache
|
||||
#@class Cache
|
||||
#@brief Funciones relativas al cache de OG
|
||||
#@warning License: GNU GPLv3+
|
||||
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
@ -10,8 +16,7 @@ import SystemLib
|
|||
import DiskLib
|
||||
import FileSystemLib
|
||||
|
||||
#/**
|
||||
# ogCreateCache [int_ndisk] int_partsize
|
||||
## ogCreateCache [int_ndisk] int_partsize
|
||||
#@brief Define la caché local, por defecto en partición 4 del disco 1.
|
||||
#@param int_ndisk numero de disco donde crear la cache, si no se indica es el 1 por defecto
|
||||
#@param int_npart número de partición (opcional, 4 por defecto)
|
||||
|
@ -21,7 +26,6 @@ import FileSystemLib
|
|||
#@note Requisitos: sfdisk, parted, awk, sed
|
||||
#@warning El tamaño de caché debe estar entre 50 MB y la mitad del disco.
|
||||
#@warning La caché no puede solaparse con las particiones de datos.
|
||||
#*/ ##
|
||||
def ogCreateCache (ndsk=1, part=4, sizecache=0):
|
||||
if not sizecache:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, '')
|
||||
|
@ -121,13 +125,11 @@ def ogCreateCache (ndsk=1, part=4, sizecache=0):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogDeleteCache
|
||||
## ogDeleteCache
|
||||
#@brief Elimina la partición de caché local.
|
||||
#@return (nada, por determinar)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@note Requisitos: fdisk, sgdisk, partprobe
|
||||
#*/ ##
|
||||
def ogDeleteCache():
|
||||
cachepart = ogFindCache()
|
||||
if not cachepart:
|
||||
|
@ -158,13 +160,11 @@ def ogDeleteCache():
|
|||
#Actualiza la tabla de particiones en el kernel.
|
||||
DiskLib.ogUpdatePartitionTable()
|
||||
|
||||
#/**
|
||||
# ogFindCache
|
||||
## ogFindCache
|
||||
#@brief Detecta la partición caché local.
|
||||
#@param No requiere parametros
|
||||
#@return int_ndisk int_npart - devuelve el par nº de disco-nº de partición .
|
||||
#@warning Si no hay cache no devuelve nada
|
||||
#*/ ##
|
||||
def ogFindCache():
|
||||
# Obtener el dispositivo del sistema de archivos etiquetado como "CACHE".
|
||||
PART = subprocess.run (['blkid', '-L', 'CACHE'], capture_output=True, text=True).stdout.strip()
|
||||
|
@ -200,14 +200,12 @@ def ogFindCache():
|
|||
return DiskLib.ogDevToDisk (PART.split()[0]) # usar la 1ª partición encontrada.
|
||||
|
||||
|
||||
#/**
|
||||
# ogFormatCache
|
||||
## ogFormatCache
|
||||
#@brief Formatea el sistema de ficheros para la caché local.
|
||||
#@return (por determinar)
|
||||
#@warning Prueba con formato Reiser.
|
||||
#@attention
|
||||
#@note El sistema de archivos de la caché se queda montado.
|
||||
#*/ ##
|
||||
def ogFormatCache():
|
||||
cachepart = ogFindCache()
|
||||
if cachepart is None:
|
||||
|
@ -239,12 +237,10 @@ def ogFormatCache():
|
|||
subprocess.run ([f'{ogGlobals.OGSCRIPTS}/updateBootCache'])
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetCacheSize
|
||||
## ogGetCacheSize
|
||||
#@brief Devuelve el tamaño definido para la partición de caché.
|
||||
#@return int_partsize tamaño de la partición (en KB)
|
||||
#@exception OG_ERR_PARTITION No existe partición de caché.
|
||||
#*/ ##
|
||||
def ogGetCacheSize():
|
||||
cachepart = ogFindCache()
|
||||
if cachepart is None:
|
||||
|
@ -254,12 +250,10 @@ def ogGetCacheSize():
|
|||
disk, par = cachepart.split()
|
||||
return DiskLib.ogGetPartitionSize (disk, par)
|
||||
|
||||
#/**
|
||||
# ogGetCacheSpace
|
||||
## ogGetCacheSpace
|
||||
#@brief Devuelve el espacio de disco disponible para la partición de caché.
|
||||
#@return int_size tamaño disponible (en KB)
|
||||
#@note El espacio disponible es el que hay entre el límite superior de la partición 3 del disco 1 y el final de dicho disco, y no puede ser superior a la mitad de dicho disco.
|
||||
#*/ ##
|
||||
def ogGetCacheSpace():
|
||||
cachepart = ogFindCache()
|
||||
if not cachepart:
|
||||
|
@ -308,13 +302,11 @@ def ogGetCacheSpace():
|
|||
return sectors // 4
|
||||
|
||||
|
||||
#/**
|
||||
# ogMountCache
|
||||
## ogMountCache
|
||||
#@brief Monta la partición Cache y exporta la variable $OGCAC
|
||||
#@param sin parametros
|
||||
#@return path_mountpoint - Punto de montaje del sistema de archivos de cache.
|
||||
#@warning Salidas de errores no determinada
|
||||
#*/ ##
|
||||
def ogMountCache():
|
||||
c = ogFindCache()
|
||||
if not c:
|
||||
|
@ -329,13 +321,11 @@ def ogMountCache():
|
|||
return m
|
||||
|
||||
|
||||
#/**
|
||||
# ogUnmountCache
|
||||
## ogUnmountCache
|
||||
#@brief Desmonta la particion Cache y elimina la variable $OGCAC
|
||||
#@param sin parametros
|
||||
#@return nada
|
||||
#@warning Salidas de errores no determinada
|
||||
#*/ ##
|
||||
def ogUnmountCache():
|
||||
cachepart = ogFindCache()
|
||||
if cachepart is None:
|
||||
|
@ -352,24 +342,20 @@ def ogUnmountCache():
|
|||
if os.path.exists (dev): os.remove (dev)
|
||||
|
||||
|
||||
#/**
|
||||
# initCache
|
||||
## initCache
|
||||
#@brief Simplemente llama al script initCache
|
||||
#@brief Es necesario tener una función para poder pasársela a ogExecAndLog
|
||||
#@param los mismos parametros que initCache
|
||||
#@return lo mismo que devuelve initCache
|
||||
#*/ ##
|
||||
def initCache (*args):
|
||||
p = subprocess.run ([f'{ogGlobals.OGSCRIPTS}/initCache'] + list(args))
|
||||
return not p.returncode ## negate shell return code
|
||||
|
||||
|
||||
#/**
|
||||
# ogCheckNewCacheSize
|
||||
## ogCheckNewCacheSize
|
||||
#@brief Comprueba si un cache de X tamaño cabe en el hueco que dejan las demás particiones
|
||||
#@param Tamaño de la nueva hipotética cache
|
||||
#@return Boolean, True si la nueva cache cabría, False si no
|
||||
#*/ ##
|
||||
def ogCheckNewCacheSize (disk, kB):
|
||||
DISK = DiskLib.ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#/**
|
||||
#@file DiskLib.py
|
||||
##@file DiskLib.py
|
||||
#@brief Librería o clase Disk
|
||||
#@class Disk
|
||||
#@brief Funciones para gestión de discos y particiones.
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
import filecmp
|
||||
import subprocess
|
||||
|
@ -38,12 +36,10 @@ def parted(*args):
|
|||
return "Error: 'parted' command not found"
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetIoSize int_ndisk
|
||||
## ogGetIoSize int_ndisk
|
||||
#@brief Devuelve el tamaño de sector de un disco
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return Tamaño de sector
|
||||
#*/ ##
|
||||
def ogGetIoSize (disk):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
|
@ -64,8 +60,7 @@ def ogGetIoSize (disk):
|
|||
return int (IOSIZE)
|
||||
|
||||
|
||||
#/**
|
||||
# ogCreatePartitions int_ndisk str_parttype:int_partsize ...
|
||||
## ogCreatePartitions int_ndisk str_parttype:int_partsize ...
|
||||
#@brief Define el conjunto de particiones de un disco.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param str_parttype mnemónico del tipo de partición
|
||||
|
@ -79,7 +74,6 @@ def ogGetIoSize (disk):
|
|||
#@attention No puede definirse partición de cache y no se modifica si existe.
|
||||
#@note Requisitos: sfdisk, parted, partprobe, awk
|
||||
#@todo Definir atributos (arranque, oculta) y tamaños en MB, GB, etc.
|
||||
#*/ ##
|
||||
def ogCreatePartitions (disk, parts):
|
||||
ND = disk
|
||||
DISK = ogDiskToDev (ND)
|
||||
|
@ -241,8 +235,7 @@ def ogCreatePartitions (disk, parts):
|
|||
return not p.returncode
|
||||
|
||||
|
||||
#/**
|
||||
# ogCreatePartitionTable int_ndisk [str_tabletype]
|
||||
## ogCreatePartitionTable int_ndisk [str_tabletype]
|
||||
#@brief Genera una tabla de particiones en caso de que no sea valida, si es valida no hace nada.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param str_tabletype tipo de tabla de particiones (opcional)
|
||||
|
@ -251,7 +244,6 @@ def ogCreatePartitions (disk, parts):
|
|||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@note tabletype: { MSDOS, GPT }, MSDOS por defecto
|
||||
#@note Requisitos: fdisk, gdisk, parted
|
||||
#*/ ##
|
||||
def ogCreatePartitionTable (disk, createptt=None):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
|
@ -296,12 +288,10 @@ def ogCreatePartitionTable (disk, createptt=None):
|
|||
return None
|
||||
|
||||
|
||||
#/**
|
||||
# ogDeletePartitionTable ndisk
|
||||
## ogDeletePartitionTable ndisk
|
||||
#@brief Borra la tabla de particiones del disco.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return la informacion propia del fdisk
|
||||
#*/ ##
|
||||
def ogDeletePartitionTable (disk):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
|
@ -313,8 +303,7 @@ def ogDeletePartitionTable (disk):
|
|||
subprocess.run (['fdisk', DISK], input='o\nw', text=True)
|
||||
return
|
||||
|
||||
#/**
|
||||
# ogDevToDisk path_device | LABEL="str_label" | UUID="str_uuid"
|
||||
## ogDevToDisk path_device | LABEL="str_label" | UUID="str_uuid"
|
||||
#@brief Devuelve el nº de orden de dicso (y partición) correspondiente al nombre de fichero de dispositivo o a la etiqueta o UUID del sistema de archivos asociado.
|
||||
#@param path_device Camino del fichero de dispositivo.
|
||||
#@param str_label etiqueta de sistema de archivos.
|
||||
|
@ -324,7 +313,6 @@ def ogDeletePartitionTable (disk):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Dispositivo no detectado.
|
||||
#@note Solo se acepta en cada llamada 1 de los 3 tipos de parámetros.
|
||||
#*/ ##
|
||||
def ogDevToDisk(arg_dev):
|
||||
CACHEFILE = "/var/cache/disks.cfg"
|
||||
|
||||
|
@ -413,8 +401,7 @@ def _getAllZFSVols():
|
|||
zfsvols = subprocess.run(['blkid'], capture_output=True, text=True).stdout.splitlines()
|
||||
return [line.split(":")[0] for line in zfsvols if "zfs" in line]
|
||||
|
||||
#/**
|
||||
# ogDiskToDev [int_ndisk [int_npartition]]
|
||||
## ogDiskToDev [int_ndisk [int_npartition]]
|
||||
#@brief Devuelve la equivalencia entre el nº de orden del dispositivo (dicso o partición) y el nombre de fichero de dispositivo correspondiente.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -423,7 +410,6 @@ def _getAllZFSVols():
|
|||
#@return Para 2 parametros: Devuelve la ruta de la particion indicada.
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Dispositivo no detectado.
|
||||
#*/ ##
|
||||
def ogDiskToDev (arg_disk=None, arg_part=None):
|
||||
CACHEFILE = "/var/cache/disks.cfg"
|
||||
|
||||
|
@ -555,15 +541,13 @@ def ogDiskToDev (arg_disk=None, arg_part=None):
|
|||
return part
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetDiskSize int_ndisk
|
||||
## ogGetDiskSize int_ndisk
|
||||
#@brief Muestra el tamaño en KB de un disco.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return int_size - Tamaño en KB del disco.
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo).
|
||||
#@note Requisitos: sfdisk, awk
|
||||
#*/ ##
|
||||
def ogGetDiskSize (disk):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
|
@ -587,14 +571,12 @@ def ogGetDiskSize (disk):
|
|||
return SIZE
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetDiskType path_device
|
||||
## ogGetDiskType path_device
|
||||
#@brief Muestra el tipo de disco (real, RAID, meta-disco, USB, etc.).
|
||||
#@param path_device Dispositivo
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND disco no detectado o no es un dispositivo de bloques.
|
||||
#@note Requisitos: udevadm
|
||||
#*/ ##
|
||||
def ogGetDiskType (dev):
|
||||
DEV = os.path.basename (dev)
|
||||
|
||||
|
@ -648,10 +630,8 @@ def ogGetDiskType (dev):
|
|||
return TYPE
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetEsp
|
||||
## ogGetEsp
|
||||
#@brief Devuelve números de disco y partición para la partición EFI (ESP).
|
||||
#*/ ##
|
||||
def ogGetEsp():
|
||||
devices = subprocess.run (['blkid', '-o', 'device'], capture_output=True, text=True).stdout.splitlines()
|
||||
devices.sort()
|
||||
|
@ -672,8 +652,7 @@ def ogGetEsp():
|
|||
return None
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetLastSector int_ndisk [int_npart]
|
||||
## ogGetLastSector int_ndisk [int_npart]
|
||||
#@brief Devuelve el último sector usable del disco o de una partición.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npart nº de orden de la partición (opcional)
|
||||
|
@ -681,7 +660,6 @@ def ogGetEsp():
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o partición no corresponde con un dispositivo.
|
||||
#@note Requisitos: sfdisk, sgdisk
|
||||
#*/ ##
|
||||
def ogGetLastSector (disk, par=None):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
|
@ -709,15 +687,13 @@ def ogGetLastSector (disk, par=None):
|
|||
return last
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetPartitionActive int_ndisk
|
||||
## ogGetPartitionActive int_ndisk
|
||||
#@brief Muestra que particion de un disco esta marcada como de activa.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@note Requisitos: parted
|
||||
#@todo Queda definir formato para atributos (arranque, oculta, ...).
|
||||
#*/ ##
|
||||
def ogGetPartitionActive (disk):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if DISK is None: return
|
||||
|
@ -743,8 +719,7 @@ def ogGetPartitionActive (disk):
|
|||
return ret
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetPartitionId int_ndisk int_npartition
|
||||
## ogGetPartitionId int_ndisk int_npartition
|
||||
#@brief Devuelve el mnemónico con el tipo de partición.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -752,7 +727,6 @@ def ogGetPartitionActive (disk):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o partición no corresponde con un dispositivo.
|
||||
#@note Requisitos: sfdisk
|
||||
#*/ ##
|
||||
def ogGetPartitionId (disk, par):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if DISK is None: return
|
||||
|
@ -779,8 +753,7 @@ def ogGetPartitionId (disk, par):
|
|||
return fsid
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetPartitionSize int_ndisk int_npartition
|
||||
## ogGetPartitionSize int_ndisk int_npartition
|
||||
#@brief Muestra el tamano en KB de una particion determinada.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -788,7 +761,6 @@ def ogGetPartitionId (disk, par):
|
|||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo).
|
||||
#@note Requisitos: sfdisk, awk
|
||||
#*/ ##
|
||||
def ogGetPartitionSize (disk, par):
|
||||
PART = ogDiskToDev (disk, par)
|
||||
if PART is None: return
|
||||
|
@ -802,15 +774,13 @@ def ogGetPartitionSize (disk, par):
|
|||
return FileSystemLib.ogGetFsSize (disk, par)
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetPartitionsNumber int_ndisk
|
||||
## ogGetPartitionsNumber int_ndisk
|
||||
#@brief Detecta el numero de particiones del disco duro indicado.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return Devuelve el numero paritiones del disco duro indicado
|
||||
#@warning Salidas de errores no determinada
|
||||
#@attention Requisitos: parted
|
||||
#@note Notas sin especificar
|
||||
#*/ ##
|
||||
def ogGetPartitionsNumber (disk):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
|
@ -841,15 +811,13 @@ def ogGetPartitionsNumber (disk):
|
|||
return int (out)
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetPartitionTableType int_ndisk
|
||||
## ogGetPartitionTableType int_ndisk
|
||||
#@brief Devuelve el tipo de tabla de particiones del disco (GPT o MSDOS)
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return str_tabletype - Tipo de tabla de paritiones
|
||||
#@warning Salidas de errores no determinada
|
||||
#@note tabletype = { MSDOS, GPT }
|
||||
#@note Requisitos: blkid, parted, vgs
|
||||
#*/ ##
|
||||
def ogGetPartitionTableType (disk):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if DISK is None: return
|
||||
|
@ -875,8 +843,7 @@ def ogGetPartitionTableType (disk):
|
|||
return type
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetPartitionType int_ndisk int_npartition
|
||||
## ogGetPartitionType int_ndisk int_npartition
|
||||
#@brief Devuelve el mnemonico con el tipo de partición.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -884,7 +851,6 @@ def ogGetPartitionTableType (disk):
|
|||
#@note Mnemonico: valor devuelto por ogIdToType.
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#*/ ##
|
||||
def ogGetPartitionType (disk, par):
|
||||
ID = ogGetPartitionId (disk, par)
|
||||
if ID is None: return None
|
||||
|
@ -892,8 +858,7 @@ def ogGetPartitionType (disk, par):
|
|||
return ogIdToType (ID)
|
||||
|
||||
|
||||
#/**
|
||||
# ogHidePartition int_ndisk int_npartition
|
||||
## ogHidePartition int_ndisk int_npartition
|
||||
#@brief Oculta un apartición visible.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -901,7 +866,6 @@ def ogGetPartitionType (disk, par):
|
|||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo).
|
||||
#@exception OG_ERR_PARTITION tipo de partición no reconocido.
|
||||
#*/ ##
|
||||
def ogHidePartition (disk, par):
|
||||
PART = ogDiskToDev (disk, par)
|
||||
if not PART: return None
|
||||
|
@ -919,13 +883,11 @@ def ogHidePartition (disk, par):
|
|||
ogSetPartitionType (disk, par, NEWTYPE)
|
||||
|
||||
|
||||
#/**
|
||||
# ogIdToType int_idpart
|
||||
## ogIdToType int_idpart
|
||||
#@brief Devuelve el identificador correspondiente a un tipo de partición.
|
||||
#@param int_idpart identificador de tipo de partición.
|
||||
#@return str_parttype mnemónico de tipo de partición.
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#*/ ##
|
||||
def ogIdToType (ID):
|
||||
# Obtener valor hexadecimal de 4 caracteres rellenado con 0 por delante.
|
||||
ID = ID.zfill(4).lower()
|
||||
|
@ -996,20 +958,18 @@ def ogIdToType (ID):
|
|||
return 'UNKNOWN'
|
||||
|
||||
|
||||
# ogIsDiskLocked int_ndisk
|
||||
## ogIsDiskLocked int_ndisk
|
||||
#@brief Comprueba si un disco está bloqueado por una operación de uso exclusivo.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return Código de salida: 0 - bloqueado, 1 - sin bloquear o error.
|
||||
#@note Los ficheros de bloqueo se localizan en \c /var/lock/dev, siendo \c dev el dispositivo de la partición o de su disco, sustituyendo el carácter "/" por "-".
|
||||
#*/ ##
|
||||
def ogIsDiskLocked (disk):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return False
|
||||
return os.path.isfile (f'/var/lock/lock{DISK.replace("/", "-")}')
|
||||
|
||||
|
||||
#/**
|
||||
# ogListPartitions int_ndisk
|
||||
## ogListPartitions int_ndisk
|
||||
#@brief Lista las particiones definidas en un disco.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return str_parttype:int_partsize ...
|
||||
|
@ -1018,7 +978,6 @@ def ogIsDiskLocked (disk):
|
|||
#@note Requisitos: \c parted \c awk
|
||||
#@attention El nº de partición se indica por el orden de los párametros \c parttype:partsize
|
||||
#@attention Las tuplas de valores están separadas por espacios.
|
||||
#*/ ##
|
||||
def ogListPartitions (disk):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
|
@ -1034,12 +993,10 @@ def ogListPartitions (disk):
|
|||
return p
|
||||
|
||||
|
||||
#/**
|
||||
# ogListPrimaryPartitions int_ndisk
|
||||
## ogListPrimaryPartitions int_ndisk
|
||||
#@brief Metafunción que lista las particiones primarias no vacías de un disco.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@see ogListPartitions
|
||||
#*/ ##
|
||||
def ogListPrimaryPartitions (disk):
|
||||
PTTYPE = ogGetPartitionTableType (disk)
|
||||
if not PTTYPE: return None
|
||||
|
@ -1058,12 +1015,10 @@ def ogListPrimaryPartitions (disk):
|
|||
return PARTS[0:4]
|
||||
|
||||
|
||||
#/**
|
||||
# ogListLogicalPartitions int_ndisk
|
||||
## ogListLogicalPartitions int_ndisk
|
||||
#@brief Metafunción que lista las particiones lógicas de una tabla tipo MSDOS.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@see ogListPartitions
|
||||
#*/ ##
|
||||
def ogListLogicalPartitions (disk):
|
||||
PTTYPE = ogGetPartitionTableType (disk)
|
||||
if not PTTYPE: return None
|
||||
|
@ -1074,23 +1029,20 @@ def ogListLogicalPartitions (disk):
|
|||
return PARTS[4:]
|
||||
|
||||
|
||||
#/**
|
||||
# ogLockDisk int_ndisk
|
||||
## ogLockDisk int_ndisk
|
||||
#@brief Genera un fichero de bloqueo para un disco en uso exlusivo.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@note El fichero de bloqueo se localiza en \c /var/lock/disk, siendo \c disk el dispositivo del disco, sustituyendo el carácter "/" por "-".
|
||||
#*/ ##
|
||||
def ogLockDisk (disk):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
open (f'/var/lock/lock{DISK.replace("/", "-")}', 'a').close()
|
||||
|
||||
|
||||
#/**
|
||||
# ogSetPartitionActive int_ndisk int_npartition
|
||||
## ogSetPartitionActive int_ndisk int_npartition
|
||||
#@brief Establece cual es la partición activa de un disco.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -1098,7 +1050,6 @@ def ogLockDisk (disk):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo.
|
||||
#@note Requisitos: parted
|
||||
#*/ ##
|
||||
def ogSetPartitionActive (disk, par):
|
||||
if InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogEcho (['session', 'log'], 'warning', f'EFI: {ogGlobals.lang.MSG_DONTUSE} ogSetPartitionActive')
|
||||
|
@ -1114,8 +1065,7 @@ def ogSetPartitionActive (disk, par):
|
|||
return
|
||||
|
||||
|
||||
#/**
|
||||
# ogSetPartitionId int_ndisk int_npartition hex_partid
|
||||
## ogSetPartitionId int_ndisk int_npartition hex_partid
|
||||
#@brief Cambia el identificador de la partición.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -1126,9 +1076,8 @@ def ogSetPartitionActive (disk, par):
|
|||
#@exception OG_ERR_OUTOFLIMIT Valor no válido.
|
||||
#@exception OG_ERR_PARTITION Error al cambiar el id. de partición.
|
||||
#@attention Requisitos: fdisk, sgdisk
|
||||
#*/ ##
|
||||
## for GPT partitions, id must be one of the valid types as reported by 'sgdisk --list-types', eg. 0700 or 8200
|
||||
def ogSetPartitionId (disk, par, id):
|
||||
## for GPT partitions, id must be one of the valid types as reported by 'sgdisk --list-types', eg. 0700 or 8200
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
|
||||
|
@ -1159,8 +1108,7 @@ def ogSetPartitionId (disk, par, id):
|
|||
return None
|
||||
|
||||
|
||||
#/**
|
||||
# ogSetPartitionSize int_ndisk int_npartition int_size
|
||||
## ogSetPartitionSize int_ndisk int_npartition int_size
|
||||
#@brief Muestra el tamano en KB de una particion determinada.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -1170,7 +1118,6 @@ def ogSetPartitionId (disk, par, id):
|
|||
#@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo).
|
||||
#@note Requisitos: sfdisk, awk
|
||||
#@todo Compruebar que el tamaño sea numérico positivo y evitar que pueda solaparse con la siguiente partición.
|
||||
#*/ ##
|
||||
def ogSetPartitionSize (disk, par, size):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
|
@ -1188,15 +1135,13 @@ def ogSetPartitionSize (disk, par, size):
|
|||
subprocess.run (['partprobe', DISK])
|
||||
|
||||
|
||||
#/**
|
||||
# ogSetPartitionType int_ndisk int_npartition str_type
|
||||
## ogSetPartitionType int_ndisk int_npartition str_type
|
||||
#@brief Cambia el identificador de la partición.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@param str_type mnemónico de tipo de partición
|
||||
#@return (nada)
|
||||
#@attention Requisitos: fdisk, sgdisk
|
||||
#*/ ##
|
||||
def ogSetPartitionType (disk, par, t):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
|
@ -1215,18 +1160,16 @@ def ogSetPartitionType (disk, par, t):
|
|||
ogSetPartitionId (disk, par, ID)
|
||||
|
||||
|
||||
#/**
|
||||
# ogTypeToId str_parttype [str_tabletype]
|
||||
## ogTypeToId str_parttype [str_tabletype]
|
||||
#@brief Devuelve el identificador correspondiente a un tipo de partición.
|
||||
#@param str_parttype mnemónico de tipo de partición.
|
||||
#@param str_tabletype mnemónico de tipo de tabla de particiones (MSDOS por defecto).
|
||||
#@return int_idpart identificador de tipo de partición.
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@note tabletype = { MSDOS, GPT }, (MSDOS, por defecto)
|
||||
#*/ ##
|
||||
#ogTypeToId ('LINUX') => "83"
|
||||
#ogTypeToId ('LINUX', 'MSDOS') => "83"
|
||||
def ogTypeToId (type, pttype='MSDOS'):
|
||||
#ogTypeToId ('LINUX') => "83"
|
||||
#ogTypeToId ('LINUX', 'MSDOS') => "83"
|
||||
data = {
|
||||
'GPT_GUID': {
|
||||
## https://en.wikipedia.org/wiki/GUID_Partition_Table?useskin=vector
|
||||
|
@ -1338,8 +1281,7 @@ def ogTypeToId (type, pttype='MSDOS'):
|
|||
return data[pttype.upper()][type.upper()]
|
||||
|
||||
|
||||
#/**
|
||||
# ogUnhidePartition int_ndisk int_npartition
|
||||
## ogUnhidePartition int_ndisk int_npartition
|
||||
#@brief Hace visible una partición oculta.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -1347,7 +1289,6 @@ def ogTypeToId (type, pttype='MSDOS'):
|
|||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND disco o particion no detectado (no es un dispositivo).
|
||||
#@exception OG_ERR_PARTITION tipo de partición no reconocido.
|
||||
#*/ ##
|
||||
def ogUnhidePartition (disk, par):
|
||||
PART = ogDiskToDev (disk, par)
|
||||
if not PART: return None
|
||||
|
@ -1365,29 +1306,25 @@ def ogUnhidePartition (disk, par):
|
|||
ogSetPartitionType (disk, par, NEWTYPE)
|
||||
|
||||
|
||||
#/**
|
||||
# ogUnlockDisk int_ndisk
|
||||
## ogUnlockDisk int_ndisk
|
||||
#@brief Elimina el fichero de bloqueo para un disco.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@note El fichero de bloqueo se localiza en \c /var/lock/disk, siendo \c disk el dispositivo del disco, sustituyendo el carácter "/" por "-".
|
||||
#*/ ##
|
||||
def ogUnlockDisk (disk):
|
||||
DISK = ogDiskToDev (disk)
|
||||
if not DISK: return None
|
||||
os.remove (f'/var/lock/lock{DISK.replace("/", "-")}')
|
||||
|
||||
|
||||
#/**
|
||||
# ogUpdatePartitionTable
|
||||
## ogUpdatePartitionTable
|
||||
#@brief Fuerza al kernel releer la tabla de particiones de los discos duros
|
||||
#@param no requiere
|
||||
#@return informacion propia de la herramienta
|
||||
#@note Requisitos: \c partprobe
|
||||
#@warning pendiente estructurar la funcion a opengnsys
|
||||
#*/ ##
|
||||
def ogUpdatePartitionTable():
|
||||
for disk in ogDiskToDev():
|
||||
subprocess.run(["partprobe", disk])
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#/**
|
||||
#@file FileLib.py
|
||||
##@file FileLib.py
|
||||
#@brief Librería o clase File
|
||||
#@class File
|
||||
#@brief Funciones para gestión de archivos y directorios.
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
import subprocess
|
||||
import os
|
||||
|
@ -16,19 +14,17 @@ import SystemLib
|
|||
import CacheLib
|
||||
import FileSystemLib
|
||||
|
||||
#/**
|
||||
# ogCalculateChecksum [ str_repo | int_ndisk int_npart ] path_filepath
|
||||
## ogCalculateChecksum [ str_repo | int_ndisk int_npart ] path_filepath
|
||||
#@brief Devuelve la suma de comprobación (checksum) de un fichero.
|
||||
#@param path_filepath camino del fichero (independiente de mayúsculas)
|
||||
#@param str_repo repositorio de ficheros
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@return hex_checksum Checksum del fichero
|
||||
#*/ ##
|
||||
#ogCalculateChecksum ([ str_repo | int_ndisk int_npartition ] path_filepath")
|
||||
#ogCalculateChecksum (container='REPO', file='ubuntu.img') ==> ef899299caf8b517ce36f1157a93d8bf
|
||||
#ogCalculateChecksum (disk=1, par=1, file='ubuntu.img') ==> ef899299caf8b517ce36f1157a93d8bf
|
||||
def ogCalculateChecksum (disk=None, par=None, container=None, file=None):
|
||||
#ogCalculateChecksum ([ str_repo | int_ndisk int_npartition ] path_filepath")
|
||||
#ogCalculateChecksum (container='REPO', file='ubuntu.img') ==> ef899299caf8b517ce36f1157a93d8bf
|
||||
#ogCalculateChecksum (disk=1, par=1, file='ubuntu.img') ==> ef899299caf8b517ce36f1157a93d8bf
|
||||
if file is None:
|
||||
raise TypeError ('missing required argument: "file"')
|
||||
|
||||
|
@ -70,12 +66,10 @@ def ogCalculateChecksum (disk=None, par=None, container=None, file=None):
|
|||
return md5
|
||||
|
||||
|
||||
#/**
|
||||
# ogCompareChecksumFiles [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target
|
||||
## ogCompareChecksumFiles [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target
|
||||
#@brief Metafunción que compara las sumas de comprobación almacenadas de 2 ficheros.
|
||||
#@return bool_compare Valor de comparación.
|
||||
#@warning No es necesario especificar la extensión ".sum".
|
||||
#*/ ##
|
||||
def ogCompareChecksumFiles(*args):
|
||||
# Variables locales.
|
||||
ARGS = args
|
||||
|
@ -110,15 +104,13 @@ def ogCompareChecksumFiles(*args):
|
|||
return False
|
||||
|
||||
|
||||
#/**
|
||||
# ogCalculateFullChecksum [ str_repo | int_ndisk int_npart ] path_filepath
|
||||
## ogCalculateFullChecksum [ str_repo | int_ndisk int_npart ] path_filepath
|
||||
#@brief Devuelve la suma COMPLETA de comprobación (checksum) de un fichero.
|
||||
#@param path_filepath camino del fichero (independiente de mayúsculas)
|
||||
#@param str_repo repositorio de ficheros
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@return hex_checksum Checksum del fichero
|
||||
#*/ ##
|
||||
def ogCalculateFullChecksum (disk=None, par=None, container=None, file=None):
|
||||
if file is None:
|
||||
raise TypeError ('missing required argument: "file"')
|
||||
|
@ -159,17 +151,15 @@ def ogCalculateFullChecksum (disk=None, par=None, container=None, file=None):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogCopyFile [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target
|
||||
## 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.
|
||||
#@see ogGetPath
|
||||
#@return Progreso de la copia.
|
||||
#@warning Deben existir tanto el fichero origen como el directorio destino.
|
||||
#*/ ##
|
||||
#ogCopyFile (src, dst)
|
||||
#ogCopyFile ({container='REPO', file='newfile.txt'}, {disk=1, par=2, file='/tmp/newfile.txt'})
|
||||
#ogCopyFile ({disk=1, par=2, file='/tmp/newfile.txt'}, {container='REPO', file='newfile.txt'})
|
||||
def ogCopyFile (src, dst):
|
||||
#ogCopyFile (src, dst)
|
||||
#ogCopyFile ({container='REPO', file='newfile.txt'}, {disk=1, par=2, file='/tmp/newfile.txt'})
|
||||
#ogCopyFile ({disk=1, par=2, file='/tmp/newfile.txt'}, {container='REPO', file='newfile.txt'})
|
||||
for elem in src, dst:
|
||||
if elem == src: which = 'source'
|
||||
else: which = 'target'
|
||||
|
@ -219,18 +209,16 @@ def ogCopyFile (src, dst):
|
|||
return not result.returncode ## negate shell result
|
||||
|
||||
|
||||
#/**
|
||||
# ogDeleteFile [ str_repo | int_ndisk int_npartition ] path_filepath
|
||||
## 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
|
||||
#*/ ##
|
||||
#ogDeleteFile ([ str_repo | int_ndisk int_npartition ] path_file)
|
||||
#ogDeleteFile (container='REPO', file='/tmp/newfile.txt')
|
||||
#ogDeleteFile (disk=1, par=2, file='/tmp/newfile.txt')
|
||||
def ogDeleteFile (disk=None, par=None, container=None, file=None):
|
||||
#ogDeleteFile ([ str_repo | int_ndisk int_npartition ] path_file)
|
||||
#ogDeleteFile (container='REPO', file='/tmp/newfile.txt')
|
||||
#ogDeleteFile (disk=1, par=2, file='/tmp/newfile.txt')
|
||||
if file is None:
|
||||
raise TypeError ('missing required argument: "file"')
|
||||
|
||||
|
@ -260,14 +248,12 @@ def ogDeleteFile (disk=None, par=None, container=None, file=None):
|
|||
return
|
||||
|
||||
|
||||
#/**
|
||||
# ogDeleteTree [ str_repo | int_ndisk int_npartition ] path_dirpath
|
||||
## 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
|
||||
#*/ ##
|
||||
#ogDeleteTree (container='REPO', file='/tmp/newdir')
|
||||
#ogDeleteTree (disk=1, par=2, file='/tmp/newdir')
|
||||
def ogDeleteTree (disk=None, par=None, container=None, file=None):
|
||||
#ogDeleteTree (container='REPO', file='/tmp/newdir')
|
||||
#ogDeleteTree (disk=1, par=2, file='/tmp/newdir')
|
||||
if file is None:
|
||||
raise TypeError ('missing required argument: "file"')
|
||||
|
||||
|
@ -297,8 +283,7 @@ def ogDeleteTree (disk=None, par=None, container=None, file=None):
|
|||
return
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetPath [ str_repo | int_ndisk int_npartition ] path_filepath
|
||||
## ogGetPath [ str_repo | int_ndisk int_npartition ] path_filepath
|
||||
#@brief Inicia el proceso de arranque de un sistema de archivos.
|
||||
#@param path_filepath camino del fichero (independiente de mayúsculas)
|
||||
#@param str_repo repositorio de ficheros
|
||||
|
@ -312,11 +297,10 @@ def ogDeleteTree (disk=None, par=None, container=None, file=None):
|
|||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#@warning En caso de error, sólo devuelve el código y no da mensajes.
|
||||
#@todo Terminar de definir parámetros para acceso a repositorios.
|
||||
#*/ ##
|
||||
#ogGetPath (file='/mnt/sda1/windows/system32') ==> '/mnt/sda1/WINDOWS/System32'
|
||||
#ogGetPath (src='REPO', file='/etc/fstab') ==> '/opt/opengnsys/images/etc/fstab'
|
||||
#ogGetPath (src='1 1', file='/windows/system32') ==> '/mnt/sda1/WINDOWS/System32'
|
||||
def ogGetPath (src=None, file=None):
|
||||
#ogGetPath (file='/mnt/sda1/windows/system32') ==> '/mnt/sda1/WINDOWS/System32'
|
||||
#ogGetPath (src='REPO', file='/etc/fstab') ==> '/opt/opengnsys/images/etc/fstab'
|
||||
#ogGetPath (src='1 1', file='/windows/system32') ==> '/mnt/sda1/WINDOWS/System32'
|
||||
if file is None:
|
||||
raise TypeError ('missing required argument: "file"')
|
||||
|
||||
|
@ -374,17 +358,14 @@ def ogGetPath (src=None, file=None):
|
|||
return filepath
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetParentPath [ str_repo | int_ndisk int_npartition ] path_filepath
|
||||
## ogGetParentPath [ str_repo | int_ndisk int_npartition ] path_filepath
|
||||
#@brief Metafunción que devuelve el camino del directorio padre.
|
||||
#@see ogGetPath
|
||||
#*/ ##
|
||||
|
||||
#ogGetParentPath ([ str_repo | int_ndisk int_npartition ] path_filepath
|
||||
#ogGetParentPath ( file='/mnt/sda1/windows/system32') ==> '/mnt/sda1/WINDOWS'
|
||||
#ogGetParentPath (src='REPO', file='/etc/fstab') ==> '/opt/opengnsys/images/etc'
|
||||
#ogGetParentPath (src='1 1', file='/windows/system32') ==> '/mnt/sda1/WINDOWS'
|
||||
def ogGetParentPath (src=None, file=None):
|
||||
#ogGetParentPath ([ str_repo | int_ndisk int_npartition ] path_filepath
|
||||
#ogGetParentPath ( file='/mnt/sda1/windows/system32') ==> '/mnt/sda1/WINDOWS'
|
||||
#ogGetParentPath (src='REPO', file='/etc/fstab') ==> '/opt/opengnsys/images/etc'
|
||||
#ogGetParentPath (src='1 1', file='/windows/system32') ==> '/mnt/sda1/WINDOWS'
|
||||
if file is None:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, '')
|
||||
return
|
||||
|
@ -394,13 +375,11 @@ def ogGetParentPath (src=None, file=None):
|
|||
else:
|
||||
return ogGetPath (src=src, file=os.path.dirname('/'+file))
|
||||
|
||||
#/**
|
||||
# ogIsNewerFile [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target
|
||||
## ogIsNewerFile [ str_repo | int_ndisk int_npart ] path_source [ str_repo | int_ndisk int_npart ] path_target
|
||||
#@brief Metafunción que indica se un fichero es más nuevo que otro.
|
||||
#@see ogGetPath
|
||||
#@return Código de salida: 0 - nuevo, 1 - antiguo o error
|
||||
#@warning Deben existir tanto el fichero origen como el destino.
|
||||
#*/ ##
|
||||
def ogIsNewerFile(*args):
|
||||
# Variables locales.
|
||||
ARGS = args
|
||||
|
@ -443,12 +422,10 @@ def ogIsNewerFile(*args):
|
|||
# Devolver si el primer fichero se ha modificado después que el segundo.
|
||||
return os.path.getmtime(SOURCE) > os.path.getmtime(TARGET)
|
||||
|
||||
#/**
|
||||
# ogMakeChecksumFile [ str_repo | int_ndisk int_npart ] path_filepath
|
||||
## ogMakeChecksumFile [ str_repo | int_ndisk int_npart ] path_filepath
|
||||
#@brief Metafunción que guarda el valor de comprobación de un fichero.
|
||||
#@see ogCalculateChecksum
|
||||
#@warning Genera un fichero con extensión ".sum".
|
||||
#*/ ##
|
||||
def ogMakeChecksumFile(*args):
|
||||
# Variables locales.
|
||||
FILE = None
|
||||
|
@ -470,14 +447,12 @@ def ogMakeChecksumFile(*args):
|
|||
f.write(checksum)
|
||||
|
||||
|
||||
#/**
|
||||
# ogMakeDir [ str_repo | int_ndisk int_npartition ] path_dirpath
|
||||
## ogMakeDir [ str_repo | int_ndisk int_npartition ] path_dirpath
|
||||
#@brief Metafunción que crea un subdirectorio vacío en un dispositivo.
|
||||
#@see ogGetParentPath
|
||||
#*/ ##
|
||||
#ogMakeDir (container='REPO', file='/tmp/newdir')
|
||||
#ogMakeDir (disk='1', par='2', file='/tmp/newdir')
|
||||
def ogMakeDir (container=None, disk=None, par=None, file=None):
|
||||
#ogMakeDir (container='REPO', file='/tmp/newdir')
|
||||
#ogMakeDir (disk='1', par='2', file='/tmp/newdir')
|
||||
if file is None:
|
||||
raise TypeError ('missing required argument: "file"')
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#/**
|
||||
#@file FileSystemLib.py
|
||||
##@file FileSystemLib.py
|
||||
#@brief Librería o clase FileSystem
|
||||
#@class FileSystem
|
||||
#@brief Funciones para gestión de sistemas de archivos.
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -16,8 +14,7 @@ import DiskLib
|
|||
import CacheLib
|
||||
|
||||
|
||||
#/**
|
||||
# ogCheckFs int_ndisk int_nfilesys
|
||||
## ogCheckFs int_ndisk int_nfilesys
|
||||
#@brief Comprueba el estado de un sistema de archivos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -28,7 +25,6 @@ import CacheLib
|
|||
#@note Requisitos: *fsck*
|
||||
#@warning No se comprueban sistemas de archivos montados o bloqueados.
|
||||
#@todo Definir salidas.
|
||||
#*/ ##
|
||||
def ogCheckFs (disk, par):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return
|
||||
|
@ -87,8 +83,7 @@ def ogCheckFs (disk, par):
|
|||
return not errcode ## reverse to indicate success
|
||||
|
||||
|
||||
#/**
|
||||
# ogExtendFs int_ndisk int_nfilesys
|
||||
## ogExtendFs int_ndisk int_nfilesys
|
||||
#@brief Extiende un sistema de archivos al tamaño de su partición.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -97,7 +92,6 @@ def ogCheckFs (disk, par):
|
|||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@exception OG_ERR_PARTITION Partición desconocida o no accesible.
|
||||
#@note Requisitos: *resize*
|
||||
#*/ ##
|
||||
def ogExtendFs (disk, par):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return
|
||||
|
@ -166,11 +160,8 @@ def ogExtendFs (disk, par):
|
|||
return not rc ## reverse to indicate success
|
||||
|
||||
|
||||
#/**
|
||||
# ogFormat int_ndisk int_nfilesys | CACHE
|
||||
## ogFormat int_ndisk int_nfilesys | CACHE
|
||||
#@see ogFormatFs ogFormatCache
|
||||
#*/ ##
|
||||
|
||||
def ogFormat (disk, par=None, fs=None, label=None):
|
||||
if disk.lower() == "cache":
|
||||
return CacheLib.ogFormatCache()
|
||||
|
@ -178,8 +169,7 @@ def ogFormat (disk, par=None, fs=None, label=None):
|
|||
return ogFormatFs (disk, par, fs=fs, label=label)
|
||||
|
||||
|
||||
#/**
|
||||
# ogFormatFs int_ndisk int_nfilesys [type_fstype] [str_label]
|
||||
## ogFormatFs int_ndisk int_nfilesys [type_fstype] [str_label]
|
||||
#@brief Formatea un sistema de ficheros según el tipo de su partición.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -189,10 +179,9 @@ def ogFormat (disk, par=None, fs=None, label=None):
|
|||
#@exception OG_ERR_FORMAT Formato de ejecución incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@exception OG_ERR_PARTITION Partición no accesible o desconocida.
|
||||
#@note Requisitos: mkfs*
|
||||
#@note Requisitos: mkfs*
|
||||
#@warning No formatea particiones montadas ni bloqueadas.
|
||||
#@todo Definir salidas.
|
||||
#*/ ##
|
||||
def ogFormatFs (disk, par, fs=None, label=None):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return
|
||||
|
@ -266,17 +255,15 @@ def ogFormatFs (disk, par, fs=None, label=None):
|
|||
return not errcode ## reverse to indicate success
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetFsSize int_ndisk int_npartition [str_unit]
|
||||
## ogGetFsSize int_ndisk int_npartition [str_unit]
|
||||
#@brief Muestra el tamanio del sistema de archivos indicado, permite definir la unidad de medida, por defecto GB
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@param str_unit unidad (opcional, por defecto: KB)
|
||||
#@return float_size - Tamaño del sistema de archivos
|
||||
#@note str_unit = { KB, MB, GB, TB }
|
||||
#@note str_unit = { KB, MB, GB, TB }
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositivo.
|
||||
#*/ ##
|
||||
def ogGetFsSize (disk, par, unit='KB'):
|
||||
factor = 1
|
||||
if unit.upper() == "MB":
|
||||
|
@ -302,16 +289,14 @@ def ogGetFsSize (disk, par, unit='KB'):
|
|||
return int (sz)
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetFsType int_ndisk int_nfilesys
|
||||
## ogGetFsType int_ndisk int_nfilesys
|
||||
#@brief Devuelve el mnemonico con el tipo de sistema de archivos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@return Mnemonico
|
||||
#@note Mnemonico: { EXT2, EXT3, EXT4, BTRFS, REISERFS, XFS, JFS, FAT12, FAT16, FAT32, NTFS, LINUX-SWAP, LINUX-LVM, LINUX-RAID, HFS, HFSPLUS, CACHE }
|
||||
#@note Mnemonico: { EXT2, EXT3, EXT4, BTRFS, REISERFS, XFS, JFS, FAT12, FAT16, FAT32, NTFS, LINUX-SWAP, LINUX-LVM, LINUX-RAID, HFS, HFSPLUS, CACHE }
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#*/ ##
|
||||
def ogGetFsType(disk, part):
|
||||
PART = DiskLib.ogDiskToDev(disk, part)
|
||||
if not PART: return
|
||||
|
@ -364,8 +349,7 @@ def ogGetFsType(disk, part):
|
|||
return TYPE
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetMountPoint int_ndisk int_nfilesys
|
||||
## ogGetMountPoint int_ndisk int_nfilesys
|
||||
#@brief Devuelve el punto de montaje de un sistema de archivos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -373,8 +357,6 @@ def ogGetFsType(disk, part):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@note Requisitos: \c mount* \c awk
|
||||
#*/ ##
|
||||
|
||||
def ogGetMountPoint(disk, par):
|
||||
PART = DiskLib.ogDiskToDev(disk, par)
|
||||
if not PART: return
|
||||
|
@ -383,13 +365,11 @@ def ogGetMountPoint(disk, par):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogIsFormated int_ndisk int_nfilesys
|
||||
## ogIsFormated int_ndisk int_nfilesys
|
||||
#@brief Comprueba si un sistema de archivos está formateado.
|
||||
#@param int_ndisk nº de orden del disco o volumen.
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@return Código de salida: True - formateado, False - sin formato o error.
|
||||
#*/ ##
|
||||
def ogIsFormated(disk, part):
|
||||
PART = DiskLib.ogDiskToDev (disk, part)
|
||||
if not PART:
|
||||
|
@ -407,23 +387,18 @@ def ogIsFormated(disk, part):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogIsLocked int_ndisk int_npartition
|
||||
## ogIsLocked int_ndisk int_npartition
|
||||
#@see ogIsPartitionLocked
|
||||
#*/
|
||||
|
||||
def ogIsLocked(disk, par):
|
||||
return ogIsPartitionLocked(disk, par)
|
||||
|
||||
|
||||
#/**
|
||||
# ogIsPartitionLocked int_ndisk int_npartition
|
||||
## ogIsPartitionLocked int_ndisk int_npartition
|
||||
#@brief Comprueba si una partición o su disco están bloqueados por una operación de uso exclusivo.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@return Código de salida: 0 - bloqueado, 1 - sin bloquear o error.
|
||||
#@note Los ficheros de bloqueo se localizan en \c /var/lock/dev, siendo \c dev el dispositivo de la partición o de su disco, sustituyendo el carácter "/" por "-".
|
||||
#*/ ##
|
||||
def ogIsPartitionLocked(disk, par):
|
||||
DISK = DiskLib.ogDiskToDev(disk)
|
||||
PART = DiskLib.ogDiskToDev(disk, par)
|
||||
|
@ -434,19 +409,16 @@ def ogIsPartitionLocked(disk, par):
|
|||
rc = os.path.isfile(LOCKDISK) or os.path.isfile(LOCKPART)
|
||||
return rc
|
||||
|
||||
#/**
|
||||
# ogIsMounted int_ndisk int_nfilesys
|
||||
## ogIsMounted int_ndisk int_nfilesys
|
||||
#@brief Comprueba si un sistema de archivos está montado.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@return Código de salida: 0 - montado, 1 - sin montar o error.
|
||||
#*/ ##
|
||||
def ogIsMounted (disk, par):
|
||||
return bool (ogGetMountPoint (disk, par))
|
||||
|
||||
|
||||
#/**
|
||||
# ogIsReadonly int_ndisk int_nfilesys
|
||||
## ogIsReadonly int_ndisk int_nfilesys
|
||||
#@brief Comprueba si un sistema de archivos está montado solo de lectura.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -454,8 +426,6 @@ def ogIsMounted (disk, par):
|
|||
#@version 1.1.0 - Primera versión para OpenGnsys.
|
||||
#@author Ramon Gomez, ETSII Universidad de Sevilla
|
||||
#@date 2016-01-20
|
||||
#*/ ##
|
||||
|
||||
def ogIsReadonly(disk, par):
|
||||
PART = DiskLib.ogDiskToDev(disk, par)
|
||||
if not PART: return
|
||||
|
@ -465,13 +435,11 @@ def ogIsReadonly(disk, par):
|
|||
return "ro" in options
|
||||
|
||||
|
||||
#/**
|
||||
# ogIsWritable int_ndisk int_nfilesys
|
||||
## ogIsWritable int_ndisk int_nfilesys
|
||||
#@brief Comprueba si un sistema de archivos está montado de lectura y escritura.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@return Código de salida: 0 - lectura y escritura, 1 - solo lectura o no montado.
|
||||
#*/ ##
|
||||
def ogIsWritable (disk, par):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return
|
||||
|
@ -481,15 +449,12 @@ def ogIsWritable (disk, par):
|
|||
return "rw" in options
|
||||
|
||||
|
||||
#/**
|
||||
# ogLock int_ndisk int_npartition
|
||||
## ogLock int_ndisk int_npartition
|
||||
#@see ogLockPartition
|
||||
#*/
|
||||
def ogLock(disk, par):
|
||||
return ogLockPartition(disk, par)
|
||||
|
||||
#/**
|
||||
# ogLockPartition int_ndisk int_npartition
|
||||
## ogLockPartition int_ndisk int_npartition
|
||||
#@brief Genera un fichero de bloqueo para una partición en uso exlusivo.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -497,7 +462,6 @@ def ogLock(disk, par):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@note El fichero de bloqueo se localiza en \c /var/lock/part, siendo \c part el dispositivo de la partición, sustituyendo el carácter "/" por "-".
|
||||
#*/ ##
|
||||
def ogLockPartition (disk, par):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return
|
||||
|
@ -510,10 +474,8 @@ def ogLockPartition (disk, par):
|
|||
return True
|
||||
|
||||
|
||||
#/**
|
||||
# ogMount int_ndisk int_nfilesys
|
||||
## ogMount int_ndisk int_nfilesys
|
||||
#@see ogMountFs ogMountCache ogMountCdrom
|
||||
#*/ ##
|
||||
def ogMount(*args):
|
||||
if 1 == len (args):
|
||||
if 'cache' == args[0].lower():
|
||||
|
@ -524,12 +486,10 @@ def ogMount(*args):
|
|||
return ogMountFs(args[0], args[1])
|
||||
|
||||
|
||||
#/**
|
||||
# ogMountFirstFs int_ndisk
|
||||
## ogMountFirstFs int_ndisk
|
||||
#@brief Monta el primer sistema de archivos disponible en el disco.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return Punto de montaje del primer sistema de archivos detectado
|
||||
#*/ ##
|
||||
def ogMountFirstFs (disk):
|
||||
NPARTS = DiskLib.ogGetPartitionsNumber (disk)
|
||||
for PART in range (1, NPARTS + 1):
|
||||
|
@ -539,8 +499,7 @@ def ogMountFirstFs (disk):
|
|||
SystemLib.ogRaiseError ('session', ogGlobals.OG_ERR_NOTFOUND, f'{disk}')
|
||||
return ogGlobals.OG_ERR_NOTFOUND
|
||||
|
||||
#/**
|
||||
# ogMountFs int_ndisk int_nfilesys
|
||||
## ogMountFs int_ndisk int_nfilesys
|
||||
#@brief Monta un sistema de archivos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -548,7 +507,6 @@ def ogMountFirstFs (disk):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@exception OG_ERR_PARTITION Tipo de particion desconocido o no se puede montar.
|
||||
#*/ ##
|
||||
def ogMountFs (disk, par):
|
||||
dev = DiskLib.ogDiskToDev (disk, par)
|
||||
if not dev: return
|
||||
|
@ -609,8 +567,7 @@ def ogMountFs (disk, par):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogMountCdrom
|
||||
## ogMountCdrom
|
||||
#@brief Monta dispositivo óptico por defecto
|
||||
#@return Punto de montaje
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
|
@ -618,7 +575,6 @@ def ogMountFs (disk, par):
|
|||
#@version
|
||||
#@author
|
||||
#@date
|
||||
#*/ ##
|
||||
def ogMountCdrom():
|
||||
DEV = '/dev/cdrom' # Por defecto
|
||||
outlines = subprocess.run (['mount'], capture_output=True, text=True).stdout.split ('\n')
|
||||
|
@ -641,8 +597,7 @@ def ogMountCdrom():
|
|||
return mntdir
|
||||
|
||||
|
||||
#/**
|
||||
# ogReduceFs int_ndisk int_nfilesys
|
||||
## ogReduceFs int_ndisk int_nfilesys
|
||||
#@brief Reduce el tamaño del sistema de archivos, sin tener en cuenta el espacio libre.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -652,8 +607,7 @@ def ogMountCdrom():
|
|||
#@exception OG_ERR_PARTITION Partición desconocida o no accesible.
|
||||
#@warning En Windows, se borran los ficheros de hiberanción y de paginación.
|
||||
#@warning El sistema de archivos se amplía al mínimo + 10%.
|
||||
#@note Requisitos: *resize*
|
||||
#*/ ##
|
||||
#@note Requisitos: *resize*
|
||||
def ogReduceFs (disk, par):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return
|
||||
|
@ -731,15 +685,12 @@ def ogReduceFs (disk, par):
|
|||
return ogGetFsSize (disk, par)
|
||||
|
||||
|
||||
#/**
|
||||
# ogUnlock int_ndisk int_npartition
|
||||
## ogUnlock int_ndisk int_npartition
|
||||
#@see ogUnlockPartition
|
||||
#*/ ##
|
||||
def ogUnlock (disk, par):
|
||||
return ogUnlockPartition (disk, par)
|
||||
|
||||
#/**
|
||||
# ogUnlockPartition int_ndisk int_npartition
|
||||
## ogUnlockPartition int_ndisk int_npartition
|
||||
#@brief Elimina el fichero de bloqueo para una particion.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -747,7 +698,6 @@ def ogUnlock (disk, par):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@note El fichero de bloqueo se localiza en \c /var/lock/part, siendo \c part el dispositivo de la partición, sustituyendo el carácter "/" por "-".
|
||||
#*/ ##
|
||||
def ogUnlockPartition (disk, par):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return
|
||||
|
@ -757,15 +707,12 @@ def ogUnlockPartition (disk, par):
|
|||
os.remove (LOCKFILE)
|
||||
|
||||
|
||||
#/**
|
||||
# ogUnmount int_ndisk int_npartition
|
||||
## ogUnmount int_ndisk int_npartition
|
||||
#@see ogUnmountFs
|
||||
#*/ ##
|
||||
def ogUnmount (disk, par):
|
||||
return ogUnmountFs (disk, par)
|
||||
|
||||
#/**
|
||||
# ogUnmountFs int_ndisk int_nfilesys
|
||||
## ogUnmountFs int_ndisk int_nfilesys
|
||||
#@brief Desmonta un sistema de archivos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -773,8 +720,6 @@ def ogUnmount (disk, par):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@warning La partición no está previamente montada o no se puede desmontar.
|
||||
#*/ ##
|
||||
|
||||
def ogUnmountFs(disk, par):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return
|
||||
|
@ -805,15 +750,13 @@ def ogUnmountFs(disk, par):
|
|||
return True
|
||||
|
||||
|
||||
#/**
|
||||
# ogUnmountAll int_ndisk
|
||||
## ogUnmountAll int_ndisk
|
||||
#@brief Desmonta todos los sistema de archivos de un disco, excepto el caché local.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return Nada
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@warning No se desmonta la partición marcada como caché local.
|
||||
#*/ ##
|
||||
def ogUnmountAll (disk):
|
||||
DISK = DiskLib.ogDiskToDev (disk)
|
||||
n = DiskLib.ogGetPartitionsNumber (disk)
|
||||
|
@ -823,14 +766,12 @@ def ogUnmountAll (disk):
|
|||
ogUnmount (disk, PART)
|
||||
|
||||
|
||||
#/**
|
||||
# ogUnsetDirtyBit int_ndisk int_npart
|
||||
## ogUnsetDirtyBit int_ndisk int_npart
|
||||
#@brief Inhabilita el Dirty Bit del sistema de ficheros NTFS para evitar un CHKDSK en el primer arranque
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npart nº de orden de partición
|
||||
#@return Nada
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#*/ ##
|
||||
def ogUnsetDirtyBit (disk, par):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return None
|
||||
|
@ -841,8 +782,7 @@ def ogUnsetDirtyBit (disk, par):
|
|||
subprocess.run (['ntfsfix', '--clear-dirty', PART])
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetFreeSize int_disco int_partition str_SizeOutput
|
||||
## ogGetFreeSize int_disco int_partition str_SizeOutput
|
||||
#@brief muestra informacion del tamaño total, datos y libre.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npart nº de orden de partición
|
||||
|
@ -850,8 +790,6 @@ def ogUnsetDirtyBit (disk, par):
|
|||
#@return int_size:int_data:int_free
|
||||
#@TODO Componer corretcamente esta función.
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#*/ ##
|
||||
|
||||
def ogGetFreeSize(disk, part, unit='KB'):
|
||||
PART = DiskLib.ogDiskToDev (disk, part)
|
||||
if not PART: return
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
# python3-git
|
||||
# python3.8
|
||||
# Must have working locales, or unicode strings will fail. Install 'locales', configure /etc/locale.gen, run locale-gen.
|
||||
#
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
@ -38,7 +37,6 @@ from GitLib.kernel import parse_kernel_cmdline
|
|||
from CacheLib import ogMountCache
|
||||
|
||||
|
||||
|
||||
def _git_op_to_string(op):
|
||||
op = op & git.RemoteProgress.OP_MASK
|
||||
if op == git.RemoteProgress.COMPRESSING: return "Compressing", "Obj"
|
||||
|
@ -546,6 +544,9 @@ class OpengnsysGitLibrary:
|
|||
def _efi_copy(self, root_directory, system_specific = False, config_name = None):
|
||||
meta_dir = os.path.join(root_directory, ".opengnsys-metadata")
|
||||
boot_device = self.fs.find_boot_device()
|
||||
if boot_device is None:
|
||||
self.logger.warning("Not copying EFI--boot_device is None")
|
||||
return
|
||||
boot_mount = self.fs.find_mountpoint(boot_device)
|
||||
efi_files_dir = ""
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
#!/usr/bin/python3
|
||||
##@file ImageLib.py
|
||||
#@brief Librería o clase Image
|
||||
#@class Image
|
||||
#@brief Funciones para gestionar imágenes
|
||||
#@warning License: GNU GPLv3+
|
||||
|
||||
import shutil
|
||||
import subprocess
|
||||
|
@ -29,17 +33,14 @@ import NetLib
|
|||
if not shutil.which ('mbuffer'):
|
||||
raise FileNotFoundError ('"mbuffer" utility must be present')
|
||||
|
||||
#/**
|
||||
#@file ImageLib.py
|
||||
#@brief Librería o clase Image
|
||||
#@class Image
|
||||
#@brief Funciones para creación, restauración y clonación de imágenes de sistemas.
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
|
||||
#/**
|
||||
# ogCreateImageSyntax path_device path_filename [str_tool] [str_compressionlevel]
|
||||
## ogCreateImageSyntax path_device path_filename [str_tool] [str_compressionlevel]
|
||||
#@brief Genera una cadena de texto con la instrucción para crear un fichero imagen
|
||||
#@param path_device dispositivo Linux del sistema de archivos
|
||||
#@param path_fileneme path absoluto del fichero imagen
|
||||
|
@ -48,10 +49,9 @@ if not shutil.which ('mbuffer'):
|
|||
#@return str_command - cadena con el comando que se debe ejecutar.
|
||||
#@warning Salida nula si se producen errores.
|
||||
#@TODO introducir las herramientas fsarchiver, dd
|
||||
#*/ ##
|
||||
#ogCreateImageSyntax /dev/sda1 /opt/opengnsys/images/prueba.img partclone lzop
|
||||
#ogCreateImageSyntax /dev/sda1 /opt/opengnsys/images/prueba.img
|
||||
def ogCreateImageSyntax (dev, imgfile, tool='partclone', level='gzip'):
|
||||
#ogCreateImageSyntax /dev/sda1 /opt/opengnsys/images/prueba.img partclone lzop
|
||||
#ogCreateImageSyntax /dev/sda1 /opt/opengnsys/images/prueba.img
|
||||
|
||||
if 'ntfsclone' == tool:
|
||||
param1 = f'ntfsclone --force --save-image -O - {dev}'
|
||||
|
@ -109,8 +109,7 @@ def ogCreateImageSyntax (dev, imgfile, tool='partclone', level='gzip'):
|
|||
if param1: return f'{param1} {param2} {param3} {imgfile}'
|
||||
|
||||
|
||||
#/**
|
||||
# ogRestoreImageSyntax path_filename path_device [str_tools] [str_compressionlevel]
|
||||
## ogRestoreImageSyntax path_filename path_device [str_tools] [str_compressionlevel]
|
||||
#@brief Genera una cadena de texto con la instrucción para crear un fichero imagen
|
||||
#@param path_device dispositivo Linux del sistema de archivos
|
||||
#@param path_fileneme path absoluto del fichero imagen
|
||||
|
@ -121,9 +120,8 @@ def ogCreateImageSyntax (dev, imgfile, tool='partclone', level='gzip'):
|
|||
#@warning En pruebas iniciales
|
||||
#@TODO introducir las herramientas fsarchiver, dd
|
||||
#@TODO introducir el nivel de compresion gzip
|
||||
#*/ ##
|
||||
#ogRestoreImageSyntax /opt/opengnsys/images/prueba.img /dev/sda1 [partclone] [lzop]
|
||||
def ogRestoreImageSyntax (imgfile, part, tool=None, level=None):
|
||||
#ogRestoreImageSyntax /opt/opengnsys/images/prueba.img /dev/sda1 [partclone] [lzop]
|
||||
if not os.path.exists (imgfile):
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, imgfile)
|
||||
## original bash code is broken: 'return' is never called
|
||||
|
@ -183,28 +181,7 @@ def ogRestoreImageSyntax (imgfile, part, tool=None, level=None):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogCreateDiskImage int_ndisk str_repo path_image [str_tools] [str_compressionlevel]
|
||||
#@brief Crea una imagen (copia de seguridad) de un disco completo.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param str_repo repositorio de imágenes (remoto o caché local)
|
||||
#@param path_image camino de la imagen (sin extensión)
|
||||
#@return (nada, por determinar)
|
||||
#@note repo = { REPO, CACHE }
|
||||
#@note Esta primera versión crea imágenes con dd comprimidas con gzip.
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#@exception OG_ERR_LOCKED particion bloqueada por otra operación.
|
||||
#@exception OG_ERR_IMAGE error al crear la imagen del sistema.
|
||||
#@warning En pruebas iniciales
|
||||
#@todo Gestión de bloqueos de disco
|
||||
#@todo Comprobar si debe desmontarse la caché local
|
||||
#@todo Comprobar que no se crea la imagen en el propio disco
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogCreateImage int_ndisk int_npartition str_repo path_image [str_tools] [str_compressionlevel]
|
||||
## ogCreateImage int_ndisk int_npartition str_repo path_image [str_tools] [str_compressionlevel]
|
||||
#@brief Crea una imagen a partir de una partición.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -220,7 +197,6 @@ def ogRestoreImageSyntax (imgfile, part, tool=None, level=None):
|
|||
#@exception OG_ERR_LOCKED particion bloqueada por otra operación.
|
||||
#@exception OG_ERR_IMAGE error al crear la imagen del sistema.
|
||||
#@todo Comprobaciones, control de errores, definir parámetros, etc.
|
||||
#*/ ##
|
||||
def ogCreateImage (disk, par, container, imgfile, tool='partclone', level='gzip'):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return None
|
||||
|
@ -269,38 +245,10 @@ def ogCreateImage (disk, par, container, imgfile, tool='partclone', level='gzip'
|
|||
return not errcode ## reverse to indicate success
|
||||
|
||||
|
||||
#/**
|
||||
# ogCreateMbrImage int_ndisk str_repo path_image
|
||||
#@brief Crea una imagen a partir del sector de arranque de un disco.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param str_repo repositorio de imágenes (remoto o caché local)
|
||||
#@param path_image camino de la imagen (sin extensión)
|
||||
#@return (nada, por determinar)
|
||||
#@note repo = { REPO, CACHE }
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#@exception OG_ERR_IMAGE error al crear la imagen del sistema.
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogCreateBootLoaderImage int_ndisk str_repo path_image
|
||||
#@brief Crea una imagen del boot loader a partir del sector de arranque de un disco.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param str_repo repositorio de imágenes (remoto o caché local)
|
||||
#@param path_image camino de la imagen (sin extensión)
|
||||
#@return (nada, por determinar)
|
||||
#@note repo = { REPO, CACHE }
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#@exception OG_ERR_IMAGE error al crear la imagen del sistema.
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogGetSizeParameters int_num_disk int_num_part str_repo [monolit|sync|diff]
|
||||
## ogGetSizeParameters int_num_disk int_num_part str_repo [monolit|sync|diff]
|
||||
#@brief Devuelve el tamaño de los datos de un sistema de ficheros, el espacio necesario para la imagen y si cabe en el repositorio elegido.
|
||||
#@param int_disk numero de disco
|
||||
#@param int_part numero de particion
|
||||
#@param int_part numero de particion
|
||||
#@param str_repo repositorio de imágenes { REPO, CACHE }
|
||||
#@param str_imageName Nombre de la imagen
|
||||
#@param str_imageType Tipo de imagen: monolit (por defecto), sync o diff. (parametro opcional)
|
||||
|
@ -308,9 +256,8 @@ def ogCreateImage (disk, par, container, imgfile, tool='partclone', level='gzip'
|
|||
#@note si str_imageType= diff necesario /tmp/ogimg.info, que es creado por ogCreateInfoImage.
|
||||
#@note para el tamaño de la imagen no sigue enlaces simbólicos.
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#*/ ##
|
||||
#SIZEDATA, SIZEREQUIRED, SIZEFREE, ISENOUGHSPACE = ogGetSizeParameters (1, 1, 'REPO', 'myimg')
|
||||
def ogGetSizeParameters (disk, par, repo, imgname, imgtype=None):
|
||||
#SIZEDATA, SIZEREQUIRED, SIZEFREE, ISENOUGHSPACE = ogGetSizeParameters (1, 1, 'REPO', 'myimg')
|
||||
repo = repo.upper()
|
||||
## imgtype se soporta como parametro pero se ignora
|
||||
|
||||
|
@ -381,18 +328,16 @@ def ogGetSizeParameters (disk, par, repo, imgname, imgtype=None):
|
|||
|
||||
return sizedata, sizerequired, sizefree, isenoughspace
|
||||
|
||||
#/**
|
||||
# ogIsImageLocked [str_repo] path_image
|
||||
## ogIsImageLocked [str_repo] path_image
|
||||
#@brief Comprueba si una imagen está bloqueada para uso exclusivo.
|
||||
#@param str_repo repositorio de imágenes (opcional)
|
||||
#@param path_image camino de la imagen (sin extensión)
|
||||
#@return Código de salida: 0 - bloqueado, 1 - sin bloquear o error.
|
||||
#@note repo = { REPO, CACHE }
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#*/ ##
|
||||
#ogIsImageLocked ('/opt/opengnsys/images/aula1/win7.img')
|
||||
#ogIsImageLocked ('REPO', '/aula1/win7.img')
|
||||
def ogIsImageLocked (container=None, imgfile=None):
|
||||
#ogIsImageLocked ('/opt/opengnsys/images/aula1/win7.img')
|
||||
#ogIsImageLocked ('REPO', '/aula1/win7.img')
|
||||
if container and imgfile:
|
||||
p = FileLib.ogGetPath (src=container, file=f'{imgfile}.lock')
|
||||
elif imgfile:
|
||||
|
@ -403,8 +348,7 @@ def ogIsImageLocked (container=None, imgfile=None):
|
|||
return os.path.exists (p)
|
||||
|
||||
|
||||
#/**
|
||||
# ogLockImage [str_repo] path_image
|
||||
## ogLockImage [str_repo] path_image
|
||||
#@brief Bloquea una imagen para uso exclusivo.
|
||||
#@param str_repo repositorio de imágenes (opcional)
|
||||
#@param path_image camino de la imagen (sin extensión)
|
||||
|
@ -412,7 +356,6 @@ def ogIsImageLocked (container=None, imgfile=None):
|
|||
#@note Se genera un fichero con extensión .lock
|
||||
#@note repo = { REPO, CACHE }
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#*/ ##
|
||||
def ogLockImage (container=None, imgfile=None):
|
||||
if not imgfile:
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, '')
|
||||
|
@ -432,26 +375,7 @@ def ogLockImage (container=None, imgfile=None):
|
|||
return None
|
||||
|
||||
|
||||
#/**
|
||||
# ogRestoreDiskImage str_repo path_image int_npartition
|
||||
#@brief Restaura (recupera) una imagen de un disco completo.
|
||||
#@param str_repo repositorio de imágenes o caché local
|
||||
#@param path_image camino de la imagen
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return (por determinar)
|
||||
#@warning Primera versión en pruebas
|
||||
#@todo Gestionar bloqueos de disco
|
||||
#@todo Comprobar que no se intenta restaurar de la caché sobre el mismo disco
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero de imagen o partición no detectados.
|
||||
#@exception OG_ERR_LOCKED partición bloqueada por otra operación.
|
||||
#@exception OG_ERR_IMAGE error al restaurar la imagen del sistema.
|
||||
#@exception OG_ERR_IMGSIZEPARTITION Tamaño de la particion es menor al tamaño de la imagen.
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogRestoreImage str_repo path_image int_ndisk int_npartition
|
||||
## ogRestoreImage str_repo path_image int_ndisk int_npartition
|
||||
#@brief Restaura una imagen de sistema de archivos en una partición.
|
||||
#@param str_repo repositorio de imágenes o caché local
|
||||
#@param path_image camino de la imagen
|
||||
|
@ -460,13 +384,11 @@ def ogLockImage (container=None, imgfile=None):
|
|||
#@return (por determinar)
|
||||
#@exception OG_ERR_FORMAT 1 formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND 2 fichero de imagen o partición no detectados.
|
||||
#@exception OG_ERR_PARTITION 3 # Error en partición de disco.
|
||||
#@exception OG_ERR_PARTITION 3 # Error en partición de disco.
|
||||
#@exception OG_ERR_LOCKED 4 partición bloqueada por otra operación.
|
||||
#@exception OG_ERR_IMAGE 5 error al restaurar la imagen del sistema.
|
||||
#@exception OG_ERR_IMGSIZEPARTITION 30 Tamaño de la particion es menor al tamaño de la imagen.
|
||||
#@todo Comprobar incongruencias partición-imagen, control de errores, definir parámetros, caché/repositorio, etc.
|
||||
#*/ ##
|
||||
#ogRestoreImage ('REPO', '/aula1/win7', '1', '1')
|
||||
def ogRestoreImage (repo, imgpath, disk, par):
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART:
|
||||
|
@ -528,33 +450,7 @@ def ogRestoreImage (repo, imgpath, disk, par):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogRestoreMbrImage str_repo path_image int_ndisk
|
||||
#@brief Restaura la imagen del sector de arranque de un disco.
|
||||
#@param str_repo repositorio de imágenes o caché local
|
||||
#@param path_image camino de la imagen
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return (por determinar)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero de imagen o partición no detectados.
|
||||
#@exception OG_ERR_IMAGE error al restaurar la imagen del sistema.
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogRestoreBootLoaderImage str_repo path_image int_ndisk
|
||||
#@brief Restaura la imagen del boot loader del sector de arranque de un disco.
|
||||
#@param str_repo repositorio de imágenes o caché local
|
||||
#@param path_image camino de la imagen
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return (por determinar)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero de imagen o partición no detectados.
|
||||
#@exception OG_ERR_IMAGE error al restaurar la imagen del sistema.
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogUnlockImage [str_repo] path_image
|
||||
## ogUnlockImage [str_repo] path_image
|
||||
#@brief Desbloquea una imagen con uso exclusivo.
|
||||
#@param str_repo repositorio de imágenes (opcional)
|
||||
#@param path_image camino de la imagen (sin extensión)
|
||||
|
@ -562,8 +458,6 @@ def ogRestoreImage (repo, imgpath, disk, par):
|
|||
#@note repo = { REPO, CACHE }
|
||||
#@note Se elimina el fichero de bloqueo con extensión .lock
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#*/ ##
|
||||
#ogUnlockImage REPO /cucu.img
|
||||
def ogUnlockImage (container=None, imgfile=None):
|
||||
f = f'{imgfile}.lock'
|
||||
if container:
|
||||
|
@ -575,8 +469,7 @@ def ogUnlockImage (container=None, imgfile=None):
|
|||
os.unlink (p)
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetImageInfo filename
|
||||
## ogGetImageInfo filename
|
||||
#@brief muestra información sobre la imagen monolitica.
|
||||
#@param 1 filename path absoluto del fichero imagen
|
||||
#@return cadena compuesta por clonacion:compresor:sistemaarchivos:tamañoKB
|
||||
|
@ -587,9 +480,8 @@ def ogUnlockImage (container=None, imgfile=None):
|
|||
#@TODO Definir sintaxis de salida (herramienta y compresor en minuscula)
|
||||
#@TODO Arreglar loop para ntfsclone
|
||||
#@TODO insertar parametros entrada tipo OG
|
||||
#*/ ##
|
||||
#ogGetImageInfo /opt/opengnsys/images/prueba.img ==> PARTCLONE:LZOP:NTFS:5642158"
|
||||
def ogGetImageInfo (imgfile):
|
||||
#ogGetImageInfo /opt/opengnsys/images/prueba.img ==> PARTCLONE:LZOP:NTFS:5642158"
|
||||
if not os.path.exists (imgfile):
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, imgfile)
|
||||
return
|
||||
|
@ -726,8 +618,7 @@ def ogGetImageInfo (imgfile):
|
|||
compressor = compressor.upper()
|
||||
return ':'.join ([tools, compressor, fs, str (size)])
|
||||
|
||||
#/**
|
||||
# ogGetImageProgram str_REPO str_imagen
|
||||
## ogGetImageProgram str_REPO str_imagen
|
||||
#@brief muestra información sobre la imagen monolitica.
|
||||
#@see ogGetImageInfo
|
||||
#@param 1 REPO o CACHE contenedor de la imagen
|
||||
|
@ -736,9 +627,6 @@ def ogGetImageInfo (imgfile):
|
|||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero no encontrado.
|
||||
#@note ogGetImageProgram REPO imagenA -> partclone
|
||||
#*/ ##
|
||||
|
||||
#ogGetImageProgram ('REPO', 'prueba') ==> 'PARTCLONE'
|
||||
def ogGetImageProgram (container, filename):
|
||||
imgfile = FileLib.ogGetPath (container, f'{filename}.img')
|
||||
if not os.path.exists (imgfile):
|
||||
|
@ -747,8 +635,7 @@ def ogGetImageProgram (container, filename):
|
|||
i = ogGetImageInfo (imgfile)
|
||||
return i.split (':')[0]
|
||||
|
||||
#/**
|
||||
# ogGetImageCompressor str_REPO str_imagen
|
||||
## ogGetImageCompressor str_REPO str_imagen
|
||||
#@brief muestra información sobre la imagen monolitica.
|
||||
#@see ogGetImageInfo
|
||||
#@param 1 REPO o CACHE contenedor de la imagen
|
||||
|
@ -757,9 +644,6 @@ def ogGetImageProgram (container, filename):
|
|||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero no encontrado.
|
||||
#@note ogGetImageCompressor REPO imagenA -> lzop
|
||||
#*/ ##
|
||||
|
||||
#ogGetImageCompressor ('REPO', 'prueba') ==> 'LZOP'
|
||||
def ogGetImageCompressor (container, filename):
|
||||
imgfile = FileLib.ogGetPath (container, f'{filename}.img')
|
||||
if not os.path.exists (imgfile):
|
||||
|
@ -769,8 +653,7 @@ def ogGetImageCompressor (container, filename):
|
|||
return i.split (':')[1]
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetImageType str_REPO str_imagen
|
||||
## ogGetImageType str_REPO str_imagen
|
||||
#@brief muestra información sobre el sistema de archivos de imagen monolitica.
|
||||
#@see ogGetImageInfo
|
||||
#@param 1 REPO o CACHE contenedor de la imagen
|
||||
|
@ -779,10 +662,9 @@ def ogGetImageCompressor (container, filename):
|
|||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero no encontrado.
|
||||
#@note ogGetImageType REPO imagenA -> NTFS
|
||||
#*/ ##
|
||||
#ogGetImageType ('REPO', 'imgprueba') ==> 'NTFS'
|
||||
#ogGetImageType ('CACHE', 'testimg') ==> 'EXTFS'
|
||||
def ogGetImageType (repo, imgname):
|
||||
#ogGetImageType ('REPO', 'imgprueba') ==> 'NTFS'
|
||||
#ogGetImageType ('CACHE', 'testimg') ==> 'EXTFS'
|
||||
imgfile = FileLib.ogGetPath (src=repo, file=f'{imgname}.img')
|
||||
if not os.path.exists (imgfile):
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, imgfile)
|
||||
|
@ -793,8 +675,7 @@ def ogGetImageType (repo, imgname):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetImageSize str_REPO str_imagen
|
||||
## ogGetImageSize str_REPO str_imagen
|
||||
#@brief muestra información sobre el tamaño (KB) del sistema de archivos de imagen monolitica.
|
||||
#@see ogGetImageInfo
|
||||
#@param 1 REPO o CACHE contenedor de la imagen
|
||||
|
@ -803,8 +684,6 @@ def ogGetImageType (repo, imgname):
|
|||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero no encontrado.
|
||||
#@note ogGetImagesize REPO imagenA -> 56432234 > Kb
|
||||
#*/ ##
|
||||
#ogGetImageSize ('REPO', 'prueba') ==> '5642158'
|
||||
def ogGetImageSize (repo, imgname):
|
||||
imgfile = FileLib.ogGetPath (src=repo, file=f'{imgname}.img')
|
||||
if not os.path.exists (imgfile):
|
||||
|
@ -813,29 +692,3 @@ def ogGetImageSize (repo, imgname):
|
|||
|
||||
i = ogGetImageInfo (imgfile)
|
||||
return i.split (':')[3]
|
||||
|
||||
|
||||
#/**
|
||||
# ogCreateGptImage int_ndisk str_repo path_image
|
||||
#@brief Crea una imagen de la tabla de particiones GPT de un disco.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param str_repo repositorio de imágenes (remoto o caché local)
|
||||
#@param path_image camino de la imagen (sin extensión)
|
||||
#@return (nada, por determinar)
|
||||
#@note repo = { REPO, CACHE }
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#@exception OG_ERR_IMAGE error al crear la imagen del sistema.
|
||||
#*/ ##
|
||||
|
||||
#/**
|
||||
# ogRestoreGptImage str_repo path_image int_ndisk
|
||||
#@brief Restaura la imagen de la tabla de particiones GPT de un disco.
|
||||
#@param str_repo repositorio de imágenes o caché local
|
||||
#@param path_image camino de la imagen
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@return (por determinar)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero de imagen o partición no detectados.
|
||||
#@exception OG_ERR_IMAGE error al restaurar la imagen del sistema.
|
||||
#*/ ##
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#/**
|
||||
#@file InventoryLib.py
|
||||
##@file InventoryLib.py
|
||||
#@brief Librería o clase Inventory
|
||||
#@class Inventory
|
||||
#@brief Funciones para recogida de datos de inventario de hardware y software de los clientes.
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
import platform
|
||||
import sys
|
||||
|
@ -24,11 +22,9 @@ import RegistryLib
|
|||
import FileLib
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetArch
|
||||
## ogGetArch
|
||||
#@brief Devuelve el tipo de arquitectura del cliente.
|
||||
#@return str_arch - Arquitectura (i386 para 32 bits, x86_64 para 64 bits).
|
||||
#*/
|
||||
def ogGetArch():
|
||||
if os.path.isdir ('/lib64'):
|
||||
return 'x86_64'
|
||||
|
@ -36,14 +32,12 @@ def ogGetArch():
|
|||
return 'i386'
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetOsType int_ndisk int_npartition
|
||||
## ogGetOsType int_ndisk int_npartition
|
||||
#@brief Devuelve el tipo del sistema operativo instalado.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@return OSType - Tipo de sistema operativo.
|
||||
#@see ogGetOsVersion
|
||||
#*/ ##
|
||||
def ogGetOsType(disk, partition):
|
||||
try:
|
||||
os_version = ogGetOsVersion(disk, partition)
|
||||
|
@ -56,15 +50,13 @@ def ogGetOsType(disk, partition):
|
|||
return "Unknown"
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetOsUuid int_ndisk int_nfilesys
|
||||
## ogGetOsUuid int_ndisk int_nfilesys
|
||||
#@brief Devuelve el UUID del sistema operativo instalado en un sistema de archivos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden de la partición
|
||||
#@return str_uuid - UUID del sistema operativo.
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositiv
|
||||
#*/ ##
|
||||
def ogGetOsUuid (disk, par):
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
if not mntdir: return None
|
||||
|
@ -83,10 +75,8 @@ def ogGetOsUuid (disk, par):
|
|||
return uuid
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetSerialNumber
|
||||
## ogGetSerialNumber
|
||||
#@brief Obtiene el nº de serie del cliente.
|
||||
#*/ ##
|
||||
def ogGetSerialNumber():
|
||||
SERIALNO = subprocess.check_output(["dmidecode", "-s", "system-serial-number"]).decode().strip()
|
||||
SERIALNO = re.sub(r"(not specified|to be filled|invalid entry|default string)", "", SERIALNO, flags=re.IGNORECASE)
|
||||
|
@ -96,22 +86,18 @@ def ogGetSerialNumber():
|
|||
return None
|
||||
|
||||
|
||||
#/**
|
||||
# ogIsEfiActive
|
||||
## ogIsEfiActive
|
||||
#@brief Comprueba si el sistema tiene activo el arranque EFI.
|
||||
#*/ ##
|
||||
def ogIsEfiActive():
|
||||
return os.path.isdir("/sys/firmware/efi")
|
||||
|
||||
|
||||
#/**
|
||||
# ogListHardwareInfo
|
||||
## ogListHardwareInfo
|
||||
#@brief Lista el inventario de hardware de la máquina cliente.
|
||||
#@return TipoDispositivo:Modelo (por determinar)
|
||||
#@warning Se ignoran los parámetros de entrada.
|
||||
#@note TipoDispositivo = { bio, boa, bus, cha, cdr, cpu, dis, fir, mem, mod, mul, net, sto, usb, vga }
|
||||
#@note Requisitos: dmidecode, lshw, awk
|
||||
#*/ ##
|
||||
def ogListHardwareInfo():
|
||||
ret = ''
|
||||
|
||||
|
@ -176,8 +162,7 @@ def ogListHardwareInfo():
|
|||
return ret
|
||||
|
||||
|
||||
#/**
|
||||
# ogListSoftware int_ndisk int_npartition
|
||||
## ogListSoftware int_ndisk int_npartition
|
||||
#@brief Lista el inventario de software instalado en un sistema operativo.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -185,7 +170,6 @@ def ogListHardwareInfo():
|
|||
#@warning Se ignoran los parámetros de entrada.
|
||||
#@note Requisitos: ...
|
||||
#@todo Detectar software en Linux
|
||||
#*/ ##
|
||||
def ogListSoftware (disk, par):
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
if not mntdir: return None
|
||||
|
@ -332,8 +316,7 @@ def _find_key_recursive(plist_dict, key_substr):
|
|||
return value
|
||||
return ''
|
||||
|
||||
#/**
|
||||
# ogGetOsVersion int_ndisk int_nfilesys
|
||||
## ogGetOsVersion int_ndisk int_nfilesys
|
||||
#@brief Devuelve la versión del sistema operativo instalado en un sistema de archivos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden de la partición
|
||||
|
@ -343,9 +326,8 @@ def _find_key_recursive(plist_dict, key_substr):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o partición no corresponden con un dispositiv
|
||||
#@exception OG_ERR_PARTITION Fallo al montar el sistema de archivos.
|
||||
#*/ ##
|
||||
#ogGetOsVersion ("1", "2") => "Linux:Ubuntu precise (12.04 LTS) 64 bits"
|
||||
def ogGetOsVersion(disk, part):
|
||||
#ogGetOsVersion ("1", "2") => "Linux:Ubuntu precise (12.04 LTS) 64 bits"
|
||||
mntdir = FileSystemLib.ogMount (disk, part)
|
||||
if not mntdir:
|
||||
return None
|
||||
|
@ -462,15 +444,14 @@ def ogGetOsVersion(disk, part):
|
|||
# Para cargador Windows: buscar versión en fichero BCD (basado en os-prober).
|
||||
if not version:
|
||||
type = 'WinLoader'
|
||||
file = FileLib.ogGetPath (file=f'{mntdir}/boot/bcd')
|
||||
if not file:
|
||||
file = FileLib.ogGetPath (file=f'{mntdir}/EFI/Microsoft/boot/bcd')
|
||||
if file:
|
||||
find_out = subprocess.run (['find', mntdir, '-type', 'f'], capture_output=True, text=True).stdout
|
||||
bcd_files = list (filter (lambda x: 'Boot/BCD' in x, find_out.splitlines()))
|
||||
if bcd_files:
|
||||
for distrib in 'Windows Recovery', 'Windows Boot':
|
||||
with open (file, 'rb') as fd:
|
||||
contents = fd.read()
|
||||
distrib_utf16_regex = re.sub (r'(.)', '\\1.', distrib)
|
||||
distrib_utf16_regex = bytes (distrib_utf16_regex, 'ascii')
|
||||
with open (bcd_files[0], 'rb') as fd:
|
||||
contents = fd.read()
|
||||
if re.search (distrib_utf16_regex, contents):
|
||||
version = f'{distrib} loader'
|
||||
# Para macOS: detectar kernel y completar con fichero plist de información del sistema.
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#/**
|
||||
#@file NetLib.py
|
||||
##@file NetLib.py
|
||||
#@brief Librería o clase Net
|
||||
#@class Net
|
||||
#@brief Funciones básicas de red.
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -32,13 +30,11 @@ def _ogConnect (server, protocol, src, dst, options, readonly):
|
|||
return not subprocess.run (['mount.cifs', f'//{server}/{src}', dst] + options.split()).returncode
|
||||
|
||||
|
||||
#/**
|
||||
# ogChangeRepo IPREPO [ OgUnit ]
|
||||
## ogChangeRepo IPREPO [ OgUnit ]
|
||||
#@brief Cambia el repositorio para el recurso remoto images.
|
||||
#@param 1 Ip Repositorio
|
||||
#@param 2 Abreviatura Unidad Organizativa
|
||||
#@return Cambio recurso remoto en OGIMG.
|
||||
#*/
|
||||
def ogChangeRepo (ip_repo):
|
||||
ogprotocol = os.environ.get ('ogprotocol', 'smb')
|
||||
|
||||
|
@ -67,14 +63,12 @@ def ogChangeRepo (ip_repo):
|
|||
SystemLib.ogRaiseError ('session', ogGlobals.OG_ERR_GENERIC, f'Error executing ogChangeRepo: {e}')
|
||||
return None
|
||||
|
||||
#/**
|
||||
# ogGetGroupDir [ str_repo ]
|
||||
## ogGetGroupDir [ str_repo ]
|
||||
#@brief Devuelve el camino del directorio para el grupo del cliente.
|
||||
#@param str_repo repositorio de imágenes (opcional)
|
||||
#@return path_dir - Camino al directorio del grupo.
|
||||
#@note repo = { REPO, CACHE } REPO por defecto
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#*/
|
||||
def ogGetGroupDir(repo=None):
|
||||
try:
|
||||
repo = repo or "REPO"
|
||||
|
@ -95,11 +89,9 @@ def ogGetGroupDir(repo=None):
|
|||
)
|
||||
return None
|
||||
|
||||
#/**
|
||||
# ogGetGroupName
|
||||
## ogGetGroupName
|
||||
#@brief Devuelve el nombre del grupo al que pertenece el cliente.
|
||||
#@return str_group - Nombre de grupo.
|
||||
#*/
|
||||
def ogGetGroupName():
|
||||
try:
|
||||
group = globals().get("group", None)
|
||||
|
@ -108,11 +100,9 @@ def ogGetGroupName():
|
|||
print(f"Error in ogGetGroupName: {e}")
|
||||
return None
|
||||
|
||||
#/**
|
||||
# ogGetHostname
|
||||
## ogGetHostname
|
||||
#@brief Muestra el nombre del cliente.
|
||||
#@return str_host - nombre de máquina
|
||||
#*/ ##
|
||||
def ogGetHostname():
|
||||
# Tomar nombre de la variable HOSTNAME
|
||||
host = os.getenv("HOSTNAME", "").strip()
|
||||
|
@ -135,12 +125,10 @@ def ogGetHostname():
|
|||
return entry.split("=")[1].strip()
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetIpAddress
|
||||
## ogGetIpAddress
|
||||
#@brief Muestra la dirección IP del sistema
|
||||
#@return str_ip - Dirección IP
|
||||
#@note Usa las variables utilizadas por el initrd "/etc/net-ethX.conf
|
||||
#*/ ##
|
||||
def ogGetIpAddress():
|
||||
if "IPV4ADDR" in os.environ:
|
||||
ip = os.environ["IPV4ADDR"]
|
||||
|
@ -167,11 +155,9 @@ def ogGetIpAddress():
|
|||
return addresses[0]
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetMacAddress
|
||||
## ogGetMacAddress
|
||||
#@brief Muestra la dirección Ethernet del cliente.
|
||||
#@return str_ether - Dirección Ethernet
|
||||
#*/ ##
|
||||
def ogGetMacAddress():
|
||||
try:
|
||||
if "DEVICE" in os.environ:
|
||||
|
@ -211,27 +197,9 @@ def ogGetMacAddress():
|
|||
print(f"Unexpected error: {str(e)}")
|
||||
return None
|
||||
|
||||
#/**
|
||||
# ogGetNetInterface
|
||||
#@brief Muestra la interfaz de red del sistema
|
||||
#@return str_interface - interfaz de red
|
||||
#@note Usa las variables utilizadas por el initrd "/etc/net-ethX.conf
|
||||
#*/ ##
|
||||
#def ogGetNetInterface():
|
||||
# if len(sys.argv) >= 2 and sys.argv[1] == "help":
|
||||
# SystemLib.ogHelp("ogGetNetInterface", "ogGetNetInterface", "ogGetNetInterface => eth0")
|
||||
# return
|
||||
#
|
||||
# if "DEVICE" in os.environ:
|
||||
# print(os.environ["DEVICE"])
|
||||
#
|
||||
# return 0
|
||||
|
||||
#/**
|
||||
# ogGetRepoIp
|
||||
## ogGetRepoIp
|
||||
#@brief Muestra la dirección IP del repositorio de datos.
|
||||
#@return str_ip - Dirección IP
|
||||
#*/ ##
|
||||
def ogGetRepoIp():
|
||||
out = subprocess.run (["findmnt", "--json", "--output", "SOURCE,FSTYPE", ogGlobals.OGIMG], capture_output=True, text=True).stdout
|
||||
try:
|
||||
|
@ -248,48 +216,15 @@ def ogGetRepoIp():
|
|||
|
||||
return None
|
||||
|
||||
#/**
|
||||
# ogGetServerIp
|
||||
## ogGetServerIp
|
||||
#@brief Muestra la dirección IP del Servidor de OpenGnSys.
|
||||
#@return str_ip - Dirección IP
|
||||
#@note Comprobacion segun protocolo de conexion al Repo
|
||||
#*/ ##
|
||||
def ogGetServerIp():
|
||||
return os.environ.get ('ogcore', '')
|
||||
|
||||
#/**
|
||||
# ogGetServerPort
|
||||
## ogGetServerPort
|
||||
#@brief Muestra el puerto del Servidor de OpenGnSys.
|
||||
#@return str_port - Puerto
|
||||
#*/ ##
|
||||
def ogGetServerPort():
|
||||
return os.environ.get ('ogcore_port', '8443')
|
||||
|
||||
|
||||
#/**
|
||||
# ogMakeGroupDir [ str_repo ]
|
||||
#@brief Crea el directorio para el grupo del cliente.
|
||||
#@param str_repo repositorio de imágenes (opcional)
|
||||
#@return (nada)
|
||||
#@note repo = { REPO, CACHE } REPO por defecto
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#*/
|
||||
#def ogMakeGroupDir():
|
||||
# REPO = ""
|
||||
# DIR = ""
|
||||
# GROUP = ""
|
||||
#
|
||||
# if len(sys.argv) < 2:
|
||||
# SystemLib.ogHelp("ogMakeGroupDir", "ogMakeGroupDir str_repo", "ogMakeGroupDir", "ogMakeGroupDir REPO")
|
||||
# return
|
||||
#
|
||||
# if len(sys.argv) == 1:
|
||||
# REPO = "REPO"
|
||||
# else:
|
||||
# REPO = sys.argv[1]
|
||||
#
|
||||
# DIR = FileLib.ogGetPath(REPO, "/groups/" + ogGetGroupName(), stderr=subprocess.DEVNULL)
|
||||
# if DIR:
|
||||
# subprocess.run(["mkdir", "-p", DIR], stderr=subprocess.DEVNULL)
|
||||
#
|
||||
# return 0
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#/**
|
||||
#@file PostConfLib.py
|
||||
##@file PostConfLib.py
|
||||
#@brief Librería o clase PostConf
|
||||
#@class PostConf
|
||||
#@brief Funciones para la postconfiguración de sistemas operativos.
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
import os
|
||||
import re
|
||||
|
@ -20,8 +18,7 @@ import RegistryLib
|
|||
import InventoryLib
|
||||
import BootLib
|
||||
|
||||
#/**
|
||||
# ogCleanOs int_ndisk int_nfilesys
|
||||
## ogCleanOs int_ndisk int_nfilesys
|
||||
#@brief Elimina los archivos que no son necesarios en el sistema operativo.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
|
@ -30,8 +27,6 @@ import BootLib
|
|||
#@exception OG_ERR_PARTITION Partición desconocida o no accesible.
|
||||
#@note Antes incluido en la funcion ogReduceFs
|
||||
#@return (nada)
|
||||
#*/ ##
|
||||
#ogCleanOs (1, 1)
|
||||
def ogCleanOs (disk, par):
|
||||
t = InventoryLib.ogGetOsType (disk, par)
|
||||
if 'Linux' == t:
|
||||
|
@ -46,11 +41,9 @@ def ogCleanOs (disk, par):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogInstallMiniSetup int_ndisk int_npartition str_filename [str_admuser str_admpassword bool_autologin [str_autouser str_autopassword] ]
|
||||
## ogInstallMiniSetup int_ndisk int_npartition str_filename [str_admuser str_admpassword bool_autologin [str_autouser str_autopassword] ]
|
||||
#@brief Metafunción para instalar archivo que se ejecutará en el arranque de Windows.
|
||||
#@see ogInstallFirstBoot ogInstallRunonce
|
||||
#*/ ##
|
||||
def ogInstallMiniSetup (disk, par, cmdfile, user=None, pwd=None, autologin=False, userauto=None, pwdauto=None):
|
||||
if user:
|
||||
ogInstallRunonce (disk, par, cmdfile, user, pwd, autologin, userauto, pwdauto)
|
||||
|
@ -58,8 +51,7 @@ def ogInstallMiniSetup (disk, par, cmdfile, user=None, pwd=None, autologin=False
|
|||
ogInstallFirstBoot (disk, par, cmdfile)
|
||||
|
||||
|
||||
#/**
|
||||
# ogInstallFirstBoot int_ndisk int_npartition str_filename
|
||||
## ogInstallFirstBoot int_ndisk int_npartition str_filename
|
||||
#@brief Crea unas claves del registro y el archivo cmd que se ejecutara en el primer arranque estando la maquina en un estado bloqueado
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -67,8 +59,6 @@ def ogInstallMiniSetup (disk, par, cmdfile, user=None, pwd=None, autologin=False
|
|||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@note El archivo estará en system32 y será visible por el sistema.
|
||||
#*/ ##
|
||||
#ogInstallFirstBoot ('1', '1', 'filename.cmd')
|
||||
def ogInstallFirstBoot (disk, par, cmdfile):
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
if not mntdir: return
|
||||
|
@ -95,8 +85,7 @@ def ogInstallFirstBoot (disk, par, cmdfile):
|
|||
RegistryLib.ogSetRegistryValue (mntdir, 'SYSTEM', r'\Setup\CmdLine', f'cmd.exe /c {bn}')
|
||||
|
||||
|
||||
#/**
|
||||
# ogInstallRunonce int_ndisk int_npartition str_filename str_adm_user str_adm_password bool_autologin [str_auto_user str_auto_password]
|
||||
## ogInstallRunonce int_ndisk int_npartition str_filename str_adm_user str_adm_password bool_autologin [str_auto_user str_auto_password]
|
||||
#@brief Crea el archivo cmd que se ejecutara en el runonce de un usuario administrador
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -108,10 +97,9 @@ def ogInstallFirstBoot (disk, par, cmdfile):
|
|||
#@param str_auto_password Password del usuario que hara autologin
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#*/ ##
|
||||
#ogInstallRunonce ('1', '1', 'filename.cmd', 'administrator', 'passadmin', '1', 'userauto', 'pwdauto')
|
||||
#ogInstallRunonce ('1', '1', 'filename.cmd', 'administrator', 'passadmin', '0')
|
||||
def ogInstallRunonce (disk, par, cmdfile, user, pwd, autologin, userauto=None, pwdauto=None):
|
||||
#ogInstallRunonce ('1', '1', 'filename.cmd', 'administrator', 'passadmin', '1', 'userauto', 'pwdauto')
|
||||
#ogInstallRunonce ('1', '1', 'filename.cmd', 'administrator', 'passadmin', '0')
|
||||
mountpoint = FileLib.ogGetPath (src=f'{disk} {par}', file='/')
|
||||
for i in ['winnt', 'windows']:
|
||||
dir = FileLib.ogGetPath (file=f'{mountpoint}/{i}/system32')
|
||||
|
@ -148,18 +136,14 @@ def ogInstallRunonce (disk, par, cmdfile, user, pwd, autologin, userauto=None, p
|
|||
RegistryLib.ogDeleteRegistryValue (mountpoint, 'software', r'\Microsoft\Windows NT\CurrentVersion\Winlogon\ForceAutoLockOnLogon')
|
||||
RegistryLib.ogDeleteRegistryValue (mountpoint, 'software', r'\Microsoft\Windows NT\CurrentVersion\Winlogon\AutoLogonCount')
|
||||
|
||||
#/**
|
||||
# ogAddCmd int_ndisk int_npartition str_filename str_commands
|
||||
## ogAddCmd int_ndisk int_npartition str_filename str_commands
|
||||
#@brief Añade comandos al cmd creado por ogInstalMiniSetup
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@param str_filename nombre del fichero cmd (siempre se guardara en windows\system32\para que sea visible por el sistema
|
||||
#@param str_commands comando o comandos que se añadiran al fichero
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#*/ ##
|
||||
#ogAddCmd ('1', '1', 'filename.cmd', 'command')
|
||||
def ogAddCmd (disk, par, cmdfile, cmd):
|
||||
mountpoint = FileSystemLib.ogMount (disk, par)
|
||||
if not mountpoint: return
|
||||
|
@ -175,24 +159,7 @@ def ogAddCmd (disk, par, cmdfile, cmd):
|
|||
fd.write (cmd + '\n')
|
||||
|
||||
|
||||
#/**
|
||||
# ogDomainScript int_ndisk int_npartition str_domain str_user str_password
|
||||
#@brief Crea un script .vbs para unir al dominio una maquina windows y el comando adequado en el archivo cmd creado por ogInstallMiniSetup
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
#@param str_filename nombre del fichero cmd donde deberemos introducir el comando de ejecutar el script vbs
|
||||
#@param str_domain dominio donde se quiere conectar
|
||||
#@param str_user usuario con privilegios para unir al dominio
|
||||
#@param str_password password del usuario con privilegios
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#*/ ##
|
||||
|
||||
|
||||
### PRUEBAS.
|
||||
|
||||
#/**
|
||||
# ogConfigureOgagent int_ndisk int_filesys
|
||||
## ogConfigureOgagent int_ndisk int_filesys
|
||||
#@brief Modifica el fichero de configuración del nuevo agente OGAent para sistemas operativos.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_filesys nº de orden del sistema de archivos
|
||||
|
@ -200,7 +167,6 @@ def ogAddCmd (disk, par, cmdfile, cmd):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero o dispositivo no encontrado.
|
||||
#@exception OG_ERR_LOCKED Sistema de archivos bloqueado.
|
||||
#*/ ##
|
||||
def ogConfigureOgagent (disk, par, imgname=''):
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
if not mntdir:
|
||||
|
@ -238,36 +204,7 @@ def ogConfigureOgagent (disk, par, imgname=''):
|
|||
os.rename (cfgfile_patched, cfgfile)
|
||||
|
||||
|
||||
#/**
|
||||
# ogInstallLaunchDaemon int_ndisk int_nfilesys str_filename
|
||||
#@brief Instala archivo que se ejecutará en el arranque de macOS.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@param str_filename nombre del script
|
||||
#return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero o directorio no encontrado.
|
||||
#@npte Crea ficheros de configuración /Library/LaunchDaemon/es.opengnsys.Script.plist.
|
||||
#*/ ##
|
||||
|
||||
|
||||
### PRUEBAS.
|
||||
|
||||
#/**
|
||||
# ogAddToLaunchDaemon int_ndisk int_nfilesys str_filename str_commands
|
||||
#@brief Añade comandos al script creado por ogInstalLaunchDaemon.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@param str_filename nombre del script (siempre se guardará en /usr/share para que sea visible por el sistema
|
||||
#@param str_commands comando o comandos que se añadiran al fichero
|
||||
#return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Fichero o directorio no encontrado.
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogUninstallLinuxClient int_ndisk int_filesys
|
||||
## ogUninstallLinuxClient int_ndisk int_filesys
|
||||
#@brief Desinstala el cliente OpenGnSys para sistemas operativos GNU/Linux.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_filesys nº de orden del sistema de archivos
|
||||
|
@ -275,7 +212,6 @@ def ogConfigureOgagent (disk, par, imgname=''):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Paritición o sistema de archivos incorrectos.
|
||||
#@exception OG_ERR_LOCKED Sistema de archivos bloqueado.
|
||||
#*/ ##
|
||||
def ogUninstallLinuxClient (disk, par):
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
if not mntdir:
|
||||
|
@ -300,8 +236,7 @@ def ogUninstallLinuxClient (disk, par):
|
|||
subprocess.run (['sed', '-i', '-e', '/ogAdmLnxClient/ d', f], stderr=subprocess.DEVNULL)
|
||||
|
||||
|
||||
#/**
|
||||
# ogUninstallWindowsClient int_ndisk int_filesys str_filename
|
||||
## ogUninstallWindowsClient int_ndisk int_filesys str_filename
|
||||
#@brief Desinstala el cliente OpenGnSys para sistemas operativos Windows.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_npartition nº de orden de la partición
|
||||
|
@ -310,7 +245,6 @@ def ogUninstallLinuxClient (disk, par):
|
|||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION Paritición o sistema de archivos incorrectos.
|
||||
#@exception OG_ERR_LOCKED Sistema de archivos bloqueado.
|
||||
#*/ ##
|
||||
#ogUninstallWindowsClient ('1', '1', 'filename.cmd')
|
||||
def ogUninstallWindowsClient (disk, par, cmdfile):
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
#!/usr/bin/python3
|
||||
##@file ProtocolLib.py
|
||||
#@brief Librería o clase Protocol
|
||||
#@class Protocol
|
||||
#@brief Funciones de protocolo de red
|
||||
#@warning License: GNU GPLv3+
|
||||
|
||||
import subprocess
|
||||
import re
|
||||
|
@ -16,19 +20,16 @@ import DiskLib
|
|||
import FileLib
|
||||
import CacheLib
|
||||
|
||||
#/**
|
||||
#@file ProtocolLib.py
|
||||
#@brief Librería o clase Protocol
|
||||
#@class Protocol
|
||||
#@brief Funciones para transmisión de datos
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
|
||||
##################### FUNCIONES UNICAST ################
|
||||
|
||||
#/**
|
||||
# ogUcastSyntax
|
||||
## ogUcastSyntax
|
||||
#@brief Función para generar la instrucción de transferencia de datos unicast
|
||||
#@param 1 Tipo de operación [ SENDPARTITION RECEIVERPARTITION SENDFILE RECEIVERFILE ]
|
||||
#@param 2 Sesion Unicast
|
||||
|
@ -40,15 +41,11 @@ import CacheLib
|
|||
#@exception OG_ERR_UCASTSYNTAXT formato de la sesion unicast incorrecta.
|
||||
#@note Requisitos: mbuffer
|
||||
#@todo: controlar que mbuffer esta disponible para los clientes.
|
||||
#*/ ##
|
||||
|
||||
#ogUcastSyntax SENDPARTITION 8000:172.17.36.11:172.17.36.12 device tool level
|
||||
#ogUcastSyntax RECEIVERPARTITION 8000:172.17.36.249 device tool level
|
||||
|
||||
#ogUcastSyntax SENDFILE 8000:172.17.36.11:172.17.36.12 file
|
||||
#ogUcastSyntax RECEIVERFILE 8000:172.17.36.249 file
|
||||
|
||||
def ogUcastSyntax (op, sess, file=None, device=None, tool=None, level=None):
|
||||
#ogUcastSyntax SENDPARTITION 8000:172.17.36.11:172.17.36.12 device tool level
|
||||
#ogUcastSyntax RECEIVERPARTITION 8000:172.17.36.249 device tool level
|
||||
#ogUcastSyntax SENDFILE 8000:172.17.36.11:172.17.36.12 file
|
||||
#ogUcastSyntax RECEIVERFILE 8000:172.17.36.249 file
|
||||
if 'SENDPARTITION' == op or 'RECEIVERPARTITION' == op:
|
||||
if device is None:
|
||||
raise TypeError ('missing required argument: "device"')
|
||||
|
@ -106,22 +103,19 @@ def ogUcastSyntax (op, sess, file=None, device=None, tool=None, level=None):
|
|||
pass ## shouldn't happen
|
||||
|
||||
|
||||
#/**
|
||||
# ogUcastSendPartition
|
||||
## ogUcastSendPartition
|
||||
#@brief Función para enviar el contenido de una partición a multiples particiones remotas usando UNICAST.
|
||||
#@param 1 disk
|
||||
#@param 2 partition
|
||||
#@param 3 sesionUcast
|
||||
#@param 4 tool image
|
||||
#@param 5 tool compresor
|
||||
#@return
|
||||
#@exception $OG_ERR_FORMAT
|
||||
#@exception $OG_ERR_UCASTSENDPARTITION
|
||||
#@note
|
||||
#@todo: ogIsLocked siempre devuelve 1
|
||||
#*/ ##
|
||||
#ogUcastSendPartition 1 2 8001:192.168.1.113 partclone lzop
|
||||
def ogUcastSendPartition (disk, par, sess, tool, level):
|
||||
#ogUcastSendPartition 1 2 8001:192.168.1.113 partclone lzop
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return None
|
||||
|
||||
|
@ -137,22 +131,19 @@ def ogUcastSendPartition (disk, par, sess, tool, level):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogUcastReceiverPartition
|
||||
## ogUcastReceiverPartition
|
||||
#@brief Función para recibir directamente en la partición el contenido de un fichero imagen remoto enviado por UNICAST.
|
||||
#@param 1 disk
|
||||
#@param 2 partition
|
||||
#@param 3 session unicast
|
||||
#@param 4 tool image
|
||||
#@param 5 tool compresor
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT
|
||||
#@exception OG_ERR_UCASTRECEIVERPARTITION
|
||||
#@note
|
||||
#@todo:
|
||||
#*/ ##
|
||||
#ogUcastReceiverPartition 1 1 8001:192.168.1.111 partclone lzop
|
||||
def ogUcastReceiverPartition (disk, par, sess, tool, level):
|
||||
#ogUcastReceiverPartition 1 1 8001:192.168.1.111 partclone lzop
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return None
|
||||
|
||||
|
@ -168,32 +159,25 @@ def ogUcastReceiverPartition (disk, par, sess, tool, level):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogUcastSendFile [ str_repo | int_ndisk int_npart ] /Relative_path_file sessionMulticast
|
||||
## ogUcastSendFile [ str_repo | int_ndisk int_npart ] /Relative_path_file sessionMulticast
|
||||
#@brief Envía un fichero por unicast ORIGEN(fichero) DESTINO(sessionmulticast)
|
||||
#@param (2 parámetros) $1 path_aboluto_fichero $2 sesionMcast
|
||||
#@param (3 parámetros) $1 Contenedor REPO|CACHE $2 path_absoluto_fichero $3 sesionMulticast
|
||||
#@param (4 parámetros) $1 disk $2 particion $3 path_absoluto_fichero $4 sesionMulticast
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception $OG_ERR_NOTFOUND
|
||||
#@exception OG_ERR_UCASTSENDFILE
|
||||
#@note Requisitos:
|
||||
#*/ ##
|
||||
#
|
||||
|
||||
## TODO esta función es idéntica a ogMcastSendFile pero con s/Ucast/Mcast/;
|
||||
|
||||
#ogUcastSendFile ([str_REPOSITORY] [int_ndisk int_npart] /Relative_path_file sesionMcast(puerto:ip:ip:ip)" \
|
||||
#ogUcastSendFile (disk=1, par=1, file='/aula1/winxp.img', sess='8000:172.17.36.11:172.17.36.12')
|
||||
#ogUcastSendFile (container='REPO', file='/aula1/ubuntu.iso', sess='sesionUcast')
|
||||
#ogUcastSendFile (container='CACHE', file='/aula1/winxp.img', sess='sesionUcast')
|
||||
#ogUcastSendFile ( file='/opt/opengnsys/images/aula1/hd500.vmx', sess='sesionUcast')
|
||||
|
||||
#ogUcastSendFile 1 2 /boot/vmlinuz-6.8.0-51-generic 8000:192.168.1.113
|
||||
#ogUcastSendFile 1 4 /swapfile.sys 8000:192.168.1.111
|
||||
#ogUcastSendFile REPO /ubu24.img 8000:192.168.1.111
|
||||
def ogUcastSendFile (disk=None, par=None, container=None, file=None, sess=None):
|
||||
## TODO esta función es idéntica a ogMcastSendFile pero con s/Ucast/Mcast/;
|
||||
#ogUcastSendFile ([str_REPOSITORY] [int_ndisk int_npart] /Relative_path_file sesionMcast(puerto:ip:ip:ip)" \
|
||||
#ogUcastSendFile (disk=1, par=1, file='/aula1/winxp.img', sess='8000:172.17.36.11:172.17.36.12')
|
||||
#ogUcastSendFile (container='REPO', file='/aula1/ubuntu.iso', sess='sesionUcast')
|
||||
#ogUcastSendFile (container='CACHE', file='/aula1/winxp.img', sess='sesionUcast')
|
||||
#ogUcastSendFile ( file='/opt/opengnsys/images/aula1/hd500.vmx', sess='sesionUcast')
|
||||
#ogUcastSendFile 1 2 /boot/vmlinuz-6.8.0-51-generic 8000:192.168.1.113
|
||||
#ogUcastSendFile 1 4 /swapfile.sys 8000:192.168.1.111
|
||||
#ogUcastSendFile REPO /ubu24.img 8000:192.168.1.111
|
||||
if file is None:
|
||||
raise TypeError ('missing required argument: "file"')
|
||||
if sess is None:
|
||||
|
@ -258,8 +242,7 @@ def _binary_ip (ip):
|
|||
break
|
||||
return match
|
||||
|
||||
#/**
|
||||
# ogMcastSyntax
|
||||
## ogMcastSyntax
|
||||
#@brief Función para generar la instrucción de ejucción la transferencia de datos multicast
|
||||
#@param 1 Tipo de operación [ SENDPARTITION RECEIVERPARTITION SENDFILE RECEIVERFILE ]
|
||||
#@param 2 Sesión Mulicast
|
||||
|
@ -272,17 +255,13 @@ def _binary_ip (ip):
|
|||
#@exception OG_ERR_MCASTSYNTAXT
|
||||
#@note Requisitos: upd-cast 2009 o superior
|
||||
#@todo localvar check versionudp
|
||||
#*/ ##
|
||||
#
|
||||
|
||||
#ogMcastSyntax SENDPARTITION 9000:full-duplex|half-duplex|broadcast:239.194.17.36:80M:50:60 device tools level
|
||||
#ogMcastSyntax RECEIVERPARTITION 9000 device tools level
|
||||
#ogMcastSyntax RECEIVERPARTITION 9000:172.17.88.161:40:120 device tools level
|
||||
|
||||
#ogMcastSyntax SENDFILE 9000:full-duplex|half-duplex|broadcast:239.194.17.36:80M:50:60 file
|
||||
#ogMcastSyntax RECEIVERFILE 9000 file
|
||||
#ogMcastSyntax RECEIVERFILE 9000:172.17.88.161:40:120 file
|
||||
def ogMcastSyntax (op, sess, file=None, device=None, tool=None, level=None):
|
||||
#ogMcastSyntax SENDPARTITION 9000:full-duplex|half-duplex|broadcast:239.194.17.36:80M:50:60 device tools level
|
||||
#ogMcastSyntax RECEIVERPARTITION 9000 device tools level
|
||||
#ogMcastSyntax RECEIVERPARTITION 9000:172.17.88.161:40:120 device tools level
|
||||
#ogMcastSyntax SENDFILE 9000:full-duplex|half-duplex|broadcast:239.194.17.36:80M:50:60 file
|
||||
#ogMcastSyntax RECEIVERFILE 9000 file
|
||||
#ogMcastSyntax RECEIVERFILE 9000:172.17.88.161:40:120 file
|
||||
if 'SENDPARTITION' == op or 'RECEIVERPARTITION' == op:
|
||||
if device is None:
|
||||
raise TypeError ('missing required argument: "device"')
|
||||
|
@ -431,29 +410,23 @@ def ogMcastSyntax (op, sess, file=None, device=None, tool=None, level=None):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogMcastSendFile [ str_repo | int_ndisk int_npart ] /Relative_path_file sessionMulticast
|
||||
## ogMcastSendFile [ str_repo | int_ndisk int_npart ] /Relative_path_file sessionMulticast
|
||||
#@brief Envía un fichero por multicast ORIGEN(fichero) DESTINO(sessionmulticast)
|
||||
#@param (2 parámetros) $1 path_aboluto_fichero $2 sesionMcast
|
||||
#@param (3 parámetros) $1 Contenedor REPO|CACHE $2 path_absoluto_fichero $3 sesionMulticast
|
||||
#@param (4 parámetros) $1 disk $2 particion $3 path_absoluto_fichero $4 sesionMulticast
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception $OG_ERR_NOTFOUND
|
||||
#@exception OG_ERR_MCASTSENDFILE
|
||||
#*/ ##
|
||||
#
|
||||
|
||||
#ogMcastSendFile [str_REPOSITORY] [int_ndisk int_npart] /Relative_path_file sesionMcast" \
|
||||
#ogMcastSendFile (disk=1, par=1, file='/aula1/winxp.img', sess='sesionMcast')
|
||||
#ogMcastSendFile (container='REPO', file='/aula1/ubuntu.iso', sess='sesionMcast')
|
||||
#ogMcastSendFile (container='CACHE', file='/aula1/winxp.img', sess='sesionMcast')
|
||||
#ogMcastSendFile ( file='/opt/opengnsys/images/aula1/hd500.vmx', sess='sesionMcast')
|
||||
|
||||
#ogMcastSendFile 1 2 /boot/vmlinuz-6.8.0-51-generic 9000:full-duplex:239.194.37.31:50M:20:10
|
||||
#ogMcastSendFile REPO /ubu24.img 9000:full-duplex:239.194.37.31:50M:20:10
|
||||
#ogMcastSendFile /usr/lib64/ld-linux-x86-64.so.2 9000:full-duplex:239.194.37.31:50M:20:10
|
||||
def ogMcastSendFile (disk=None, par=None, container=None, file=None, sess=None):
|
||||
#ogMcastSendFile [str_REPOSITORY] [int_ndisk int_npart] /Relative_path_file sesionMcast" \
|
||||
#ogMcastSendFile (disk=1, par=1, file='/aula1/winxp.img', sess='sesionMcast')
|
||||
#ogMcastSendFile (container='REPO', file='/aula1/ubuntu.iso', sess='sesionMcast')
|
||||
#ogMcastSendFile (container='CACHE', file='/aula1/winxp.img', sess='sesionMcast')
|
||||
#ogMcastSendFile ( file='/opt/opengnsys/images/aula1/hd500.vmx', sess='sesionMcast')
|
||||
#ogMcastSendFile 1 2 /boot/vmlinuz-6.8.0-51-generic 9000:full-duplex:239.194.37.31:50M:20:10
|
||||
#ogMcastSendFile REPO /ubu24.img 9000:full-duplex:239.194.37.31:50M:20:10
|
||||
#ogMcastSendFile /usr/lib64/ld-linux-x86-64.so.2 9000:full-duplex:239.194.37.31:50M:20:10
|
||||
if file is None:
|
||||
raise TypeError ('missing required argument: "file"')
|
||||
if sess is None:
|
||||
|
@ -498,26 +471,20 @@ def ogMcastSendFile (disk=None, par=None, container=None, file=None, sess=None):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogMcastReceiverFile sesion Multicast [ str_repo | int_ndisk int_npart ] /Relative_path_file
|
||||
## ogMcastReceiverFile sesion Multicast [ str_repo | int_ndisk int_npart ] /Relative_path_file
|
||||
#@brief Recibe un fichero multicast ORIGEN(sesionmulticast) DESTINO(fichero)
|
||||
#@param (2 parámetros) $1 sesionMcastCLIENT $2 path_aboluto_fichero_destino
|
||||
#@param (3 parámetros) $1 sesionMcastCLIENT $2 Contenedor REPO|CACHE $3 path_absoluto_fichero_destino
|
||||
#@param (4 parámetros) $1 sesionMcastCLIENT $2 disk $3 particion $4 path_absoluto_fichero_destino
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception $OG_ERR_MCASTRECEIVERFILE
|
||||
#@note Requisitos:
|
||||
#*/ ##
|
||||
#
|
||||
|
||||
#ogMcastReceiverFile ([ str_portMcast] [ [Relative_path_file] | [str_REPOSITORY path_file] | [int_ndisk int_npart path_file ] ]" \
|
||||
#ogMcastReceiverFile ( file='/PS1_PH1.img', sess='9000')
|
||||
#ogMcastReceiverFile (container='CACHE', file='/aula1/PS2_PH4.img', sess='9000')
|
||||
#ogMcastReceiverFile (disk=1, par=1, file='/isos/linux.iso', sess='9000')
|
||||
|
||||
#ogMcastReceiverFile 9000:full-duplex:239.194.37.31 1 4 /hola
|
||||
def ogMcastReceiverFile (disk=None, par=None, container=None, file=None, sess=None):
|
||||
#ogMcastReceiverFile ([ str_portMcast] [ [Relative_path_file] | [str_REPOSITORY path_file] | [int_ndisk int_npart path_file ] ]" \
|
||||
#ogMcastReceiverFile ( file='/PS1_PH1.img', sess='9000')
|
||||
#ogMcastReceiverFile (container='CACHE', file='/aula1/PS2_PH4.img', sess='9000')
|
||||
#ogMcastReceiverFile (disk=1, par=1, file='/isos/linux.iso', sess='9000')
|
||||
#ogMcastReceiverFile 9000:full-duplex:239.194.37.31 1 4 /hola
|
||||
if file is None:
|
||||
raise TypeError ('missing required argument: "file"')
|
||||
if sess is None:
|
||||
|
@ -558,25 +525,21 @@ def ogMcastReceiverFile (disk=None, par=None, container=None, file=None, sess=No
|
|||
return True
|
||||
|
||||
|
||||
#/**
|
||||
# ogMcastSendPartition
|
||||
## ogMcastSendPartition
|
||||
#@brief Función para enviar el contenido de una partición a multiples particiones remotas.
|
||||
#@param 1 disk
|
||||
#@param 2 partition
|
||||
#@param 3 session multicast
|
||||
#@param 4 tool clone
|
||||
#@param 5 tool compressor
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT
|
||||
#@exception OG_ERR_MCASTSENDPARTITION
|
||||
#@note
|
||||
#@todo: ogIsLocked siempre devuelve 1. crear ticket
|
||||
#*/ ##
|
||||
|
||||
#ogMcastSendPartition (disk, par, SessionMulticastSERVER, tools, compresor)
|
||||
#ogMcastSendPartition (1, 1, '9000:full-duplex:239.194.37.31:50M:20:2', 'partclone', 'lzop')
|
||||
#ogMcastSendPartition 1 2 9000:full-duplex:239.194.37.31:50M:20:10 partclone lzop
|
||||
def ogMcastSendPartition (disk, par, sess, tool, compressor):
|
||||
#ogMcastSendPartition (disk, par, SessionMulticastSERVER, tools, compresor)
|
||||
#ogMcastSendPartition (1, 1, '9000:full-duplex:239.194.37.31:50M:20:2', 'partclone', 'lzop')
|
||||
#ogMcastSendPartition 1 2 9000:full-duplex:239.194.37.31:50M:20:10 partclone lzop
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return
|
||||
|
||||
|
@ -589,19 +552,16 @@ def ogMcastSendPartition (disk, par, sess, tool, compressor):
|
|||
return None
|
||||
return True
|
||||
|
||||
#/**
|
||||
# ogMcastReceiverPartition
|
||||
## ogMcastReceiverPartition
|
||||
#@brief Función para recibir directamente en la partición el contenido de un fichero imagen remoto enviado por multicast.
|
||||
#@param 1 disk
|
||||
#@param 2 partition
|
||||
#@param 3 session multicast
|
||||
#@param 4 tool clone
|
||||
#@param 5 tool compressor
|
||||
#@return
|
||||
#@exception $OG_ERR_FORMAT
|
||||
#*/ ##
|
||||
#ogMcastReceiverPartition 1 1 9000:full-duplex:239.194.37.31 partclone lzop
|
||||
def ogMcastReceiverPartition (disk, par, sess, tool, compressor):
|
||||
#ogMcastReceiverPartition 1 1 9000:full-duplex:239.194.37.31 partclone lzop
|
||||
PART = DiskLib.ogDiskToDev (disk, par)
|
||||
if not PART: return
|
||||
|
||||
|
@ -615,10 +575,7 @@ def ogMcastReceiverPartition (disk, par, sess, tool, compressor):
|
|||
return True
|
||||
|
||||
|
||||
##########################################
|
||||
############## funciones torrent
|
||||
#/**
|
||||
# ogTorrentStart [ str_repo | int_ndisk int_npart ] Relative_path_file.torrent | SessionProtocol
|
||||
## ogTorrentStart [ str_repo | int_ndisk int_npart ] Relative_path_file.torrent | SessionProtocol
|
||||
#@brief Función iniciar P2P - requiere un tracker para todos los modos, y un seeder para los modos peer y leecher y los ficheros .torrent.
|
||||
#@param str_pathDirectory str_Relative_path_file
|
||||
#@param int_disk int_partition str_Relative_path_file
|
||||
|
@ -626,16 +583,14 @@ def ogMcastReceiverPartition (disk, par, sess, tool, compressor):
|
|||
#@param (2 parámetros) $1 path_aboluto_fichero_torrent $2 Parametros_Session_Torrent
|
||||
#@param (3 parámetros) $1 Contenedor CACHE $2 path_absoluto_fichero_Torrent $3 Parametros_Session_Torrent
|
||||
#@param (4 parámetros) $1 disk $2 particion $3 path_absoluto_fichero_Torrent 4$ Parametros_Session_Torrent
|
||||
#@return
|
||||
#@note protocoloTORRENT=mode:time mode=seeder -> Dejar el equipo seedeando hasta que transcurra el tiempo indicado o un kill desde consola, mode=peer -> seedear mientras descarga mode=leecher -> NO seedear mientras descarga time tiempo que una vez descargada la imagen queremos dejar al cliente como seeder.
|
||||
#*/ ##
|
||||
#ogTorrentStart ( torrentfile='/opt/opengnsys/cache/linux.iso', torrentsess='peer:60')
|
||||
#ogTorrentStart (container='CACHE', torrentfile='/PS1_PH1.img.torrent', torrentsess='seeder:10000')
|
||||
#ogTorrentStart (disk=1, par=1, torrentfile='/linux.iso.torrent', torrentsess='leecher:60')
|
||||
#ogTorrentStart /opt/opengnsys/cache/opt/opengnsys/images/ubu24.EXTFS.torrent seeder:10000
|
||||
#ogTorrentStart 1 4 /opt/opengnsys/images/ubu24.EXTFS.torrent seeder:10000
|
||||
#ogTorrentStart CACHE /ubu24.EXTFS.torrent seeder:10000
|
||||
def ogTorrentStart (disk=None, par=None, container=None, torrentfile=None, torrentsess=None):
|
||||
#ogTorrentStart ( torrentfile='/opt/opengnsys/cache/linux.iso', torrentsess='peer:60')
|
||||
#ogTorrentStart (container='CACHE', torrentfile='/PS1_PH1.img.torrent', torrentsess='seeder:10000')
|
||||
#ogTorrentStart (disk=1, par=1, torrentfile='/linux.iso.torrent', torrentsess='leecher:60')
|
||||
#ogTorrentStart /opt/opengnsys/cache/opt/opengnsys/images/ubu24.EXTFS.torrent seeder:10000
|
||||
#ogTorrentStart 1 4 /opt/opengnsys/images/ubu24.EXTFS.torrent seeder:10000
|
||||
#ogTorrentStart CACHE /ubu24.EXTFS.torrent seeder:10000
|
||||
if torrentfile is None:
|
||||
raise TypeError ('missing required argument: "torrentfile"')
|
||||
if torrentsess is None:
|
||||
|
@ -698,22 +653,22 @@ def ogTorrentStart (disk=None, par=None, container=None, torrentfile=None, torre
|
|||
OPTION = None
|
||||
cwd = os.getcwd()
|
||||
# si No fichero .aria2, y Si fichero destino imagen ya descargada y su chequeo fue comprobado en su descarga inicial.
|
||||
|
||||
|
||||
if not os.path.exists (f'{target}.aria2') and os.path.exists (target):
|
||||
print ('imagen ya descargada')
|
||||
if 'seeder' != mode: return 'success' ## return any true value
|
||||
print ('MODE seeder aria2c')
|
||||
os.chdir (dirsource)
|
||||
aria2_cmd = [
|
||||
"aria2c",
|
||||
"--check-integrity=true",
|
||||
"--bt-seed-unverified=true",
|
||||
"aria2c",
|
||||
"--check-integrity=true",
|
||||
"--bt-seed-unverified=true",
|
||||
"--disable-ipv6",
|
||||
"--seed-ratio=0.0",
|
||||
f"--seed-time={time}",
|
||||
"--enable-dht=false",
|
||||
"--enable-peer-exchange=false",
|
||||
f"--dir={dirsource}",
|
||||
"--seed-ratio=0.0",
|
||||
f"--seed-time={time}",
|
||||
"--enable-dht=false",
|
||||
"--enable-peer-exchange=false",
|
||||
f"--dir={dirsource}",
|
||||
f"{source}"
|
||||
]
|
||||
subprocess.run (aria2_cmd)
|
||||
|
@ -737,12 +692,12 @@ def ogTorrentStart (disk=None, par=None, container=None, torrentfile=None, torre
|
|||
print ('Donwloading Torrent as peer')
|
||||
SystemLib.ogEcho(["session","log"],"warning",f'Starting PeerTorrent download in PEER mode')
|
||||
aria2_cmd = [
|
||||
"aria2c",
|
||||
"--enable-dht=false",
|
||||
"--enable-peer-exchange=false",
|
||||
"--disable-ipv6" ,
|
||||
f"--seed-time={time}",
|
||||
f"--dir={dirsource}",
|
||||
"aria2c",
|
||||
"--enable-dht=false",
|
||||
"--enable-peer-exchange=false",
|
||||
"--disable-ipv6" ,
|
||||
f"--seed-time={time}",
|
||||
f"--dir={dirsource}",
|
||||
f"{source}"
|
||||
]
|
||||
|
||||
|
@ -750,12 +705,12 @@ def ogTorrentStart (disk=None, par=None, container=None, torrentfile=None, torre
|
|||
print ('Donwloading Torrent as leecher')
|
||||
SystemLib.ogEcho(["session","log"],"warning",f'Starting PeerTorrent download in LEECHER mode')
|
||||
aria2_cmd = [
|
||||
"aria2c",
|
||||
"--enable-dht=false",
|
||||
"--enable-peer-exchange=false",
|
||||
"--disable-ipv6" ,
|
||||
"--seed-time=0",
|
||||
f"--dir={dirsource}",
|
||||
"aria2c",
|
||||
"--enable-dht=false",
|
||||
"--enable-peer-exchange=false",
|
||||
"--disable-ipv6" ,
|
||||
"--seed-time=0",
|
||||
f"--dir={dirsource}",
|
||||
f"{source}"
|
||||
]
|
||||
|
||||
|
@ -763,14 +718,14 @@ def ogTorrentStart (disk=None, par=None, container=None, torrentfile=None, torre
|
|||
print ('MODE seeder aria2c')
|
||||
SystemLib.ogEcho(["session","log"],"warning",f'Starting PeerTorrent download in SEEDER mode')
|
||||
aria2_cmd = [
|
||||
"aria2c",
|
||||
"--check-integrity=true",
|
||||
"--bt-seed-unverified=true",
|
||||
"--disable-ipv6" ,
|
||||
"--seed-ratio=0.0",
|
||||
f"--seed-time={time}",
|
||||
"--enable-dht=false",
|
||||
"--enable-peer-exchange=false",
|
||||
"aria2c",
|
||||
"--check-integrity=true",
|
||||
"--bt-seed-unverified=true",
|
||||
"--disable-ipv6" ,
|
||||
"--seed-ratio=0.0",
|
||||
f"--seed-time={time}",
|
||||
"--enable-dht=false",
|
||||
"--enable-peer-exchange=false",
|
||||
f"--dir={dirsource}", f"{source}"
|
||||
]
|
||||
|
||||
|
@ -783,24 +738,20 @@ def ogTorrentStart (disk=None, par=None, container=None, torrentfile=None, torre
|
|||
os.chdir (cwd)
|
||||
|
||||
|
||||
#/**
|
||||
# ogCreateTorrent [ str_repo | int_ndisk int_npart ] Relative_path_file
|
||||
## ogCreateTorrent [ str_repo | int_ndisk int_npart ] Relative_path_file
|
||||
#@brief Función para crear el fichero torrent.
|
||||
#@param str_pathDirectory str_Relative_path_file
|
||||
#@param int_disk int_partition str_Relative_path_file
|
||||
#@param str_REPOSITORY(CACHE - LOCAL) str_Relative_path_file
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||
#@exception OG_ERR_NOTOS La partición no tiene instalado un sistema operativo.
|
||||
#*/ ##
|
||||
|
||||
#ogCreateTorrent ([str_REPOSITORY] [int_ndisk int_npart] Relative_path_file IpBttrack)
|
||||
#ogCreateTorrent (disk=1, par=1, file='/aula1/winxp', ip_bttrack='10.1.15.23')
|
||||
#ogCreateTorrent (container='REPO', file='/aula1/winxp', ip_bttrack='10.1.15.45')
|
||||
#ogCreateTorrent (container='CACHE', file='/aula1/winxp', ip_bttrack='10.1.15.45')
|
||||
def ogCreateTorrent (disk=None, par=None, container=None, file=None, ip_bttrack=None):
|
||||
#ogCreateTorrent ([str_REPOSITORY] [int_ndisk int_npart] Relative_path_file IpBttrack)
|
||||
#ogCreateTorrent (disk=1, par=1, file='/aula1/winxp', ip_bttrack='10.1.15.23')
|
||||
#ogCreateTorrent (container='REPO', file='/aula1/winxp', ip_bttrack='10.1.15.45')
|
||||
#ogCreateTorrent (container='CACHE', file='/aula1/winxp', ip_bttrack='10.1.15.45')
|
||||
if file is None:
|
||||
raise TypeError ('missing required argument: "file"')
|
||||
if ip_bttrack is None:
|
||||
|
@ -856,8 +807,7 @@ def ogCreateTorrent (disk=None, par=None, container=None, file=None, ip_bttrack=
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogUpdateCacheIsNecesary [ str_repo ] Relative_path_file_OGIMG_with_/
|
||||
## ogUpdateCacheIsNecesary [ str_repo ] Relative_path_file_OGIMG_with_/
|
||||
#@brief Comprueba que el fichero que se desea almacenar en la cache del cliente, no esta.
|
||||
#@param 1 str_REPO
|
||||
#@param 2 str_Relative_path_file_OGIMG_with_/
|
||||
|
@ -868,11 +818,10 @@ def ogCreateTorrent (disk=None, par=None, container=None, file=None, ip_bttrack=
|
|||
#@note
|
||||
#@todo: Proceso en el caso de que el fichero tenga el mismo nombre, pero su contenido sea distinto.
|
||||
#@todo: Se dejan mensajes mientras se confirma su funcionamiento.
|
||||
#*/ ##
|
||||
#ogUpdateCacheIsNecesary ('REPO', '/PS1_PH1.img', 'UNICAST')
|
||||
#ogUpdateCacheIsNecesary ('REPO', '/ogclient.sqfs', 'FULL')
|
||||
#ogUpdateCacheIsNecesary ('REPO', '/ogclient.sqfs', 'TORRENT')
|
||||
def ogUpdateCacheIsNecesary (repo, file, proto):
|
||||
#ogUpdateCacheIsNecesary ('REPO', '/PS1_PH1.img', 'UNICAST')
|
||||
#ogUpdateCacheIsNecesary ('REPO', '/ogclient.sqfs', 'FULL')
|
||||
#ogUpdateCacheIsNecesary ('REPO', '/ogclient.sqfs', 'TORRENT')
|
||||
if not CacheLib.ogFindCache():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTCACHE, '')
|
||||
return None
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#/**
|
||||
#@file RegistryLib.py
|
||||
##@file RegistryLib.py
|
||||
#@brief Librería o clase Registry
|
||||
#@class Boot
|
||||
#@class Registry
|
||||
#@brief Funciones para gestión del registro de Windows.
|
||||
#@warning License: GNU GPLv3+
|
||||
#*/
|
||||
|
||||
import subprocess
|
||||
import os
|
||||
|
@ -32,8 +30,7 @@ def _split_k (k):
|
|||
k_basename = k_elems[-1]
|
||||
return k_dirname, k_basename
|
||||
|
||||
#/**
|
||||
# ogAddRegistryKey path_mountpoint str_hive str_keyname
|
||||
## ogAddRegistryKey path_mountpoint str_hive str_keyname
|
||||
#@brief Añade una nueva clave al registro de Windows.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
|
@ -44,7 +41,6 @@ def _split_k (k):
|
|||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw
|
||||
#@warning El sistema de archivos de Windows debe estar montada previamente.
|
||||
#*/ ##
|
||||
def ogAddRegistryKey (mntpt, hive, k):
|
||||
hivefile = ogGetHivePath (mntpt, hive)
|
||||
if not hivefile: return
|
||||
|
@ -59,8 +55,7 @@ def ogAddRegistryKey (mntpt, hive, k):
|
|||
chntpw (hivefile, f.name)
|
||||
os.remove (f.name)
|
||||
|
||||
#/**
|
||||
# ogAddRegistryValue path_mountpoint str_hive str_valuename [str_valuetype]
|
||||
## ogAddRegistryValue path_mountpoint str_hive str_valuename [str_valuetype]
|
||||
#@brief Añade un nuevo valor al registro de Windows, indicando su tipo de datos.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
|
@ -73,12 +68,11 @@ def ogAddRegistryKey (mntpt, hive, k):
|
|||
#@note valuetype = { STRING, BINARY, DWORD }, por defecto: STRING
|
||||
#@warning Requisitos: chntpw
|
||||
#@warning El sistema de archivos de Windows debe estar montada previamente.
|
||||
#*/ ##
|
||||
#ogAddRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Microsoft\NewKey\Value1') ## type STRING by default
|
||||
#ogAddRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Microsoft\NewKey\Value1', 'STRING')
|
||||
#ogAddRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Microsoft\NewKey\Value1', 'BINARY')
|
||||
#ogAddRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Microsoft\NewKey\Value1', 'DWORD')
|
||||
def ogAddRegistryValue (mntpt, hive, k, vtype='STRING'):
|
||||
#ogAddRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Microsoft\NewKey\Value1') ## type STRING by default
|
||||
#ogAddRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Microsoft\NewKey\Value1', 'STRING')
|
||||
#ogAddRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Microsoft\NewKey\Value1', 'BINARY')
|
||||
#ogAddRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Microsoft\NewKey\Value1', 'DWORD')
|
||||
hivefile = ogGetHivePath (mntpt, hive)
|
||||
if not hivefile: return
|
||||
|
||||
|
@ -101,8 +95,7 @@ def ogAddRegistryValue (mntpt, hive, k, vtype='STRING'):
|
|||
os.remove (f.name)
|
||||
|
||||
|
||||
#/**
|
||||
# ogDeleteRegistryKey path_mountpoint str_hive str_keyname
|
||||
## ogDeleteRegistryKey path_mountpoint str_hive str_keyname
|
||||
#@brief Elimina una clave del registro de Windows con todo su contenido.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
|
@ -114,7 +107,6 @@ def ogAddRegistryValue (mntpt, hive, k, vtype='STRING'):
|
|||
#@warning Requisitos: chntpw
|
||||
#@warning El sistema de archivos de Windows debe estar montada previamente.
|
||||
#@warning La clave debe estar vacía para poder ser borrada.
|
||||
#*/ ##
|
||||
def ogDeleteRegistryKey (mntpt, hive, k):
|
||||
hivefile = ogGetHivePath (mntpt, hive)
|
||||
if not hivefile: return
|
||||
|
@ -130,8 +122,7 @@ def ogDeleteRegistryKey (mntpt, hive, k):
|
|||
os.remove (f.name)
|
||||
|
||||
|
||||
#/**
|
||||
# ogDeleteRegistryValue path_mountpoint str_hive str_valuename
|
||||
## ogDeleteRegistryValue path_mountpoint str_hive str_valuename
|
||||
#@brief Elimina un valor del registro de Windows.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
|
@ -142,8 +133,6 @@ def ogDeleteRegistryKey (mntpt, hive, k):
|
|||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw
|
||||
#@warning El sistema de archivos de Windows debe estar montada previamente.
|
||||
#*/ ##
|
||||
#ogDeleteRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Microsoft\NewKey\Value1')
|
||||
def ogDeleteRegistryValue (mntpt, hive, k):
|
||||
hivefile = ogGetHivePath (mntpt, hive)
|
||||
if not hivefile: return
|
||||
|
@ -159,8 +148,7 @@ def ogDeleteRegistryValue (mntpt, hive, k):
|
|||
os.remove(f.name)
|
||||
|
||||
|
||||
#/**
|
||||
# ogGetHivePath path_mountpoint [str_hive|str_user]
|
||||
## ogGetHivePath path_mountpoint [str_hive|str_user]
|
||||
#@brief Función básica que devuelve el camino del fichero con una sección del registro.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
|
@ -169,11 +157,10 @@ def ogDeleteRegistryValue (mntpt, hive, k):
|
|||
#@exception OG_ERR_NOTFOUND Fichero de registro no encontrado.
|
||||
#@note hive = { DEFAULT, SAM, SECURITY, SOFTWARE, SYSTEM, COMPONENTS, NombreDeUsuario }
|
||||
#@warning El sistema de archivos de Windows debe estar montada previamente.
|
||||
#*/ ##
|
||||
#ogGetHivePath ('/mnt/sda1', 'user1') => /mnt/sda1/Users/user1/NTUSER.DAT
|
||||
#ogGetHivePath ('/mnt/sda1', 'SYSTEM') => //mnt/sda1/Windows/System32/config/SYSTEM
|
||||
#ogGetHivePath ('/mnt/sda1', 'IEUser') => //mnt/sda1/Users/IEUser/NTUSER.DAT
|
||||
def ogGetHivePath(mntpt, hive):
|
||||
#ogGetHivePath ('/mnt/sda1', 'user1') => /mnt/sda1/Users/user1/NTUSER.DAT
|
||||
#ogGetHivePath ('/mnt/sda1', 'SYSTEM') => //mnt/sda1/Windows/System32/config/SYSTEM
|
||||
#ogGetHivePath ('/mnt/sda1', 'IEUser') => //mnt/sda1/Users/IEUser/NTUSER.DAT
|
||||
# Camino del fichero de registro de usuario o de sistema (de menor a mayor prioridad).
|
||||
FILE = FileLib.ogGetPath(file=f"/{mntpt}/Windows/System32/config/{hive}")
|
||||
if not FILE: FILE = FileLib.ogGetPath(file=f"/{mntpt}/Users/{hive}/NTUSER.DAT")
|
||||
|
@ -197,8 +184,7 @@ def _grep_A1 (strings, search_term):
|
|||
|
||||
return results
|
||||
|
||||
#/**
|
||||
# ogGetRegistryValue path_mountpoint str_hive str_valuename
|
||||
## ogGetRegistryValue path_mountpoint str_hive str_valuename
|
||||
#@brief Devuelve el dato de un valor del registro de Windows.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
|
@ -209,7 +195,6 @@ def _grep_A1 (strings, search_term):
|
|||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw, awk
|
||||
#@warning El sistema de archivos de Windows debe estar montado previamente.
|
||||
#*/ ##
|
||||
def ogGetRegistryValue (mntpt, hive, k):
|
||||
hivefile = ogGetHivePath(mntpt, hive)
|
||||
if not hivefile: return
|
||||
|
@ -238,8 +223,7 @@ def ogGetRegistryValue (mntpt, hive, k):
|
|||
return ret
|
||||
|
||||
|
||||
#/**
|
||||
# ogListRegistryKeys path_mountpoint str_hive str_key
|
||||
## ogListRegistryKeys path_mountpoint str_hive str_key
|
||||
#@brief Lista los nombres de subclaves de una determinada clave del registro de Windows.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
|
@ -250,8 +234,6 @@ def ogGetRegistryValue (mntpt, hive, k):
|
|||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw, awk
|
||||
#@warning El sistema de archivos de Windows debe estar montado previamente.
|
||||
#*/ ##
|
||||
#ogListRegistryKeys ('/mnt/sda1', 'SOFTWARE', '\Microsoft\Windows\CurrentVersion')
|
||||
def ogListRegistryKeys (mntpt, hive, k):
|
||||
hivefile = ogGetHivePath(mntpt, hive)
|
||||
if not hivefile: return
|
||||
|
@ -273,8 +255,7 @@ def ogListRegistryKeys (mntpt, hive, k):
|
|||
return ret
|
||||
|
||||
|
||||
#/**
|
||||
# ogListRegistryValues path_mountpoint str_hive str_key
|
||||
## ogListRegistryValues path_mountpoint str_hive str_key
|
||||
#@brief Lista los nombres de valores de una determinada clave del registro de Windows.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
|
@ -285,8 +266,6 @@ def ogListRegistryKeys (mntpt, hive, k):
|
|||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw, awk
|
||||
#@warning El sistema de archivos de Windows debe estar montado previamente.
|
||||
#*/ ##
|
||||
#ogListRegistryValues ('/mnt/sda1', 'SOFTWARE', '\Microsoft\Windows\CurrentVersion')
|
||||
def ogListRegistryValues (mntpt, hive, k):
|
||||
hivefile = ogGetHivePath(mntpt, hive)
|
||||
if not hivefile: return
|
||||
|
@ -327,8 +306,7 @@ def _format_hex (hex_string):
|
|||
|
||||
return '\n'.join (result)
|
||||
|
||||
#/**
|
||||
# ogSetRegistryValue path_mountpoint str_hive str_valuename str_valuedata
|
||||
## ogSetRegistryValue path_mountpoint str_hive str_valuename str_valuedata
|
||||
#@brief Establece el dato asociado a un valor del registro de Windows.
|
||||
#@param path_mountpoint directorio donde está montado el sistema Windows
|
||||
#@param str_hive sección del registro
|
||||
|
@ -340,11 +318,10 @@ def _format_hex (hex_string):
|
|||
#@note hive = { default, sam, security, software, system, components }
|
||||
#@warning Requisitos: chntpw
|
||||
#@warning El sistema de archivos de Windows debe estar montado previamente.
|
||||
#*/ ##
|
||||
#ogSetRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Key\SubKey\StringValue', 'Abcde Fghij')
|
||||
#ogSetRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Key\SubKey\DwordValue', 1)
|
||||
#ogSetRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Key\SubKey\BinaryValue', '04 08 0C 10')
|
||||
def ogSetRegistryValue (mntpt, hive, k, v):
|
||||
#ogSetRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Key\SubKey\StringValue', 'Abcde Fghij')
|
||||
#ogSetRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Key\SubKey\DwordValue', 1)
|
||||
#ogSetRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Key\SubKey\BinaryValue', '04 08 0C 10')
|
||||
hivefile = ogGetHivePath (mntpt, hive)
|
||||
if not hivefile: return
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
##@file StringLib.py
|
||||
#@brief Librería o clase String
|
||||
#@class String
|
||||
#@brief Funciones para gestionar cadenas de texto
|
||||
#@warning License: GNU GPLv3+
|
||||
|
||||
import re
|
||||
|
||||
|
||||
|
||||
#/**
|
||||
# ogCheckIpAddress
|
||||
## ogCheckIpAddress
|
||||
#@brief Función para determinar si una cadena es una dirección ipv4 válida
|
||||
#@param 1 string de la ip a comprobar
|
||||
#@return 0 si es una dirección válida
|
||||
|
@ -11,7 +14,6 @@ import re
|
|||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@note
|
||||
#@todo
|
||||
#*/ ##
|
||||
def ogCheckIpAddress(ip):
|
||||
"""
|
||||
Función para determinar si una cadena es una dirección ipv4 válida.
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
##@file SystemLib.py
|
||||
#@brief Librería o clase System
|
||||
#@class System
|
||||
#@brief Funciones genéricas de sistema
|
||||
#@warning License: GNU GPLv3+
|
||||
|
||||
import subprocess
|
||||
import datetime
|
||||
from zoneinfo import ZoneInfo
|
||||
|
@ -18,14 +24,13 @@ def _logtype2logfile (t):
|
|||
elif 'command' == t.lower(): return ogGlobals.OGLOGCOMMAND
|
||||
elif 'session' == t.lower(): return ogGlobals.OGLOGSESSION
|
||||
else: raise Exception (f'unknown log type ({t})')
|
||||
#/**
|
||||
# ogEcho [str_logtype ...] [str_loglevel] "str_message" ...
|
||||
|
||||
## ogEcho [str_logtype ...] [str_loglevel] "str_message" ...
|
||||
#@brief Muestra mensajes en consola y lo registra en fichero de incidencias.
|
||||
#@param str_logtype tipo de registro de incidencias ("log", "command", "session")
|
||||
#@param str_loglevel nivel de registro de incidencias ("info", "warning", "error")
|
||||
#@param str_message mensaje (puede recibir más de 1 parámetro.
|
||||
#@return Mensaje mostrado.
|
||||
#*/
|
||||
def ogEcho (logtypes, loglevel, msg):
|
||||
logfiles = ['/dev/stdout']
|
||||
if type (logtypes) is list:
|
||||
|
@ -68,20 +73,18 @@ def ogEcho (logtypes, loglevel, msg):
|
|||
raise Exception (f'unknown loglevel ({loglevel})')
|
||||
|
||||
|
||||
#/**
|
||||
# ogExecAndLog str_logfile ... str_command ...
|
||||
## ogExecAndLog str_logfile ... str_command ...
|
||||
#@brief Ejecuta un comando y guarda su salida en fichero de registro.
|
||||
#@param str_logfile fichero de registro (pueden ser varios).
|
||||
#@param str_command comando y comandos a ejecutar.
|
||||
#@return Salida de ejecución del comando.
|
||||
#@note str_logfile = { LOG, SESSION, COMMAND }
|
||||
#*/
|
||||
#ogExecAndLog (str_logfile ... str_command ...",
|
||||
#ogExecAndLog ([], ['/path/to/script', *args])
|
||||
#ogExecAndLog ('command', ['/path/to/script', *args])
|
||||
#ogExecAndLog (['command'], ['/path/to/script', *args])
|
||||
#ogExecAndLog (['log', 'command'], ['/path/to/script', *args])
|
||||
def ogExecAndLog (logtypes, script_and_args):
|
||||
#ogExecAndLog (str_logfile ... str_command ...",
|
||||
#ogExecAndLog ([], ['/path/to/script', *args])
|
||||
#ogExecAndLog ('command', ['/path/to/script', *args])
|
||||
#ogExecAndLog (['command'], ['/path/to/script', *args])
|
||||
#ogExecAndLog (['log', 'command'], ['/path/to/script', *args])
|
||||
logfiles = ['/dev/stdout']
|
||||
if type (logtypes) is list:
|
||||
for l in logtypes:
|
||||
|
@ -155,11 +158,9 @@ def ogExecAndLog (logtypes, script_and_args):
|
|||
rc = p.returncode
|
||||
return not rc ## negate shell return code
|
||||
|
||||
#/**
|
||||
# ogGetCaller
|
||||
## ogGetCaller
|
||||
#@brief Devuelve nombre del programa o script ejecutor (padre).
|
||||
#@return str_name - Nombre del programa ejecutor.
|
||||
#*/
|
||||
def ogGetCaller():
|
||||
if 'COLUMNS' in os.environ:
|
||||
cols = os.environ['COLUMNS']
|
||||
|
@ -184,8 +185,7 @@ def ogGetCaller():
|
|||
|
||||
return os.path.basename(caller)
|
||||
|
||||
#/**
|
||||
# ogHelp ["str_function" ["str_format" ["str_example" ... ]]]
|
||||
## ogHelp ["str_function" ["str_format" ["str_example" ... ]]]
|
||||
#@brief Muestra mensaje de ayuda para una función determinda.
|
||||
#@param str_function Nombre de la función.
|
||||
#@param str_format Formato de ejecución de la función.
|
||||
|
@ -194,7 +194,6 @@ def ogGetCaller():
|
|||
#@note Si no se indican parámetros, la función se toma de la variable \c $FUNCNAME
|
||||
#@note La descripción de la función se toma de la variable compuesta por \c MSG_FUNC_$función incluida en el fichero de idiomas.
|
||||
#@note Pueden especificarse varios mensajes con ejemplos.
|
||||
#*/
|
||||
def ogHelp (fname, fmt=None, examples=[]):
|
||||
FUNC = fname or inspect.stack()[1][3]
|
||||
MSG = f'ogGlobals.lang.MSG_HELP_{FUNC}'
|
||||
|
@ -212,14 +211,12 @@ def ogHelp (fname, fmt=None, examples=[]):
|
|||
else: ## string
|
||||
ogEcho([], "help", f" {ogGlobals.lang.MSG_EXAMPLE}: {examples}")
|
||||
|
||||
#/**
|
||||
# ogRaiseError [str_logtype ...] int_errcode ["str_errmessage" ...]
|
||||
## ogRaiseError [str_logtype ...] int_errcode ["str_errmessage" ...]
|
||||
#@brief Devuelve el mensaje y el código de error correspondiente.
|
||||
#@param str_logtype tipo de registro de incidencias.
|
||||
#@param int_errcode código de error.
|
||||
#@param str_errmessage mensajes complementarios de error.
|
||||
#@return str_code - código de error
|
||||
#*/
|
||||
def ogRaiseError (logtypes, code, msg):
|
||||
if code == ogGlobals.OG_ERR_FORMAT: MSG = f'{ogGlobals.lang.MSG_ERR_FORMAT} "{msg}"'
|
||||
elif code == ogGlobals.OG_ERR_NOTFOUND: MSG = f'{ogGlobals.lang.MSG_ERR_NOTFOUND} "{msg}"'
|
||||
|
@ -280,12 +277,10 @@ def ogRaiseError (logtypes, code, msg):
|
|||
|
||||
return code
|
||||
|
||||
#/**
|
||||
# ogIsRepoLocked
|
||||
## ogIsRepoLocked
|
||||
#@brief Comprueba si el repositorio está siendo usado (tiene ficheros abiertos).
|
||||
#@param No.
|
||||
#@return Código de salida: 0 - bloqueado, 1 - sin bloquear o error.
|
||||
#*/
|
||||
def ogIsRepoLocked():
|
||||
# No hacer nada, si no está definido el punto de montaje del repositorio.
|
||||
if not ogGlobals.OGIMG:
|
||||
|
@ -313,7 +308,7 @@ def ogIsRepoLocked():
|
|||
# return
|
||||
#
|
||||
# return 0
|
||||
|
||||
|
||||
def ogIsVirtualMachine():
|
||||
output = subprocess.run (["dmidecode", "-s", "system-product-name"], capture_output=True, text=True).stdout
|
||||
return "KVM" in output or "VirtualBox" in output
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
##@file UEFILib.py
|
||||
#@brief Librería o clase UEFI
|
||||
#@class UEFI
|
||||
#@brief Funciones para sistemas EFI
|
||||
#@warning License: GNU GPLv3+
|
||||
|
||||
import os.path
|
||||
import re
|
||||
import subprocess
|
||||
|
@ -10,22 +16,16 @@ import DiskLib
|
|||
import FileLib
|
||||
import InventoryLib
|
||||
|
||||
#!/bin/bash
|
||||
# Libreria provisional para uso de UEFI
|
||||
# Las funciones se incluirán las librerías ya existentes
|
||||
|
||||
#/**
|
||||
# ogNvramActiveEntry
|
||||
## ogNvramActiveEntry
|
||||
#@brief Activa entrada de la NVRAM identificada por la etiqueta o el orden
|
||||
#@param Num_order_entry | Label_entry Número de orden o la etiqueta de la entrada a borrar.
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#*/ ##
|
||||
#ogNvramActiveEntry ('2')
|
||||
#ogNvramActiveEntry ('Windows Boot Manager')
|
||||
def ogNvramActiveEntry (entry):
|
||||
#ogNvramActiveEntry ('2')
|
||||
#ogNvramActiveEntry ('Windows Boot Manager')
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTUEFI, '')
|
||||
return
|
||||
|
@ -57,8 +57,7 @@ def ogNvramActiveEntry (entry):
|
|||
|
||||
subprocess.run (['efibootmgr', '-a', '-b', numentries[0]], capture_output=True, text=True)
|
||||
|
||||
#/**
|
||||
# ogNvramAddEntry
|
||||
## ogNvramAddEntry
|
||||
#@brief Crea nueva entrada en el gestor de arranque (NVRAM), opcionalmente la incluye al final del orden de arranque.
|
||||
#@param Str_Label_entry Número de disco o etiqueta de la entrada a crear.
|
||||
#@param Str_BootLoader Número de partición o cargador de arranque.
|
||||
|
@ -67,11 +66,10 @@ def ogNvramActiveEntry (entry):
|
|||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#*/ ##
|
||||
#ogNvramAddEntry ('1', '2', True)
|
||||
#ogNvramAddEntry ('grub', '/EFI/grub/grubx64.efi', True)
|
||||
#ogNvramAddEntry ('Windows', '/EFI/Microsoft/Boot/bootmgfw.efi')
|
||||
def ogNvramAddEntry (bootlbl, bootldr, nvram_set=False):
|
||||
#ogNvramAddEntry ('1', '2', True)
|
||||
#ogNvramAddEntry ('grub', '/EFI/grub/grubx64.efi', True)
|
||||
#ogNvramAddEntry ('Windows', '/EFI/Microsoft/Boot/bootmgfw.efi')
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTUEFI, '')
|
||||
return
|
||||
|
@ -109,8 +107,7 @@ def ogNvramAddEntry (bootlbl, bootldr, nvram_set=False):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogCopyEfiBootLoader int_ndisk str_repo path_image
|
||||
## ogCopyEfiBootLoader int_ndisk str_repo path_image
|
||||
#@brief Copia el cargador de arranque desde la partición EFI a la de sistema.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_part nº de partición
|
||||
|
@ -118,7 +115,6 @@ def ogNvramAddEntry (bootlbl, bootldr, nvram_set=False):
|
|||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#@note Si existe el cargador en la partición de sistema no es válido
|
||||
#*/ ##
|
||||
def ogCopyEfiBootLoader (disk, par):
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
if not mntdir:
|
||||
|
@ -152,18 +148,16 @@ def ogCopyEfiBootLoader (disk, par):
|
|||
shutil.copytree (f'{dirloader}/Boot', f'{mntdir}/ogBoot')
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramDeleteEntry
|
||||
## ogNvramDeleteEntry
|
||||
#@brief Borra entrada de la NVRAM identificada por la etiqueta o el orden
|
||||
#@param Num_order_entry | Label_entry Número de orden o la etiqueta de la entrada a borrar.
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado (entrada en NVRAM).
|
||||
#*/ ##
|
||||
#ogNvramDeleteEntry ('2')
|
||||
#ogNvramDeleteEntry ('Windows Boot Manager')
|
||||
def ogNvramDeleteEntry (entry):
|
||||
#ogNvramDeleteEntry ('2')
|
||||
#ogNvramDeleteEntry ('Windows Boot Manager')
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTUEFI, '')
|
||||
return
|
||||
|
@ -197,12 +191,10 @@ def ogNvramDeleteEntry (entry):
|
|||
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramGetCurrent
|
||||
## ogNvramGetCurrent
|
||||
#@brief Muestra la entrada del gestor de arranque (NVRAM) que ha iniciado el equipo.
|
||||
#@return Entrada con la que se ha iniciado el equipo
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
def ogNvramGetCurrent():
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTUEFI, '')
|
||||
|
@ -223,11 +215,10 @@ def ogNvramGetCurrent():
|
|||
return ret
|
||||
|
||||
|
||||
# ogNvramGetNext
|
||||
## ogNvramGetNext
|
||||
#@brief Muestra la entrada del gestor de arranque (NVRAM) que se utilizará en el próximo arranque.
|
||||
#@return Entrada que se utilizará en el próximo arranque
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
def ogNvramGetNext():
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTUEFI, '')
|
||||
|
@ -243,11 +234,10 @@ def ogNvramGetNext():
|
|||
return ret
|
||||
|
||||
|
||||
# ogNvramGetOrder
|
||||
## ogNvramGetOrder
|
||||
#@brief Muestra el orden de las entradas del gestor de arranque (NVRAM)
|
||||
#@return Array, orden de las entradas
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
def ogNvramGetOrder():
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTUEFI, '')
|
||||
|
@ -263,12 +253,10 @@ def ogNvramGetOrder():
|
|||
return ret
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramGetTimeout
|
||||
## ogNvramGetTimeout
|
||||
#@brief Muestra el tiempo de espera del gestor de arranque (NVRAM)
|
||||
#@return Timeout de la NVRAM
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
def ogNvramGetTimeout():
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTUEFI, '')
|
||||
|
@ -284,31 +272,16 @@ def ogNvramGetTimeout():
|
|||
return ret
|
||||
|
||||
|
||||
#/**
|
||||
# ogGrubUefiConf int_ndisk int_part str_dir_grub
|
||||
#@brief Genera el fichero grub.cfg de la ESP
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_part nº de partición
|
||||
#@param str_dir_grub prefijo del directorio de grub en la partición de sistema. ej: /boot/grubPARTITION
|
||||
#@return (nada, por determinar)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#@TODO Confirmar si el fichero "$EFIDIR/EFI/$BOOTLABEL/grub.cfg" es necesario.
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramInactiveEntry
|
||||
## ogNvramInactiveEntry
|
||||
#@brief Inactiva entrada de la NVRAM identificada por la etiqueta o el orden
|
||||
#@param Num_order_entry | Label_entry Número de orden o la etiqueta de la entrada a borrar.
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
#ogNvramInactiveEntry ('2')
|
||||
#ogNvramInactiveEntry ('Windows Boot Manager')
|
||||
def ogNvramInactiveEntry (entry):
|
||||
#ogNvramInactiveEntry ('2')
|
||||
#ogNvramInactiveEntry ('Windows Boot Manager')
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTUEFI, '')
|
||||
return
|
||||
|
@ -341,12 +314,10 @@ def ogNvramInactiveEntry (entry):
|
|||
subprocess.run (['efibootmgr', '-A', '-b', numentries[0]], capture_output=True, text=True)
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramList
|
||||
## ogNvramList
|
||||
#@brief Lista las entradas de la NVRAN (sólo equipos UEFI)
|
||||
#@return Multiline string: entradas de la NVRAM con el formato: orden etiqueta [* (si está activa) ]
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
def ogNvramList():
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTUEFI, '')
|
||||
|
@ -364,12 +335,10 @@ def ogNvramList():
|
|||
return ret
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramPxeFirstEntry
|
||||
## ogNvramPxeFirstEntry
|
||||
#@brief Sitúa la entrada de la tarjeta de red en el primer lugar en la NVRAM.
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#*/ ##
|
||||
def ogNvramPxeFirstEntry():
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTUEFI, '')
|
||||
|
@ -398,8 +367,7 @@ def ogNvramPxeFirstEntry():
|
|||
return True
|
||||
|
||||
|
||||
#/**
|
||||
# ogRestoreEfiBootLoader int_ndisk str_repo
|
||||
## ogRestoreEfiBootLoader int_ndisk str_repo
|
||||
#@brief Copia el cargador de arranque de la partición de sistema a la partición EFI.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_part nº de partición
|
||||
|
@ -407,7 +375,6 @@ def ogNvramPxeFirstEntry():
|
|||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado (partición de sistema o EFI).
|
||||
#@exception OG_ERR_NOTOS sin sistema operativo.
|
||||
#*/ ##
|
||||
def ogRestoreEfiBootLoader (disk, par):
|
||||
mntdir = FileSystemLib.ogMount (disk, par)
|
||||
if not mntdir:
|
||||
|
@ -441,36 +408,22 @@ def ogRestoreEfiBootLoader (disk, par):
|
|||
shutil.copytree (os.path.dirname (loader), f'{efi_bl}/Boot', symlinks=True)
|
||||
shutil.copy (loader, f'{efi_bl}/Boot/ogloader.efi')
|
||||
if '' != FileLib.ogGetPath (file=f'{efidir}/EFI/Microsoft'):
|
||||
os.rename (f'{efidir}/EFI/Microsoft', f'{efidir}/EFI/Microsoft.backup.og')
|
||||
if not os.path.exists (f'{efidir}/EFI/Microsoft.backup.og'):
|
||||
os.rename (f'{efidir}/EFI/Microsoft', f'{efidir}/EFI/Microsoft.backup.og')
|
||||
|
||||
return
|
||||
|
||||
|
||||
#/**
|
||||
# ogRestoreUuidPartitions
|
||||
#@brief Restaura los uuid de las particiones y la tabla de particiones
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_nfilesys nº de orden del sistema de archivos
|
||||
#@param REPO|CACHE repositorio
|
||||
#@param str_imgname nombre de la imagen
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND No encontrado fichero de información de la imagen (con uuid)
|
||||
#*/ ##
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramSetNext
|
||||
## ogNvramSetNext
|
||||
#@brief Configura el próximo arranque con la entrada del gestor de arranque (NVRAM) identificada por la etiqueta o el orden.
|
||||
#@param Num_order_entry | Label_entry Número de orden o la etiqueta de la entrada a borrar.
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#*/ ##
|
||||
#ogNvramSetNext ('2')
|
||||
#ogNvramSetNext ('Windows Boot Manager')
|
||||
def ogNvramSetNext (entry):
|
||||
#ogNvramSetNext ('2')
|
||||
#ogNvramSetNext ('Windows Boot Manager')
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTUEFI, '')
|
||||
return
|
||||
|
@ -503,17 +456,15 @@ def ogNvramSetNext (entry):
|
|||
SystemLib.ogEcho ([], 'info', f'setting "{numentries[0]}" as next entry in NVRAM')
|
||||
subprocess.run (['efibootmgr', '-n', numentries[0]], capture_output=True, text=True)
|
||||
|
||||
#/**
|
||||
# ogNvramSetOrder
|
||||
## ogNvramSetOrder
|
||||
#@brief Configura el orden de las entradas de la NVRAM
|
||||
#@param Orden de las entradas separadas por espacios
|
||||
#@return (nada)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTUEFI UEFI no activa.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado (entrada NVRAM).
|
||||
#*/ ##
|
||||
#ogNvramSetOrder (['1', '3'])
|
||||
def ogNvramSetOrder (order):
|
||||
#ogNvramSetOrder (['1', '3'])
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_NOTUEFI, '')
|
||||
return
|
||||
|
@ -545,15 +496,12 @@ def ogNvramSetOrder (order):
|
|||
subprocess.run (['efibootmgr', '-o', ','.join (new_order)])
|
||||
|
||||
|
||||
#/**
|
||||
# ogNvramSetTimeout
|
||||
## ogNvramSetTimeout
|
||||
#@brief Configura el tiempo de espera de la NVRAM
|
||||
#@param Orden de las entradas separadas por espacios
|
||||
#@return (nada)
|
||||
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#*/ ##
|
||||
#ogNvramSetTimeout ('2')
|
||||
def ogNvramSetTimeout (t):
|
||||
if not InventoryLib.ogIsEfiActive():
|
||||
|
@ -567,14 +515,3 @@ def ogNvramSetTimeout (t):
|
|||
return
|
||||
|
||||
subprocess.run (['efibootmgr', '-t', t])
|
||||
|
||||
|
||||
#/**
|
||||
# ogUuidChange int_ndisk str_repo
|
||||
#@brief Reemplaza el UUID de un sistema de ficheros.
|
||||
#@param int_ndisk nº de orden del disco
|
||||
#@param int_part nº de partición
|
||||
#@return (nada, por determinar)
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND fichero o dispositivo no encontrado.
|
||||
#*/ ##
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
#/**
|
||||
# bootOsCustomTemplate
|
||||
#@brief Plantilla para script de configuración personalizada de sistema operativo restaurado.
|
||||
#@param $1 nº de disco
|
||||
#@param $2 nº de partición
|
||||
#@warning Renombrar este fichero como "bootOsCustom" para personalizar el script estándar "bootOs".
|
||||
#@note La partición a inicializar debe estar montada
|
||||
#**/
|
||||
# bootOsCustomTemplate
|
||||
# Plantilla para script de configuración personalizada de sistema operativo restaurado.
|
||||
# bootOsCustomTemplate $disk $part
|
||||
|
||||
import sys
|
||||
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
#/**
|
||||
# configureOs
|
||||
#@brief Script para realizar la configuracion del sistema operativo restaurado.
|
||||
#@param 1 disco
|
||||
#@param 2 particion
|
||||
#@param 3 nombre imagen
|
||||
#@return
|
||||
#@TODO comprobar que el tipo de particion corresponde con el sistema de archivos.
|
||||
#@exception OG_ERR_FORMAT # 1 formato incorrecto.
|
||||
#*/ ##
|
||||
# configureOs
|
||||
# Script para realizar la configuracion del sistema operativo restaurado.
|
||||
# configureOs $disk $par $nombre
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
#!/usr/bin/python3
|
||||
#/**
|
||||
# configureOsCustom
|
||||
#@brief Plantilla para scirpt de configuracion personalizada de sistema operativo restaurado.
|
||||
#@param $1 nº de disco
|
||||
#@param $2 nº de partición
|
||||
#@param $3 Repositorio: CACHE, REPO o dirección IP (opcional)
|
||||
#@param $4 Nombre canónico de la imagen sin extensión (opcional)
|
||||
#@warning Renombrar este fichero como "configureOsCustom" para sustituir al script estándar "configureOs".
|
||||
#@note Los parámetros disco y partición son obligatorios y opcionalmente puede recibir también el repositorio y la imagen usada para en el despliegue.
|
||||
#**/
|
||||
|
||||
# configureOsCustom
|
||||
# Plantilla para scirpt de configuracion personalizada de sistema operativo restaurado.
|
||||
# configureOsCustom $disk $part $repo $nombre
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
# createImage
|
||||
# Scirpt de ejemplo para crear una imagen de un sistema de archivos.
|
||||
# Se usa como base para el programa de creación de imágenes de OpenGnsys Admin).
|
||||
# createImage $disk $par $repo $imagen
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
@ -18,34 +23,6 @@ import FileSystemLib
|
|||
import InventoryLib
|
||||
import UEFILib
|
||||
|
||||
#/**
|
||||
#@file createImage
|
||||
#@brief Scirpt de ejemplo para crear una imagen de un sistema de archivos.
|
||||
#@brief Se usa como base para el programa de creación de imágenes de OpenGnsys Admin).
|
||||
#@param 1 disco
|
||||
#@param 2 particion
|
||||
#@param 3 REPO|CACHE
|
||||
#@param 4 imagen
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT # 1 formato incorrecto.
|
||||
#@exception OG_ERR_PARTITION # 3 Error en partición de disco o en su sistema de archivos
|
||||
#@exception OG_ERR_IMAGE # 5 Error en funcion ogCreateImage o ogRestoreImage.
|
||||
#@exception OG_ERR_NOTWRITE # 14 error de escritura
|
||||
#@exception OG_ERR_NOTCACHE # 15 si cache no existe 15
|
||||
#@exception OG_ERR_CACHESIZE # 16 si espacio de la cache local o remota no tiene espacio 16
|
||||
#@exception OG_ERR_REDUCEFS # 17 error al reducir sistema de archivos.
|
||||
#@exception OG_ERR_EXTENDFS # 18 Errror al expandir el sistema de archivos.
|
||||
#@note
|
||||
#@todo: que hacer, si el tamaño de la cache es sufciente, pero no tiene espacio libre
|
||||
#@todo: que hacer, si hay una imagen con igual nombre en la cache
|
||||
#*/ ##
|
||||
|
||||
# Test 1. crear una imagen en un REPO sin espacio libre.
|
||||
# test 2. crear una imagen en un REPO en modo solo lectura.
|
||||
# test 3. intentar crear una imagen en la cache de un equipo que no la disponga.
|
||||
# test 4. crear una imagen en la Cache sin espacio sufiente.
|
||||
# test 5. intentar crear una imagen, en la que no se puede reducir el FS.
|
||||
|
||||
prog = os.path.basename (sys.argv[0])
|
||||
|
||||
def main (disk, par, repo, imgname):
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
#!/usr/bin/python3
|
||||
#/**
|
||||
# createImageCustom
|
||||
#@brief Plantilla para scirpt de creación personalizada de imagen.
|
||||
#@param $1 nº de disco
|
||||
#@param $2 nº de partición
|
||||
#@param $3 Repositorio: CACHE, REPO o dirección IP
|
||||
#@param $4 Nombre canónico de la imagen sin extensión
|
||||
#@warning Renombrar este fichero como "createImageCustom" para sustituir al script estándar "createImage".
|
||||
#**/
|
||||
|
||||
# createImageCustom
|
||||
# Plantilla para scirpt de creación personalizada de imagen.
|
||||
# createImageCustom $disk $par $repo $nombre
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
|
|
|
@ -1,20 +1,9 @@
|
|||
#!/usr/bin/python3
|
||||
#/**
|
||||
#@file restoreImage
|
||||
#@brief Script de ejemplo para restaurar una imagen.
|
||||
#@param $1 Repositorio (CACHE, REPO o dirección IP)
|
||||
#@param $2 Nombre canónico de la imagen (sin extensión)
|
||||
#@param $3 Número de disco
|
||||
#@param $4 Número de particion
|
||||
#@param $5 Protocolo (UNICAST, UNICAST-DIRECT, MULTICAST o MULTICAST-DIRECT)
|
||||
#@param $6 Opciones del protocolo
|
||||
#@ejemplo restoreImage REPO imgname 2 2 unicast
|
||||
#@exception OG_ERR_FORMAT 1 formato incorrecto.
|
||||
#@exception OG_ERR_NOTFOUND 2 cambio de repositorio: repositorio no encontrado
|
||||
#@exception OG_ERR_NOTFOUND 2 fichero de imagen o partición no detectados.
|
||||
#@exception $OG_ERR_MCASTRECEIVERFILE 57 Error en la recepción Multicast de un fichero
|
||||
#@exception $OG_ERR_PROTOCOLJOINMASTER 60 Error en la conexión de una sesión Unicast|Multicast con el Master
|
||||
#**/
|
||||
|
||||
# restoreImage
|
||||
# Script de ejemplo para restaurar una imagen.
|
||||
# restoreImage $repo $nombre $disk $par $proto $protoopts
|
||||
# restoreImage REPO imgname 2 2 unicast
|
||||
|
||||
import os
|
||||
import os.path
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
#!/usr/bin/python3
|
||||
#/**
|
||||
# restoreImageCustom
|
||||
#@brief Plantilla para scirpt de rastauración personalizada de imagen.
|
||||
#@param $1 nº de disco
|
||||
#@param $2 nº de partición
|
||||
#@param $3 Repositorio: CACHE, REPO o dirección IP
|
||||
#@param $4 Nombre canónico de la imagen sin extensión
|
||||
#@warning Renombrar este fichero como "restoreImageCustom" para sustituir al script estándar "restoreImage".
|
||||
#**/
|
||||
|
||||
# restoreImageCustom
|
||||
# Plantilla para scirpt de rastauración personalizada de imagen.
|
||||
# restoreImageCustom $disk $par $repo $nombre
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
|
|
|
@ -8,17 +8,8 @@ import ogGlobals
|
|||
import SystemLib
|
||||
import CacheLib
|
||||
|
||||
#/**
|
||||
# updateBootCache
|
||||
#@brief acelerador arranque pxe. incorpora a la cache el initrd y el kernel.
|
||||
#@param 1
|
||||
#@param ejemplo:
|
||||
#@return
|
||||
#@exception OG_ERR_NOTCACHE # 15 si cache no existe 15
|
||||
#@exception OG_ERR_NOTFOUND=2 # Fichero o dispositivo no encontrado.
|
||||
#@note
|
||||
#@todo:
|
||||
#*/ ##
|
||||
# updateBootCache
|
||||
# acelerador arranque pxe. incorpora a la cache el initrd y el kernel.
|
||||
|
||||
oglivedir = os.environ.get ('oglivedir', 'ogLive')
|
||||
ogbtftp = f'/opt/oglive/tftpboot/{oglivedir}'
|
||||
|
|
|
@ -1,22 +1,9 @@
|
|||
#!/usr/bin/python3
|
||||
#/**
|
||||
# updateCache
|
||||
#@brief Actualiza la cache del cliente con imagen o fichero iso.
|
||||
#@param 1 REPO Origen del fichero. -accesible por nfs-samba-
|
||||
#@param 2 str_fichero nombre del fichero a actualizar.
|
||||
#@param 3 str_protoco. TORRENT | MULTICAST | UNICAST.
|
||||
#@param 4 str_opcionesprotocolo
|
||||
#@param 4 str_opcionesupdatecache
|
||||
#@ejemplo: updateCache REPO imgname.img UNICAST 8042:42
|
||||
#@return
|
||||
#@exception OG_ERR_FORMAT formato incorrecto.
|
||||
#@exception OG_ERR_NOTCACHE No existe cache -15-
|
||||
#@exception $OG_ERR_CACHESIZE Tamaño de la paticion menor al archivo a descargar -16-
|
||||
#@exception $OG_ERR_MCASTRECEIVERFILE Error en la recepción Multicast de un fichero -57-
|
||||
#@exception $OG_ERR_PROTOCOLJOINMASTER Error en la conexión de una sesión Unicast|Multicast con el Master -60-
|
||||
#@note
|
||||
#@todo:
|
||||
#*/ ##
|
||||
|
||||
# updateCache
|
||||
# Actualiza la cache del cliente con imagen o fichero iso.
|
||||
# updateCache $repo $file $proto $protoopt $opciones_updatecache
|
||||
# updateCache REPO imgname.img UNICAST 8042:42
|
||||
|
||||
import os.path
|
||||
import sys
|
||||
|
|
Loading…
Reference in New Issue