refs #1468 fix bug and permissions in opt opengnsys
testing/og-dhcp-API/pipeline/head There was a failure building this commit
Details
testing/og-dhcp-API/pipeline/head There was a failure building this commit
Details
parent
ebfecedcec
commit
642c1d8e3e
|
@ -147,6 +147,31 @@ function createDirs() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
# Mover el fichero de registro de instalación al directorio de logs.
|
||||
echoAndLog "${FUNCNAME}(): moving installation log file"
|
||||
mv "$LOG_FILE" "$path_opengnsys_base/var/log" && LOG_FILE="$OGLOGFILE"
|
||||
chmod 644 "$LOG_FILE"
|
||||
chmod -R 644 "$path_opengnsys_base/etc"
|
||||
|
||||
# Mover el fichero de registro de instalación al directorio de logs.
|
||||
echoAndLog "${FUNCNAME}(): moving installation log file"
|
||||
touch "$path_opengnsys_base/var/log/dev.log"
|
||||
chmod 644 "$path_opengnsys_base/var/log/dev.log"
|
||||
|
||||
echoAndLog "${FUNCNAME}(): directory paths created"
|
||||
return 0
|
||||
|
||||
# Cambiar permisos de usuario
|
||||
echoAndLog "Changing user permission"
|
||||
chown -R "$OPENGNSYS_CLIENT_USER:$OPENGNSYS_CLIENT_USER" "$INSTALL_TARGET"
|
||||
}
|
||||
|
||||
|
||||
function create_ogdhcp_project {
|
||||
# Crea el usuario ogdhcp si no existe
|
||||
echo "Creating ogdhcp user..."
|
||||
local path_opengnsys_base="$1"
|
||||
echo $path_opengnsys_base
|
||||
# Verificar si el usuario OPENGNSYS_CLIENT_USER existe
|
||||
if id -u "$OPENGNSYS_CLIENT_USER" &>/dev/null; then
|
||||
# Salida de getent passwd -> opengnsys:x:1001:1001::/opt/opengnsys:/bin/sh
|
||||
|
@ -172,37 +197,9 @@ function createDirs() {
|
|||
fi
|
||||
fi
|
||||
|
||||
# Mover el fichero de registro de instalación al directorio de logs.
|
||||
echoAndLog "${FUNCNAME}(): moving installation log file"
|
||||
mv "$LOG_FILE" "$path_opengnsys_base/var/log" && LOG_FILE="$OGLOGFILE"
|
||||
chmod 644 "$LOG_FILE"
|
||||
chmod -R 644 "$path_opengnsys_base/etc"
|
||||
|
||||
# Mover el fichero de registro de instalación al directorio de logs.
|
||||
echoAndLog "${FUNCNAME}(): moving installation log file"
|
||||
touch "$path_opengnsys_base/var/log/dev.log"
|
||||
chmod 644 "$path_opengnsys_base/var/log/dev.log"
|
||||
|
||||
echoAndLog "${FUNCNAME}(): directory paths created"
|
||||
return 0
|
||||
|
||||
# Cambiar permisos de usuario
|
||||
echoAndLog "Changing user permission"
|
||||
chown -R "$OPENGNSYS_CLIENT_USER:$OPENGNSYS_CLIENT_USER" "$INSTALL_TARGET"
|
||||
}
|
||||
|
||||
|
||||
function create_ogdhcp_project {
|
||||
# Crea el usuario ogdhcp si no existe
|
||||
local path_opengnsys_base="$1"
|
||||
if ! id -u opengnsys &>/dev/null; then
|
||||
echoAndLog "${FUNCNAME}(): creating opengnsys user"
|
||||
useradd opengnsys 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
errorAndLog "${FUNCNAME}(): error creating opengnsys user"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
# Asegurar que todos los usuarios puedan entrar y leer /opt/opengnsys
|
||||
echoAndLog "${FUNCNAME[0]}(): setting permissions for /opt/opengnsys"
|
||||
sudo chmod 755 /opt/opengnsys
|
||||
|
||||
# Crea el directorio path_opengnsys_base con el usuario opengnsys
|
||||
echoAndLog "${FUNCNAME}(): creating directory $path_opengnsys_base with opengnsys user"
|
||||
|
@ -594,6 +591,18 @@ if [ "$(whoami)" != 'root' ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Verificar si jq está instalado, si no, instalarlo
|
||||
if ! command -v jq &> /dev/null; then
|
||||
echo "jq no está instalado. Instalando jq..."
|
||||
apt-get update -y
|
||||
apt-get install -y jq
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error al instalar jq. Por favor, instala jq manualmente y vuelve a intentarlo."
|
||||
exit 1
|
||||
fi
|
||||
echo "jq instalado correctamente."
|
||||
fi
|
||||
|
||||
globalSetup
|
||||
|
||||
echoAndLog "OpenGnsys installation begins at $(date)"
|
||||
|
@ -603,6 +612,7 @@ pushd $WORKDIR
|
|||
|
||||
checkDependencies
|
||||
# Si es necesario, descarga el repositorio de código en directorio temporal
|
||||
|
||||
if [ $REMOTE -eq 1 ]; then
|
||||
downloadCode $GIT_REPO
|
||||
if [ $? -ne 0 ]; then
|
||||
|
@ -613,6 +623,7 @@ else
|
|||
ln -fs "$(dirname $PROGRAMDIR)" ogdhcp
|
||||
fi
|
||||
|
||||
|
||||
create_ogdhcp_project ${INSTALL_TARGET}
|
||||
if [ $? -ne 0 ]; then
|
||||
errorAndLog "Error while creating skeleton directory!"
|
||||
|
|
Loading…
Reference in New Issue