There is already a beep, i knew it

#!/bin/bash
# ubuntu_preseed.sh

cat << ‘EOF’ > ubuntu_preseed.cfg
# Ubuntu Server Preseed Configuration

# Localization
d-i debian-installer/locale string en_US
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us
d-i keyboard-configuration/xkb-keymap select us

# Network configuration
d-i netcfg/choose_interface select auto
d-i netcfg/get_hostname string my-ubuntu-server
d-i netcfg/get_domain string example.com

# Set a predefined IP address
d-i netcfg/disable_autoconfig boolean true
d-i netcfg/get_ipaddress string 192.168.1.10
d-i netcfg/get_netmask string 255.255.255.0
d-i netcfg/get_gateway string 192.168.1.1
d-i netcfg/get_nameservers string 192.168.1.1
d-i netcfg/confirm_static boolean true

# Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string

# Clock and time zone
d-i clock-setup/utc boolean true
d-i time/zone string America/New_York

# Partitioning
d-i partman-auto/method string lvm
d-i partman-auto-lvm/guided_size string max
d-i partman-auto-lvm/new_vg_name string vg01
d-i partman-auto/expert_recipe string \
boot-root :: \
500 10000 1000000000 lvm \
$primary{ } $bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /boot } \
. \
500 10000 100% lvm \
$lvmok{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
.

# User account setup
d-i passwd/user-fullname string My User
d-i passwd/username string myuser
d-i passwd/user-password password insecure
d-i passwd/user-password-again password insecure

# Apt setup
tasksel tasksel/first multiselect standard
popularity-contest popularity-contest/participate boolean false

# Additional Automation Tasks (Note: These commands will run during installation)
d-i preseed/late_command string \
in-target apt-get update; \
in-target apt-get upgrade -y; \
in-target apt-get install -y jenkins shfmt bats shellcheck pandoc; \
in-target echo “Additional automation tasks completed.” > /root/installation_done

EOF

# Start the installation with the preseed configuration
sudo cp ubuntu_preseed.cfg /var/www/html/preseed.cfg
sudo apt-get install -y apache2
sudo systemctl enable apache2
sudo systemctl start apache2

# Replace <UBUNTU_ISO_PATH> with the path to your Ubuntu Server ISO
sudo mkdir -p /mnt/iso
sudo mount -o loop <UBUNTU_ISO_PATH> /mnt/iso
sudo cp -r /mnt/iso/* /var/www/html/

# Adjust the IP address accordingly
sudo sed -i ‘s/10.0.2.2/your_server_ip/’ /var/www/html/ubuntu_preseed.cfg

# Access the preseed file via a web server
sudo apt-get install -y apache2
sudo systemctl enable apache2
sudo systemctl start apache2

# Create a symlink for easier access
sudo ln -s /var/www/html/ubuntu_preseed.cfg /var/www/html/preseed.cfg

# Verify that the preseed file is accessible
curl http://your_server_ip/preseed.cfg

#!/bin/bash
# preseed.sh

# … (your existing preseed configuration)

# Add the script for generating the man page
echo -e “\n# Script for generating man page” >> preseed.cfg
echo ‘#!/bin/bash’ >> preseed.cfg
echo ‘cat << “EOF” > /usr/local/share/man/man1/custom_scripts.1’ >> preseed.cfg
echo ‘.TH CUSTOM_SCRIPTS 1 “January 2024” “Version 1.0” “User Commands”‘ >> preseed.cfg
echo ‘.SH NAME’ >> preseed.cfg
echo ‘custom_scripts \- Collection of custom automation scripts’ >> preseed.cfg
echo ‘.SH SYNOPSIS’ >> preseed.cfg
echo ‘.B custom_scripts’ >> preseed.cfg
echo ‘[\fIOPTION\fR]’ >> preseed.cfg
echo ‘.SH DESCRIPTION’ >> preseed.cfg
echo ‘This manual page documents the custom_scripts command, which is a collection of custom automation scripts installed on the system during Ubuntu Server installation.’ >> preseed.cfg
echo ‘.P’ >> preseed.cfg
echo ‘The available scripts and their functions are:’ >> preseed.cfg
echo ‘.PP’ >> preseed.cfg
echo ‘.TP’ >> preseed.cfg
echo ‘.B jenkins’ >> preseed.cfg
echo ‘.RS’ >> preseed.cfg
echo ‘Installs Jenkins for Continuous Integration (CI).’ >> preseed.cfg
echo ‘.RE’ >> preseed.cfg
echo ‘.TP’ >> preseed.cfg
echo ‘.B git_hooks’ >> preseed.cfg
echo ‘.RS’ >> preseed.cfg
echo ‘Configures version control hooks for Git.’ >> preseed.cfg
echo ‘.RE’ >> preseed.cfg
echo ‘.TP’ >> preseed.cfg
echo ‘.B shfmt’ >> preseed.cfg
echo ‘.RS’ >> preseed.cfg
echo ‘Installs and sets up the shfmt code formatter.’ >> preseed.cfg
echo ‘.RE’ >> preseed.cfg
echo ‘.TP’ >> preseed.cfg
echo ‘.B bats’ >> preseed.cfg
echo ‘.RS’ >> preseed.cfg
echo ‘Installs and sets up the Bats testing framework.’ >> preseed.cfg
echo ‘.RE’ >> preseed.cfg
echo ‘.TP’ >> preseed.cfg
echo ‘.B shellcheck’ >> preseed.cfg
echo ‘.RS’ >> preseed.cfg
echo ‘Installs and sets up the ShellCheck code analyzer.’ >> preseed.cfg
echo ‘.RE’ >> preseed.cfg
echo ‘.TP’ >> preseed.cfg
echo ‘.B pandoc’ >> preseed.cfg
echo ‘.RS’ >> preseed.cfg
echo ‘Installs Pandoc for documentation generation.’ >> preseed.cfg
echo ‘.RE’ >> preseed.cfg
echo ‘.PP’ >> preseed.cfg
echo ‘.SH OPTIONS’ >> preseed.cfg
echo ‘.TP’ >> preseed.cfg
echo ‘.B \-h, \-\-help’ >> preseed.cfg
echo ‘Display this help message.’ >> preseed.cfg
echo ‘.SH SEE ALSO’ >> preseed.cfg
echo ‘The full documentation for \fBcustom_scripts\fR is available online at:’ >> preseed.cfg
echo ‘.PP’ >> preseed.cfg
echo ‘https://example.com/custom_scripts’ >> preseed.cfg
echo ‘.SH AUTHOR’ >> preseed.cfg
echo ‘Your Name’ >> preseed.cfg
echo ‘EOF**⬤**


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *