Compare commits
3 Commits
main
...
deb-packag
Author | SHA1 | Date |
---|---|---|
|
b24a260e5f | |
|
50b52b92d4 | |
|
af00b6eedb |
157
CHANGELOG.md
|
@ -1,158 +1,7 @@
|
|||
# Changelog
|
||||
|
||||
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).
|
||||
|
||||
## [0.8.0] - 2025-04-23
|
||||
|
||||
### Added
|
||||
|
||||
- Have the oglive agent send /stopped on poweroff or restart
|
||||
|
||||
## [0.7.2] - 2025-04-21
|
||||
|
||||
### Fixed
|
||||
|
||||
- Have the partitioning functions return a meaningful rc
|
||||
|
||||
## [0.7.1] - 2025-04-15
|
||||
|
||||
### Fixed
|
||||
|
||||
- getConfiguration.py: don't fail if NTFS filesystems are mounted ro
|
||||
|
||||
## [0.7.0] - 2025-04-15
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed references to ogGlobals.OGLOG in python code
|
||||
|
||||
## [0.6.1] - 2025-04-15
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed capturing of partclone output and management of return value
|
||||
|
||||
## [0.6.0] - 2025-04-15
|
||||
|
||||
### Changed
|
||||
|
||||
- ogGetIpAddress() is no longer required in ogGlobals--move it back into NetLib
|
||||
|
||||
## [0.5.0] - 2025-04-15
|
||||
|
||||
### Changed
|
||||
|
||||
- Log to /var/log/clone-engine.log and clone-engine.json.log
|
||||
|
||||
## [0.4.1] - 2025-04-10
|
||||
|
||||
### Fixed
|
||||
|
||||
- restoreImage.py: return negated rc to the shell
|
||||
|
||||
## [0.4.0] - 2025-04-10
|
||||
|
||||
### Changed
|
||||
|
||||
- Make /opt/opengnsys writable in clients, just like it used to be
|
||||
|
||||
## [0.3.6] - 2025-04-09
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed ogReduceFs
|
||||
|
||||
## [0.3.5] - 2025-04-09
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed syntax
|
||||
|
||||
## [0.3.4] - 2025-04-09
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed usage of ogEcho in FileSystemLib
|
||||
|
||||
## [0.3.3] - 2025-04-09
|
||||
|
||||
### Fixed
|
||||
|
||||
- Kill coproc'ed browser in all execution branches in Configurar.py
|
||||
|
||||
## [0.3.2] - 2025-04-07
|
||||
|
||||
### Fixed
|
||||
|
||||
- Handle invalid number of arguments pass to functions/ogCopyFile
|
||||
|
||||
## [0.3.1] - 2025-04-03
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed invocation to ogCheckIpAddress in interfaceAdm/CrearImagen.py
|
||||
|
||||
## [0.3.0] - 2025-04-03
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed burg and rsync 3.1
|
||||
|
||||
## [0.2.6] - 2025-03-31
|
||||
|
||||
### Fixed
|
||||
|
||||
- Restore qt4 browser
|
||||
|
||||
## [0.2.5] - 2025-03-31
|
||||
|
||||
### Fixed
|
||||
|
||||
- Don't require protoopts in interfaceAdm/RestaurarImagen.py
|
||||
|
||||
## [0.2.4] - 2025-03-28
|
||||
|
||||
### Removed
|
||||
|
||||
- Removed burg, QT4 stuff, rsync 3.1 and the old browser
|
||||
|
||||
## [0.2.3] - 2025-03-28
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed some errors in Configurar.py, ogCreateCache, ogCreatePartitions and initCache.py
|
||||
|
||||
## [0.2.2] - 2025-03-26
|
||||
|
||||
### Fixed
|
||||
|
||||
- Prevent EjecutarScript.py from capturing the output of the script
|
||||
|
||||
## [0.2.1] - 2025-03-26
|
||||
|
||||
### Fixed
|
||||
|
||||
- Run scripts with bash to avoid errno 8 "Exec format error"
|
||||
|
||||
## [0.2.0] - 2025-03-25
|
||||
|
||||
### Added
|
||||
|
||||
- getConfiguration.py now collects the firmware type
|
||||
- Configurar.py now creates partition tables of the right type (MSDOS/GPT) for each machine
|
||||
|
||||
## [0.1.1] - 2025-03-19
|
||||
|
||||
### Added
|
||||
|
||||
- Missing functions in BootLib
|
||||
- Some interfaceAdm python scripts
|
||||
|
||||
# Changelog
|
||||
## [0.1.0] - 2025-02-28
|
||||
|
||||
### Added
|
||||
### Addded
|
||||
|
||||
- Merge pull request 'Include all client files, build debian package' (#2) from deb-package into main
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ pipeline {
|
|||
stage('Prepare Workspace') {
|
||||
steps {
|
||||
script {
|
||||
env.BUILD_DIR = "${WORKSPACE}/ogclient"
|
||||
env.BUILD_DIR = "${WORKSPACE}/oggui"
|
||||
sh "mkdir -p ${env.BUILD_DIR}"
|
||||
}
|
||||
}
|
||||
|
@ -48,50 +48,16 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
stage('Generate Changelog (Nightly)'){
|
||||
when {
|
||||
branch 'main'
|
||||
}
|
||||
steps {
|
||||
script {
|
||||
def devName = params.DEV_NAME ? params.DEV_NAME : env.DEFAULT_DEV_NAME
|
||||
def devEmail = params.DEV_EMAIL ? params.DEV_EMAIL : env.DEFAULT_DEV_EMAIL
|
||||
generateDebianChangelog(env.BUILD_DIR, devName, devEmail,"nightly")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('Build') {
|
||||
steps {
|
||||
script {
|
||||
construirPaquete(env.BUILD_DIR, "../artifacts", "172.17.8.68", "/var/tmp/opengnsys/debian-repo/ogclient")
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ('Publish to Debian Repository') {
|
||||
when {
|
||||
expression {
|
||||
return env.TAG_NAME != null
|
||||
}
|
||||
}
|
||||
agent { label 'debian-repo' }
|
||||
steps {
|
||||
script {
|
||||
// Construir el patrón de versión esperado en el nombre del paquete
|
||||
def versionPattern = "${env.TAG_NAME}-${env.BUILD_NUMBER}"
|
||||
publicarEnAptly('/var/tmp/opengnsys/debian-repo/ogclient', 'opengnsys-devel', versionPattern)
|
||||
}
|
||||
}
|
||||
}
|
||||
stage ('Publish to Debian Repository (Nightly)') {
|
||||
when {
|
||||
branch 'main'
|
||||
}
|
||||
agent { label 'debian-repo' }
|
||||
steps {
|
||||
script {
|
||||
// Construir el patrón de versión esperado en el nombre del paquete
|
||||
def versionPattern = "-${env.BUILD_NUMBER}~nightly"
|
||||
publicarEnAptly('/var/tmp/opengnsys/debian-repo/ogclient', 'nightly', versionPattern)
|
||||
dir("${env.BUILD_DIR}") {
|
||||
sh '''
|
||||
dpkg-buildpackage -us -uc
|
||||
mkdir -p ../artifacts && mv ../*.deb ../*.changes ../*.buildinfo ../artifacts/
|
||||
ssh aptly@172.17.8.68 "rm -rf /var/tmp/opengnsys/debian-repo && mkdir -p /var/tmp/opengnsys/debian-repo"
|
||||
scp -r ../artifacts/* aptly@172.17.8.68:/var/tmp/opengnsys/debian-repo/
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,4 +68,10 @@ pipeline {
|
|||
}
|
||||
}
|
||||
}
|
||||
// stage ('Publish to Debian Repository') {
|
||||
// agent { label 'debian-repo' }
|
||||
// steps {
|
||||
// sh "aptly repo add opengnsys-devel /var/tmp/opengnsys/debian-repo/*.deb"
|
||||
// }
|
||||
// }
|
||||
|
||||
|
|
|
@ -23,7 +23,13 @@ case "$1" in
|
|||
cp -a "$OLD_FILE" "$NEW_FILE"
|
||||
|
||||
# Append our configuration
|
||||
echo "include = /etc/samba/smb-ogclient.conf" >> "$OLD_FILE"
|
||||
echo "include = /etc/samba/smb-ogclient.conf" >> "$NEW_FILE"
|
||||
|
||||
# Use ucf to handle the file update
|
||||
ucf --debconf-ok "$NEW_FILE" "$OLD_FILE"
|
||||
|
||||
# Clean up
|
||||
rm -f "$NEW_FILE"
|
||||
|
||||
# Reload Samba
|
||||
if command -v systemctl >/dev/null 2>&1; then
|
||||
|
@ -42,8 +48,6 @@ case "$1" in
|
|||
;;
|
||||
esac
|
||||
|
||||
chown -R opengnsys:opengnsys /opt/opengnsys/ogclient
|
||||
chown -R opengnsys:opengnsys /opt/opengnsys/ogclient_log
|
||||
#DEBHELPER#
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Asegurarse de que el usuario exista
|
||||
USER="opengnsys"
|
||||
HOME_DIR="/opt/opengnsys"
|
||||
if id "$USER" &>/dev/null; then
|
||||
echo "El usuario $USER ya existe."
|
||||
else
|
||||
echo "Creando el usuario $USER con home en $HOME_DIR."
|
||||
useradd -m -d "$HOME_DIR" -s /bin/bash "$USER"
|
||||
fi
|
||||
|
||||
exit 0
|
|
@ -1,7 +1,7 @@
|
|||
[ogclient]
|
||||
comment = OpenGnsys Client
|
||||
browseable = no
|
||||
writeable = yes
|
||||
writeable = no
|
||||
locking = no
|
||||
path = /opt/opengnsys/ogclient
|
||||
guest ok = no
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogBoot
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogBoot', 'ogBoot int_ndisk int_nfilesys [ NVRAMPERM ] [str_kernel str_initrd str_kernelparams]', ['ogBoot 1 2 "/boot/vmlinuz /boot/initrd.img root=/dev/sda2 ro"', 'ogBoot 1 2 NVRAMPERM'])
|
||||
sys.exit (0)
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
if 3 == len (sys.argv):
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
elif 4 == len (sys.argv):
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('nvramperm_or_params')
|
||||
elif 5 == len (sys.argv):
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('nvramperm')
|
||||
parser.add_argument ('params')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if 3 == len (sys.argv):
|
||||
ret = ogBoot (args.disk, args.par)
|
||||
elif 4 == len (sys.argv):
|
||||
if 'NVRAMPERM' == args.nvramperm_or_params.upper():
|
||||
nvramperm = True
|
||||
params = ''
|
||||
else:
|
||||
nvramperm = False
|
||||
params = args.nvramperm_or_params
|
||||
ret = ogBoot (args.disk, args.par, nvramperm, params)
|
||||
elif 5 == len (sys.argv):
|
||||
ret = ogBoot (args.disk, args.par, not not args.nvramperm, args.params)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import ogGlobals
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogBootLoaderDefaultEntry
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('diskdefault')
|
||||
parser.add_argument ('pardefault')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogBootLoaderDefaultEntry', ogGlobals.lang.MSG_SEE+' ogGrubDefaultEntry', [])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogBootLoaderDefaultEntry (args.disk, args.par, args.diskdefault, args.pardefault)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,26 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import ogGlobals
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogBootLoaderDeleteEntry
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('diskdel')
|
||||
parser.add_argument ('pardel')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogBootLoaderDeleteEntry', ogGlobals.lang.MSG_SEE+' ogGrubDeleteEntry', [])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogBootLoaderDeleteEntry (args.disk, args.par, args.diskdel, args.pardel)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import ogGlobals
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogBootLoaderHidePartitions
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogBootLoaderHidePartitions', ogGlobals.lang.MSG_SEE+' ogGrubHidePartitions', [])
|
||||
sys.exit (0)
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
if 3 == len (sys.argv):
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
elif 5 == len (sys.argv):
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('datadisk')
|
||||
parser.add_argument ('datapar')
|
||||
|
||||
args = parser.parse_args()
|
||||
if 3 == len (sys.argv):
|
||||
ret = ogBootLoaderHidePartitions (args.disk, args.par)
|
||||
elif 5 == len (sys.argv):
|
||||
ret = ogBootLoaderHidePartitions (args.disk, args.par, args.datadisk, args.datapar)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import ogGlobals
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogBootLoaderOgliveDefaultEntry
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogBootLoaderOgliveDefaultEntry', ogGlobals.lang.MSG_SEE+' ogGrubOgliveDefaultEntry', [])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogBootLoaderOgliveDefaultEntry (args.disk, args.par)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import ogGlobals
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogBootLoaderSetTimeOut
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('timeout')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogBootLoaderSetTimeOut', ogGlobals.lang.MSG_SEE+' ogGrubSetTimeOut', [])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogBootLoaderSetTimeOut (args.disk, args.par, args.timeout)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogBootMbrGeneric
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogBootMbrGeneric', 'ogBootMbrGeneric int_ndisk', ['ogBootMbrGeneric 1'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogBootMbrGeneric (args.disk)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogBootMbrXP
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogBootMbrXP', 'ogBootMbrXP int_ndisk', ['ogBootMbrXP 1'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogBootMbrXP (args.disk)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -7,6 +7,7 @@ from NetLib import ogChangeRepo
|
|||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('ip_repo')
|
||||
parser.add_argument ('og_unit', nargs='?', default=None)
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
|
@ -15,7 +16,7 @@ if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
|||
|
||||
args = parser.parse_args()
|
||||
|
||||
ret = ogChangeRepo (args.ip_repo)
|
||||
ret = ogChangeRepo (args.ip_repo, args.og_unit)
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
|
|
|
@ -55,9 +55,6 @@ elif 6 == len (sys.argv):
|
|||
args = parser.parse_args()
|
||||
src = { 'container': args.src_container, 'file': args.src_file }
|
||||
dst = { 'disk': args.dst_disk, 'par': args.dst_par, 'file': args.dst_file }
|
||||
else:
|
||||
ogHelp ('ogCopyFile', 'ogCopyFile [ str_repo | int_ndisk int_npartition ] path_source [ str_repo | int_ndisk int_npartition ] path_target', ['ogCopyFile REPO newfile.txt 1 2 /tmp/newfile.txt'])
|
||||
sys.exit (1)
|
||||
|
||||
ret = ogCopyFile (src, dst)
|
||||
if ret is not None:
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogGetBootMbr
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogGetBootMbr', 'ogGetBootMbr int_ndisk', ['ogGetBootMbr 1'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogGetBootMbr (args.disk)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogGetWindowsName
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogGetWindowsName', 'ogGetWindowsName int_ndisk int_npartition', ['ogGetWindowsName 1 1'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogGetWindowsName (args.disk, args.par)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogGrub4dosInstallMbr
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogGrub4dosInstallMbr', 'ogGrub4dosInstallMbr int_ndisk int_part', ['ogGrub4dosInstallMbr 1 1'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogGrub4dosInstallMbr (args.disk, args.par)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogGrubAddOgLive
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('timeout', nargs='?')
|
||||
parser.add_argument ('offline', nargs='?')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogGrubAddOgLive', 'ogGrubAddOgLive int_ndisk int_npartition [ time_out ] [ offline|online ]', ['ogGrubAddOgLive 1 1', 'ogGrubAddOgLive 1 6 15 offline'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogGrubAddOgLive (args.disk, args.par, args.timeout, args.offline)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogGrubDefaultEntry
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('diskdefault')
|
||||
parser.add_argument ('pardefault')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogGrubDefaultEntry', 'ogGrubDefaultEntry int_ndisk int_npartition int_disk_default_entry int_npartition_default_entry', ['ogGrubDefaultEntry 1 6 1 1'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogGrubDefaultEntry (args.disk, args.par, args.diskdefault, args.pardefault)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogGrubDeleteEntry
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('diskdel')
|
||||
parser.add_argument ('pardel')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogGrubDeleteEntry', 'ogGrubDeleteEntry int_ndisk int_npartition int_disk_delete int_npartition_delete', ['ogGrubDeleteEntry 1 6 2 1'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogGrubDeleteEntry (args.disk, args.par, args.diskdel, args.pardel)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import ogGlobals
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogGrubHidePartitions
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogGrubHidePartitions', 'ogGrubHidePartitions int_ndisk int_npartition [ num_disk_partdata num_partdata ]', ['ogGrubHidePartitions 1 2', 'ogGrubHidePartitions 1 2 1 3'])
|
||||
sys.exit (0)
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
if 3 == len (sys.argv):
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
elif 5 == len (sys.argv):
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('datadisk')
|
||||
parser.add_argument ('datapar')
|
||||
|
||||
args = parser.parse_args()
|
||||
if 3 == len (sys.argv):
|
||||
ret = ogGrubHidePartitions (args.disk, args.par)
|
||||
elif 5 == len (sys.argv):
|
||||
ret = ogGrubHidePartitions (args.disk, args.par, args.datadisk, args.datapar)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogGrubOgliveDefaultEntry
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogGrubOgliveDefaultEntry', 'ogGrubOgliveDefaultEntry int_ndiskSecondStage int_partitionSecondStage', ['ogGrubOgliveDefaultEntry 1 6'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogGrubOgliveDefaultEntry (args.disk, args.par)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogGrubSecurity
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('user', nargs='?', default='root')
|
||||
parser.add_argument ('passwd', nargs='?', default='')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogGrubSecurity', 'ogGrubSecurity int_ndiskSecondStage int_partitionSecondStage [USER] [PASSWORD]', ['ogGrubSecurity 1 1', 'ogGrubSecurity 1 2 user clave'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogGrubSecurity (args.disk, args.par, args.user, args.passwd)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogGrubSetTimeOut
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('timeout')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogGrubSetTimeOut', 'ogGrubSetTimeOut int_ndiskSecondStage int_partitionSecondStage int_timeout_seconds', ['ogGrubSetTimeOut 1 4 50'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogGrubSetTimeOut (args.disk, args.par, args.timeout)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogLinuxBootParameters
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogLinuxBootParameters', 'ogLinuxBootParameters int_ndisk int_nfilesys', ['ogLinuxBootParameters 1 2'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogLinuxBootParameters (args.disk, args.par)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogSetLinuxName
|
||||
from NetLib import ogGetHostname
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogSetLinuxName', 'ogSetLinuxName int_ndisk int_nfilesys [str_name]', ['ogSetLinuxName 1 1 practica-pc'])
|
||||
sys.exit (0)
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
if 3 == len (sys.argv):
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
elif 4 == len (sys.argv):
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('hostname')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if 3 == len (sys.argv):
|
||||
h = ogGetHostname()
|
||||
if h:
|
||||
ret = ogSetLinuxName (args.disk, args.par, h)
|
||||
else:
|
||||
ret = ogSetLinuxName (args.disk, args.par)
|
||||
elif 4 == len (sys.argv):
|
||||
ret = ogSetLinuxName (args.disk, args.par, args.hostname)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,24 +0,0 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
from SystemLib import ogHelp
|
||||
from BootLib import ogSetWinlogonUser
|
||||
|
||||
parser = argparse.ArgumentParser (add_help=False)
|
||||
parser.add_argument ('disk')
|
||||
parser.add_argument ('par')
|
||||
parser.add_argument ('username')
|
||||
|
||||
if 2 == len (sys.argv) and 'help' == sys.argv[1]:
|
||||
#parser.print_help() sale en inglés aunque la locale indique otra cosa
|
||||
ogHelp ('ogSetWinlogonUser', 'ogSetWinlogonUser int_ndisk int_npartition str_username', ['ogSetWinlogonUser 1 1 USUARIO'])
|
||||
sys.exit (0)
|
||||
|
||||
args = parser.parse_args()
|
||||
ret = ogSetWinlogonUser (args.disk, args.par, args.username)
|
||||
|
||||
if ret is not None:
|
||||
if ret == True: sys.exit (0)
|
||||
elif ret == False: sys.exit (1)
|
||||
else: print (ret)
|
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
os.system ('pkill -f OGAgent')
|
||||
time.sleep (3)
|
||||
os.system ('poweroff')
|
||||
sys.exit (0)
|
||||
def main():
|
||||
os.system('poweroff')
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -1,62 +1,54 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
#______________________________________
|
||||
#
|
||||
# PARAMETROS RECIBIDOS DESDE EL CLIENTE
|
||||
# $1 modo (admin, user)
|
||||
#______________________________________
|
||||
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import subprocess
|
||||
import NetLib
|
||||
import SystemLib
|
||||
|
||||
import ogGlobals
|
||||
from SystemLib import ogEcho, ogRaiseError, ogIsRepoLocked
|
||||
from NetLib import ogGetRepoIp
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage: CambiarAcceso.py <mode>")
|
||||
sys.exit(1)
|
||||
|
||||
# Error si llamada no se realliza desde OpenGnsys Client.
|
||||
prog = sys.argv[0]
|
||||
if len (sys.argv) != 2:
|
||||
print (f'Usage: {prog} <mode>')
|
||||
sys.exit (1)
|
||||
mode = sys.argv[1]
|
||||
repo_ip = NetLib.ogGetRepoIp()
|
||||
|
||||
# Salir si el repositorio está bloquedo (tiene ficheros abiertos).
|
||||
mode = sys.argv[1]
|
||||
repoip = ogGetRepoIp()
|
||||
if not repoip:
|
||||
ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, 'repo no montado')
|
||||
sys.exit (1)
|
||||
if ogIsRepoLocked():
|
||||
ogRaiseError ([], ogGlobals.OG_ERR_LOCKED, f'repo {repoip}')
|
||||
sys.exit (1)
|
||||
if not repo_ip:
|
||||
SystemLib.ogRaiseError("OG_ERR_NOTFOUND", "repo no montado")
|
||||
|
||||
# Comprobar protocolo y modo de acceso.
|
||||
proto = os.getenv ('ogprotocol', 'smb')
|
||||
if proto not in ['nfs', 'smb']:
|
||||
ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f'protocolo desconocido {proto}')
|
||||
sys.exit (1)
|
||||
if 'admin' == mode: mount_mode = 'rw'
|
||||
elif 'user' == mode: mount_mode = 'ro'
|
||||
else:
|
||||
ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f'modo desconocido {mode}')
|
||||
sys.exit (1)
|
||||
if SystemLib.ogIsRepoLocked():
|
||||
SystemLib.ogRaiseError("OG_ERR_LOCKED", f"repo {repo_ip}")
|
||||
|
||||
# Desmontar repositorio y volver a montarlo con el modo adecuado.
|
||||
subprocess.run (['umount', ogGlobals.OGIMG])
|
||||
ogEcho ([], 'info', f'Montar repositorio {repoip} por {proto} en modo {mode}')
|
||||
if 'nfs' == proto:
|
||||
subprocess.run (['mount', '-t', 'nfs', f'{repoip}:{ogGlobals.OGIMG}', ogGlobals.OGIMG, '-o', mount_mode])
|
||||
elif 'smb' == proto:
|
||||
pass_option = ''
|
||||
with open ('/scripts/ogfunctions', 'r') as fd:
|
||||
while True:
|
||||
line = fd.readline()
|
||||
if not line: break
|
||||
if not re.search ('^[\t ]*(export )?OPTIONS=', line): continue
|
||||
m = re.search (r'pass=(\w*)', line)
|
||||
if m:
|
||||
pass_option = m.groups (0)[0]
|
||||
break
|
||||
if not pass_option: pass_option = 'og'
|
||||
subprocess.run (['mount.cifs', f'//{repoip}/ogimages', ogGlobals.OGIMG, '-o', f'{mount_mode},serverino,acl,username=opengnsys,password={pass_option}'])
|
||||
proto = os.getenv("ogprotocol", "smb")
|
||||
if proto not in ["nfs", "smb"]:
|
||||
SystemLib.ogRaiseError("OG_ERR_FORMAT", f"protocolo desconocido {proto}")
|
||||
|
||||
if mode == "admin":
|
||||
mount_mode = "rw"
|
||||
elif mode == "user":
|
||||
mount_mode = "ro"
|
||||
else:
|
||||
SystemLib.ogRaiseError("OG_ERR_FORMAT", f"modo desconocido {mode}")
|
||||
|
||||
OGIMG = os.getenv("OGIMG", "/mnt/OGIMG")
|
||||
OGUNIT = os.getenv("OGUNIT", "")
|
||||
if OGUNIT:
|
||||
OGUNIT = f"/{OGUNIT}"
|
||||
|
||||
subprocess.run(["umount", OGIMG], check=True)
|
||||
SystemLib.ogEcho("info", f"Montar repositorio {repo_ip} por {proto} en modo {mode}")
|
||||
|
||||
if proto == "nfs":
|
||||
subprocess.run(["mount", "-t", "nfs", f"{repo_ip}:{OGIMG}{OGUNIT}", OGIMG, "-o", mount_mode], check=True)
|
||||
elif proto == "smb":
|
||||
with open("/scripts/ogfunctions", "r") as f:
|
||||
for line in f:
|
||||
if "OPTIONS=" in line:
|
||||
pass_option = line.split("pass=")[1].split()[0]
|
||||
break
|
||||
else:
|
||||
pass_option = "og"
|
||||
subprocess.run(["mount.cifs", f"//{repo_ip}/ogimages{OGUNIT}", OGIMG, "-o", f"{mount_mode},serverino,acl,username=opengnsys,password={pass_option}"], check=True)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -9,7 +9,6 @@ import SystemLib
|
|||
import CacheLib
|
||||
import FileSystemLib
|
||||
import DiskLib
|
||||
import InventoryLib
|
||||
|
||||
#Load engine configurator from engine.cfg file.
|
||||
#Carga el configurador del engine desde el fichero engine.cfg
|
||||
|
@ -62,24 +61,23 @@ sparam = tbprm[1] # Partitioning and formatting parameters
|
|||
# Toma valores de disco y caché, separados por "*".
|
||||
# Los valores están en las variables $dis: disco, $che: existe cache (1, 0), $tch: Tamaño de la cache.
|
||||
tbprm = pparam.split ('*')
|
||||
dis = tch = None
|
||||
dis = ptt = tch = None
|
||||
for item in tbprm:
|
||||
if '=' not in item: continue
|
||||
|
||||
k, v = item.split ('=', 1)
|
||||
if k not in ['dis', 'tch']:
|
||||
if k not in ['dis', 'tch', 'ptt']: ## 'ptt' added, unused 'che' removed
|
||||
print (f'ignoring unknown disk parameter ({k})')
|
||||
continue
|
||||
|
||||
if 'dis' == k: dis = int (v)
|
||||
elif 'ptt' == k: ptt = v
|
||||
elif 'tch' == k: tch = v
|
||||
|
||||
# Error si no se define el parámetro de disco (dis).
|
||||
if dis is None:
|
||||
coproc.kill()
|
||||
sys.exit (ogGlobals.OG_ERR_FORMAT)
|
||||
if tch is None:
|
||||
tch = '0'
|
||||
if dis is None: sys.exit (ogGlobals.OG_ERR_FORMAT)
|
||||
if ptt is None: ptt = 'MSDOS'
|
||||
if tch is None: tch = '0'
|
||||
|
||||
# Toma valores de distribución de particiones, separados por "%".
|
||||
tbp = [] # Valores de configuración (parámetros para ogCreatePartitions)
|
||||
|
@ -114,7 +112,6 @@ for item in tbprm:
|
|||
if tam is None: missing_params.append ('tam')
|
||||
if missing_params:
|
||||
print (f'partition data ({item}) missing required parameters ({' '.join (missing_params)})')
|
||||
coproc.kill()
|
||||
sys.exit (1)
|
||||
|
||||
# Componer datos de particionado.
|
||||
|
@ -141,21 +138,18 @@ CacheLib.ogUnmountCache()
|
|||
|
||||
# Elimina la tabla de particiones
|
||||
cur_ptt = DiskLib.ogGetPartitionTableType (dis)
|
||||
ptt = 'GPT' if InventoryLib.ogIsEfiActive() else 'MSDOS'
|
||||
if not cur_ptt or ptt != cur_ptt:
|
||||
DiskLib.ogDeletePartitionTable (dis)
|
||||
SystemLib.ogExecAndLog ('command', DiskLib.ogUpdatePartitionTable)
|
||||
|
||||
# Crea tabla de particiones MSDOS (NOTA: adaptar para tablas GPT).
|
||||
DiskLib.ogCreatePartitionTable (dis, ptt)
|
||||
|
||||
# Inicia la cache.
|
||||
if 'CACHE' in sparam:
|
||||
SystemLib.ogEcho (['session', 'log'], None, f'[30] {ogGlobals.lang.MSG_HELP_ogCreateCache}')
|
||||
SystemLib.ogEcho (['session', 'log'], None, f' initCache {tch}')
|
||||
rc = SystemLib.ogExecAndLog ('command', CacheLib.initCache, tch)
|
||||
if rc:
|
||||
SystemLib.ogRaiseError (['log', 'session'], ogGlobals.OG_ERR_CACHE, f'initCache failed')
|
||||
coproc.kill()
|
||||
sys.exit (1)
|
||||
SystemLib.ogExecAndLog ('command', CacheLib.initCache, tch)
|
||||
|
||||
# Definir particionado.
|
||||
SystemLib.ogEcho (['session', 'log'], None, f'[50] {ogGlobals.lang.MSG_HELP_ogCreatePartitions}')
|
||||
|
|
|
@ -1,109 +1,74 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
#___________________________________________________
|
||||
#
|
||||
# PARAMETROS RECIBIDOS DESDE EL CLIENTE:
|
||||
# $1 Número de disco
|
||||
# $2 Número de particion
|
||||
# $3 Nombre canónico de la imagen (sin extensión)
|
||||
# $4 Dirección del repositorio (REPO, por defecto)
|
||||
#___________________________________________________
|
||||
|
||||
|
||||
#$OG_ERR_NOTEXEC Si no es llamada por OG client
|
||||
#$OG_ERR_LOCKED=4 Si la particion está bloqueada.
|
||||
|
||||
|
||||
#Codigos de error del scripts createImage
|
||||
#@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.
|
||||
|
||||
|
||||
#Códigos de error de la funcion ogCreateImage
|
||||
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
import NetLib
|
||||
import ogGlobals
|
||||
from SystemLib import ogEcho, ogRaiseError
|
||||
from NetLib import ogGetIpAddress, ogChangeRepo
|
||||
from StringLib import ogCheckIpAddress
|
||||
|
||||
prog = sys.argv[0]
|
||||
if len (sys.argv) < 4:
|
||||
ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, 'Incorrect number of arguments')
|
||||
sys.exit (1)
|
||||
disk, par, imgname, *other = sys.argv[1:]
|
||||
arg_repo = other[0] if len (other) > 0 else 'REPO'
|
||||
dirname = os.path.dirname (prog)
|
||||
def load_engine_config():
|
||||
engine_config_path = "/opt/opengnsys/etc/engine.cfg"
|
||||
if os.path.exists(engine_config_path):
|
||||
with open(engine_config_path) as f:
|
||||
exec(f.read(), globals())
|
||||
|
||||
start_time = time.time()
|
||||
env_boot = os.getenv ('boot')
|
||||
def clear_temp_logs():
|
||||
open(os.getenv('OGLOGSESSION'), 'w').close()
|
||||
open(os.getenv('OGLOGCOMMAND'), 'w').close()
|
||||
open(f"{os.getenv('OGLOGCOMMAND')}.tmp", 'w').close()
|
||||
|
||||
#Load engine configurator from engine.cfg file.
|
||||
#Carga el configurador del engine desde el fichero engine.cfg
|
||||
## (ogGlobals se encarga)
|
||||
def log_session_start(script_name, args):
|
||||
SystemLib.ogEcho("log session", f"{os.getenv('MSG_INTERFACE_START')} {script_name} {' '.join(args)}")
|
||||
|
||||
# Clear temporary file used as log track by httpdlog
|
||||
# Limpia los ficheros temporales usados como log de seguimiento para httpdlog
|
||||
open (ogGlobals.OGLOGSESSION, 'w').close()
|
||||
open (ogGlobals.OGLOGCOMMAND, 'w').close()
|
||||
open (f"{ogGlobals.OGLOGCOMMAND}.tmp", 'w').close()
|
||||
def log_session_end(retval):
|
||||
SystemLib.ogEcho("log session", f"{os.getenv('MSG_INTERFACE_END')} {retval}")
|
||||
|
||||
# Registro de inicio de ejecución
|
||||
ogEcho (['log', 'session'], None, f'{ogGlobals.lang.MSG_INTERFACE_START} {prog} {disk} {par} {imgname} {arg_repo}')
|
||||
def ogCheckIpAddress(ip):
|
||||
try:
|
||||
subprocess.check_call(["ping", "-c", "1", ip])
|
||||
return 0
|
||||
except subprocess.CalledProcessError:
|
||||
return 1
|
||||
|
||||
# Valor por defecto para el repositorio.
|
||||
repo = arg_repo
|
||||
if not repo: repo = 'REPO'
|
||||
if repo == ogGetIpAddress(): repo = 'CACHE'
|
||||
# Si es una ip y es distinta a la del recurso samba cambiamos de REPO.
|
||||
if 'REPO' == repo or ogCheckIpAddress (repo):
|
||||
# Si falla el cambio -> salimos con error repositorio no valido
|
||||
if not ogChangeRepo (repo):
|
||||
ogRaiseError ([], ogGlobals.OG_ERR_NOTFOUND, repo)
|
||||
sys.exit (1)
|
||||
def create_image(disk_num, partition_num, repo, image_name):
|
||||
if subprocess.call(["which", "createImageCustom"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) == 0:
|
||||
return subprocess.call(["createImageCustom", disk_num, partition_num, repo, f"/{image_name}"])
|
||||
else:
|
||||
return subprocess.call(["createImage", disk_num, partition_num, repo, f"/{image_name}"])
|
||||
|
||||
# Si el destino es REPO y el cliente no está en modo "admin"; activar repositorio para escritura,
|
||||
if 'REPO' == repo and 'admin' != env_boot:
|
||||
retval = subprocess.run ([f'{dirname}/CambiarAcceso.py', 'admin']).returncode
|
||||
if retval:
|
||||
sys.exit (retval)
|
||||
def main():
|
||||
if len(sys.argv) != 5:
|
||||
sys.exit(SystemLib.ogRaiseError(OG_ERR_FORMAT, "Incorrect number of arguments"))
|
||||
|
||||
ogEcho ([], None, f'createImage "{disk}" "{par}" "{arg_repo}" /"{imgname}"')
|
||||
# Si existe, ejecuta script personalizado "createImageCustom"; si no, llama al genérico "createImage".
|
||||
if os.path.exists ('{ogGlobals.OGSCRIPTS}/createImageCustom.py'):
|
||||
script = f'{ogGlobals.OGSCRIPTS}/createImageCustom.py'
|
||||
else:
|
||||
script = f'{ogGlobals.OGSCRIPTS}/createImage.py'
|
||||
disk_num, partition_num, image_name, repo = sys.argv[1:5]
|
||||
|
||||
with open (ogGlobals.OGLOGCOMMAND, 'a') as fd:
|
||||
p = subprocess.Popen ([script, disk, par, arg_repo, f'/{imgname}'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
while p.poll() is None:
|
||||
for l in iter (p.stdout.readline, b''):
|
||||
partial = l.decode ('utf-8', 'ignore')
|
||||
fd.write (partial)
|
||||
print (partial, end='') ## so that the agent captures out output and reports progress to ogcore
|
||||
for l in iter (p.stderr.readline, b''):
|
||||
partial = l.decode ('utf-8', 'ignore')
|
||||
fd.write (partial)
|
||||
print (partial, end='')
|
||||
retval = p.returncode
|
||||
start_time = time.time()
|
||||
|
||||
# Cambiar acceso a modo usuario, si es necesario.
|
||||
if 'REPO' == repo and 'admin' != env_boot:
|
||||
subprocess.run ([f'{dirname}/CambiarAcceso.py', 'user'])
|
||||
load_engine_config()
|
||||
clear_temp_logs()
|
||||
log_session_start(sys.argv[0], sys.argv[1:])
|
||||
|
||||
# Registro de fin de ejecución
|
||||
ogEcho (['log', 'session'], None, f'{ogGlobals.lang.MSG_INTERFACE_END} {retval}')
|
||||
repo = repo if repo else "REPO"
|
||||
if repo == NetLib.ogGetIpAddress():
|
||||
repo = "CACHE"
|
||||
|
||||
sys.exit (retval)
|
||||
if ogCheckIpAddress(repo) == 0 or repo == "REPO":
|
||||
OGUNIT = os.getenv('OGUNIT', "")
|
||||
if not NetLib.ogChangeRepo(repo, OGUNIT):
|
||||
sys.exit(SystemLib.ogRaiseError(OG_ERR_NOTFOUND, f"{repo}"))
|
||||
|
||||
if repo == "REPO" and os.getenv('boot') != "admin":
|
||||
retval = CambiarAcceso("admin")
|
||||
if retval > 0:
|
||||
sys.exit(retval)
|
||||
|
||||
retval = create_image(disk_num, partition_num, repo, image_name)
|
||||
|
||||
if repo == "REPO" and os.getenv('boot') != "admin":
|
||||
CambiarAcceso("user")
|
||||
|
||||
log_session_end(retval)
|
||||
sys.exit(retval)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -1,50 +1,62 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import time
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import SystemLib
|
||||
import ogGlobals
|
||||
from SystemLib import ogEcho, ogRaiseError
|
||||
|
||||
#sys.path.append('/opt/opengnsys/lib/engine/bin')
|
||||
|
||||
prog = sys.argv[0]
|
||||
if len (sys.argv) != 2:
|
||||
print (f'Usage: {prog} <script_path>')
|
||||
sys.exit (1)
|
||||
def main(script_path):
|
||||
start_time = time.time()
|
||||
print(f"Ejecutando:",script_path)
|
||||
|
||||
TIME1 = time.time()
|
||||
script_path = sys.argv[1]
|
||||
# Load engine configurator from engine.cfg file.
|
||||
engine_config_path = '/opt/opengnsys/etc/engine.cfg'
|
||||
# if 'OGENGINECONFIGURATE' not in os.environ:
|
||||
# with open(engine_config_path) as f:
|
||||
# exec(f.read(), globals())
|
||||
|
||||
# Clear temporary file used as log track by httpdlog
|
||||
# Limpia los ficheros temporales usados como log de seguimiento para httpdlog
|
||||
open (ogGlobals.OGLOGSESSION, 'w').close()
|
||||
open (ogGlobals.OGLOGCOMMAND, 'w').close()
|
||||
# Clear temporary file used as log track by httpdlog
|
||||
with open(os.environ['OGLOGSESSION'], 'w') as f:
|
||||
f.write("")
|
||||
with open(os.environ['OGLOGCOMMAND'], 'w') as f:
|
||||
f.write("")
|
||||
|
||||
# Registro de inicio de ejecución
|
||||
ogEcho (['log', 'session'], None, f'{ogGlobals.lang.MSG_INTERFACE_START} {prog} {script_path}')
|
||||
# Registro de inicio de ejecución
|
||||
SystemLib.ogEcho('log session', f"{os.environ['MSG_INTERFACE_START']} {sys.argv[0]} {' '.join(sys.argv[1:])}")
|
||||
|
||||
with open (ogGlobals.OGLOGFILE, 'a') as logfd:
|
||||
with open (script_path) as scriptfd:
|
||||
logfd.write ('\n Instrucciones a ejecutar: *****************************\n')
|
||||
logfd.write (scriptfd.read())
|
||||
with open(os.environ['OGLOGFILE'], 'a') as log_file:
|
||||
log_file.write("\n Instrucciones a ejecutar: *****************************\n"
|
||||
with open(script_path.split()[1]) as script_file: # Obtener solo el nombre del script
|
||||
log_file.write(script_file.read()) )
|
||||
|
||||
logfd.write ('\n Salida de las instrucciones: *****************************\n')
|
||||
log_file.write("\n Salida de las instrucciones: *****************************\n")
|
||||
|
||||
os.chmod (script_path, 0o755)
|
||||
# Si mandamos la salida a OGLOGCOMMAND reescribimos lo que manda el comando.
|
||||
RETVAL = subprocess.run (['bash', script_path]).returncode
|
||||
# Cambiar permisos y ejecutar el script
|
||||
os.chmod(script_path.split()[1], 0o755)
|
||||
result = subprocess.run([sys.executable] + script_path.split(), capture_output=True, text=True)
|
||||
ret_val = result.returncode
|
||||
|
||||
with open(os.environ['OGLOGCOMMAND'], 'a') as log_command_file:
|
||||
log_command_file.write(result.stdout)
|
||||
log_command_file.write(result.stderr)
|
||||
|
||||
TIME = time.time() - TIME1
|
||||
if 0 == RETVAL:
|
||||
ogEcho (['log', 'session'], None, f'[100] Duracion de la operacion {int(TIME // 60)}m {int(TIME % 60)}s')
|
||||
else:
|
||||
ogRaiseError (['log', 'session'], RETVAL, '')
|
||||
ogEcho (['log', 'session'], 'error', 'Operacion no realizada')
|
||||
elapsed_time = time.time() - start_time
|
||||
if ret_val == 0:
|
||||
SystemLib.ogEcho('log session', f"[100] Duracion de la operacion {int(elapsed_time // 60)}m {int(elapsed_time % 60)}s")
|
||||
else:
|
||||
SystemLib.ogRaiseError('log session', ret_val)
|
||||
SystemLib.ogEcho('log session', 'error "Operacion no realizada"')
|
||||
|
||||
# Registro de fin de ejecución
|
||||
ogEcho (['log', 'session'], None, f'{ogGlobals.lang.MSG_INTERFACE_END} {RETVAL}')
|
||||
# Registro de fin de ejecución
|
||||
SystemLib.ogEcho('log session', f"{os.environ['MSG_INTERFACE_END']} {ret_val}")
|
||||
|
||||
sys.exit (RETVAL)
|
||||
sys.exit(ret_val)
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage: python EjecutarScript.py <script_path>")
|
||||
sys.exit(1)
|
||||
main(sys.argv[1])
|
||||
|
|
|
@ -1,23 +1,18 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
import ogGlobals
|
||||
from SystemLib import ogRaiseError
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
|
||||
if len(args) == 1:
|
||||
disk = 1
|
||||
part = args[0]
|
||||
else:
|
||||
disk = args[0]
|
||||
part = args[1]
|
||||
|
||||
boot_os(disk, part)
|
||||
|
||||
# UHU - Comprobamos el disco, si solo hay un parametro, disco es 1, por compatibilidad con clientes antiguos
|
||||
prog = sys.argv[0]
|
||||
if len (sys.argv) < 2 or len (sys.argv) > 3:
|
||||
ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f'{prog} disk [partition]')
|
||||
sys.exit (1)
|
||||
args = sys.argv[1:]
|
||||
|
||||
if 1 == len (args):
|
||||
disk = '1'
|
||||
part = args[0]
|
||||
else:
|
||||
disk = args[0]
|
||||
part = args[1]
|
||||
|
||||
subprocess.run ([f'{ogGlobals.OGSCRIPTS}/bootOs.py', disk, part])
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -1,25 +1,33 @@
|
|||
#!/usr/bin/python3
|
||||
# Script de interfaz para guardar en un fichero el inventario de hardware de un cliente.
|
||||
|
||||
import sys
|
||||
#!/usr/bin/env python3
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import ogGlobals
|
||||
from SystemLib import ogRaiseError
|
||||
def main(output_file):
|
||||
# Ejecutar el comando `listHardwareInfo.py` y capturar el resultado
|
||||
try:
|
||||
print(f"------------------------------------------ loading listHardwareInfo.py")
|
||||
result = subprocess.run(
|
||||
["python3", "/opt/opengnsys/scripts/listHardwareInfo.py"],
|
||||
capture_output=True, text=True, check=True
|
||||
)
|
||||
output_lines = result.stdout.strip().split('\n')
|
||||
file_path = output_lines[-1] # Obtener la última línea como la ruta del archivo de salida
|
||||
print(f"------------------------------------------ archivo:{file_path}")
|
||||
|
||||
# Leer desde la segunda línea del archivo y escribir en el archivo de salida especificado
|
||||
with open(file_path, 'r') as input_file, open(output_file, 'w') as output:
|
||||
lines = input_file.readlines()[1:] # Saltar la primera línea
|
||||
output.writelines(lines)
|
||||
|
||||
prog = sys.argv[0]
|
||||
if len (sys.argv) != 2:
|
||||
print (f'Usage: {prog} <output_file>')
|
||||
sys.exit (1)
|
||||
output_file = sys.argv[1]
|
||||
except subprocess.CalledProcessError as e:
|
||||
print("Error ejecutando listHardwareInfo.py:", e.stderr, file=sys.stderr)
|
||||
sys.exit(e.returncode)
|
||||
except FileNotFoundError as e:
|
||||
print(f"Archivo no encontrado: {e.filename}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
listhi_out = subprocess.run ( [f'{ogGlobals.OGSCRIPTS}/listHardwareInfo.py'], capture_output=True, text=True).stdout
|
||||
if listhi_out:
|
||||
inventory_path = listhi_out.splitlines()[0]
|
||||
else:
|
||||
ogRaiseError ([], ogGlobals.OG_ERR_GENERIC, 'listHardwareInfo.py failed')
|
||||
sys.exit (1)
|
||||
|
||||
with open (inventory_path, 'r') as fdin, open (output_file, 'w') as fdout:
|
||||
lines = fdin.readlines()[1:] # 'tail -n +2'
|
||||
fdout.writelines (lines)
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
print("Uso: python3 InventarioHardware.py <archivo_salida>")
|
||||
sys.exit(1)
|
||||
main(sys.argv[1])
|
||||
|
|
|
@ -1,40 +1,53 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import time
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
sys.path.append('/opt/opengnsys/lib/engine/bin')
|
||||
import ogGlobals
|
||||
from SystemLib import ogEcho, ogRaiseError
|
||||
import SystemLib
|
||||
|
||||
def main(arg1, arg2, dest_file):
|
||||
start_time = time.time()
|
||||
|
||||
og_log_session = os.getenv(ogGlobals.OGLOGSESSION)
|
||||
og_log_command = os.getenv(ogGlobals.OGLOGCOMMAND)
|
||||
if og_log_session and og_log_command:
|
||||
with open(og_log_session, 'w') as f:
|
||||
f.write(" ")
|
||||
with open(og_log_command, 'w') as f:
|
||||
f.write(" ")
|
||||
with open(f"{og_log_command}.tmp", 'w') as f:
|
||||
f.write(" ")
|
||||
|
||||
msg_interface_start = os.getenv(ogGlobals.lang.MSG_INTERFACE_START)
|
||||
if msg_interface_start:
|
||||
SystemLib.ogEcho("log", "session", f"{msg_interface_start} {__file__} {arg1} {arg2}")
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["python3", "/opt/opengnsys/scripts/listSoftwareInfo.py", arg1, arg2],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True
|
||||
)
|
||||
file = result.stdout.strip().splitlines()[-1]
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error al ejecutar listSoftwareInfo: {e.stderr}")
|
||||
sys.exit(e.returncode)
|
||||
|
||||
print(f"Copying:( {file} to {dest_file} )")
|
||||
shutil.copy(file, dest_file)
|
||||
|
||||
elapsed_time = time.time() - start_time
|
||||
msg_scripts_time_partial = os.getenv(ogGlobals.lang.MSG_SCRIPTS_TIME_PARTIAL)
|
||||
if msg_scripts_time_partial:
|
||||
SystemLib.ogEcho("log", "session", f" [ ] {msg_scripts_time_partial} : {int(elapsed_time // 60)}m {int(elapsed_time % 60)}s")
|
||||
|
||||
if __name__ == "__main__":
|
||||
prog = sys.argv[0]
|
||||
if len (sys.argv) != 4:
|
||||
print (f'Usage: {prog} <disk> <partition> <dest_file>')
|
||||
sys.exit (1)
|
||||
|
||||
disk, par, dest_file = sys.argv[1:]
|
||||
|
||||
TIME1 = time.time()
|
||||
|
||||
# Limpia los ficheros temporales usados como log de seguimiento para httpdlog
|
||||
open (ogGlobals.OGLOGSESSION, 'w').close()
|
||||
open (ogGlobals.OGLOGCOMMAND, 'w').close()
|
||||
open (f"{ogGlobals.OGLOGCOMMAND}.tmp", 'w').close()
|
||||
|
||||
# Registro de inicio de ejecución
|
||||
ogEcho (['log', 'session'], None, f'{ogGlobals.lang.MSG_INTERFACE_START} {prog} {disk} {par} {dest_file}')
|
||||
|
||||
listsi_out = subprocess.run ([f'{ogGlobals.OGSCRIPTS}/listSoftwareInfo.py', disk, par], capture_output=True, text=True).stdout
|
||||
if listsi_out:
|
||||
file = listsi_out.splitlines()[0]
|
||||
else:
|
||||
ogRaiseError ([], ogGlobals.OG_ERR_GENERIC, 'listSoftwareInfo.py failed')
|
||||
sys.exit (1)
|
||||
|
||||
shutil.copy (file, dest_file)
|
||||
|
||||
TIME = time.time() - TIME1
|
||||
ogEcho(['log', 'session'], None, f' [ ] {ogGlobals.lang.MSG_SCRIPTS_TIME_PARTIAL} : {int(TIME // 60)}m {int(TIME % 60)}s')
|
||||
if len(sys.argv) != 4:
|
||||
print("Usage: python InventarioSoftware.py <arg1> <arg2> <dest_file>")
|
||||
sys.exit(1)
|
||||
main(sys.argv[1], sys.argv[2], sys.argv[3])
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
||||
os.system ('pkill -f OGAgent')
|
||||
time.sleep (3)
|
||||
os.system ('reboot')
|
||||
sys.exit (0)
|
||||
def reboot_system():
|
||||
os.system('reboot')
|
||||
|
||||
if __name__ == "__main__":
|
||||
reboot_system()
|
||||
|
|
|
@ -1,29 +1,19 @@
|
|||
#!/usr/bin/python3
|
||||
#_______________________________________________________________________________________________________________________________
|
||||
#
|
||||
# PARAMETROS RECIBIDOS DESDE EL CLIENTE:
|
||||
# $1 disco
|
||||
# $2 par=Número de particion
|
||||
# $3 Nombre canónico de la imagen
|
||||
# $4 Dirección IP del repositorio
|
||||
# $5 Protocolo UNICAST MULTICAST TORRENT
|
||||
# $6 Opciones del protocolo
|
||||
#_______________________________________________________________________________________________________________________________
|
||||
|
||||
# Llamar al script de despliegue "deployImage".
|
||||
|
||||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
import ogGlobals
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) < 7:
|
||||
print("Usage: python RestaurarImagen.py <disk> <partition> <image_name> <ip> <protocol> <protocol_options> [additional_args...]")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
prog = sys.argv[0]
|
||||
if len (sys.argv) < 6:
|
||||
print (f'Usage: {prog} <disk> <partition> <image_name> <repo_ip> <protocol> [protocol_options] [additional_args...]')
|
||||
sys.exit (1)
|
||||
disk = sys.argv[1]
|
||||
partition = sys.argv[2]
|
||||
image_name = sys.argv[3]
|
||||
ip = sys.argv[4]
|
||||
protocol = sys.argv[5]
|
||||
protocol_options = sys.argv[6]
|
||||
additional_args = sys.argv[7:]
|
||||
|
||||
disk, par, imgname, repo, proto, *extra = sys.argv[1:]
|
||||
|
||||
rc = subprocess.run ([f'{ogGlobals.OGSCRIPTS}/deployImage.py', repo, imgname, disk, par, proto] + extra).returncode
|
||||
sys.exit (rc)
|
||||
exit_code = deploy_image(ip, image_name, disk, partition, protocol, protocol_options, *additional_args)
|
||||
sys.exit(exit_code)
|
||||
|
|
|
@ -1,78 +1,80 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import glob
|
||||
import subprocess
|
||||
|
||||
from InventoryLib import ogGetSerialNumber, ogGetOsVersion, ogIsEfiActive
|
||||
from DiskLib import ogDiskToDev, ogGetPartitionsNumber, ogGetPartitionTableType, ogGetDiskSize, ogGetPartitionId, ogGetPartitionSize
|
||||
from FileSystemLib import ogMount, ogGetMountPoint, ogGetFsType
|
||||
def run_command(command):
|
||||
result = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
return result.stdout.decode().strip()
|
||||
|
||||
ser = ogGetSerialNumber()
|
||||
fwt = 'UEFI' if ogIsEfiActive() else 'BIOS'
|
||||
print (f'ser={ser}\nfwt={fwt}')
|
||||
def main():
|
||||
# No registrar los errores.
|
||||
os.environ["DEBUG"] = "no"
|
||||
|
||||
ser = run_command("ogGetSerialNumber")
|
||||
cfg = ""
|
||||
disks = int(run_command("ogDiskToDev | wc -w"))
|
||||
|
||||
for dsk in range(1, disks + 1):
|
||||
particiones = run_command(f"ogGetPartitionsNumber {dsk}")
|
||||
particiones = int(particiones) if particiones else 0
|
||||
ptt = run_command(f"ogGetPartitionTableType {dsk}")
|
||||
|
||||
disks = len (ogDiskToDev())
|
||||
if disks:
|
||||
for dsk in range (1, disks+1):
|
||||
# Tipo de tabla de particiones: 1=MSDOS, 2=GPT
|
||||
ptt = ogGetPartitionTableType (dsk)
|
||||
ptt_map = {
|
||||
'MSDOS': 1,
|
||||
'GPT': 2,
|
||||
'LVM': 3,
|
||||
'ZPOOL': 4,
|
||||
"MSDOS": 1,
|
||||
"GPT": 2,
|
||||
"LVM": 3,
|
||||
"ZPOOL": 4
|
||||
}
|
||||
ptt = ptt_map.get (ptt, 0)
|
||||
ptt = ptt_map.get(ptt, 0)
|
||||
|
||||
# Información de disco (partición 0)
|
||||
s = ogGetDiskSize (dsk)
|
||||
print (f'disk={dsk}\tpar=0\tcpt={ptt}\tfsi=\tsoi=\ttam={s}\tuso=0')
|
||||
cfg += f"{dsk}:0:{ptt}:::{run_command(f'ogGetDiskSize {dsk}')}:0;"
|
||||
|
||||
particiones = ogGetPartitionsNumber (dsk)
|
||||
particiones = int (particiones) if particiones else 0
|
||||
for par in range (1, particiones+1):
|
||||
# Código del identificador de tipo de partición
|
||||
cod = ogGetPartitionId (dsk, par)
|
||||
for par in range(1, particiones + 1):
|
||||
cod = run_command(f"ogGetPartitionId {dsk} {par} 2>/dev/null")
|
||||
fsi = run_command(f"getFsType {dsk} {par} 2>/dev/null") or "EMPTY"
|
||||
tam = run_command(f"ogGetPartitionSize {dsk} {par} 2>/dev/null") or "0"
|
||||
soi = ""
|
||||
uso = 0
|
||||
|
||||
# Tipo del sistema de ficheros
|
||||
fsi = ogGetFsType (dsk, par)
|
||||
if not fsi: fsi = 'EMPTY'
|
||||
|
||||
# Tamaño de la particón
|
||||
tam = ogGetPartitionSize (dsk, par)
|
||||
if not tam: tam = '0'
|
||||
|
||||
# Sistema operativo instalado y porcentaje de uso
|
||||
soi = ''
|
||||
uso = '0'
|
||||
if fsi not in ['', 'EMPTY', 'LINUX-SWAP', 'LINUX-LVM', 'ZVOL']:
|
||||
if ogMount (dsk, par):
|
||||
soi = ogGetOsVersion (dsk, par)
|
||||
# Hacer un 2º intento para algunos casos especiales.
|
||||
if fsi not in ["", "EMPTY", "LINUX-SWAP", "LINUX-LVM", "ZVOL"]:
|
||||
if run_command(f"ogMount {dsk} {par} 2>/dev/null"):
|
||||
soi = run_command(f"getOsVersion {dsk} {par} 2>/dev/null").split(":")[1]
|
||||
if not soi:
|
||||
soi = ogGetOsVersion (dsk, par)
|
||||
if not soi: soi = ''
|
||||
if soi: soi = soi.split (':')[1]
|
||||
# Sistema de archivos para datos (sistema operativo "DATA")
|
||||
if not soi and fsi not in ['EMPTY', 'CACHE']:
|
||||
soi = 'DATA'
|
||||
mntpt = ogGetMountPoint (dsk, par)
|
||||
uso = subprocess.run (['df', mntpt], capture_output=True, text=True).stdout.splitlines()[-1].split()[4].replace ('%', '')
|
||||
if not uso: uso = '0'
|
||||
soi = run_command(f"getOsVersion {dsk} {par} 2>/dev/null").split(":")[1]
|
||||
if not soi and fsi not in ["EMPTY", "CACHE"]:
|
||||
soi = "DATA"
|
||||
uso = int(run_command(f"df $(ogGetMountPoint {dsk} {par}) | awk '{{getline; printf \"%d\",$5}}'") or 0)
|
||||
else:
|
||||
soi = ''
|
||||
uso = '0'
|
||||
soi = ""
|
||||
uso = 0
|
||||
|
||||
print (f'disk={dsk}\tpar={par}\tcpt={cod}\tfsi={fsi}\tsoi={soi}\ttam={tam}\tuso={uso}')
|
||||
else:
|
||||
print ('disk=1\tpar=0\tcpt=0\tfsi=\tsoi=\ttam=0\tuso=0')
|
||||
cfg += f"{dsk}:{par}:{cod}:{fsi}:{soi}:{tam}:{uso};"
|
||||
|
||||
# Crear el menú por defecto a partir del fichero generado (no dar ninguna salida).
|
||||
# requiere /tmp/getconfig pero este script ya no lo crea
|
||||
#subprocess.run ([f'{ogGlobals.OGSCRIPTS}/generateMenuDefault'])
|
||||
if not cfg:
|
||||
cfg = "1:0:0:::0;"
|
||||
|
||||
# Borramos marcas de arranque de Windows
|
||||
for f in glob.glob ('/mnt/*/ogboot.*') + glob.glob ('/mnt/*/*/ogboot.*'):
|
||||
try: os.unlink (f)
|
||||
except: pass
|
||||
cfgfile = "/tmp/getconfig"
|
||||
with open(cfgfile, "w") as f:
|
||||
f.write(f"{ser + ';' if ser else ''}{cfg}")
|
||||
|
||||
run_command("generateMenuDefault &>/dev/null")
|
||||
|
||||
with open(cfgfile, "r") as f:
|
||||
data = f.read()
|
||||
|
||||
lines = data.split(";")
|
||||
for line in lines:
|
||||
if line:
|
||||
parts = line.split(":")
|
||||
if len(parts) == 1:
|
||||
print(f"ser={parts[0]}")
|
||||
else:
|
||||
print(f"disk={parts[0]}\tpar={parts[1]}\tcpt={parts[2]}\tfsi={parts[3]}\tsoi={parts[4]}\ttam={parts[5]}\tuso={parts[6]}")
|
||||
|
||||
run_command("rm -f /mnt/*/ogboot.* /mnt/*/*/ogboot.*")
|
||||
|
||||
# Volver a registrar los errores.
|
||||
os.environ.pop("DEBUG", None)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
#!/usr/bin/python3
|
||||
#!/usr/bin/env python3
|
||||
import socket
|
||||
|
||||
from NetLib import ogGetIpAddress
|
||||
def get_ip_address():
|
||||
hostname = socket.gethostname()
|
||||
ip_address = socket.gethostbyname(hostname)
|
||||
return ip_address
|
||||
|
||||
print (ogGetIpAddress())
|
||||
if __name__ == "__main__":
|
||||
print(get_ip_address())
|
||||
|
|
After Width: | Height: | Size: 136 B |
After Width: | Height: | Size: 73 KiB |
|
@ -0,0 +1,79 @@
|
|||
include "theme"
|
||||
|
||||
screen {
|
||||
background = "$$/background.png"
|
||||
|
||||
panel {
|
||||
halign = center
|
||||
attach_vcenter = 0
|
||||
height = 19
|
||||
# Flip so the cursor defaults to the main menu
|
||||
direction = bottom_to_top
|
||||
|
||||
### Main Menu ###
|
||||
panel {
|
||||
height = 15
|
||||
max_width = 120
|
||||
margin_top = 1
|
||||
class = container-body
|
||||
# No need for a min width and centering panel because extended width > min width
|
||||
|
||||
direction = left_to_right
|
||||
anchor = 1
|
||||
id = __menu__
|
||||
}
|
||||
|
||||
panel {
|
||||
height = 4
|
||||
width = 100%
|
||||
class = container-title
|
||||
|
||||
direction = left_to_right
|
||||
|
||||
image {
|
||||
image = "$$/images/txt-select.png"
|
||||
attach_top = 0
|
||||
attach_left = 0
|
||||
}
|
||||
|
||||
### Tools Menu ###
|
||||
image {
|
||||
attach_right = 2
|
||||
image = "$$/images/button-tools.png:$$/images/button-tools-hover.png"
|
||||
command = "menu_popup tools_menu"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
### Progress Bar ###
|
||||
panel {
|
||||
halign = center
|
||||
attach_vcenter = 20
|
||||
width = 80
|
||||
class = progressbar-background
|
||||
id = __timeout__
|
||||
|
||||
progressbar { }
|
||||
}
|
||||
}
|
||||
|
||||
template_menuitem {
|
||||
panel {
|
||||
width = 40
|
||||
height = 12
|
||||
|
||||
parameters = "class=image.class:title=panel.text.text"
|
||||
|
||||
image {
|
||||
attach_vcenter = 0
|
||||
attach_hcenter = 0
|
||||
}
|
||||
|
||||
panel {
|
||||
attach_vcenter = 0
|
||||
attach_hcenter = 0
|
||||
class = text-line
|
||||
text { font = "Helvetica Regular 22" }
|
||||
}
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.5 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 1.5 KiB |
|
@ -0,0 +1,21 @@
|
|||
+class
|
||||
{
|
||||
-opengnsys { image = "$$/normal_opengnsys.png:$$/hover_opengnsys.png" }
|
||||
-windows10 { image = "$$/normal_windows10.png:$$/hover_windows10.png" }
|
||||
-windows7 { image = "$$/normal_windows7.png:$$/hover_windows7.png" }
|
||||
-windows { image = "$$/normal_windows.png:$$/hover_windows.png" }
|
||||
-elementary { image = "$$/normal_elementary.png:$$/hover_elementary.png" }
|
||||
-elementaryos { image = "$$/normal_elementary.png:$$/hover_elementary.png" }
|
||||
-recovery { image = "$$/normal_recovery.png:$$/hover_recovery.png" }
|
||||
-shutdown { image = "$$/normal_shutdown.png:$$/hover_shutdown.png" }
|
||||
-restart { image = "$$/normal_restart.png:$$/hover_restart.png" }
|
||||
-linux { image = "$$/normal_linux.png:$$/hover_linux.png" }
|
||||
-ubuntu { image = "$$/normal_ubuntu.png:$$/hover_ubuntu.png" }
|
||||
-debian { image = "$$/normal_debian.png:$$/hover_debian.png" }
|
||||
-suse { image = "$$/normal_opensuse.png:$$/hover_opensuse.png" }
|
||||
-freebsd { image = "$$/normal_freebsd.png:$$/hover_freebsd.png" }
|
||||
-macosx { image = "$$/normal_osx.png:$$/hover_osx.png" }
|
||||
-haiku { image = "$$/normal_haiku.png:$$/hover_haiku.png" }
|
||||
-image { image = "$$/normal_os.png:$$/hover_os.png" }
|
||||
-os { image = "$$/normal_os.png:$$/hover_os.png" }
|
||||
}
|
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 5.1 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 109 B |
After Width: | Height: | Size: 146 B |
After Width: | Height: | Size: 146 B |
After Width: | Height: | Size: 525 B |
After Width: | Height: | Size: 671 B |
After Width: | Height: | Size: 725 B |
After Width: | Height: | Size: 562 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 153 B |
After Width: | Height: | Size: 146 B |
After Width: | Height: | Size: 154 B |
After Width: | Height: | Size: 154 B |
After Width: | Height: | Size: 155 B |
After Width: | Height: | Size: 148 B |
After Width: | Height: | Size: 159 B |
After Width: | Height: | Size: 144 B |
After Width: | Height: | Size: 139 B |
After Width: | Height: | Size: 139 B |
After Width: | Height: | Size: 151 B |
After Width: | Height: | Size: 181 B |