# Pitt CS Kickstart file for AlmaLinux 9 on aster18.cs.pitt.edu

#version=RHEL9
# Partition clearing information
clearpart --all --initlabel
# Disk partitions and logical volumes
part /boot/efi --fstype=vfat --size=640
part /boot --fstype=xfs --size=1074
part pv.sda --grow --size=1
volgroup vg_cen9 --pesize=4096 pv.sda
logvol / --fstype=ext4 --name=lv_root --vgname=vg_cen9 --size=1024 --maxsize=51200
logvol /usr --fstype=ext4 --name=lv_usr --vgname=vg_cen9 --size=24576
logvol /tmp --fstype=ext4 --name=lv_tmp --vgname=vg_cen9 --size=16384
logvol /var --fstype=ext4 --name=lv_var --vgname=vg_cen9 --size=32768
logvol /opt --fstype=ext4 --name=lv_opt --vgname=vg_cen9 --size=16384
logvol /home --fstype=ext4 --name=lv_home --vgname=vg_cen9 --size=524288
logvol swap --name=lv_swap --vgname=vg_cen9 --size=32768
# Authentication
authselect select winbind with-mkhomedir
# Turn off security-enhanced Linux
selinux --disabled
# Boot loader
bootloader --location=mbr --append="crashkernel=auto rhgb quiet consoleblank=0"

# Use graphical install
#graphical
# Use text install
text
##repo --name="BaseOS" --baseurl=http://mirror-int.cs.pitt.edu/almalinux/9/BaseOS/x86_64/kickstart/ --cost=100
##repo --name="AppStream" --baseurl=http://mirror-int.cs.pitt.edu/almalinux/9/AppStream/x86_64/kickstart/
# Use our mirror for installation
##url --url=http://mirror-int.cs.pitt.edu/almalinux/9/BaseOS/x86_64/kickstart
# Keyboard layouts
keyboard --xlayouts='us'
# System language
lang en_US.UTF-8
# Network information
network --bootproto static --device=eno8303 --ip=10.27.1.27 --netmask=255.255.255.0 --gateway=10.27.1.1 --nameserver=10.10.10.10,10.10.20.10 --noipv6 --onboot=on --activate
network --bootproto static --device=ens1f0 --ip=192.168.53.27 --netmask=255.255.255.0 --onboot=on --activate
network --bootproto static --device=ens1f1 --ip=192.168.54.27 --netmask=255.255.255.0 --onboot=on --activate
network --hostname=aster18.cs.pitt.edu
# Root password
rootpw --iscrypted $6$bXw3FW8Ly0b6J.V9$oceMRKq950IpKhhTP8QW5xn9PD1ILk8z5rhKPmOk.gB8OinGR2HAhtA8ynlVVQ6/gRdEECwxEU.hpolvXaant1
# X Window System configuration information
#xconfig --startxonboot
# Disable the initial setup after first boot
firstboot --disabled
# Disable EULA prompt after first boot
eula --agreed
# System services
services --enabled="chronyd"
# System timezone
timezone America/New_York




