first install required programs

sudo apt-get install python-pip
pip instal GitPython
sudo salt-run winrepo.update_git_repos

install firefox


firefox:
   pkg.installed:
     - pkgs:
       - firefox

install git from the cmd


salt-call --local pkg.install git

configure vlc


C:/Users/username/AppData/Roaming/vlc/vlc-gt-interface.ini:
  file.managed:
      - source: salt://vlc/vlc.ini

This bash script is based from this

https://omarbenchbana.com/en/ubuntu-18-10-with-apache-preinstalled/
First save build.sh with its source

build.sh


wget http://cdimage.ubuntu.com/ubuntu-budgie/releases/18.10/release/ubuntu-budgie-18.10-desktop-amd64.iso -4
export iso_file=ubuntu-budgie-18.10-desktop-amd64.iso
mkdir mnt
sudo mount -o loop ${iso_file} mnt/
mkdir extract-cd
sudo rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd
mkdir squashfs
sudo unsquashfs mnt/casper/filesystem.squashfs
sudo mv squashfs-root edit
sudo mount --bind /dev/ edit/dev
sudo cp  startup.sh edit/usr/bin/
sudo chmod +x edit/usr/bin/startup.sh
sudo chroot edit /bin/bash -c "su - -c startup.sh"
sudo rm edit/usr/bin/startup.sh
sudo umount edit/dev
sudo echo "php" >> extract-cd/preseed/ubuntu-budgie.seed
sudo chmod +w extract-cd/casper/filesystem.manifest
sudo chroot edit dpkg-query -W --showformat='${Package} ${Version}\n' > extract-cd/casper/filesystem.manifest
sudo mksquashfs edit extract-cd/casper/filesystem.squashfs
export output_file=ubuntu-budgie-18.10-desktop-apache-remix-amd64.iso

#export IMAGE_NAME="Ubuntu Budgie 18.10"
#sudo sed -i -e "s/$IMAGE_NAME/$IMAGE_NAME (Apache Remix)/" extract-cd/README.diskdefines
#sudo sed -i -e "s/$IMAGE_NAME/$IMAGE_NAME (Apache Remix)/" extract-cd/.disk/info
cd extract-cd
sudo rm -f md5sum.txt
(find -type f -print0 | xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee ../md5sum.txt)
mv -f ../md5sum.txt ./
# If the following is not done, causes an error in the boot menu disk check option
sed -i -e '/isolinux/d' md5sum.txt
export IMAGE_NAME="Ubuntu Budgie 18.04 apache-remix amd64"
genisoimage -r -V "Ubuntu Budgie 18.10" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -o ../${output_file} .
cd ..
isohybrid --uefi ubuntu-budgie-18.10-desktop-apache-remix-amd64.iso
umount squashfs/
umount mnt/
exit
echo "done"

startup.sh

then save startup.sh with the source below


mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts
export HOME=/root
export LC_ALL=C
echo "nameserver 1.1.1.1" >> /run/systemd/resolve/stub-resolv.conf
sudo apt update && sudo apt upgrade
sudo apt install php-fpm php
apt clean
rm -rf /tmp/*
rm -rf /var/cache/apt-xapian-index/*
rm -rf /var/lib/apt/lists/*
umount /proc
umount /sys
umount /dev/pts

now run with sudo bash build.sh and wait 15-30 minutes and you will have your own ubuntu iso

Refer this for inital setup

https://omarbenchbana.com/en/salt-with-nginx-php-fpm-and-ufw/
and this first current setup
https://github.com/obb12/pcs

first let install virtualbox

virtualbox:
  pkg.installed
vagrant:
  pkg.installed
'vagrant init bento/ubuntu-10.04':
  cmd.run
'vagrant up'
  cmd.run

Lets first upload our salt repo to github

git init
git add .
git commit -m "first commit"
git remote add origin https://github.com/username/repo
got push -u origin master

Next i added git to the config


 git:
   pkg.installed
'git config --global user.name "Mona Lisa"':
  cmd.run

Heres the ouput of git log


commit c7898d83ffacc488f39e6b502673cc82b3af69a4 (HEAD -> master, origin/master)
Author: Your Name 
Date:   Thu Nov 15 08:51:45 2018 +0200

    hellO

commit 3af2c3db62fa207099cc2cd8676e8d3051f6c159
Author: Your Name 
Date:   Thu Nov 15 08:36:13 2018 +0200

    hellO

heres the output of git blame top.sls


^3af2c3d (Your Name 2018-11-15 08:36:13 +0200  1) base:
^3af2c3d (Your Name 2018-11-15 08:36:13 +0200  2)   'pc':
^3af2c3d (Your Name 2018-11-15 08:36:13 +0200  3)     - firewall
^3af2c3d (Your Name 2018-11-15 08:36:13 +0200  4)     - apache
^3af2c3d (Your Name 2018-11-15 08:36:13 +0200  5)     - ssh
^3af2c3d (Your Name 2018-11-15 08:36:13 +0200  6)     - git
^3af2c3d (Your Name 2018-11-15 08:36:13 +0200  7)   'manjaro':
^3af2c3d (Your Name 2018-11-15 08:36:13 +0200  8)     - firewall
^3af2c3d (Your Name 2018-11-15 08:36:13 +0200  9)     - nginx
^3af2c3d (Your Name 2018-11-15 08:36:13 +0200 10)     - git

I made a .gitignore
file with the following contents


*.sls

i ran git reset --hard
to remove this gitignore file

This is Thursday’s Assigment

Refer this for inital setup

https://omarbenchbana.com/en/salt-with-nginx-php-fpm-and-ufw/

First configure your salt to include the sshd_config

sudoedit /srv/salt/ssh/init.sls

https://raw.githubusercontent.com/obb12/apache-server/master/ssh.sls
then change your port in the config

sudoedit /srv/salts/ssh/sshd_config

https://raw.githubusercontent.com/obb12/apache-server/master/sshd_config

Next configure apache

sudoedit /srv/salt/apache/init.sls

apache2:
 pkg.installed

/var/www/html/index.html:
 file.managed:
   - source: salt://apache/default-index.html

/etc/apache2/mods-enabled/userdir.conf:
 file.symlink:
   - target: ../mods-available/userdir.conf

/etc/apache2/mods-enabled/userdir.load:
 file.symlink:
   - target: ../mods-available/userdir.load

apache2service:
 service.running:
   - name: apache2
   - watch:
     - file: /etc/apache2/mods-enabled/userdir.conf
     - file: /etc/apache2/mods-enabled/userdir.load
     


Next enable cgi-bin scripts



install_apache:
   pkg.installed:
     - pkgs:
       - apache2
       - php-fpm
       - composer
/etc/apache2/mods-enabled/userdir.conf:
 file.symlink:
   - target: ../mods-available/userdir.conf
/usr/lib/cgi-bin/test.pl:
 file.managed:
   - source: salt://apache/test.pl
/etc/apache2/mods-enabled/userdir.load:
 file.symlink:
   - target: ../mods-available/userdir.load
/etc/apache2/mods-enabled/userdir.conf:
 file.symlink:
   - target: ../mods-available/userdir.conf

/etc/apache2/mods-enabled/cgid.load:
 file.symlink:
   - target: ../mods-available/cgid.load
/etc/apache2/mods-enabled/cgid.conf:
 file.symlink:
   - target: ../mods-available/cgid.conf

apache2service:
 service.running:
   - name: apache2
   - watch:
     - file: /etc/apache2/mods-enabled/userdir.conf
     - file: /etc/apache2/mods-enabled/userdir.load
     - file: /etc/apache2/mods-enabled/cgid.load
     - file: /etc/apache2/mods-enabled/cgid.conf

Write your Cgi script


 /srv/salt/apache/test.pl

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "Hello, World.";


first update your system

sudo pacman -Syu 

Reboot your system

next install the required tools

sudo pacman -Syu manjaro-tools-iso manjaro-iso-profiles-official

Edit the Packages-Desktop file

sudo nano /usr/share/manjaro-tools/iso-profiles/official/xfce/Packages-Desktop
## Php server
php 
apache

Compile the iso

 buildiso -p xfce

Select yes and wait

Clean your system

sudo rm -r /var/lib/manjaro-tools/buildiso/
paccache -ruk0

sources


  1. https://wiki.manjaro.org/Build_Manjaro_ISOs_with_buildiso

Install the required tools

sudo apt-get install squashfs-tools syslinux-utils

Download the ubuntu iso

wget http://releases.ubuntu.com/18.10/ubuntu-18.10-desktop-amd64.iso

Setup iso_file variable

export iso_file=ubuntu-18.10-desktop-amd64.iso

Extract the image and mount it

mkdir mnt
sudo mount -o loop ${iso_file} mnt/

Extract the filesystem.squashfs

mkdir extract-cd
sudo rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd
mkdir squashfs
sudo unsquashfs mnt/casper/filesystem.squashfs
sudo mv squashfs-root edit


Bind the enviroment and chroot into it

sudo mount --bind /dev/ edit/dev
sudo chroot edit
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts
export HOME=/root
export LC_ALL=C

Edit the dns config

nano /run/systemd/resolve/stub-resolv.conf
nameserver 1.1.1.1

Install php and apache

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install php

Install finnish and spanish

apt-get remove --purge language-pack-bn language-pack-bn-base language-pack-gnome-bn language-pack-gnome-bn-base language-pack-es language-pack-es-base language-pack-gnome-es language-pack-gnome-es-base language-pack-pt language-pack-pt-base language-pack-gnome-pt language-pack-gnome-pt-base language-pack-xh language-pack-xh-base language-pack-gnome-xh language-pack-gnome-xh-base language-pack-hi language-pack-hi-base language-pack-gnome-hi language-pack-gnome-hi-base language-pack-de language-pack-de-base language-pack-fr language-pack-fr-base language-pack-gnome-de language-pack-gnome-de-base language-pack-gnome-fr language-pack-gnome-fr-base firefox-locale-bn firefox-locale-de firefox-locale-es firefox-locale-pt language-pack-gnome-zh-hans language-pack-gnome-zh-hans-base language-pack-zh-hans language-pack-zh-hans-base firefox-locale-zh-hans
sed -i 's/restricted/restricted universe/' /etc/apt/sources.list
apt update
apt install gnome-getting-started-docs-fi gnome-user-docs-fi language-pack-fi language-pack-fi-base language-pack-gnome-fi language-pack-gnome-fi-base
gnome-getting-started-docs-es gnome-user-docs-es language-pack-es language-pack-es-base language-pack-gnome-es language-pack-gnome-es-base 
apt install xul-ext-mozvoikko libreoffice-l10n-fi libreoffice-voikko firefox-locale-fi libreoffice-help-fi thunderbird-locale-fi libenchant-voikko tmispell-voikko
libreoffice-l10n-es  firefox-locale-es libreoffice-help-es thunderbird-locale-es
sed -i 's/restricted universe/restricted/' /etc/apt/sources.list
apt install libreoffice-l10n-en-gb libreoffice-help-en-gb libreoffice-l10n-en-za libreoffice-help-en-us poppler-data hyphen-fi hunspell-en-ca mythes-en-au thunderbird-locale-en-gb hyphen-en-us thunderbird-locale-en-us mythes-en-us wbritish hunspell-en-za libreoffice-l10n-en-gb hunspell-en-gb

Open a new terminal to configure ubuntu preseed

sudo su
cd extract-cd 
cd preseed
nano ubuntu.seed

Ubuntu.seed contents

# Enable extras.ubuntu.com.
d-i apt-setup/extras    boolean true
# Install the Ubuntu desktop.
tasksel tasksel/first   multiselect ubuntu-desktop
# On live DVDs, don't spend huge amounts of time removing substantial
# application packages pulled in by language packs. Given that we clearly
# have the space to include them on the DVD, they're useful and we might as
# well keep them installed.
ubiquity    ubiquity/keep-installed string icedtea6-plugin openoffice.org php

Go back to the first terminal and clean up the system

apt clean
rm -rf /tmp/*
rm -rf /var/cache/apt-xapian-index/*
rm -rf /var/lib/apt/lists/*
umount /proc
umount /sys
umount /dev/pts

Exit the enviroment

exit
sudo umount edit/dev

Create the file manifest

sudo -s
chmod +w extract-cd/casper/filesystem.manifest
chroot edit dpkg-query -W --showformat='${Package} ${Version}\n' > extract-cd/casper/filesystem.manifest

Create the filesystem.squashfs

mksquashfs edit extract-cd/casper/filesystem.squashfs

Export the iso file

export output_file=ubuntu-18.04-desktop-apache-remix-amd64.iso

export IMAGE_NAME="Ubuntu 18.10"
sed -i -e "s/$IMAGE_NAME/$IMAGE_NAME (Apache Remix)/" extract-cd/README.diskdefines
sed -i -e "s/$IMAGE_NAME/$IMAGE_NAME (Apache Remix)/" extract-cd/.disk/info
cd extract-cd
rm -f md5sum.txt
(find -type f -print0 | xargs -0 md5sum | grep -v isolinux/boot.cat | sudo tee ../md5sum.txt)
mv -f ../md5sum.txt ./
# If the following is not done, causes an error in the boot menu disk check option
sed -i -e '/isolinux/d' md5sum.txt
export IMAGE_NAME="Ubuntu 18.04 apache-remix amd64"
genisoimage -r -V "$IMAGE_NAME" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -o ../${output_file} .
cd ..
isohybrid --uefi ${output_file}
umount squashfs/
umount mnt/
exit

Now you have your own customized ubuntu image with anything you want to preinstall
Here's the iso files i created for this tutorial
/files

sources

  1. https://bazaar.launchpad.net/~timo-jyrinki/ubuntu-fi-remix/main/view/head:/finnish-remix.sh

Installing salt-master on ubuntu 18.04

so install salt-master using

sudo apt install salt-master

Installing salt-minion on ubuntu 18.04

to install salt-minion run

sudo apt install salt-minion

Configuring salt minion

configure salt minion to connect to the master

sudoedit /etc/salt/minion

/etc/salt/minion

  master:192.168.8.10x
  id:your_id  

restart the minion

sudo systemctl restart salt-minion.service

accept the key from the master

 sudo salt-key -A

Now try it out

  sudo salt '*' cmd.run 'whoami'

Configuring firewall

sudoedit /srv/salt/firewall.sls

firewall.sls

sudoedit /srv/salt/firewall/user.rules

user.rules

sudoedit /srv/salt/firewall/user6.rules

user6.rules

to enable firewall on minions

sudo salt '*' state.highstate

Server info using grains

sudo salt '*' grains.items

serverinfo.txt

installing nginx with php-fpm using salt

nginx configuration

listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {

include snippets/fastcgi-php.conf;

fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}

salt configuration
init.sls
top.sls
index.php

<?php

phpinfo();

final result
phpinfo

references

  1. http://terokarvinen.com/2018/aikataulu-%E2%80%93-palvelinten-hallinta-ict4tn022-3004-ti-ja-3002-to-%E2%80%93-loppukevat-2018-5p
  2. https://github.com/joonaleppalahti/CCM/tree/master/salt/srv/salt
  3. https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-ubuntu-18-04
  4. https://github.com/obb12/vbox-server

Download and configure linux kernel

install compilation tools on a ubuntu distro 18.04 (linux mint,xubuntu)

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install fakeroot build-essential ncurses-dev xz-utils libssl-dev bc bison flex
 sudo apt-get install kernel-package

now download linux kernel in this tutorial 4.18.16 it might not be the latest

wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.18.16.tar.xz

untar the kernel

tar -xvf linux-4.18.16.tar.xz

go to the directory and copy the current config from your current kernel look carefully at what to enable in make oldconfig

 cp -v /boot/config-$(uname -r) .config
 make oldconfig

Warning do not do this if you’re not familiar with Linux. If you want to customize your kernel more you can run make menuconfig or install kernel patches (example ssd patch)

Compile the kernel you can compile using fakeroot

fakeroot make-kpkg --initrd  kernel_image kernel_headers -j 16

installing the kernel

cd ..
sudo apt install ./linux*.4.18.16*.deb

now reboot your system

  sudo reboot

sources

  1. https://www.cyberciti.biz/faq/debian-ubuntu-building-installing-a-custom-linux-kernel/