diff --git a/conf.d/service_10_main.conf.sh b/conf.d/service_10_main.conf.sh new file mode 100755 index 0000000..9ff940a --- /dev/null +++ b/conf.d/service_10_main.conf.sh @@ -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 + + + diff --git a/conf.d/service_20_tftp.conf.sh b/conf.d/service_20_tftp.conf.sh new file mode 100755 index 0000000..430088a --- /dev/null +++ b/conf.d/service_20_tftp.conf.sh @@ -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 diff --git a/conf.d/service_30_nfs.conf.sh b/conf.d/service_30_nfs.conf.sh new file mode 100755 index 0000000..e4dcb34 --- /dev/null +++ b/conf.d/service_30_nfs.conf.sh @@ -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 diff --git a/conf.d/service_40_smbd.conf.sh b/conf.d/service_40_smbd.conf.sh new file mode 100755 index 0000000..2b9d16d --- /dev/null +++ b/conf.d/service_40_smbd.conf.sh @@ -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 diff --git a/main.sh b/main.sh old mode 100644 new mode 100755 index e69de29..e7de013 --- a/main.sh +++ b/main.sh @@ -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 diff --git a/menues/pxelinux/config.sh b/menues/pxelinux/config.sh deleted file mode 100644 index e1482e4..0000000 --- a/menues/pxelinux/config.sh +++ /dev/null @@ -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 - - - diff --git a/menues/pxelinux/templates/header.cfg b/menues/pxelinux/templates/header.cfg deleted file mode 100644 index 9b75aaa..0000000 --- a/menues/pxelinux/templates/header.cfg +++ /dev/null @@ -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 diff --git a/resrc.d/service_nfs_exports.txt b/resrc.d/service_nfs_exports.txt new file mode 100644 index 0000000..26670ba --- /dev/null +++ b/resrc.d/service_nfs_exports.txt @@ -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) diff --git a/resrc.d/service_smb.conf.txt b/resrc.d/service_smb.conf.txt new file mode 100644 index 0000000..10f7a21 --- /dev/null +++ b/resrc.d/service_smb.conf.txt @@ -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 + diff --git a/settings.sh b/settings.sh index 08c5134..11310b7 100644 --- a/settings.sh +++ b/settings.sh @@ -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 + + + +} + + diff --git a/todo.md b/todo.md index a5a62fc..fb3f1d1 100644 --- a/todo.md +++ b/todo.md @@ -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