new approach

This commit is contained in:
root 2023-04-18 13:41:50 +02:00
parent 002116e26a
commit 7fd9ca7edd
11 changed files with 242 additions and 36 deletions

25
conf.d/service_10_main.conf.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
. ./settings.sh
#
# Main Service
#
S_ENABLED=YES
S_NAME="none"
S_PACKAGES="git sudo p7zip p7zip-full ipxe pxelinux syslinux syslinux-common"
# handle services
fservice $S_ENABLED $1 $S_NAME "$S_PACKAGES"
case $1 in
init)
;;
esac

21
conf.d/service_20_tftp.conf.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
. ./settings.sh
#
# Service configuration
#
S_ENABLED=YES
S_NAME="tftpd-hpa"
S_PACKAGES="tftpd-hpa"
fservice $S_ENABLED $1 $S_NAME $S_PACKAGES
case $1 in
init)
;;
esac

23
conf.d/service_30_nfs.conf.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
. ./settings.sh
#
# Service configuration
#
S_ENABLED=YES
S_NAME="nfs-kernel-server"
S_PACKAGES="nfs-kernel-server nfs-common"
fservice $S_ENABLED $1 $S_NAME $S_PACKAGES
case $1 in
init)
echo " create /etc/exports..."
cat ${D_ROOTDIR}/resrc.d/service_nfs_exports.txt | sed "s#__D_TFTP__#$D_TFTP#g" > /etc/exports
;;
esac

23
conf.d/service_40_smbd.conf.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
. ./settings.sh
#
# Service configuration
#
S_ENABLED=yes
S_NAME="smbd"
S_PACKAGES="samba"
fservice $S_ENABLED $1 $S_NAME $S_PACKAGES
case $1 in
init)
echo " create smb.conf ..."
cat ${D_ROOTDIR}/resrc.d/service_smb.conf.txt | sed "s#__D_TFTP__#$D_TFTP#g" > /etc/samba/smb.conf
;;
esac

53
main.sh Normal file → Executable file
View File

@ -0,0 +1,53 @@
#!/bin/sh
. ./settings.sh
case $1 in
# process services
services)
# find services:
SLIST=$(ls ./conf.d/service_*.conf.sh )
# process command
case $2 in
init)
echo "--------------------------------------------------"
echo "service init..."
echo "--------------------------------------------------"
for ITEM in ${SLIST};
do
$ITEM init
done
;;
start)
echo "--------------------------------------------------"
echo "service start..."
echo "--------------------------------------------------"
for ITEM in ${SLIST};
do
$ITEM start
done
;;
stop)
echo "--------------------------------------------------"
echo "service stop..."
echo "--------------------------------------------------"
for ITEM in ${SLIST};
do
$ITEM stop
done
;;
restart)
echo "--------------------------------------------------"
echo "service restart..."
echo "--------------------------------------------------"
for ITEM in ${SLIST};
do
$ITEM restart
done
;;
esac
;;
esac

View File

@ -1,19 +0,0 @@
#!/bin/sh
# source global variables
. ../../settings.sh
#
# Main Settings for this Plugin
#
P_NAME=Default pxelinux Menua
P_TYPE=menue
M_PATH=bios
M_TITLE=Default Boot Menue
M_BACKGROUND=splash.png

View File

@ -1,13 +0,0 @@
#
# Menue Header
#
rootprompt 0
PATH __M_PATH__
default __M_PATH__/vesamenu.c32
TIMEOUT 300
MENU TITLE __M_TITLE__
MENU BACKGROUND __M_BACKGROUND__
MENU ROWS 15
MENU TABMSGROW 20
MENU TIMEOUTROW 22

View File

@ -0,0 +1,11 @@
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
__D_TFTP__ *(ro,nohide,no_root_squash,no_subtree_check,insecure)

View File

@ -0,0 +1,19 @@
[global]
workgroup = PXE
map to guest = bad user
usershare allow guests = yes
[tftp]
browsable = true
read only = false
guest ok = yes
force user = root
path = __D_TFTP__
[rootdir]
browsable = true
read only = false
guest ok = yes
force user = root
path = /root

View File

@ -14,7 +14,48 @@ D_ROOTDIR=/root/pxe-bootserver
HOST_IP=192.168.75.3
HOST_FQDN=tftp.ostrach.tld
# directories
D_MENUES=${D_ROOTDIR}/menues
D_SERVICES=${D_ROOTDIR}/services
D_PLUGINS=${D_ROOTDIR}/plugins
#
# Functions
#
fservice (){
# $1 is enabled yes/no
# $2 is the command
# $3 is the program name
# $4 is a list of packages
if [ "$1" = "yes" ] || [ "$1" = "YES" ]; then
echo "touching $3 :"
case $2 in
# INIT
# Install needed Debian Packages:
init)
echo "installing: $4"
apt install -y $4
;;
start)
if ! [ "$3" = "none" ]; then
systemctl start $3
fi
;;
stop)
if ! [ "$3" = "none" ]; then
systemctl stop $3
fi
;;
restart)
if ! [ "$3" = "none" ]; then
systemctl restart $3
fi
;;
esac
else
echo "$3 is disabled. nothing to do..."
fi
}

22
todo.md
View File

@ -70,6 +70,7 @@
* create menu sections: (maybe a kind of hook for plugin-types?)
* put plugins into sections
* types: livesystem, rescue, tools, installer, etc.
* priority: sort stanzas
### ./plugins
* plugin contains all needed files
@ -82,7 +83,28 @@
* depends: nfs, samba, etc.
* plugin specific variables and settings
# Central config file approach
a main script with a conf.d/ directory. config files are sorted by numbers
and special names: menu_20_pxelinux.conf, service_10_nfs.conf, plugin_30_knoppix.conf
each .conf file contains the needed variables
the main script can select files by name (menu,service,plugin) and sort them by number
for the desired lineup.
menu* files build the menu and processes all plugin* files to fill the menu
### File structure
* main.sh
* ./conf.d/
* menu_10_default.conf
* service_10_tftp.conf
* plugin_10_knoppix.conf
* plugin_20_rescuezilla.conf
### menu*.conf
* find all enabled plugins and read them in a sorted array