Updated copyright info, added separators and missing exports

This commit is contained in:
2024-11-01 22:25:15 +01:00
parent ee28727313
commit 84a90cefaa
15 changed files with 211 additions and 13 deletions

46
conf/pcp-e3s.conf.sh Normal file
View File

@@ -0,0 +1,46 @@
# Fichier de configuration principal
# ------------------------------------------------------------------------------
# -------------------- Importation de paramêtres globaux -----------------------
# ------------------------------------------------------------------------------
# Importe les paramètres pour le lan E-3S
. $MYPATH/conf/includes/e3s.conf.sh
# Importe la sélection de paquets par défaut
. $MYPATH/conf/includes/pkgsel.base.conf.sh
# Les paramètres précédemment importés sont surchargeable après cette ligne
# ------------------------------------------------------------------------------
# ------------------------------ General Section -------------------------------
# ------------------------------------------------------------------------------
# User of the machine (must exists)
MAINUSER=root
# Authentication: use LDAP+Kerberos ?
WITH_LDAP_KERB=no
# Network
IPV4_IFACES="ens192"
NET4_MODE_ens192="dhcp"
IPV6_IFACES=""
# Mode d'installation :
# * dev : installe les paquets un par un avec apt (lent)
# * full : envoie d'un seul coup la liste de tous les paquets à apt (rapide)
INTALL_MODE=full
# Paquets additionnels
PKGSEL="$PKGSEL"
# ------------------------------------------------------------------------------
# -------------------------- Section modules d'init ----------------------------
# ------------------------------------------------------------------------------
# Liste des modules à executer (surchargeable en ligne de commande)
MODULE_LIST="conf_ntp upgrade_dist conf_locale conf_ssh \
install_pkg install_profile"

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Error management functions # Error management functions
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -33,6 +33,7 @@ function die()
trap 'error ${LINENO}' ERR trap 'error ${LINENO}' ERR
} }
export -f die export -f die
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -42,8 +43,10 @@ function terminate()
prnt E "$1 recieved, exiting at once." prnt E "$1 recieved, exiting at once."
die 128 --force die 128 --force
} }
export -f terminate
trap "terminate 'Ctrl + C'" SIGINT trap "terminate 'Ctrl + C'" SIGINT
trap "terminate 'SIGTERM'" SIGTERM trap "terminate 'SIGTERM'" SIGTERM
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -65,8 +68,10 @@ function error()
fi fi
unset parent_lineno message code unset parent_lineno message code
} }
export -f error
# Trigger error function on error # Trigger error function on error
trap "error ${LINENO}; backtrace; err_exit" ERR trap "error ${LINENO}; backtrace; err_exit" ERR
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -80,6 +85,8 @@ function err_exit
exit 255 exit 255
fi fi
} }
export -f err_exit
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -100,6 +107,9 @@ function backtrace
unset func i unset func i
echo "==============================" echo "=============================="
} }
export -f backtrace
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -125,6 +135,7 @@ noerror()
set -o errexit set -o errexit
} }
export -f noerror export -f noerror
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -140,5 +151,6 @@ check_root()
fi fi
} }
export -f check_root export -f check_root
# ------------------------------------------------------------------------------
# EOF # EOF

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Chroot system functions # Chroot system functions
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -45,5 +45,7 @@ chroot_bootstrap()
prnt I "Back to host system and clean up." prnt I "Back to host system and clean up."
rm -rf "$tmpdir" rm -rf "$tmpdir"
} }
export -f chroot_bootstrap
# ------------------------------------------------------------------------------
# EOF # EOF

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Main program functions # Main program functions
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -128,6 +128,7 @@ read_commandline()
unset opt unset opt
} }
export -f read_commandline export -f read_commandline
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -188,5 +189,6 @@ process_commandline_and_vars()
fi fi
} }
export -f process_commandline_and_vars export -f process_commandline_and_vars
# ------------------------------------------------------------------------------
# EOF # EOF

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Disks and partitions manipulation function # Disks and partitions manipulation function
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -35,6 +35,7 @@ blank_disk()
fi fi
} }
export -f blank_disk export -f blank_disk
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -58,6 +59,7 @@ is_blank()
fi fi
} }
export -f is_blank export -f is_blank
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -107,6 +109,7 @@ mkparts()
unset device parttype unset device parttype
} }
export -f mkparts export -f mkparts
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -122,6 +125,8 @@ mkfs_gen()
fi fi
done done
} }
export -f mkfs_gen
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -133,6 +138,7 @@ mkext4()
unset mkfstool unset mkfstool
} }
export -f mkext4 export -f mkext4
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -144,6 +150,7 @@ mkxfs()
unset mkfstool unset mkfstool
} }
export -f mkxfs export -f mkxfs
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -155,6 +162,7 @@ mkntfs()
unset mkfstool unset mkfstool
} }
export -f mkntfs export -f mkntfs
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -166,6 +174,7 @@ mkfat32()
unset mkfstool unset mkfstool
} }
export -f mkfat32 export -f mkfat32
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -177,6 +186,7 @@ mkbtrfs()
unset mkfstool unset mkfstool
} }
export -f mkbtrfs export -f mkbtrfs
# ------------------------------------------------------------------------------
# EOF # EOF

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Some display functions and defines color codes # Some display functions and defines color codes
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -123,6 +123,7 @@ prnt()
unset heads echoopt unset heads echoopt
} }
export -f prnt export -f prnt
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -142,6 +143,7 @@ separator()
unset i length unset i length
} }
export -f separator export -f separator
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -161,6 +163,7 @@ dsleep()
echo echo
} }
export -f dsleep export -f dsleep
# ------------------------------------------------------------------------------
# EOF # EOF

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# File manipulation function # File manipulation function
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -58,6 +58,7 @@ backup_dist()
unset file unset file
} }
export -f backup_dist export -f backup_dist
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -93,6 +94,7 @@ select_file()
unset source unset source
} }
export -f select_file export -f select_file
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -121,6 +123,7 @@ select_directory()
unset source unset source
} }
export -f select_directory export -f select_directory
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -170,6 +173,7 @@ install_file()
fi fi
} }
export -f install_file export -f install_file
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -200,6 +204,7 @@ append_file()
fi fi
} }
export -f append_file export -f append_file
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -223,6 +228,7 @@ is_dir_empty()
return 1 return 1
} }
export -f is_dir_empty export -f is_dir_empty
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -268,6 +274,7 @@ patch_file()
unset rights dstfile unset rights dstfile
} }
export -f patch_file export -f patch_file
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -285,6 +292,7 @@ tag_file()
done done
} }
export -f tag_file export -f tag_file
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -300,6 +308,7 @@ file_exists()
return 0 return 0
} }
export -f file_exists export -f file_exists
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -315,6 +324,7 @@ file_must_exists()
unset mf unset mf
} }
export -f file_must_exists export -f file_must_exists
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -330,6 +340,7 @@ directory_exists()
return 0 return 0
} }
export -f directory_exists export -f directory_exists
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -345,6 +356,7 @@ directory_must_exists()
unset md unset md
} }
export -f directory_must_exists export -f directory_must_exists
# ------------------------------------------------------------------------------
# EOF # EOF

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Loaders for conf and prepost functions # Loaders for conf and prepost functions
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -49,6 +49,7 @@ load_autoconf()
unset prefix unset prefix
} }
export -f load_autoconf export -f load_autoconf
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -129,6 +130,7 @@ load_configuration()
fi fi
} }
export -f load_configuration export -f load_configuration
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -143,5 +145,6 @@ load_prepost_actions()
unset prepost unset prepost
} }
export -f load_prepost_actions export -f load_prepost_actions
# ------------------------------------------------------------------------------
# EOF # EOF

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Network functions # Network functions
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -34,6 +34,7 @@ set_system_proxy()
fi fi
} }
export -f set_system_proxy export -f set_system_proxy
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -47,6 +48,7 @@ mask2cidr4()
echo $(( $2 + (${#x}/4) )) echo $(( $2 + (${#x}/4) ))
} }
export -f mask2cidr4 export -f mask2cidr4
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -59,6 +61,7 @@ cidr2mask4()
echo ${1-0}.${2-0}.${3-0}.${4-0} echo ${1-0}.${2-0}.${3-0}.${4-0}
} }
export -f cidr2mask4 export -f cidr2mask4
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -82,6 +85,7 @@ isipv4 ()
return 1 return 1
} }
export -f isipv4 export -f isipv4
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -96,6 +100,7 @@ isipv6 ()
return 1 return 1
} }
export -f isipv6 export -f isipv6
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -135,6 +140,7 @@ get_network_info()
done done
} }
export -f get_network_info export -f get_network_info
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -176,3 +182,6 @@ check_network()
esac esac
} }
export -f check_network export -f check_network
# ------------------------------------------------------------------------------
# EOF

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Package manager integration # Package manager integration
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -18,6 +18,7 @@ pkgupdt()
$PKG_MAN $COM_UPDATE $PKG_MAN $COM_UPDATE
} }
export -f pkgupdt export -f pkgupdt
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -56,6 +57,7 @@ pkgupgd()
exec_postupgd exec_postupgd
} }
export -f pkgupgd export -f pkgupgd
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -82,6 +84,7 @@ pkgrm()
fi fi
} }
export -f pkgrm export -f pkgrm
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -94,6 +97,7 @@ pkgautorm()
exec_postautorm exec_postautorm
} }
export -f pkgautorm export -f pkgautorm
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -111,6 +115,7 @@ exec_preinst()
unset pkglist unset pkglist
} }
export -f exec_preinst export -f exec_preinst
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -129,6 +134,7 @@ exec_postinst()
unset POSTINSTLIST unset POSTINSTLIST
} }
export -f exec_postinst export -f exec_postinst
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -147,6 +153,7 @@ exec_prerm()
unset pkglist unset pkglist
} }
export -f exec_prerm export -f exec_prerm
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -165,6 +172,7 @@ exec_postrm()
unset POSTRMLIST unset POSTRMLIST
} }
export -f exec_postrm export -f exec_postrm
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -182,6 +190,7 @@ exec_preupgd()
unset pkglist unset pkglist
} }
export -f exec_preupgd export -f exec_preupgd
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -200,6 +209,7 @@ exec_postupgd()
unset POSTUPGDLIST unset POSTUPGDLIST
} }
export -f exec_postupgd export -f exec_postupgd
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -217,6 +227,7 @@ exec_preautorm()
unset pkglist unset pkglist
} }
export -f exec_preautorm export -f exec_preautorm
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -226,6 +237,7 @@ exec_postautorm()
exec_postrm exec_postrm
} }
export -f exec_postautorm export -f exec_postautorm
# ------------------------------------------------------------------------------
# EOF # EOF

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Services manipulation functions # Services manipulation functions
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -34,6 +34,7 @@ exec_serv()
unset lineexec unset lineexec
} }
export exec_serv export exec_serv
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -47,6 +48,7 @@ svc_start()
unset svc unset svc
} }
export -f svc_start export -f svc_start
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -58,6 +60,7 @@ svc_reload()
done done
} }
export -f svc_reload export -f svc_reload
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -71,6 +74,7 @@ svc_restart()
unset svc unset svc
} }
export -f svc_restart export -f svc_restart
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -84,5 +88,6 @@ svc_stop()
unset svc unset svc
} }
export -f svc_stop export -f svc_stop
# ------------------------------------------------------------------------------
# EOF # EOF

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Base support function # Base support function
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -73,6 +73,7 @@ Fichiers de configuration :
EOF EOF
} }
export -f disp_help export -f disp_help
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -103,5 +104,6 @@ show_version()
fi fi
} }
export -f show_version export -f show_version
# ------------------------------------------------------------------------------
# EOF # EOF

