From 6bd6f4bbdbe84b579479cd9e486bf8bcda9c05ef Mon Sep 17 00:00:00 2001 From: t3chn0m4g3 Date: Fri, 28 Nov 2014 18:02:20 +0100 Subject: [PATCH] Init --- installer/install1.sh | 14 ++ installer/install2.sh | 261 +++++++++++++++++++++++++ installer/install2.sh.backup | 357 +++++++++++++++++++++++++++++++++++ isolinux/txt.cfg | 5 + kickstart/ks.cfg | 41 ++++ makeiso.sh | 71 +++++++ preseed/tpotce.seed | 82 ++++++++ 7 files changed, 831 insertions(+) create mode 100755 installer/install1.sh create mode 100755 installer/install2.sh create mode 100755 installer/install2.sh.backup create mode 100755 isolinux/txt.cfg create mode 100644 kickstart/ks.cfg create mode 100755 makeiso.sh create mode 100755 preseed/tpotce.seed diff --git a/installer/install1.sh b/installer/install1.sh new file mode 100755 index 00000000..d9ff95f8 --- /dev/null +++ b/installer/install1.sh @@ -0,0 +1,14 @@ +#!/bin/bash +############################################################# +# T-Pot Community Edition - disable splash boot permanently # +# Ubuntu server 14.04, x64 # +# # +# v0.04 by mo, 2014-11-28 # +############################################################# + +# Let's comment out the "quiet splash" options and update grub +sed -i.bak 's#GRUB_CMDLINE_LINUX_DEFAULT#\#GRUB_CMDLINE_LINUX_DEFAULT#' /etc/default/grub +update-grub + +# Let's move the install script to rc.local and reboot +mv /root/install.sh /etc/rc.local && sleep 2 && reboot diff --git a/installer/install2.sh b/installer/install2.sh new file mode 100755 index 00000000..7202e6ae --- /dev/null +++ b/installer/install2.sh @@ -0,0 +1,261 @@ +#!/bin/bash +######################################################## +# T-Pot Community Edition post install script # +# Ubuntu server 14.04, x64 # +# # +# v0.15 by mo, DTAG, 2014-11-28 # +######################################################## + +# Let's make sure there is a warning if running for a second time +if [ -f install.log ]; + then fuECHO "### Running more than once may complicate things. Erase install.log if you are really sure." + exit 1; +fi + +# Let's log for the beauty of it +set -e +exec 2> >(tee "install.err") +exec > >(tee "install.log") + +# Let's create a function for colorful output +fuECHO () { + local myRED=1 + local myWHT=7 + tput setaf $myRED + echo $1 "$2" + tput setaf $myWHT +} + +# Let's modify the sources list +sed -i '/cdrom/d' /etc/apt/sources.list + +# Let's add the docker repository +fuECHO "### Adding docker repository." +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 +tee /etc/apt/sources.list.d/docker.list < /data/puppet/name.conf + +# Let's patch sshd_config +fuECHO "### Patching sshd_config to listen on port 64295 and deny password authentication." +sed -i 's#Port 22#Port 64295#' /etc/ssh/sshd_config +sed -i 's#\#PasswordAuthentication yes#PasswordAuthentication no#' /etc/ssh/sshd_config + +# Disable ssh service +mv /etc/init/ssh.conf /etc/init/ssh.conf.disable + +# Let's add the ssh keys +#fuECHO "### Adding ssh keys for the admin user." +#mkdir -p /home/admin/.ssh/ +#tee /home/admin/.ssh/authorized_keys < /etc/rc.local.new +echo "# Let's add the first local ip to the /etc/issue file" >> /etc/rc.local.new +echo 'sed -i "s#IP:.*#IP: ""$(hostname -I | awk '"'"'{ print $1 }'"'"')""#" /etc/issue' >> /etc/rc.local.new +echo "exit 0" >> /etc/rc.local.new +chmod +x /etc/rc.local.new + +# Final steps +fuECHO "### Thanks for your patience. Now rebooting." +mv /etc/rc.local.new /etc/rc.local && chage -d 0 tsec && sleep 2 && reboot diff --git a/installer/install2.sh.backup b/installer/install2.sh.backup new file mode 100755 index 00000000..a76e5be1 --- /dev/null +++ b/installer/install2.sh.backup @@ -0,0 +1,357 @@ +#!/bin/bash +######################################################## +# Beehive post install script # +# Ubuntu server 14.04, x64 # +# # +# v0.12 by MO, DTAG, 2014-11-07 # +######################################################## + +# Let's make sure there is a warning if running for a second time +if [ -f install.log ]; + then fuECHO "### Running more than once may complicate things. Erase install.log if you are really sure." + exit 1; +fi + +# Let's log for the beauty of it +set -e +exec 2> >(tee "install.err") +exec > >(tee "install.log") + +# Let's create a function for colorful output +fuECHO () { + local myRED=1 + local myWHT=7 + tput setaf $myRED + echo $1 "$2" + tput setaf $myWHT +} + +# Let's modify the sources list +sed -i '/cdrom/d' /etc/apt/sources.list + +# Let's add the docker repository +fuECHO "### Adding docker repository." +apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 +tee /etc/apt/sources.list.d/docker.list < /data/puppet/name.conf + +# Let's modify the ownership / access rights +chmod 760 -R /data +chown bee:bee -R /data + +# Let's patch sshd_config +fuECHO "### Patching sshd_config to listen on port 64295 and deny password authentication." +sed -i 's#Port 22#Port 64295#' /etc/ssh/sshd_config +sed -i 's#\#PasswordAuthentication yes#PasswordAuthentication no#' /etc/ssh/sshd_config + +# Let's add the ssh keys +fuECHO "### Adding ssh keys for the hive user." +mkdir -p /home/hive/.ssh/ +tee /home/hive/.ssh/authorized_keys < /etc/rc.local.new +echo "# Let's add the first local ip to the /etc/issue file" >> /etc/rc.local.new +echo 'sed -i "s#IP:.*#IP: ""$(hostname -I | awk '"'"'{ print $1 }'"'"')""#" /etc/issue' >> /etc/rc.local.new +echo "exit 0" >> /etc/rc.local.new +chmod +x /etc/rc.local.new + +# Final steps +fuECHO "### Thanks for your patience. Now rebooting." +mv /etc/rc.local.new /etc/rc.local && sleep 2 && reboot diff --git a/isolinux/txt.cfg b/isolinux/txt.cfg new file mode 100755 index 00000000..08226794 --- /dev/null +++ b/isolinux/txt.cfg @@ -0,0 +1,5 @@ +default install +label install + menu label ^Install T-Pot Community Edition + kernel /install/vmlinuz + append file=/cdrom/tpotce/tpotce.seed initrd=/install/initrd.gz ks=cdrom:/tpotce/ks.cfg debian-installer/locale=en_US console-setup/ask_detect=false keyboard-configuration/layoutcode=de -- diff --git a/kickstart/ks.cfg b/kickstart/ks.cfg new file mode 100644 index 00000000..54a93810 --- /dev/null +++ b/kickstart/ks.cfg @@ -0,0 +1,41 @@ +#Generated by Kickstart Configurator +#platform=AMD64 or Intel EM64T + +#System language +lang en_US +#Language modules to install +langsupport en_US +#System keyboard +keyboard de +#System mouse +mouse +#System timezone +timezone Europe/Berlin +#Root password +rootpw --disabled +#Initial user +user tsec --fullname "tsec" --iscrypted --password $1$jAw1TW8v$a2WFamxQJfpPYZmn4qJT71 +#Reboot after installation +reboot +#Use text mode install +text +#Install OS instead of upgrade +install +#Use CDROM installation media +cdrom +#System bootloader configuration +bootloader --location=mbr +#Clear the Master Boot Record +zerombr yes +#Partition clearing information +clearpart --all --initlabel +#Disk partitioning information +part swap --recommended +part /data --fstype ext4 --size 8192 +part / --fstype ext4 --size 1 --grow +#System authorization infomation +auth --useshadow --enablemd5 +#Firewall configuration +firewall --disabled +#Do not configure the X Window System +skipx diff --git a/makeiso.sh b/makeiso.sh new file mode 100755 index 00000000..8fd86eb4 --- /dev/null +++ b/makeiso.sh @@ -0,0 +1,71 @@ +#!/bin/bash +######################################################## +# .iso maker for tpotce # +# # +# # +# v0.01 by mo, 2014-11-28 # +######################################################## + +# Let's define some global vars +myUBUNTULINK="http://de.releases.ubuntu.com/14.04.1/ubuntu-14.04.1-server-amd64.iso" +myUBUNTUISO="ubuntu-14.04.1-server-amd64.iso" +myTPOTCEISO="tpotce.iso" +myTPOTCEDIR="tpotceiso" +myTMP="tmp" + +# Let's create a function for colorful output +fuECHO () { + local myRED=1 + local myWHT=7 + tput setaf $myRED + echo $1 "$2" + tput setaf $myWHT +} + +# Let's install all the packages we need +fuECHO "### Installing packages." +apt-get install mkisofs isolinux -y + +# Let's get Ubuntu 14.04.1 as .iso +fuECHO "### Downloading Ubuntu 14.04.1." +if [ ! -f $myUBUNTUFILE ] + then wget $myUBUNTULINK; + else fuECHO "### Found it locally." +fi + +# Let's loop mount it and copy all contents +fuECHO "### Mounting .iso and copying all contents." +mkdir -p $myTMP $myTPOTCEDIR +losetup /dev/loop0 $myUBUNTUISO +mount /dev/loop0 $myTMP +cp -rT $myTMP $myTPOTCEDIR +chmod 777 -R $myTPOTCEDIR +umount $myTMP +losetup -d /dev/loop0 + +# Let's add the files for the automated install +fuECHO "### Adding the automated install files." +mkdir -p $myTPOTCEDIR/tpotce +cp installer/* $myTPOTCEDIR/tpotce/ +cp isolinux/* $myTPOTCEDIR/isolinux/ +cp kickstart/* $myTPOTCEDIR/tpotce/ +cp preseed/* $myTPOTCEDIR/tpotce/ +chmod 777 -R $myTPOTCEDIR + +# Let's create the new .iso +fuECHO "### Now creating the .iso." +cd $myTPOTCEDIR +mkisofs -D -r -V "T-Pot CE" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../$myTPOTCEISO ../$myTPOTCEDIR +cd .. +isohybrid $myTPOTCEISO + +# Let's clean up +fuECHO "### Cleaning up." +rm -rf $myTMP $myTPOTCEDIR + +# Done. +fuECHO "### Done." +fuECHO "### Install to usb stick" +fuECHO "###### Show devices: df" +fuECHO "###### Write to device: dd bs=1M if="$myTPOTCEISO" of=/dev/sdb" +exit 0 diff --git a/preseed/tpotce.seed b/preseed/tpotce.seed new file mode 100755 index 00000000..2537fb19 --- /dev/null +++ b/preseed/tpotce.seed @@ -0,0 +1,82 @@ +# Beehive preseed file by mo +# Setting locale +d-i debian-installer/language string en +d-i debian-installer/country string DE +d-i debian-installer/locale string en_US.UTF-8 + +# Keyboard selection +d-i console-setup/ask_detect boolean false +d-i keyboard-configuration/layoutcode string de + +# Network Configuration +d-i netcfg/choose_interface select auto +d-i netcfg/dhcp_timeout string 60 +d-i netcfg/get_hostname string t-pot + +# Proxy +d-i mirror/http/proxy string + +# Time +d-i clock-setup/utc boolean true +d-i time/zone string Europe/Berlin +d-i clock-setup/ntp boolean true + +# Partitioning +# old, not working with nuc +#d-i partman-auto/init_automatically_partition select biggest_free +#d-i partman-auto/choose_recipe select atomic +#d-i partman-auto/method string regular +#d-i partman-lvm/confirm boolean true +#d-i partman-lvm/confirm_nooverwrite boolean true +#d-i partman-lvm/device_remove_lvm boolean true +#d-i partman-md/device_remove_md boolean true +#d-i partman/default_filesystem string ext4 +#d-i partman-partitioning/confirm_write_new_label boolean true +#d-i partman/choose_partition select finish +#d-i partman/confirm boolean true +#d-i partman/confirm_nooverwrite boolean true + +# testing, works with nuc, but trying ks file first +#d-i partman-auto/disk string /dev/sda +#d-i partman-auto/choose_recipe select atomic +#d-i partman-auto/method string regular +#d-i partman-lvm/confirm boolean true +#d-i partman-lvm/confirm_nooverwrite boolean true +#d-i partman-lvm/device_remove_lvm boolean true +#d-i partman-md/device_remove_md boolean true +#d-i partman/default_filesystem string ext4 +#d-i partman-partitioning/confirm_write_new_label boolean true +#d-i partman/choose_partition select finish +#d-i partman/confirm boolean true +#d-i partman/confirm_nooverwrite boolean true + +# User setup +#d-i passwd/user-fullname string admin +#d-i passwd/username string admin + +# Encrypted using an MD5 hash (printf "password" | mkpasswd -s -m md5) +#d-i passwd/user-password-crypted password $1$8deB8hXr$S/5SDG559KmAPGAL62s3i1 +#d-i user-setup/allow-password-weak boolean true +#d-i user-setup/encrypt-home boolean false + +# Package Groups +tasksel tasksel/first multiselect ubuntu-server + +# Packages +d-i pkgsel/include string openssh-server + +# Update Policy +d-i pkgsel/update-policy select unattended-upgrades + +# Grub +#d-i grub-installer/only_debian boolean true + +# Post install +d-i preseed/late_command string \ +cp /cdrom/tpotce/install1.sh /target/etc/rc.local; \ +cp /cdrom/tpotce/install2.sh /target/root/install.sh +#mkdir -p /target/root/images/; \ +#cp /cdrom/tpotce/images/* /target/root/images/ + +# Reboot +d-i finish-install/reboot_in_progress note