Dotfiles config update (2022-03-13)

This commit is contained in:
q3aql 2022-03-13 16:30:06 +01:00
parent 15a4c3c92c
commit c721fbf126

View File

@ -2,16 +2,16 @@
########################################################################## ##########################################################################
# systemctl-wrapper - Wrapper for sysv init scripts simulating systemctl # # systemctl-wrapper - Wrapper for sysv init scripts simulating systemctl #
# Autor: Quique Molina # # Author: q3aql #
# Contacto: emolina@prosodie.com # # Contact: q3aql@duck.com #
# Licencia: GPL 2.0 # # License: GPL 2.0 #
# ######################################################################## # ########################################################################
VERSION=1.0 VERSION=1.0
# Variable con scripts de arranque # Variable with start-up scripts
path_scripts="/etc/init.d" path_scripts="/etc/init.d"
# Funcion para simular las units y sockets de systemctl # Function to simulate the units and sockets of systemctl
function systemctl_units() { function systemctl_units() {
list_units=$(ls -1 ${path_scripts}) list_units=$(ls -1 ${path_scripts})
echo "UNIT" echo "UNIT"
@ -20,7 +20,7 @@ function systemctl_units() {
done done
} }
# Comprobar si existe el directorio de scripts # Check if the scripts directory exists
function check_dir_scripts() { function check_dir_scripts() {
if [ -d "${path_scripts}" ] ; then if [ -d "${path_scripts}" ] ; then
echo > /dev/null echo > /dev/null
@ -34,7 +34,7 @@ function check_dir_scripts() {
fi fi
} }
# Function para mostrar la ayuda # Function to display help
function systemctl_help() { function systemctl_help() {
echo "" echo ""
echo "systemctl [OPTIONS...] {COMMAND} ..." echo "systemctl [OPTIONS...] {COMMAND} ..."
@ -63,88 +63,88 @@ echo " reboot Shut down and reboot the system"
echo "" echo ""
} }
# Function para mostrar la version # Function to display the version
function systemctl_version() { function systemctl_version() {
echo "" echo ""
echo "systemctl (wrapper) v${VERSION} for sysvinit scripts" echo "systemctl (wrapper) v${VERSION} for sysvinit scripts"
echo "" echo ""
} }
# Funcion para el mapeo de comandos # Function for command mapping
function systemctl_map() { function systemctl_map() {
# Mapeo del comando start # Mapping of the start command
if [ "${1}" == "start" ] ; then if [ "${1}" == "start" ] ; then
if [ -f "${path_scripts}/${2}" ] ; then if [ -f "${path_scripts}/${2}" ] ; then
"${path_scripts}/${2}" start "${path_scripts}/${2}" start
else else
echo "Failed to start ${2}: Unit not found." echo "Failed to start ${2}: Unit not found."
fi fi
# Mapeo del comando enable # Mapping of the enable command
elif [ "${1}" == "enable" ] ; then elif [ "${1}" == "enable" ] ; then
if [ -f "${path_scripts}/${2}" ] ; then if [ -f "${path_scripts}/${2}" ] ; then
"${path_scripts}/${2}" start "${path_scripts}/${2}" start
else else
echo "Failed to enable ${2}: Unit not found." echo "Failed to enable ${2}: Unit not found."
fi fi
# Mapeo del comando stop # Mapping of the stop command
elif [ "${1}" == "stop" ] ; then elif [ "${1}" == "stop" ] ; then
if [ -f "${path_scripts}/${2}" ] ; then if [ -f "${path_scripts}/${2}" ] ; then
"${path_scripts}/${2}" stop "${path_scripts}/${2}" stop
else else
echo "Failed to stop ${2}: Unit not found." echo "Failed to stop ${2}: Unit not found."
fi fi
# Mapeo del comando disable # Mapping of the disable command
elif [ "${1}" == "disable" ] ; then elif [ "${1}" == "disable" ] ; then
if [ -f "${path_scripts}/${2}" ] ; then if [ -f "${path_scripts}/${2}" ] ; then
"${path_scripts}/${2}" stop "${path_scripts}/${2}" stop
else else
echo "Failed to disable ${2}: Unit not found." echo "Failed to disable ${2}: Unit not found."
fi fi
# Mapeo del comando reload # Mapping of the reload command
elif [ "${1}" == "reload" ] ; then elif [ "${1}" == "reload" ] ; then
if [ -f "${path_scripts}/${2}" ] ; then if [ -f "${path_scripts}/${2}" ] ; then
"${path_scripts}/${2}" reload "${path_scripts}/${2}" reload
else else
echo "Failed to reload ${2}: Unit not found." echo "Failed to reload ${2}: Unit not found."
fi fi
# Mapeo del comando restart # Mapping of the restart command
elif [ "${1}" == "restart" ] ; then elif [ "${1}" == "restart" ] ; then
if [ -f "${path_scripts}/${2}" ] ; then if [ -f "${path_scripts}/${2}" ] ; then
"${path_scripts}/${2}" restart "${path_scripts}/${2}" restart
else else
echo "Failed to restart ${2}: Unit not found." echo "Failed to restart ${2}: Unit not found."
fi fi
# Mapeo del comando status # Mapping of the status command
elif [ "${1}" == "status" ] ; then elif [ "${1}" == "status" ] ; then
if [ -f "${path_scripts}/${2}" ] ; then if [ -f "${path_scripts}/${2}" ] ; then
"${path_scripts}/${2}" status "${path_scripts}/${2}" status
else else
echo "Failed to status ${2}: Unit not found." echo "Failed to status ${2}: Unit not found."
fi fi
# Mapeo del comando list-units # Mapping of the list-units command
elif [ "${1}" == "list-units" ] ; then elif [ "${1}" == "list-units" ] ; then
systemctl_units systemctl_units
# Mapeo del comando list-sockets # Mapping of the list-sockets command
elif [ "${1}" == "list-sockets" ] ; then elif [ "${1}" == "list-sockets" ] ; then
systemctl_units netstat -putan | grep LISTEN
# Mapeo del comando list-unit-files # Mapping of the list-unit-files command
elif [ "${1}" == "list-unit-files" ] ; then elif [ "${1}" == "list-unit-files" ] ; then
systemctl_units systemctl_units
# Mapeo del comando help # Mapping of the help command
elif [ "${1}" == "--help" ] ; then elif [ "${1}" == "--help" ] ; then
systemctl_help systemctl_help
elif [ "${1}" == "-h" ] ; then elif [ "${1}" == "-h" ] ; then
systemctl_help systemctl_help
# Mapeo del comando version # Mapping of the version command
elif [ "${1}" == "--version" ] ; then elif [ "${1}" == "--version" ] ; then
systemctl_version systemctl_version
# Mapeo del comando reboot # Mapping of the reboot command
elif [ "${1}" == "reboot" ] ; then elif [ "${1}" == "reboot" ] ; then
reboot reboot
# Mapeo del comando halt # Mapping of the halt command
elif [ "${1}" == "halt" ] ; then elif [ "${1}" == "halt" ] ; then
halt halt
# Mapeo del comando poweroff # Mapping of the poweroff command
elif [ "${1}" == "poweroff" ] ; then elif [ "${1}" == "poweroff" ] ; then
poweroff poweroff
else else
@ -152,7 +152,7 @@ function systemctl_map() {
fi fi
} }
# Iniciar el script # Start the script
check_dir_scripts check_dir_scripts
if [ -z "${1}" ] ; then if [ -z "${1}" ] ; then
systemctl_units systemctl_units