72
lib/users.sh Normal file
View File

@@ -0,0 +1,72 @@
#!/bin/bash
# ------------------------------------------------------------------------------
# Users related functions
# This file is part of the init.sh project
# Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# https://opensource.org/licenses/BSD-3-Clause
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Users (from Ldap)
add_remote_user()
{
if [[ -n $(grep "^$1:" /etc/passwd) ]]; then
prnt W "A local user with name $1 already exists, adding anyway!"
fi
if [[ -n $(grep "^+$1:" /etc/passwd) ]]; then
prnt W "The remote user $1 is already declared, nothing to do in passwd."
else
echo "+$1::::::" >> /etc/passwd
prnt I "User $1 added to passwd..."
fi
if [[ -n $(grep "^+$1:" /etc/shadow) ]]; then
prnt W "The remote user $1 is already connectable, nothing to do in shadow."
else
echo "+$1::::::::" >> /etc/shadow
prnt I "User $1 added to shadow..."
fi
}
export -f add_remote_user
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Remove users
remove_user()
{
if [[ -n $(grep "^$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
# Using sed is more universal than any distro commands - local case
sed -i -e "/^$1:/d" /etc/{passwd,shadow,group,gshadow}
elif [[ -n $(grep "^+$1:" /etc/{passwd,shadow,group,gshadow}) ]]; then
# remote case
sed -i -e "/^+$1:/d" /etc/{passwd,shadow,group,gshadow}
else
prnt W "User $1 don't exists in auth files, nothing to do."
fi
}
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Create a local user
create_local_user()
{
if [[ $(noerror --noout id $1) != 0 ]]; then
prnt I "Creating user $1..."
if [[ $(directory_exists home_skell) ]]; then
useradd --create-home --shell $DEFAULT_SHELL --user-group $1 \
--skell $(select_directory home_skell)
else
useradd --create-home --shell $DEFAULT_SHELL --user-group $1
fi
else
prnt W "The user $1 already exists. Nothing to do..."
fi
}
# ------------------------------------------------------------------------------
# EOF

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Various utilitary functions # Various utilitary functions
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -16,6 +16,7 @@ stdtime()
date --rfc-3339=seconds | sed -e 's/ /-/' -e 's/://g' | cut -d'+' -f1 date --rfc-3339=seconds | sed -e 's/ /-/' -e 's/://g' | cut -d'+' -f1
} }
export -f stdtime export -f stdtime
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -33,6 +34,7 @@ function_exists() {
fi fi
} }
export -f function_exists export -f function_exists
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -46,6 +48,7 @@ get_mod_name()
basename $1 | cut -f 1 -d '.' basename $1 | cut -f 1 -d '.'
} }
export -f get_mod_name export -f get_mod_name
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -57,6 +60,8 @@ trim()
unset string unset string
} }
export -f trim export -f trim
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Dump the keyboard's buffer # Dump the keyboard's buffer
@@ -67,6 +72,7 @@ dump_key_buffer()
done done
} }
export -f dump_key_buffer export -f dump_key_buffer
# ------------------------------------------------------------------------------
# EOF # EOF

View File

@@ -2,7 +2,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Version determination function # Version determination function
# This file is part of the init.sh project # This file is part of the init.sh project
# Copyright (c) 2019-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2019-2024 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license. # This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at: # The complete license agreement can be obtained at:
@@ -45,6 +45,7 @@ get_os_version()
) )
} }
export read_os_release export read_os_release
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -67,5 +68,6 @@ set_sys_vars()
fi fi
} }
export -f get_os_version export -f get_os_version
# ------------------------------------------------------------------------------
# EOF # EOF