You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
2.0 KiB

#!/bin/bash
#
# https://codeberg.org/angestoepselt/LinuxPXE/
# created by angestoepselt e.V.
# October 2020
## root check
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
read -p " Drop your ip adress for your Printer like (10.10.10.100): " PRINTER_IP
read -p " Drop your ip adress for your Repo like (10.10.10.100) ##the port 3142 is already set## " REPOSERVER_IP
read -p " Please enter your snipeIT API key (the key is very long): " apiKey
PXESERVER_IP=$(hostname -I | awk '{print $1}')
tftproot=/srv/tftp
echo "changing ip address in the default pxelinux.cfg to $PXESERVER_IP"
## modify pxelinux.cfg/default
sed -i -e 's/<PXESERVER_IP>/'"${PXESERVER_IP}"'/g' $tftproot/legacy/pxelinux.cfg/default
# modify preseed files
sed -i -e 's/<PXESERVER_IP>/'"${PXESERVER_IP}"'/g' $tftproot/legacy/images/ubuntu.preseed
sed -i -e 's/<PXESERVER_IP>/'"${PXESERVER_IP}"'/g' $tftproot/legacy/images/lubuntu.preseed
sed -i -e 's/<REPOSERVER_IP>/'"${REPOSERVER_IP}"'/g' $tftproot/legacy/images/ubuntu.preseed
sed -i -e 's/<REPOSERVER_IP>/'"${REPOSERVER_IP}"'/g' $tftproot/legacy/images/lubuntu.preseed
# modify post_hardware.sh
sed -i -e 's/<PRINTER_IP>/'"${PRINTER_IP}"'/g' $tftproot/post_hardware.sh
sed -i -e 's/<PXESERVER_IP>/'"${PXESERVER_IP}"'/g' $tftproot/post_hardware.sh
# modify late_late_command.sh
sed -i -e 's/<PRINTER_IP>/'"${PXESERVER_IP}"'/g' $tftproot/late_command.sh
# modify late_late_command.s.sh
sed -i -e 's/<PRINTER_IP>/'"${PXESERVER_IP}"'/g' /srv/tftp/late_command.sh
# modify .api_key
sed -i -e 's/<API_KEY>/'"${apiKey}"'/g' $tftproot/legacy/.api_key
# modify label_print.sh
sed -i -e 's/<PRINTER_IP>/'"${PRINTER_IP}"'/g' $tftproot/label_print.sh
sed -i -e 's/<PXESERVER_IP>/'"${PXESERVER_IP}"'/g' $tftproot/label_print.sh
echo '###############################################'
echo '## new PXE Server IP: '"${PXESERVER_IP}"' ##'
echo '## new PRINTER IP: '"${PRINTER_IP}"' ##'
echo '## new REPO Server IP: '"${REPOSERVER_IP}"' ##'
echo '###############################################'