%packages
%end
#%pre
#DISKS="/dev/sda"
#for DISK in ${DISKS}; do
#    parted -s ${DISK} print 2>&1 |grep "unrecognised disk label" > /dev/null
#    if [ $? -eq 0 ]; then
#        parted -s ${DISK} mklabel gpt
#    fi
#done
#%end
%post
( yum-config-manager --enable crb
  wget -O /tmp/epel-release-9-9.el9.noarch.rpm https://dl.fedoraproject.org/pub/epel/9/Everything/x86_64/Packages/e/epel-release-9-9.el9.noarch.rpm
  yum -y install /tmp/epel-release-9-9.el9.noarch.rpm
  yum -y install conda dkms htop imake iperf kstart picosat-libs python3-conda python3-conda-package-handling python3-cpuinfo python3-cytoolz python3-frozendict python3-pyOpenSSL python3-pycosat python3-toolz python3-tqdm qt5-qtwebkit qt5-qtwebkit-devel tofrodos
  yum makecache
  yum -y install swig
  mv /etc/hosts /etc/hosts.orig
  cat > /etc/hosts << \EOFEOF
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.53.10    aster1-10gb-a
192.168.53.11    aster2-10gb-a
192.168.53.12    aster3-10gb-a
192.168.53.13    aster4-10gb-a
192.168.53.14    aster5-10gb-a
192.168.53.15    aster6-10gb-a
192.168.53.16    aster7-10gb-a
192.168.53.17    aster8-10gb-a
192.168.53.18    aster9-10gb-a
192.168.53.19    aster10-10gb-a
192.168.53.20    aster11-10gb-a
192.168.53.21    aster12-10gb-a
192.168.53.22    aster13-10gb-a
192.168.53.23    aster14-10gb-a
192.168.53.24    aster15-10gb-a
192.168.53.25    aster16-10gb-a
192.168.53.26    aster17-10gb-a
192.168.53.27    aster18-10gb-a
192.168.53.28    aster19-10gb-a
192.168.53.29    aster20-10gb-a

192.168.54.10    aster1-10gb-b
192.168.54.11    aster2-10gb-b
192.168.54.12    aster3-10gb-b
192.168.54.13    aster4-10gb-b
192.168.54.14    aster5-10gb-b
192.168.54.15    aster6-10gb-b
192.168.54.16    aster7-10gb-b
192.168.54.17    aster8-10gb-b
192.168.54.18    aster9-10gb-b
192.168.54.19    aster10-10gb-b
192.168.54.20    aster11-10gb-b
192.168.54.21    aster12-10gb-b
192.168.54.22    aster13-10gb-b
192.168.54.23    aster14-10gb-b
192.168.54.24    aster15-10gb-b
192.168.54.25    aster16-10gb-b
192.168.54.26    aster17-10gb-b
192.168.54.27    aster18-10gb-b
192.168.54.28    aster19-10gb-b
192.168.54.29    aster20-10gb-b
EOFEOF

  echo "babay        ALL=(ALL)       ALL" > /etc/sudoers.d/babay
  cat > /etc/sudoers.d/students << \EOFEOF
hun13        ALL=(ALL)       ALL
ara128       ALL=(ALL)       ALL
sahiti       ALL=(ALL)       ALL
EOFEOF
  cat > /etc/sudoers.d/techstaff << \EOFEOF
hoffman    ALL=(ALL)       ALL
n3cvl      ALL=(ALL)       ALL
mad371     ALL=(ALL)       ALL
barbosa    ALL=(ALL)       ALL
mas        ALL=(ALL)       ALL
mittens    ALL=(ALL)       ALL
schivins   ALL=(ALL)       ALL
ahobaugh   ALL=(ALL)       ALL
ach54      ALL=(ALL)       ALL
EOFEOF
  chmod 440 /etc/sudoers.d/babay /etc/sudoers.d/students /etc/sudoers.d/techstaff

mv /etc/security/pam_winbind.conf /etc/security/pam_winbind.conf.orig
sed -e "s/^;krb5_auth =.*/krb5_auth = yes/" -e "s/^;krb5_ccache_type =.*/krb5_ccache_type = FILE:\/tmp\/krb5cc_%u/" /etc/security/pam_winbind.conf.orig > /etc/security/pam_winbind.conf

mv /etc/samba/smb.conf /etc/samba/smb.conf.orig
  cat > /etc/samba/smb.conf << \EOFEOF
[global]
   workgroup = PITT
   server string = %h server (Samba, Ubuntu)
   log file = /var/log/samba/log.%m
   max log size = 1000
   logging = file
   panic action = /usr/share/samba/panic-action %d
   server role = auto
   security = ads
   realm = UNIV.PITT.EDU
   password server = pitt-proddc-01.cssd.pitt.edu
   template homedir = /home/%U
EOFEOF
echo "   netbios name =  CS-ASTER18" >> /etc/samba/smb.conf
  cat >> /etc/samba/smb.conf << \EOFEOF
# Parameters suggested by CSSD
   idmap uid = 16777216-33554431
   idmap gid = 16777216-33554431
   template shell = /bin/bash
   winbind use default domain = true
   winbind offline logon = false
   winbind nested groups = yes
   encrypt passwords = yes
   kerberos encryption types = all
   require strong key = yes
   allow nt4 crypto = yes
EOFEOF
  cat >> /etc/yum.repos.d/SCI.repo << \EOFEOF
[sci]
name=SCI packages for AlmaLinux 9 - $basearch
baseurl=http://install.cs.pitt.edu/alma9/$basearch
enabled=1
EOFEOF
mv /etc/krb5.conf /etc/krb5.conf.orig
  cat > /etc/krb5.conf << \EOFEOF
# To opt out of the system crypto-policies configuration of krb5, remove the
# symlink at /etc/krb5.conf.d/crypto-policies which will not be recreated.
includedir /etc/krb5.conf.d/

[logging]
    default = FILE:/var/log/krb5libs.log
    kdc = FILE:/var/log/krb5kdc.log
    admin_server = FILE:/var/log/kadmind.log

[libdefaults]
    dns_lookup_realm = false
    dns_lookup_kdc = false
    ticket_lifetime = 25h
    renew_lifetime = 8d
    clockskew = 300
    forwardable = true
    rdns = false
    pkinit_anchors = FILE:/etc/pki/tls/certs/ca-bundle.crt
    spake_preauth_groups = edwards25519
    dns_canonicalize_hostname = fallback
    qualify_shortname = ""
    default_realm = UNIV.PITT.EDU
    default_ccache_name = KEYRING:persistent:%{uid}

[realms]
    UNIV.PITT.EDU = {
     kdc = pitt-proddc-01.cssd.pitt.edu
     kdc = pitt-proddc-02.cssd.pitt.edu
     kdc = pitt-proddc-03.cssd.pitt.edu
     kdc = pitt-proddc-04.cssd.pitt.edu
     kdc = pitt-proddc-05.cssd.pitt.edu
     admin_server = pitt-proddc-01.cssd.pitt.edu
     default_domain = univ.pitt.edu
    }

[domain_realm]
    .univ.pitt.edu = UNIV.PITT.EDU
    univ.pitt.edu = UNIV.PITT.EDU

[appdefaults]
    pam = {
     ticket_lifetime = 25h
     renew_lifetime = 8d
     forwardable = true
     debug = false
     ignore_afs = true
     retain_after_close = false
    }
EOFEOF
  systemctl enable smb.service
  systemctl enable winbind.service
  systemctl enable oddjobd.service

# Build the post-install shell script
cat > /root/run-after-reboot.sh << \EOFEOF
net ads join -U n3cvl
systemctl start winbind.service
wget -O /tmp/install_openafs.sh http://install.cs.pitt.edu/alma9/install_openafs.sh
sh /tmp/install_openafs.sh
wget -O /tmp/install_defender.sh http://install.cs.pitt.edu/pittit/install_defender.sh
sh /tmp/install_defender.sh
wget -O /tmp/install_cribl.sh http://install.cs.pitt.edu/pittit/install_cribl.sh
sh /tmp/install_cribl.sh
wget -O /tmp/install_netcool.sh http://install.cs.pitt.edu/pittit/install_netcool.sh
sh /tmp/install_netcool.sh
EOFEOF
  sync
) 1>/root/post_install.log 2>&1
echo "After rebooting, run /root/run-after-reboot.sh"
%end

%addon com_redhat_kdump --enable --reserve-mb='auto'

%end
