summaryrefslogtreecommitdiffstats
path: root/linhes/linhes-dev/LinHES9_iso/build_iso.sh
diff options
context:
space:
mode:
Diffstat (limited to 'linhes/linhes-dev/LinHES9_iso/build_iso.sh')
-rwxr-xr-xlinhes/linhes-dev/LinHES9_iso/build_iso.sh296
1 files changed, 296 insertions, 0 deletions
diff --git a/linhes/linhes-dev/LinHES9_iso/build_iso.sh b/linhes/linhes-dev/LinHES9_iso/build_iso.sh
new file mode 100755
index 0000000..51aba98
--- /dev/null
+++ b/linhes/linhes-dev/LinHES9_iso/build_iso.sh
@@ -0,0 +1,296 @@
+#!/bin/bash
+
+# Revision: 2022.06.15
+# (GNU/General Public License version 3.0)
+# by Cecil Watson for LinHES.
+# based on work by eznix (https://sourceforge.net/projects/ezarch/)
+
+# ----------------------------------------
+# Define Variables
+# ----------------------------------------
+
+LCLST="en_US"
+# Format is language_COUNTRY where language is lower case two letter code
+# and country is upper case two letter code, separated with an underscore
+
+KEYMP="us"
+# Use lower case two letter country code
+
+KEYMOD="pc105"
+# pc105 and pc104 are modern standards, all others need to be researched
+
+MYUSERNM="km"
+# use all lowercase letters only
+
+MYUSRPASSWD="mtv"
+# Pick a password of your choice
+
+RTPASSWD="roto"
+# Pick a root password
+
+MYHOSTNM="linhes"
+# Pick a hostname for the machine
+
+# ----------------------------------------
+# Functions
+# ----------------------------------------
+
+# Test for root user
+rootuser () {
+ if [[ "$EUID" = 0 ]]; then
+ continue
+ else
+ echo "Please Run As Root or sudo"
+ sleep 2
+ exit
+ fi
+}
+
+# Display line error
+handlerror () {
+clear
+set -uo pipefail
+trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR
+}
+
+# Clean up working directories
+cleanup () {
+[[ -d ./arch_skel ]] && rm -r ./arch_skel
+[[ -d ./work ]] && rm -r ./work
+sleep 2
+}
+
+# Requirements and preparation
+_isInstalled() {
+ package="$1";
+ check="$(sudo pacman -Qs --color always "${package}" | grep "local" | grep "${package} ")";
+ if [ -n "${check}" ] ; then
+ echo 0; #'0' means 'true' in Bash
+ return; #true
+ fi;
+ echo 1; #'1' means 'false' in Bash
+ return; #false
+}
+
+prereqs() {
+
+ # The packages that are not installed will be added to this array.
+ toInstall=();
+
+ for pkg; do
+ # If the package IS installed, skip it.
+ if [[ $(_isInstalled "${pkg}") == 0 ]]; then
+ echo "${pkg} is already installed.";
+ continue;
+ fi;
+
+ #Otherwise, add it to the list of packages to install.
+ toInstall+=("${pkg}");
+ done;
+
+ # If no packages were added to the "${toInstall[@]}" array,
+ # don't do anything and stop this function.
+ if [[ "${toInstall[@]}" == "" ]] ; then
+ echo "All packages are already installed.";
+ return;
+ fi;
+
+ # Otherwise, install all the packages that have been added to the "${toInstall[@]}" array.
+ printf "Packages not installed:\n%s\n" "${toInstall[@]}";
+ sudo pacman -S --needed --noconfirm "${toInstall[@]}";
+}
+
+# Copy Arch profile to working directory
+cp_releng () {
+cp -r /usr/share/archiso/configs/releng/ ./arch_skel
+rm -r ./arch_skel/efiboot
+rm -r ./arch_skel/syslinux
+}
+
+# Copy cust_repo to opt
+cp_repo () {
+if [ -d "./cust_repo" ]
+then
+ cp -r ./cust_repo /opt/repo
+fi
+}
+
+# Remove ezrepo from opt
+rm_repo () {
+if [ -d "/opt/repo" ]
+then
+ rm -r /opt/repo
+fi
+}
+
+# Delete automatic login
+nalogin () {
+rm -r ./arch_skel/airootfs/etc/systemd/system/getty@tty1.service.d
+}
+
+# Remove cloud-init, hyper-v, qemu-guest, vmtoolsd, sshd, systemd-networkd & iwd services
+rmunitsd () {
+rm ./arch_skel/airootfs/etc/systemd/system/multi-user.target.wants/hv_fcopy_daemon.service
+rm ./arch_skel/airootfs/etc/systemd/system/multi-user.target.wants/hv_kvp_daemon.service
+rm ./arch_skel/airootfs/etc/systemd/system/multi-user.target.wants/hv_vss_daemon.service
+rm ./arch_skel/airootfs/etc/systemd/system/multi-user.target.wants/qemu-guest-agent.service
+rm ./arch_skel/airootfs/etc/systemd/system/multi-user.target.wants/vmtoolsd.service
+rm ./arch_skel/airootfs/etc/systemd/system/multi-user.target.wants/vmware-vmblock-fuse.service
+rm ./arch_skel/airootfs/etc/systemd/system/multi-user.target.wants/sshd.service
+rm ./arch_skel/airootfs/etc/systemd/system/multi-user.target.wants/systemd-networkd.service
+rm ./arch_skel/airootfs/etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service
+rm ./arch_skel/airootfs/etc/systemd/system/sockets.target.wants/systemd-networkd.socket
+rm ./arch_skel/airootfs/etc/systemd/system/dbus-org.freedesktop.network1.service
+rm ./arch_skel/airootfs/etc/systemd/system/multi-user.target.wants/iwd.service
+rm -r ./arch_skel/airootfs/etc/systemd/system/cloud-init.target.wants
+}
+
+# Add Bluetooth, cups, haveged, NetworkManager, & sddm systemd links
+addnmlinks () {
+mkdir -p ./arch_skel/airootfs/etc/systemd/system/network-online.target.wants
+mkdir -p ./arch_skel/airootfs/etc/systemd/system/multi-user.target.wants
+mkdir -p ./arch_skel/airootfs/etc/systemd/system/bluetooth.target.wants
+mkdir -p ./arch_skel/airootfs/etc/systemd/system/printer.target.wants
+mkdir -p ./arch_skel/airootfs/etc/systemd/system/sockets.target.wants
+mkdir -p ./arch_skel/airootfs/etc/systemd/system/timers.target.wants
+mkdir -p ./arch_skel/airootfs/etc/systemd/system/sysinit.target.wants
+ln -sf /usr/lib/systemd/system/NetworkManager-wait-online.service ./arch_skel/airootfs/etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service
+ln -sf /usr/lib/systemd/system/NetworkManager-dispatcher.service ./arch_skel/airootfs/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service
+ln -sf /usr/lib/systemd/system/NetworkManager.service ./arch_skel/airootfs/etc/systemd/system/multi-user.target.wants/NetworkManager.service
+ln -sf /usr/lib/systemd/system/bluetooth.service ./arch_skel/airootfs/etc/systemd/system/bluetooth.target.wants/bluetooth.service
+ln -sf /usr/lib/systemd/system/haveged.service ./arch_skel/airootfs/etc/systemd/system/sysinit.target.wants/haveged.service
+ln -sf /usr/lib/systemd/system/cups.service ./arch_skel/airootfs/etc/systemd/system/printer.target.wants/cups.service
+ln -sf /usr/lib/systemd/system/cups.socket ./arch_skel/airootfs/etc/systemd/system/sockets.target.wants/cups.socket
+ln -sf /usr/lib/systemd/system/cups.path ./arch_skel/airootfs/etc/systemd/system/multi-user.target.wants/cups.path
+ln -sf /usr/lib/systemd/system/bluetooth.service ./arch_skel/airootfs/etc/systemd/system/dbus-org.bluez.service
+ln -sf /usr/lib/systemd/system/lightdm.service ./arch_skel/airootfs/etc/systemd/system/display-manager.service
+}
+
+# Copy files to customize the ISO
+cpmyfiles () {
+cp ./cust_skel/packages.x86_64 ./arch_skel/
+cp ./cust_skel/pacman.conf ./arch_skel/
+cp ./cust_skel/profiledef.sh ./arch_skel/
+cp -r ./cust_skel/grub ./arch_skel/
+cp -r ./cust_skel/efiboot ./arch_skel/
+cp -r ./cust_skel/syslinux ./arch_skel/
+cp -r ./cust_skel/airootfs ./arch_skel/
+}
+
+# Set hostname
+sethostname () {
+echo "${MYHOSTNM}" > ./arch_skel/airootfs/etc/hostname
+}
+
+# Create passwd file
+# Changed user to 1000 from 1010
+crtpasswd () {
+echo "root:x:0:0:root:/root:/usr/bin/bash
+"${MYUSERNM}":x:1000:1000::/home/"${MYUSERNM}":/bin/bash" > ./arch_skel/airootfs/etc/passwd
+}
+
+# Create group file
+# Changed user to 1000 from 1010
+crtgroup () {
+echo "root:x:0:root
+sys:x:3:"${MYUSERNM}"
+adm:x:4:"${MYUSERNM}"
+wheel:x:10:"${MYUSERNM}"
+log:x:19:"${MYUSERNM}"
+network:x:90:"${MYUSERNM}"
+floppy:x:94:"${MYUSERNM}"
+scanner:x:96:"${MYUSERNM}"
+power:x:98:"${MYUSERNM}"
+rfkill:x:850:"${MYUSERNM}"
+users:x:985:"${MYUSERNM}"
+video:x:860:"${MYUSERNM}"
+storage:x:870:"${MYUSERNM}"
+optical:x:880:"${MYUSERNM}"
+lp:x:840:"${MYUSERNM}"
+audio:x:890:"${MYUSERNM}"
+autologin:x:965:"${MYUSERNM}"
+"${MYUSERNM}":x:1000:" > ./arch_skel/airootfs/etc/group
+}
+
+# Create shadow file
+crtshadow () {
+usr_hash=$(openssl passwd -6 "${MYUSRPASSWD}")
+root_hash=$(openssl passwd -6 "${RTPASSWD}")
+echo "root:"${root_hash}":14871::::::
+"${MYUSERNM}":"${usr_hash}":14871::::::" > ./arch_skel/airootfs/etc/shadow
+}
+
+# create gshadow file
+crtgshadow () {
+echo "root:!*::root
+"${MYUSERNM}":!*::" > ./arch_skel/airootfs/etc/gshadow
+}
+
+# Set the keyboard layout
+setkeylayout () {
+echo "KEYMAP="${KEYMP}"" > ./arch_skel/airootfs/etc/vconsole.conf
+}
+
+# Create 00-keyboard.conf file
+crtkeyboard () {
+mkdir -p ./arch_skel/airootfs/etc/X11/xorg.conf.d
+echo "Section \"InputClass\"
+ Identifier \"system-keyboard\"
+ MatchIsKeyboard \"on\"
+ Option \"XkbLayout\" \""${KEYMP}"\"
+ Option \"XkbModel\" \""${KEYMOD}"\"
+EndSection" > ./arch_skel/airootfs/etc/X11/xorg.conf.d/00-keyboard.conf
+}
+
+# Fix 40-locale-gen.hook and create locale.conf
+crtlocalec () {
+sed -i "s/en_US/"${LCLST}"/g" ./arch_skel/airootfs/etc/pacman.d/hooks/40-locale-gen.hook
+echo "LANG="${LCLST}".UTF-8" > ./arch_skel/airootfs/etc/locale.conf
+}
+
+# Start mkarchiso
+runmkarchiso () {
+mkarchiso -v -w ./work -o ./out ./arch_skel
+}
+
+# ----------------------------------------
+# Run Functions
+# ----------------------------------------
+
+rootuser
+handlerror
+prereqs "archlinux-keyring" "archiso" "mkinitcpio-archiso"
+cleanup
+cp_releng
+addnmlinks
+cp_repo
+nalogin
+rmunitsd
+cpmyfiles
+sethostname
+crtpasswd
+crtgroup
+crtshadow
+crtgshadow
+setkeylayout
+crtkeyboard
+crtlocalec
+runmkarchiso
+rm_repo
+
+
+# Disclaimer:
+#
+# THIS SOFTWARE IS PROVIDED BY EZNIX “AS IS” AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL EZNIX BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# END
+#