SpectreOS-old/arch-install

1272 lines
44 KiB
Text
Raw Normal View History

2018-02-26 02:41:29 +01:00
#!/bin/bash
#
set -ex
2018-02-27 22:53:24 +01:00
echo "Version : DI 27. Feb 22:52:41 CET 2017"
2018-02-26 02:41:29 +01:00
2018-07-05 15:45:24 +02:00
WEBADDRESS="ssh://git@5.83.162.84:22/home/git/SpectreOS"
2018-02-26 02:41:29 +01:00
repo="SpectreOS"
user="user1"
2018-04-21 03:29:50 +02:00
version="${2}"
hostname="$(cat /etc/hostname)"
[[ -z "${version}" ]] && version="${hostname#*-}"
2018-02-26 02:41:29 +01:00
2018-05-10 03:47:10 +02:00
2018-02-26 02:41:29 +01:00
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
2018-04-07 19:07:06 +02:00
sudo "$0" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9" 2>&1 | tee /home/user1/install.log
2018-02-26 02:41:29 +01:00
exit 0
fi
2018-03-05 16:53:39 +01:00
echo "Logged in as root"
2018-02-26 02:41:29 +01:00
function minimalinstallation() {
2018-04-27 21:04:17 +02:00
2018-05-06 01:29:06 +02:00
if [ -f base.txt ]; then
pacstrap -c -d -G -M ${mountpoint} $(cat base.txt)
elif [ -f /opt/${repo}/base.txt ]; then
pacstrap -c -d -G -M ${mountpoint} $(cat /opt/${repo}/base.txt)
fi
2018-04-27 21:04:17 +02:00
2018-05-27 02:51:22 +02:00
# hooks
cp -v /opt/${repo}/install/archiso* ${mountpoint}/usr/lib/initcpio/install/
cp -v /opt/${repo}/hooks/archiso* ${mountpoint}/usr/lib/initcpio/hooks/
cp -v /opt/${repo}/script/archiso* ${mountpoint}/usr/lib/initcpio/
cp -v /opt/${repo}/install/cow_device ${mountpoint}/usr/lib/initcpio/install/
cp -v /opt/${repo}/hooks/cow_device ${mountpoint}/usr/lib/initcpio/hooks/
# scripts
cp /opt/${repo}/arch-graphical-install-auto ${mountpoint}/usr/bin/arch-graphical-install-auto
chmod +x ${mountpoint}/usr/bin/arch-graphical-install-auto
# mirrors
# pacman-config
if [ "${version}" == "libre" ]; then
cp /opt/${repo}/pacman.conf_libre ${mountpoint}/etc/pacman.conf
elif [ "${version}" == "manjaro" ]; then
cp /opt/${repo}/pacman.conf_manjaro ${mountpoint}/etc/pacman.conf
else
cp /opt/${repo}/pacman.conf ${mountpoint}/etc/pacman.conf
fi
# mirrorlist
cp /opt/${repo}/mirrorlist* ${mountpoint}/etc/pacman.d/
2018-05-27 02:41:02 +02:00
# aurinstaller
cp /opt/${repo}/aurinstall.sh ${mountpoint}/usr/bin/aurinstaller
chmod +x ${mountpoint}/usr/bin/aurinstaller
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-06-14 13:30:42 +02:00
echo "${name}´s_PC-${version}" > ${mountpoint}/etc/hostname
2018-06-07 03:31:01 +02:00
fi
2018-05-27 02:51:22 +02:00
2018-05-27 02:48:44 +02:00
arch-chroot ${mountpoint} arch-graphical-install-auto adduser user1 user1
2018-05-27 02:51:22 +02:00
arch-chroot ${mountpoint} pacman -Syu --needed --noconfirm
2018-05-27 02:48:44 +02:00
arch-chroot ${mountpoint} su "$user" -c "aurinstaller "https://aur.archlinux.org/plymouth.git""
2018-05-27 02:41:02 +02:00
2018-05-27 03:14:20 +02:00
# x11vnc
mkdir -p ${mountpoint}/etc/systemd/system/
cp /opt/${repo}/x11vnc.service ${mountpoint}/etc/systemd/system/x11vnc.service
chmod 644 ${mountpoint}/etc/systemd/system/x11vnc.service
arch-chroot ${mountpoint} systemctl enable x11vnc.service
2018-02-26 02:41:29 +01:00
}
function gitclone() {
2018-03-14 04:16:18 +01:00
if [ -d "/opt/${repo}" ]; then
2018-03-05 16:53:39 +01:00
echo "${repo} already exists!!!"
2018-03-14 04:16:18 +01:00
cd /opt/${repo}
git pull
else
git clone ${WEBADDRESS} /opt/${repo}
2018-02-26 02:41:29 +01:00
fi
2018-04-01 17:34:57 +02:00
cd /
2018-02-26 02:41:29 +01:00
}
function secureumount() {
if [ "${dateisystem}" == "btrfs" ]; then
if cat /proc/mounts | grep ${mountpoint} > /dev/null; then
umount ${mountpoint}/boot
btrfs filesystem df ${mountpoint}
echo "umount!!!"
umount ${mountpoint}/home
umount ${mountpoint}/opt
umount ${mountpoint}/var/cache/pacman/pkg
umount ${mountpoint}/var/lib
# custom-mounts
for wort in ${mountsnaps}
do
2018-05-10 03:57:29 +02:00
if cat /proc/mounts | grep ${mountpoint}${wort} > /dev/null; then
2018-05-11 12:52:42 +02:00
umount ${mountpoint}${wort}
2018-05-10 03:57:29 +02:00
fi
2018-02-26 02:41:29 +01:00
done
umount ${mountpoint}
umount /mnt/btrfs-root
#umount -R /mnt
fi
elif [ "${dateisystem}" == "ext4" ]; then
2018-04-08 21:25:09 +02:00
if cat /proc/mounts | grep ${mountpoint}/boot > /dev/null; then
2018-02-26 02:41:29 +01:00
umount ${mountpoint}/boot
2018-04-08 21:25:09 +02:00
fi
if cat /proc/mounts | grep ${mountpoint} > /dev/null; then
2018-02-26 02:41:29 +01:00
umount ${mountpoint}
fi
fi
2018-03-04 19:38:17 +01:00
2018-03-04 18:54:00 +01:00
if fdisk -l | grep /dev/mapper/luks0 > /dev/null; then
2018-03-05 16:53:39 +01:00
read -p "Should /dev/mapper/luks0 be removed? [Y/n] : " cryptremove
2018-03-04 19:38:17 +01:00
if [ "${cryptremove}" != "n" ]; then
cryptsetup remove /dev/mapper/luks0
fi
2018-03-04 18:50:24 +01:00
fi
2018-03-04 19:38:17 +01:00
2018-03-04 18:54:00 +01:00
if cat /proc/mounts | grep ${device}1 > /dev/null; then
umount ${device}1
fi
2018-03-04 19:38:17 +01:00
2018-04-01 17:26:56 +02:00
if [ -n "${usbkeydevice}" ]; then
2018-04-01 17:34:57 +02:00
if cat /proc/mounts | grep ${usbkeydevice} > /dev/null; then
umount ${usbkeydevice}
fi
2018-03-04 18:54:00 +01:00
fi
2018-02-26 02:41:29 +01:00
}
2018-04-05 20:39:14 +02:00
function formatencrypt() {
if [ "${verschluesselung}" == "y" ]; then
echo "Please write big YES"
cryptsetup -c aes-xts-plain64 -y -s 512 luksFormat ${device}${rootpartitionnummer}
2018-04-06 17:09:08 +02:00
mountencrypt
2018-04-05 20:39:14 +02:00
fi
}
2018-04-06 17:09:08 +02:00
function mountencrypt() {
cryptsetup luksOpen ${device}${rootpartitionnummer} luks0
}
2018-02-26 02:41:29 +01:00
function partionierenmitswap() {
wipefs -a -f ${device}
sgdisk -o ${device}
sgdisk -a 2048 -n 1::+1024K -c 1:"BIOS Boot Partition" -t 1:ef02 ${device}
sgdisk -a 2048 -n 2::+1G -c 2:"EFI Boot Partition" -t 2:ef00 ${device}
sgdisk -a 2048 -n 3::+8G -c 3:"Linux swap" -t 3:8200 ${device}
sgdisk -a 2048 -n 4:: -c 4:"Linux filesystem" -t 4:8300 ${device}
2018-04-05 20:39:14 +02:00
formatencrypt
2018-02-26 02:41:29 +01:00
}
function partionierenohneswap() {
wipefs -a -f ${device}
sgdisk -o ${device}
sgdisk -a 2048 -n 1::+1024K -c 1:"BIOS Boot Partition" -t 1:ef02 ${device}
sgdisk -a 2048 -n 2::+1G -c 2:"EFI Boot Partition" -t 2:ef00 ${device}
sgdisk -a 2048 -n 3:: -c 3:"Linux filesystem" -t 3:8300 ${device}
2018-04-05 20:39:14 +02:00
formatencrypt
2018-02-26 02:41:29 +01:00
}
2018-07-16 00:48:06 +02:00
function partitioniereonepartition() {
sgdisk -d 3 ${device}
2018-07-16 00:48:06 +02:00
sgdisk -a 2048 -n 3:: -c 3:"Linux filesystem" -t 3:8300 ${device}
formatencrypt
}
2018-07-16 02:45:11 +02:00
function partitioniereonepartitionmitswap() {
sgdisk -d 4 ${device}
sgdisk -a 2048 -n 4:: -c 4:"Linux filesystem" -t 4:8300 ${device}
formatencrypt
}
2018-02-26 02:41:29 +01:00
function usbkeyinstallation() {
2018-03-04 18:54:00 +01:00
mkdir -p /mnt/usb-stick
2018-02-26 02:41:29 +01:00
mount ${usbkeydevice} /mnt/usb-stick
2018-06-07 03:31:01 +02:00
if ! [ -f "/mnt/usb-stick/archkey" ]; then
2018-06-14 13:30:42 +02:00
dd if=/dev/urandom of=/mnt/usb-stick/archkey bs=512 count=4
2018-06-07 03:31:01 +02:00
fi
2018-02-26 02:41:29 +01:00
cryptsetup luksAddKey ${device}${rootpartitionnummer} /mnt/usb-stick/archkey
}
function usbsecret() {
2018-03-04 20:16:30 +01:00
cp /opt/${repo}/install/usbsecret ${mountpoint}/usr/lib/initcpio/install/usbsecret
cp /opt/${repo}/hooks/usbsecret ${mountpoint}/root/usbsecret
2018-02-26 02:41:29 +01:00
# hooks
#cp install/usbsecret ${mountpoint}/usr/lib/initcpio/install/usbsecret
#cp hooks/usbsecret ${mountpoint}/usr/lib/initcpio/hooks/usbsecret
sed "s|%USB_UUID%|${usbsecretdeviceuuid}|g;" ${mountpoint}/root/usbsecret > ${mountpoint}/usr/lib/initcpio/hooks/usbsecret
}
function cron() {
echo "cron-job snapshot"
mkdir -p ${mountpoint}/var/spool/cron/
2018-04-05 21:15:03 +02:00
echo -n "0 18 * * * /usr/bin/snapshot make ROOT home opt var/cache/pacman/pkg " > ${mountpoint}/var/spool/cron/root
2018-04-05 21:03:30 +02:00
# custom-mounts
for wort in ${mountsnaps}
do
echo -n "${wort#/*} " >> ${mountpoint}/var/spool/cron/root
done
echo "" >> ${mountpoint}/var/spool/cron/root
2018-02-26 02:41:29 +01:00
if [ "${update}" != "n" ]; then
2018-02-27 22:53:24 +01:00
cp /opt/${repo}/snapshot.sh ${mountpoint}/usr/bin/snapshot
2018-02-26 02:41:29 +01:00
chmod 755 ${mountpoint}/usr/bin/snapshot
fi
2018-05-27 00:39:24 +02:00
if [ "${version}" == "manjaro" ]; then
echo "0 * * * * /usr/bin/update-bootloader" >> ${mountpoint}/var/spool/cron/root
fi
2018-02-26 02:41:29 +01:00
}
function makeswapfile() {
#swapfile
2018-04-08 21:44:07 +02:00
fallocate -l 4G ${mountpoint}/swapfile
2018-02-26 02:41:29 +01:00
chmod 600 ${mountpoint}/swapfile
mkswap ${mountpoint}/swapfile
echo "/swapfile none swap defaults 0 0" >> ${mountpoint}/etc/fstab
}
function makebtrfsswapfile() {
2018-02-27 22:53:24 +01:00
/opt/${repo}/btrfs-swapon ${mountpoint}/usr/bin/btrfs-swapon
/opt/${repo}/btrfs-swapoff ${mountpoint}/usr/bin/btrfs-swapoff
/opt/${repo}/btrfs-swapon.service ${mountpoint}/root/btrfs-swapon.service
2018-02-26 02:41:29 +01:00
chmod +x ${mountpoint}/usr/bin/btrfs-swapon
chmod +x ${mountpoint}/usr/bin/btrfs-swapoff
sed "s|%swapfilespeicher%|${swapfilespeicher}|g;" ${mountpoint}/root/btrfs-swapon.service > ${mountpoint}/etc/systemd/system/btrfs-swapon.service
arch-chroot ${mountpoint} systemctl enable btrfs-swapon
}
function removeinstaller {
echo ""
if [ -f ${mountpoint}/usr/share/applications/arch-install.desktop ]
then
rm ${mountpoint}/usr/share/applications/arch-install.desktop
fi
echo ""
if [ -f ${mountpoint}/root/Schreibtisch/arch-install.desktop ]
then
rm ${mountpoint}/root/Schreibtisch/arch-install.desktop
fi
echo ""
if [ -f ${mountpoint}/home/${user}/Schreibtisch/arch-install.desktop ]
then
rm ${mountpoint}/home/${user}/Schreibtisch/arch-install.desktop
fi
echo ""
if [ -f ${mountpoint}/root/Desktop/arch-install.desktop ]
then
rm ${mountpoint}/root/Desktop/arch-install.desktop
fi
echo ""
if [ -f ${mountpoint}/home/${user}/Desktop/arch-install.desktop ]
then
rm ${mountpoint}/home/${user}/Desktop/arch-install.desktop
fi
echo ""
}
function installation {
#boot
2018-03-05 16:53:39 +01:00
echo "format"
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ] && [ "${skipbootpartition}" != "y" ]; then
2018-04-01 17:34:57 +02:00
mkfs.vfat -F 32 ${device}${efipartitionnummer}
fi
2018-02-26 02:41:29 +01:00
#root
if [ "${dateisystem}" == "btrfs" ]; then
#mkfs.btrfs -f -L p_arch ${device}2
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-04-01 17:34:57 +02:00
btrfsformat #btrfs
2018-04-01 17:15:12 +02:00
fi
2018-02-26 02:41:29 +01:00
subvolume #btrfs
elif [ "${dateisystem}" == "ext4" ]; then
2018-04-27 20:14:52 +02:00
echo "confirm with y"
2018-02-26 02:41:29 +01:00
if [ "${verschluesselung}" == "y" ]; then
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-04-01 17:34:57 +02:00
mkfs.ext4 -L p_arch ${deviceluks} #ext4
2018-04-01 17:15:12 +02:00
fi
2018-02-26 02:41:29 +01:00
mount ${deviceluks} ${mountpoint}
else
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-04-01 17:34:57 +02:00
mkfs.ext4 -L p_arch ${device}${rootpartitionnummer} #ext4
2018-04-01 17:15:12 +02:00
fi
2018-02-26 02:41:29 +01:00
mount ${device}${rootpartitionnummer} ${mountpoint}
fi
2018-04-08 21:31:33 +02:00
mkdir -p ${mountpoint}/boot
mount ${device}${efipartitionnummer} ${mountpoint}/boot
2018-02-26 02:41:29 +01:00
fi
#swap
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-04-01 17:34:57 +02:00
if [ "${swap}" != "n" ]; then
mkswap -L p_swap ${device}${swappartitionnummer}
fi
2018-02-26 02:41:29 +01:00
fi
#installation
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-04-01 17:34:57 +02:00
if [ "${offline}" != "n" ]
then
if [ -f /run/archiso/bootmnt/arch/$(uname -m)/airootfs.sfs ]; then
echo "It is not a copytoram system."
unsquashfs -f -d ${mountpoint} /run/archiso/bootmnt/arch/$(uname -m)/airootfs.sfs
elif [ -f /run/archiso/copytoram/airootfs.sfs ]; then
echo "It is a copytoram system."
unsquashfs -f -d ${mountpoint} /run/archiso/copytoram/airootfs.sfs
2018-03-04 19:33:17 +01:00
else
2018-04-25 08:09:12 +02:00
read -p "Where is the airootfs.sfs? Please specify the complete path or choose the online installation? [/airootfs.sfs/online] : " installationsfehler
if [ "${installationsfehler}" == "online" ]; then
2018-04-01 17:34:57 +02:00
minimalinstallation
else
2018-04-25 08:09:12 +02:00
unsquashfs -f -d ${mountpoint} ${installationsfehler}
2018-04-01 17:34:57 +02:00
fi
2018-03-04 19:33:17 +01:00
fi
2018-04-01 17:34:57 +02:00
else
minimalinstallation
2018-02-26 02:41:29 +01:00
fi
2018-04-01 17:15:12 +02:00
fi
2018-02-26 02:41:29 +01:00
2018-03-04 18:12:07 +01:00
# module and hooks
2018-04-21 16:34:59 +02:00
parameter="base udev "
2018-05-01 01:57:36 +02:00
2018-02-26 02:41:29 +01:00
if [ "${swap}" != "n" ]; then
parameter="${parameter}resume "
fi
2018-05-01 01:57:36 +02:00
2018-02-26 02:41:29 +01:00
if [ "${verschluesselung}" == "y" ]; then
parameter="${parameter}encrypt "
fi
2018-05-01 01:57:36 +02:00
2018-02-26 02:41:29 +01:00
parameter="${parameter}block filesystems keyboard "
2018-05-01 01:57:36 +02:00
2018-04-21 16:34:59 +02:00
if [ "${dateisystem}" == "btrfs" ]; then
if [ "${raid}" != "n" ]; then
2018-02-26 02:41:29 +01:00
parameter="${parameter}btrfs "
fi
fi
2018-04-01 15:39:54 +02:00
2018-02-26 02:41:29 +01:00
if [ "${usbsecret}" == "y" ]; then
parameter="${parameter}usbsecret "
fi
2018-05-27 03:36:07 +02:00
if [ "${verschluesselung}" == "y" ]; then
parameter="${parameter}plymouth-encrypt "
else
parameter="${parameter}plymouth "
2018-05-01 02:29:47 +02:00
fi
2018-02-26 02:41:29 +01:00
echo ""
2018-05-27 03:24:22 +02:00
if [ "${version}" == "libre" ] || [ "${version}" == "manjaro" ]; then
2018-06-02 00:01:15 +02:00
echo "MODULES=\"nouveau i915 radeon ata_generic ata_piix nls_cp437 vfat ext4 btrfs\"" > ${mountpoint}/etc/mkinitcpio.conf
2018-05-15 18:17:29 +02:00
echo "HOOKS=\"${parameter}\"" >> ${mountpoint}/etc/mkinitcpio.conf
2018-04-02 04:44:41 +02:00
echo "COMPRESSION=\"lz4\"" >> ${mountpoint}/etc/mkinitcpio.conf
2018-07-16 04:30:27 +02:00
echo "FILES=\"/etc/modprobe.d/blacklist-floppy.conf\"" >> ${mountpoint}/etc/mkinitcpio.conf
2018-04-02 04:44:41 +02:00
2018-03-04 18:12:07 +01:00
else
2018-05-15 18:17:29 +02:00
echo "MODULES=\"nvidia nvidia_modeset nvidia_uvm nvidia_drm i915 radeon ata_generic ata_piix nls_cp437 vfat ext4 btrfs\"" > ${mountpoint}/etc/mkinitcpio.conf
echo "HOOKS=\"${parameter}\"" >> ${mountpoint}/etc/mkinitcpio.conf
2018-04-02 04:44:41 +02:00
echo "COMPRESSION=\"lz4\"" >> ${mountpoint}/etc/mkinitcpio.conf
2018-07-16 04:30:27 +02:00
echo "FILES=\"/etc/modprobe.d/blacklist-floppy.conf /etc/modprobe.d/blacklist_nouveau.conf\"" >> ${mountpoint}/etc/mkinitcpio.conf
2018-04-02 04:44:41 +02:00
2018-03-04 18:12:07 +01:00
fi
2018-02-26 02:41:29 +01:00
echo ""
echo "blacklist floppy" > ${mountpoint}/etc/modprobe.d/blacklist-floppy.conf
2018-04-02 04:14:38 +02:00
echo "blacklist nouveau" > ${mountpoint}/etc/modprobe.d/blacklist_nouveau.conf
2018-07-10 04:43:42 +02:00
echo "install dell-smbios /bin/false" > ${mountpoint}/etc/modprobe.d/blacklist-dell-smbios.conf
2018-07-10 23:19:22 +02:00
echo "tmpfs /tmp tmpfs defaults,size=6G 0 0" > ${mountpoint}/etc/fstab
2018-02-26 02:41:29 +01:00
echo "tmpfs /dev/shm tmpfs defaults 0 0" >> ${mountpoint}/etc/fstab
2018-06-21 07:13:42 +02:00
echo "tmpfs /home/${user}/.cache tmpfs noatime,nodev,nosuid,size=2G 0 0" >> ${mountpoint}/etc/fstab
2018-02-26 02:41:29 +01:00
#fstab
rootbind=$(blkid -s PARTUUID -o value ${device}${rootpartitionnummer})
#genfstab -Up ${mountpoint} >> ${mountpoint}/etc/fstab
if [ "${dateisystem}" == "btrfs" ]; then
btrfsfstab #btrfs
mkdir -p ${mountpoint}/run/btrfs-root
if [ "${verschluesselung}" == "y" ]; then
echo "${deviceluks} /run/btrfs-root/ btrfs defaults 0 0" >> ${mountpoint}/etc/fstab #btrfs
else
echo "PARTUUID=${rootbind} /run/btrfs-root/ btrfs defaults 0 0" >> ${mountpoint}/etc/fstab #btrfs
fi
#grep -v "/var/lib" < ${mountpoint}/etc/fstab > fstab.neu; mv fstab.neu ${mountpoint}/etc/fstab
echo "/run/btrfs-root/__current/ROOT/var/lib /var/lib none bind 0 0" >> ${mountpoint}/etc/fstab #btrfs
cron
elif [ "${dateisystem}" == "ext4" ]; then
if [ "${verschluesselung}" == "y" ]; then
2018-04-17 23:04:37 +02:00
echo "${deviceluks} / ext4 rw,defaults,noatime,nodiratime,discard 0 0" >> ${mountpoint}/etc/fstab #ext4
2018-02-26 02:41:29 +01:00
else
2018-04-17 23:04:37 +02:00
echo "PARTUUID=${rootbind} / ext4 rw,defaults,noatime,nodiratime,discard 0 0" >> ${mountpoint}/etc/fstab #ext4
2018-02-26 02:41:29 +01:00
fi
fi
bootbind=$(blkid -s PARTUUID -o value ${device}${efipartitionnummer})
echo -e "PARTUUID=${bootbind} /boot vfat rw,relatime 0 2" >> ${mountpoint}/etc/fstab
if [ "${swap}" != "n" ]; then
if [ "${verschluesselung}" == "y" ]; then
swappartition=$(blkid -s PARTUUID -o value ${device}${swappartitionnummer})
2018-04-01 17:15:12 +02:00
echo "swap PARTUUID=${swappartition} /dev/urandom swap,cipher=aes-cbc-essiv:sha256,size=256" > ${mountpoint}/etc/crypttab
2018-02-26 02:41:29 +01:00
echo "/dev/mapper/swap none swap defaults 0 0" >> ${mountpoint}/etc/fstab
else
swappartition=$(blkid -s PARTUUID -o value ${device}${swappartitionnummer})
echo "PARTUUID=${swappartition} none swap defaults 0 0" >> ${mountpoint}/etc/fstab
fi
fi
#makeswapfile+fstab
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-04-01 17:34:57 +02:00
if [ "${swapfile}" == "y" ]; then
if [ "${dateisystem}" == "btrfs" ]; then
makebtrfsswapfile
elif [ "${dateisystem}" == "ext4" ]; then
makeswapfile
fi
2018-02-26 02:41:29 +01:00
fi
fi
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-06-14 13:30:42 +02:00
#hostname
echo "${name}´s_PC-${version}" > ${mountpoint}/etc/hostname
2018-06-07 03:31:01 +02:00
fi
2018-02-26 02:41:29 +01:00
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-04-01 17:34:57 +02:00
if [ "${usbsecret}" == "y" ]; then
usbsecret
fi
2018-04-01 17:15:12 +02:00
fi
2018-02-26 02:41:29 +01:00
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-04-01 17:34:57 +02:00
if [ "${usbkey}" == "y" ]; then
usbkeyinstallation
fi
2018-04-01 17:15:12 +02:00
fi
2018-04-01 16:48:56 +02:00
2018-05-11 12:52:42 +02:00
#autdiskmount
2018-05-12 13:32:32 +02:00
if [ "${autodisk}" == "y" ]
2018-05-11 12:52:42 +02:00
then
2018-05-11 14:37:51 +02:00
for wort in ${autodiskdevice}
do
echo "fstab ${wort} wird erstellt!!!"
2018-06-09 07:55:47 +02:00
autodiskdevicedateisystem=$(blkid -s TYPE -o value ${wort})
2018-07-16 01:11:15 +02:00
autodiskdevicepartuuid=$(blkid -s PARTUUID -o value ${wort})
mkdir -p ${mountpoint}/run/media/user1/${autodiskdevicepartuuid}
echo "PARTUUID=${autodiskdevicepartuuid} /run/media/user1/${autodiskdevicepartuuid} ${autodiskdevicedateisystem} defaults 0 2" >> ${mountpoint}/etc/fstab
2018-05-11 14:37:51 +02:00
done
2018-05-11 12:52:42 +02:00
fi
2018-06-21 06:56:45 +02:00
#forbtrfssnapshots
cp ${mountpoint}/etc/fstab ${mountpoint}/etc/fstab.example
2018-02-26 02:41:29 +01:00
#sie könne hier ihre scripte die bei der installation ausgeführt werden sollen hinzufügen :D
2018-04-01 16:48:56 +02:00
}
function grubinstall() {
2018-04-01 17:34:57 +02:00
if [ "${verschluesselung}" == "y" ]; then
if [ "${boot}" == "grub" ]; then
tobootdevice=$(blkid -s PARTUUID -o value ${device}${rootpartitionnummer})
if [ "${swap}" != "n" ]; then
swappartition=$(blkid -s PARTUUID -o value ${device}${swappartitionnummer})
if [ "${usbkey}" == "y" ]; then
2018-07-16 04:33:44 +02:00
sed -i 's/GRUB_CMDLINE_LINUX=.*$/GRUB_CMDLINE_LINUX="cryptdevice=PARTUUID='$tobootdevice':luks0 resume=PARTUUID='$swappartition' cryptkey=PARTUUID='$usbkeypartuuid':'$usbkeydateisystem':\/archkey nvidia-drm.modeset=1 splash"/' ${mountpoint}/etc/default/grub
2018-04-01 17:34:57 +02:00
else
2018-04-01 17:45:48 +02:00
sed -i 's/GRUB_CMDLINE_LINUX=.*$/GRUB_CMDLINE_LINUX="cryptdevice=PARTUUID='$tobootdevice':luks0 resume=PARTUUID='$swappartition' nvidia-drm.modeset=1 splash"/' ${mountpoint}/etc/default/grub
2018-04-01 17:34:57 +02:00
fi
else
if [ "${usbkey}" == "y" ]; then
2018-07-16 04:33:44 +02:00
sed -i 's/GRUB_CMDLINE_LINUX=.*$/GRUB_CMDLINE_LINUX="cryptdevice=PARTUUID='$tobootdevice':luks0 cryptkey=PARTUUID='$usbkeypartuuid':'$usbkeydateisystem':\/archkey nvidia-drm.modeset=1 splash"/' ${mountpoint}/etc/default/grub
2018-04-01 17:34:57 +02:00
else
2018-04-01 17:45:48 +02:00
sed -i 's/GRUB_CMDLINE_LINUX=.*$/GRUB_CMDLINE_LINUX="cryptdevice=PARTUUID='$tobootdevice':luks0 nvidia-drm.modeset=1 splash"/' ${mountpoint}/etc/default/grub
2018-04-01 17:34:57 +02:00
fi
fi
echo "GRUB_ENABLE_CRYPTODISK=y" >> ${mountpoint}/etc/default/grub
fi
else
if [ "${boot}" == "grub" ]; then
tobootdevice=$(blkid -s PARTUUID -o value ${device}${rootpartitionnummer})
if [ "${swap}" != "n" ]; then
swappartition=$(blkid -s PARTUUID -o value ${device}${swappartitionnummer})
2018-04-01 17:45:48 +02:00
sed -i 's/GRUB_CMDLINE_LINUX=.*$/GRUB_CMDLINE_LINUX="resume=PARTUUID='$swappartition' nvidia-drm.modeset=1 splash"/' ${mountpoint}/etc/default/grub
2018-04-01 17:34:57 +02:00
fi
fi
fi
2018-02-26 02:41:29 +01:00
}
function btrfsformat() {
if [ "$raid" == "raid0" ]; then
if [ "${verschluesselung}" == "y" ]; then
2018-06-09 07:14:38 +02:00
mkfs.btrfs -f -m raid0 -d raid0 ${deviceluks} ${device1}
2018-02-26 02:41:29 +01:00
else
mkfs.btrfs -f -m raid0 -d raid0 ${device}${rootpartitionnummer} ${device1}
fi
elif [ "$raid" == "raid1" ]; then
if [ "${verschluesselung}" == "y" ]; then
2018-06-09 07:14:38 +02:00
mkfs.btrfs -f -m raid1 -d raid1 ${deviceluks} ${device1}
2018-02-26 02:41:29 +01:00
else
mkfs.btrfs -f -m raid1 -d raid1 ${device}${rootpartitionnummer} ${device1}
fi
elif [ "$raid" == "raid10" ]; then
if [ "${verschluesselung}" == "y" ]; then
mkfs.btrfs -f -m raid10 -d raid10 ${deviceluks} ${device1}
else
mkfs.btrfs -f -m raid10 -d raid10 ${device}${rootpartitionnummer} ${device1}
fi
else
if [ "${verschluesselung}" == "y" ]; then
mkfs.btrfs -f -m single ${deviceluks}
else
mkfs.btrfs -f -m single ${device}${rootpartitionnummer}
fi
fi
btrfs filesystem show
}
function btrfsfstab() {
rootbind=$(blkid -s PARTUUID -o value ${device}${rootpartitionnummer})
if [ "${verschluesselung}" == "y" ]; then
echo -e "${deviceluks} / btrfs rw,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/ROOT 0 0" >> ${mountpoint}/etc/fstab
echo -e "${deviceluks} /home btrfs rw,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/home 0 0" >> ${mountpoint}/etc/fstab
echo -e "${deviceluks} /opt btrfs rw,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/opt 0 0" >> ${mountpoint}/etc/fstab
echo -e "${deviceluks} /var/cache/pacman/pkg btrfs rw,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/var/cache/pacman/pkg 0 0" >> ${mountpoint}/etc/fstab
# custom-mounts
for wort in ${mountsnaps}
do
echo -e "${deviceluks} ${wort} btrfs rw,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current${wort} 0 0" >> ${mountpoint}/etc/fstab
done
else
echo -e "PARTUUID=${rootbind} / btrfs rw,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/ROOT 0 0" >> ${mountpoint}/etc/fstab
echo -e "PARTUUID=${rootbind} /home btrfs rw,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/home 0 0" >> ${mountpoint}/etc/fstab
echo -e "PARTUUID=${rootbind} /opt btrfs rw,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/opt 0 0" >> ${mountpoint}/etc/fstab
echo -e "PARTUUID=${rootbind} /var/cache/pacman/pkg btrfs rw,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/var/cache/pacman/pkg 0 0" >> ${mountpoint}/etc/fstab
# custom-mounts
for wort in ${mountsnaps}
do
echo -e "PARTUUID=${rootbind} ${wort} btrfs rw,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current${wort} 0 0" >> ${mountpoint}/etc/fstab
done
fi
}
function btrfsmount() {
#[[ -z "${device}" ]] && device=${2}
if [ "${1}" == "1" ] || [ "${1}" == "" ]; then
if [ "${verschluesselung}" == "y" ]; then
mkdir -p /mnt/btrfs-root
mount -o defaults,noatime,nodiratime,space_cache,discard,ssd,compress=lzo ${deviceluks} /mnt/btrfs-root
else
mkdir -p /mnt/btrfs-root
mount -o defaults,noatime,nodiratime,space_cache,discard,ssd,compress=lzo ${device}${rootpartitionnummer} /mnt/btrfs-root
fi
fi
if [ "${1}" == "2" ] || [ "${1}" == "" ]; then
if [ "${verschluesselung}" == "y" ]; then
mkdir -p ${mountpoint}
mount -o defaults,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/ROOT ${deviceluks} ${mountpoint}
mkdir -p ${mountpoint}/home
mkdir -p ${mountpoint}/opt
mkdir -p ${mountpoint}/var/cache/pacman/pkg
mount -o defaults,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/home ${deviceluks} ${mountpoint}/home
mount -o defaults,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/opt ${deviceluks} ${mountpoint}/opt
mount -o defaults,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/var/cache/pacman/pkg ${deviceluks} ${mountpoint}/var/cache/pacman/pkg
# custom-mounts
for wort in ${mountsnaps}
do
mkdir -p ${mountpoint}${wort}
mount -o defaults,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current${wort} ${deviceluks} ${mountpoint}${wort}
done
mkdir -p ${mountpoint}/var/lib
mount --bind /mnt/btrfs-root/__current/ROOT/var/lib ${mountpoint}/var/lib
else
mkdir -p ${mountpoint}
mount -o defaults,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/ROOT ${device}${rootpartitionnummer} ${mountpoint}
mkdir -p ${mountpoint}/home
mkdir -p ${mountpoint}/opt
mkdir -p ${mountpoint}/var/cache/pacman/pkg
mount -o defaults,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/home ${device}${rootpartitionnummer} ${mountpoint}/home
mount -o defaults,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/opt ${device}${rootpartitionnummer} ${mountpoint}/opt
mount -o defaults,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current/var/cache/pacman/pkg ${device}${rootpartitionnummer} ${mountpoint}/var/cache/pacman/pkg
# custom-mounts
for wort in ${mountsnaps}
do
mkdir -p ${mountpoint}${wort}
mount -o defaults,noatime,nodiratime,space_cache,discard,ssd,compress=lzo,subvol=__current${wort} ${device}${rootpartitionnummer} ${mountpoint}${wort}
done
mkdir -p ${mountpoint}/var/lib
mount --bind /mnt/btrfs-root/__current/ROOT/var/lib ${mountpoint}/var/lib
fi
# boot mount
mkdir -p ${mountpoint}/boot
mount -t vfat ${device}${efipartitionnummer} ${mountpoint}/boot
fi
}
function subvolume() {
# Mount
btrfsmount 1
# Create
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-04-01 17:34:57 +02:00
mkdir -p /mnt/btrfs-root/__snapshot
mkdir -p /mnt/btrfs-root/__current
btrfs subvolume create /mnt/btrfs-root/__current/ROOT
btrfs subvolume create /mnt/btrfs-root/__current/home
btrfs subvolume create /mnt/btrfs-root/__current/opt
mkdir -p /mnt/btrfs-root/__current/var/cache/pacman
btrfs subvolume create /mnt/btrfs-root/__current/var/cache/pacman/pkg/
# custom-mounts
for wort in ${mountsnaps}
do
mkdir -p /mnt/btrfs-root/__current${wort%/*}
btrfs subvolume create /mnt/btrfs-root/__current${wort}
done
2018-04-01 17:15:12 +02:00
fi
2018-02-26 02:41:29 +01:00
btrfs subvolume list -p /mnt/btrfs-root
# Mount
btrfsmount 2
}
function update() {
#statements
local if="${1}"
local of="${2}"
local execute="${3}"
local parameters="${4}"
if [ -f "${of}" ]
then
rm ${of}
else
echo "${of} noch nicht vorhanden!"
fi
/usr/bin/curl -v -C - -f ${if} > ${of}
chmod 755 ${of}
${of} ${execute} ${parameters}
}
function systemdboot() {
tobootdeviceuuid=$(blkid -s PARTUUID -o value ${device}${rootpartitionnummer})
swappartitionpart=$(blkid -s PARTUUID -o value ${device}${swappartitionnummer})
# zurücksetzen der parameter
parameter=""
if [ "${swap}" != "n" ]; then
parameter="${parameter}resume=PARTUUID=${swappartitionpart} "
fi
if [ "${verschluesselung}" == "y" ]; then
tobootdevice=${deviceluks}
parameter="${parameter}cryptdevice=PARTUUID=${tobootdeviceuuid}:luks0 "
if [ "${usbkey}" == "y" ]; then
2018-07-16 04:33:44 +02:00
parameter="${parameter}cryptkey=PARTUUID=${usbkeypartuuid}:${usbkeydateisystem}:/archkey "
2018-02-26 02:41:29 +01:00
fi
else
tobootdevice="PARTUUID=${tobootdeviceuuid}"
fi
if [ "${dateisystem}" == "btrfs" ]; then
parameter="${parameter}rootflags=subvol=__current/ROOT "
fi
#rootsub=$(btrfs subvolume list /mnt | awk 'NR<0 && NR>2 {print $2}')
2018-05-03 15:35:31 +02:00
if [ "${version}" == "manjaro" ]; then
2018-05-06 01:29:06 +02:00
kernel1="$(find /boot/ -name "initramfs*$(uname -m).img")"
linuz1="$(find /boot/ -name "vmlinuz*$(uname -m)")"
kernel="${kernel1#/*/}"
linuz="${linuz1#/*/}"
kernelback1="$(find /boot/ -name "initramfs*$(uname -m)-fallback.img")"
kernelback="${kernelback1#/*/}"
2018-05-03 15:35:31 +02:00
else
2018-05-06 01:29:06 +02:00
kernel="initramfs-linux.img"
linuz="vmlinuz-linux"
kernelback="initramfs-linux-fallback.img"
2018-05-03 15:35:31 +02:00
fi
2018-02-26 02:41:29 +01:00
mkdir -p ${mountpoint}/boot/EFI/systemd/
mkdir -p ${mountpoint}/boot/EFI/BOOT/
cp ${mountpoint}/usr/lib/systemd/boot/efi/systemd-bootx64.efi ${mountpoint}/boot/EFI/systemd/systemd-bootx64.efi
cp ${mountpoint}/usr/lib/systemd/boot/efi/systemd-bootx64.efi ${mountpoint}/boot/EFI/BOOT/BOOTX64.EFI
mkdir -p ${mountpoint}/boot/loader/entries/
echo "title "${repo}"" > ${mountpoint}/boot/loader/entries/arch-uefi.conf
2018-05-03 15:35:31 +02:00
echo "linux /${linuz}" >> ${mountpoint}/boot/loader/entries/arch-uefi.conf
2018-02-26 02:41:29 +01:00
echo "initrd /intel-ucode.img" >> ${mountpoint}/boot/loader/entries/arch-uefi.conf
2018-05-03 15:35:31 +02:00
echo "initrd /${kernel}" >> ${mountpoint}/boot/loader/entries/arch-uefi.conf
2018-04-02 04:57:34 +02:00
echo "options root=${tobootdevice} rw ${parameter}quiet splash" >> ${mountpoint}/boot/loader/entries/arch-uefi.conf
2018-02-26 02:41:29 +01:00
echo "title "${repo}"" > ${mountpoint}/boot/loader/entries/arch-uefi-fallback.conf
2018-05-03 15:35:31 +02:00
echo "linux /${linuz}" >> ${mountpoint}/boot/loader/entries/arch-uefi-fallback.conf
2018-02-26 02:41:29 +01:00
echo "initrd /intel-ucode.img" >> ${mountpoint}/boot/loader/entries/arch-uefi-fallback.conf
2018-05-03 15:35:31 +02:00
echo "initrd /${kernelback}" >> ${mountpoint}/boot/loader/entries/arch-uefi-fallback.conf
2018-04-02 04:57:34 +02:00
echo "options root=${tobootdevice} rw ${parameter}quiet splash" >> ${mountpoint}/boot/loader/entries/arch-uefi-fallback.conf
2018-02-26 02:41:29 +01:00
echo "default arch-uefi" > ${mountpoint}/boot/loader/loader.conf
echo "timeout 1" >> ${mountpoint}/boot/loader/loader.conf
2018-05-05 00:20:09 +02:00
# update-bootloader
echo "title "${repo}"" > ${mountpoint}/boot/arch-uefi.conf.example
echo "linux /%LINUZ%" >> ${mountpoint}/boot/arch-uefi.conf.example
echo "initrd /intel-ucode.img" >> ${mountpoint}/boot/arch-uefi.conf.example
echo "initrd /%KERNEL%" >> ${mountpoint}/boot/arch-uefi.conf.example
echo "options root=${tobootdevice} rw ${parameter}quiet splash" >> ${mountpoint}/boot/arch-uefi.conf.example
2018-02-26 02:41:29 +01:00
if [ "${booteintraege}" != "n" ]; then
2018-03-05 16:53:39 +01:00
echo "Additional boot entries are created !!!"
2018-02-26 02:41:29 +01:00
arch-chroot ${mountpoint} efibootmgr -c -d ${device} -p 1 -l /EFI/systemd/systemd-bootx64.efi -L "Linux Boot Manager"
2018-05-10 03:47:10 +02:00
arch-chroot ${mountpoint} efibootmgr -c -d ${device} -p 1 -l \\${linuz} -L "Arch Linux efistub" -u "initrd=/${kernel} root=${tobootdevice} rw ${parameter}quiet splash"
2018-02-26 02:41:29 +01:00
fi
2018-05-10 03:33:14 +02:00
if [ "${version}" == "manjaro" ]; then
cp /opt/${repo}/update-bootloader ${mountpoint}/usr/bin/update-bootloader
chmod +x ${mountpoint}/usr/bin/update-bootloader
2018-05-10 03:47:10 +02:00
if ! grep '/usr/bin/update-bootloader' $RCLOCALSHUTDOWN; then
2018-05-10 03:54:44 +02:00
echo "/usr/bin/update-bootloader" >> $RCLOCALSHUTDOWN
2018-05-10 03:33:14 +02:00
fi
fi
2018-02-26 02:41:29 +01:00
}
function abfrage() {
# Lade Deutsches Tastaturlayout
loadkeys de
2018-03-05 16:53:39 +01:00
read -p "What's your name?: " name
2018-02-26 02:41:29 +01:00
[[ -z "${name}" ]] && name=arch-linux
# Partionierung
# UEFI oder Legacy-BIOS
echo ""
echo "UEFI = Unified Extensible Firmware Interface"
2018-03-05 16:53:39 +01:00
echo "Recommended for newer PCs"
echo "IMPORTANT FOR THIS MUST BE SELECTED IN THE BOAT MENU THE UEFI USB STICK OTHERWISE CAN NOT BE CREATED A UEFI BOAT ENTRY !!!"
2018-02-26 02:41:29 +01:00
echo ""
echo "BIOS = basic input/output system"
2018-03-05 16:53:39 +01:00
echo "Recommended for old PCs and portable USB sticks "
2018-02-26 02:41:29 +01:00
echo ""
2018-03-05 16:53:39 +01:00
echo "Please write down the entries: D !!!"
echo "For each yes you have to make a y and for every no an n, unless it is interpreted differently!!!"
2018-02-26 02:41:29 +01:00
echo ""
2018-06-28 15:10:05 +02:00
if mount | grep efi > /dev/null && [ -d /sys/firmware/efi/efivars/ ]; then
2018-03-05 16:53:39 +01:00
echo "System supports UEFI"
read -p "How would you like to have your hard drive partitioned?: [UEFI/bios] " Partition
2018-02-26 02:41:29 +01:00
[[ -z "${Partition}" ]] && Partition=uefi
else
2018-03-05 16:53:39 +01:00
echo "System supports not UEFI"
read -p "How would you like to have your hard drive partitioned?: [uefi/BIOS] " Partition
2018-02-26 02:41:29 +01:00
[[ -z "${Partition}" ]] && Partition=bios
fi
if [ "${Partition}" == "uefi" ]
then
2018-03-05 16:53:39 +01:00
read -p "Should be booted with systemd or with grub? [systemd/GRUB] : " boot
2018-02-26 02:41:29 +01:00
if [ "${boot}" == "systemd" ]; then
2018-03-05 16:53:39 +01:00
read -p "Should additional boot entries be created? [Y/n] : " booteintraege
2018-02-26 02:41:29 +01:00
fi
fi
[[ -z "${boot}" ]] && boot=grub
fdisk -l
2018-03-05 16:53:39 +01:00
read -p "Specify a hard disk: /dev/sda " device
2018-02-26 02:41:29 +01:00
[[ -z "${device}" ]] && device=/dev/sda
if [ "${device}" == "/dev/nvme0n1" ]; then
m2ssddevice=y
fi
2018-03-05 16:53:39 +01:00
read -p "Which file system should be used? [BTRFS/ext4] " dateisystem
2018-02-26 02:41:29 +01:00
[[ -z "${dateisystem}" ]] && dateisystem=btrfs
if [ "${dateisystem}" == "btrfs" ]; then
2018-03-05 16:53:39 +01:00
read -p "Should a raid be made ?: [raid0/raid1/raid10/n] " raid
2018-02-26 02:41:29 +01:00
[[ -z "${raid}" ]] && raid=n
if [ "${raid}" == "n" ]; then
2018-03-05 16:53:39 +01:00
echo "No raid is generated!"
2018-02-26 02:41:29 +01:00
else
fdisk -l
2018-03-05 16:53:39 +01:00
read -p "Please enter the disks in a row to be connected to a raid !!!: " device1
2018-02-26 02:41:29 +01:00
fi
2018-03-05 16:53:39 +01:00
echo "Standard snapshots / /home /opt /var/cache/pacman/pkg"
echo "The directories may not overlap otherwise there may be problems with the unmount !!!"
read -p "Should more snapshots be created ?: " mountsnaps
2018-02-26 02:41:29 +01:00
fi
2018-03-05 16:53:39 +01:00
read -p "Do you want to create a swap partition? : [Y/n] " swap
read -p "Do you want to create a swapfile? : [y/N] " swapfile
2018-02-26 02:41:29 +01:00
2018-06-14 13:30:42 +02:00
# if [ "${update}" != "n" ]; then
#
# echo "WARNING the system is not encrypted !!!"
# echo "WARNING The system will not start without the USB stick !!!"
# read -p "Should a USB stick be installed as the key for the system? : [y/N] " usbsecret
# if [ "${usbsecret}" == "y" ]; then
# read -p "Which USB stick should be selected for the USB-secret key ?: /dev/sdb1 " usbsecretdevice
# [[ -z "${usbsecretdevice}" ]] && device=/dev/sdb1
# usbsecretdeviceuuid=$(blkid -s PARTUUID -o value ${usbsecretdevice})
# [[ -z "${usbsecretdeviceuuid}" ]] && mkfs.ext4 ${usbsecretdevice}
# fi
# fi
2018-02-26 02:41:29 +01:00
if [ "${raid}" == "n" ]; then
2018-03-05 16:53:39 +01:00
read -p "Should the hard disk be encrypted? : [y/N] " verschluesselung
2018-02-26 02:41:29 +01:00
if [ "${verschluesselung}" == "y" ]; then
modprobe dm-crypt
2018-03-05 16:53:39 +01:00
read -p "Should an additional USB stick be created for decryption? : [y/N] " usbkey
2018-02-26 02:41:29 +01:00
if [ "${usbkey}" == "y" ]; then
2018-03-05 16:53:39 +01:00
read -p "Which USB stick should be selected ?: /dev/sdb1 " usbkeydevice
2018-02-26 02:41:29 +01:00
[[ -z "${usbkeydevice}" ]] && usbkeydevice=/dev/sdb1
usbkeydateisystem=$(blkid -s TYPE -o value ${usbkeydevice})
usbkeyuuid=$(blkid -s UUID -o value ${usbkeydevice})
2018-07-16 04:33:44 +02:00
usbkeypartuuid=$(blkid -s PARTUUID -o value ${usbkeydevice})
2018-02-26 02:41:29 +01:00
fi
fi
fi
# berechnungen
2018-05-06 01:29:06 +02:00
# if [ "${update}" != "n" ]; then
read -p "Should an offline installation be carried out? : [Y/n] " offline
if [ "${offline}" != "n" ]
then
install="offline"
else
install="online"
fi
# else
# install="offline"
# fi
2018-02-26 02:41:29 +01:00
2018-05-11 14:37:51 +02:00
read -p "Should you an disk added to your fstab? : [y/N] " autodisk
2018-05-12 13:32:32 +02:00
if [ "${autodisk}" == "y" ]
2018-05-11 12:52:42 +02:00
then
2018-05-11 14:37:51 +02:00
read -p "Which DISK stick should be selected ?: /dev/sdb1 /dev/sdc1 " autodiskdevice
2018-05-11 12:52:42 +02:00
[[ -z "${autodiskdevice}" ]] && autodiskdevice=/dev/sdb1
2018-05-11 14:37:51 +02:00
for wort in ${autodiskdevice}
do
echo "fstab ${wort} wird erstellt!!!"
2018-06-09 07:55:47 +02:00
autodiskdevicedateisystem=$(blkid -s TYPE -o value ${wort})
2018-07-16 01:11:15 +02:00
autodiskdeviceuuid=$(blkid -s PARTUUID -o value ${wort})
2018-05-11 14:37:51 +02:00
done
2018-05-11 12:52:42 +02:00
fi
2018-06-09 08:20:47 +02:00
read -p "Do you want to activate the VNC protocol? : [y/N] " x11vnc
2018-02-26 02:41:29 +01:00
2018-05-27 03:14:20 +02:00
if [ "${offline}" != "n" ]; then
read -p "Sould the system be started without a login? : [y/N] " autostart
[[ -z "${autostart}" ]] && autostart=n
fi
2018-05-25 23:09:58 +02:00
2018-07-16 00:48:06 +02:00
read -p "Do you want a extra parameter for the installation? : [skipbootpartition/noinstall/debug] " extraparameter
for wort in ${extraparameter}
do
echo "$wort"
2018-07-16 04:44:19 +02:00
set ${wort} y
2018-07-16 00:48:06 +02:00
done
2018-02-26 02:41:29 +01:00
# Ausgaben
# Dateisystem
if [ "${dateisystem}" == "btrfs" ]; then
mountpoint="/mnt/btrfs-current"
elif [ "${dateisystem}" == "ext4" ]; then
mountpoint="/mnt"
fi
#
2018-03-05 16:53:39 +01:00
echo "Surname: ${name}"
echo "partition type: ${Partition}"
2018-02-26 02:41:29 +01:00
echo "Bootloader: ${boot}"
2018-03-05 16:53:39 +01:00
echo "Drive: ${device}"
2018-02-26 02:41:29 +01:00
if [ "${raid}" != "n" ]; then
echo "Raid: ${raid}"
2018-03-05 16:53:39 +01:00
echo "Hard Drives: ${device1}"
2018-02-26 02:41:29 +01:00
fi
2018-03-05 16:53:39 +01:00
echo "File system: ${dateisystem}"
2018-02-26 02:41:29 +01:00
#echo "System-Partition ${speicher}"
#if [ "${swap}" != "n" ]; then
# echo "Swap-partition ${swapspeicher}"
#fi
#if [ "${swapfile}" == "y" ]; then
# echo "Swapfile ${swapfilespeicher}"
#fi
#echo "Rootpasswort: ${pass}"
echo "Architektur: $(uname -m)"
echo "Installation: ${install}"
if [ "${dateisystem}" == "btrfs" ]; then
for wort in ${mountsnaps}
do
echo "Snapshot ${wort} wird erstellt!!!"
done
fi
#if [ "${openvpn}" != "n" ]; then
# echo "VPN-Verschlüsselung: aktiv"
#fi
if [ "${usbsecret}" == "y" ]; then
echo "USB-secret: aktiv"
echo "USB-UIDD: ${usbsecretdeviceuuid}"
echo "USB-Label: ${usbsecretdevice}"
fi
if [ "${verschluesselung}" == "y" ]; then
2018-03-05 16:53:39 +01:00
echo "Fesptplatte with Luks 512KB encryption: aktiv"
2018-02-26 02:41:29 +01:00
if [ "${usbkey}" == "y" ]; then
2018-03-05 16:53:39 +01:00
echo "${usbkeydevice} is used as key for decrypting: "
echo "File system: ${usbkeydateisystem}"
2018-02-26 02:41:29 +01:00
fi
fi
2018-05-10 03:54:44 +02:00
RCLOCALSHUTDOWN="${mountpoint}/etc/rc.local.shutdown"
2018-05-10 03:47:10 +02:00
2018-02-26 02:41:29 +01:00
# Partitionierung
if [ "${m2ssddevice}" == "y" ]; then
m2ssd=p
fi
if [ "${dateisystem}" == "btrfs" ]; then
if [ "${Partition}" == "uefi" ]; then
bootpartitionnummer=${m2ssd}1
efipartitionnummer=${m2ssd}2
if [ "${swap}" != "n" ]; then
swappartitionnummer=${m2ssd}3
rootpartitionnummer=${m2ssd}4
else
rootpartitionnummer=${m2ssd}3
fi
elif [ "${Partition}" == "bios" ]; then
bootpartitionnummer=${m2ssd}1
efipartitionnummer=${m2ssd}2
if [ "${swap}" != "n" ]; then
swappartitionnummer=${m2ssd}3
rootpartitionnummer=${m2ssd}4
else
rootpartitionnummer=${m2ssd}3
fi
fi
elif [ "${dateisystem}" == "ext4" ]; then
if [ "${Partition}" == "uefi" ]; then
bootpartitionnummer=${m2ssd}1
efipartitionnummer=${m2ssd}2
if [ "${swap}" != "n" ]; then
swappartitionnummer=${m2ssd}3
rootpartitionnummer=${m2ssd}4
else
rootpartitionnummer=${m2ssd}3
fi
elif [ "${Partition}" == "bios" ]; then
bootpartitionnummer=${m2ssd}1
efipartitionnummer=${m2ssd}2
if [ "${swap}" != "n" ]; then
swappartitionnummer=${m2ssd}3
rootpartitionnummer=${m2ssd}4
else
rootpartitionnummer=${m2ssd}3
fi
fi
fi
2018-04-05 20:39:14 +02:00
deviceluks="/dev/mapper/luks0"
2018-02-26 02:41:29 +01:00
echo "Boot-Partition = ${device}${bootpartitionnummer}"
echo "EFI-Partition = ${device}${efipartitionnummer}"
if [ "${swap}" != "n" ]; then
echo "Swap-Partition = ${device}${swappartitionnummer}"
fi
echo "ROOT-Partition = ${device}${rootpartitionnummer}"
#
2018-03-05 16:53:39 +01:00
read -p "Are all the details correct ?: [y/N] " sicherheitsabfrage
2018-02-26 02:41:29 +01:00
if [ "$sicherheitsabfrage" != "y" ]
then
echo "ABGEBROCHEN"
exit 1
fi
2018-03-05 16:53:39 +01:00
echo "Operating system is installed !!!"
2018-02-26 02:41:29 +01:00
sleep 5
}
if [ "${1}" != "n" ]
then
2018-02-27 23:31:13 +01:00
if wget -qO- ipv4.icanhazip.com 1>/dev/null 2>&1; then
2018-03-05 16:53:39 +01:00
read -p "Should I look at the internet for a new install script and then run it ?: [Y/n] " update
2018-02-26 02:41:29 +01:00
if [ "${update}" == "debug" ]
then
2018-03-05 16:53:39 +01:00
echo "Skip the download a new script !!!"
2018-02-26 02:41:29 +01:00
else
if [ "${update}" != "n" ]
then
2018-05-06 01:17:45 +02:00
echo "Please dont update the linux kernel!!!"
2018-04-27 20:08:23 +02:00
if [ -f base.txt ]; then
2018-05-06 01:17:45 +02:00
pacman -Sy $(cat base.txt) --needed --ignore linux
2018-04-27 20:08:23 +02:00
elif [ -f /opt/${repo}/base.txt ]; then
2018-05-06 01:17:45 +02:00
pacman -Sy $(cat /opt/${repo}/base.txt) --needed --ignore linux
2018-02-26 02:41:29 +01:00
else
2018-04-27 20:08:23 +02:00
echo "Kann keine neuen Packete nachinstallieren weil die base.txt nicht gefunden werden kann!!"
echo "Es kann sein das dass Programm nicht korrekt funktioniert!!!"
2018-02-26 02:41:29 +01:00
fi
2018-03-22 23:48:58 +01:00
gitclone
2018-02-27 22:53:24 +01:00
/opt/${repo}/arch-install n ${version}
2018-02-26 02:41:29 +01:00
exit 0
fi
fi
else
2018-03-05 16:53:39 +01:00
echo "No internet connection detected!"
2018-02-26 02:41:29 +01:00
update=n
fi
fi
if [ "${update}" != "n" ]; then
2018-03-05 16:53:39 +01:00
echo "Online-Modus activated!"
2018-02-26 02:41:29 +01:00
#vpntunnel
fi
# debug = Installation ueberspringen zu arch-graphical-install und DEBEUG-MODUS
abfrage
secureumount
2018-07-16 00:48:06 +02:00
if [ "y" == "debug" ] || [ "y" == "noinstall" ]
2018-02-26 02:41:29 +01:00
then
echo "DEBEUG-MODUS"
2018-03-05 16:53:39 +01:00
echo "If no more commands are required, simply press enter"
echo "Which command should be executed? "
2018-02-26 02:41:29 +01:00
befehl=blablabla
while [ "$befehl" != "" ]
do
read -p "" befehl
$befehl
done
fi
#
2018-03-05 16:53:39 +01:00
echo "A purge stops the chance of installing on the system."
echo "It may take a while!"
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-04-01 17:34:57 +02:00
dd if=/dev/zero of=${device} bs=64M count=10 status=progress
2018-04-01 16:52:36 +02:00
fi
2018-02-26 02:41:29 +01:00
#
if [ "${Partition}" == "uefi" ]
then
2018-03-05 16:53:39 +01:00
echo "Partitions with UEFI"
2018-02-26 02:41:29 +01:00
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-07-16 02:45:11 +02:00
if [ "${skipbootpartition}" == "y" ] && [ "${swap}" != "n" ]; then
partitioniereonepartitionmitswap
elif [ "${skipbootpartition}" == "y" ]; then
2018-07-16 00:48:06 +02:00
partitioniereonepartition
elif [ "${swap}" != "n" ]; then
2018-04-01 17:34:57 +02:00
echo "Create additional swap partition"
partionierenmitswap
else
partionierenohneswap
fi
2018-04-05 20:39:14 +02:00
else
2018-04-05 21:03:30 +02:00
if [ "${verschluesselung}" == "y" ]; then
2018-04-06 17:09:08 +02:00
mountencrypt
2018-04-05 21:03:30 +02:00
fi
2018-02-26 02:41:29 +01:00
fi
2018-04-01 16:45:09 +02:00
2018-04-01 17:15:12 +02:00
echo "installation"
installation
2018-04-01 16:48:56 +02:00
grubinstall
2018-04-01 16:45:09 +02:00
2018-05-03 16:08:01 +02:00
if [ "${version}" == "libre" ]; then
2018-04-01 17:34:57 +02:00
arch-chroot ${mountpoint} mkinitcpio -p linux-libre
2018-04-01 16:45:09 +02:00
else
2018-05-03 13:59:43 +02:00
arch-chroot ${mountpoint} mkinitcpio -P -c /etc/mkinitcpio.conf
2018-04-01 16:45:09 +02:00
fi
2018-02-26 02:41:29 +01:00
echo ""
if [ "${boot}" == "grub" ]
then
arch-chroot ${mountpoint} grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id="${repo}" --recheck
arch-chroot ${mountpoint} grub-mkconfig -o /boot/grub/grub.cfg
else
systemdboot
fi
#removeinstaller
2018-03-05 16:53:39 +01:00
echo "Finished"
2018-02-26 02:41:29 +01:00
elif [ "${Partition}" == "bios" ]; then
2018-03-05 16:53:39 +01:00
echo "Partitions with MBR"
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ]; then
2018-07-16 02:45:11 +02:00
if [ "${skipbootpartition}" == "y" ] && [ "${swap}" != "n" ]; then
partitioniereonepartitionmitswap
elif [ "${skipbootpartition}" == "y" ]; then
2018-07-16 00:48:06 +02:00
partitioniereonepartition
elif [ "${swap}" != "n" ]; then
2018-04-01 17:34:57 +02:00
echo "Create additional swap partition"
partionierenmitswap
else
partionierenohneswap
fi
2018-04-05 20:39:14 +02:00
else
2018-04-05 21:03:30 +02:00
if [ "${verschluesselung}" == "y" ]; then
2018-04-06 17:09:08 +02:00
mountencrypt
2018-04-05 21:03:30 +02:00
fi
2018-02-26 02:41:29 +01:00
fi
2018-04-01 16:45:09 +02:00
2018-04-01 17:15:12 +02:00
echo "installation"
installation
2018-04-01 16:48:56 +02:00
grubinstall
2018-04-01 16:45:09 +02:00
2018-05-03 16:08:01 +02:00
if [ "${version}" == "libre" ]; then
2018-04-01 17:34:57 +02:00
arch-chroot ${mountpoint} mkinitcpio -p linux-libre
2018-04-01 16:45:09 +02:00
else
2018-05-03 16:08:01 +02:00
arch-chroot ${mountpoint} mkinitcpio -P linux -c /etc/mkinitcpio.conf
2018-04-01 16:45:09 +02:00
fi
2018-02-26 02:41:29 +01:00
arch-chroot ${mountpoint} grub-install --target=i386-pc --recheck ${device}
arch-chroot ${mountpoint} grub-mkconfig -o /boot/grub/grub.cfg
#removeinstaller
2018-03-05 16:53:39 +01:00
echo "Finished"
2018-02-26 02:41:29 +01:00
else
2018-03-05 16:53:39 +01:00
echo "Entry Invalid"
2018-02-26 02:41:29 +01:00
exit 1
fi
if [ "${x11vnc}" == "y" ]; then
2018-03-05 16:53:39 +01:00
echo "Please enter a password for the VNC protocol!"
2018-02-26 02:41:29 +01:00
arch-chroot ${mountpoint} x11vnc -storepasswd /etc/x11vnc.pass
2018-03-04 18:50:24 +01:00
arch-chroot ${mountpoint} systemctl enable x11vnc.service
else
arch-chroot ${mountpoint} systemctl disable x11vnc.service
2018-02-26 02:41:29 +01:00
fi
2018-04-11 18:01:17 +02:00
# benutzerwechsel
2018-07-16 00:48:06 +02:00
if [ "y" != "noinstall" ] && [ -z "${installationsfehler}" ]; then
2018-04-18 00:01:10 +02:00
#arch-chroot ${mountpoint} usermod -l "${name}" user1
#arch-chroot ${mountpoint} usermod -d /home/"${name}" -m "${name}"
arch-chroot ${mountpoint} chfn -f "${name}" user1
arch-chroot ${mountpoint} passwd user1
2018-05-04 05:55:49 +02:00
2018-05-27 03:24:22 +02:00
if [ -f ${mountpoint}/usr/bin/lightdm ]; then
2018-05-26 03:00:13 +02:00
mkdir -p ${mountpoint}/etc/lightdm/
cp /opt/${repo}/Xsession /opt/${repo}/keys.conf /opt/${repo}/lightdm-gtk-greeter.conf /opt/${repo}/lightdm.conf /opt/${repo}/users.conf ${mountpoint}/etc/lightdm/
if [ "${autostart}" == "n" ]; then
2018-05-25 23:09:58 +02:00
arch-chroot ${mountpoint} systemctl enable lightdm-plymouth.service
fi
2018-05-26 03:00:13 +02:00
else
echo "lightdm nicht vorhanden!!!"
2018-05-04 05:55:49 +02:00
fi
2018-04-11 18:01:17 +02:00
fi
2018-04-25 08:09:12 +02:00
if [ "${update}" != "n" ] && [ "${offline}" == "n" ] || [ -n "${installationsfehler}" ]; then
2018-03-05 16:53:39 +01:00
read -p "Should the extended installation be carried out? [Y/n] " graphical
2018-02-26 02:41:29 +01:00
if [ "$graphical" != "n" ]
then
2018-02-27 22:53:24 +01:00
cp /opt/${repo}/arch-graphical-install-auto ${mountpoint}/root/arch-graphical-install-auto
2018-05-27 03:36:07 +02:00
arch-chroot ${mountpoint} /root/arch-graphical-install-auto ${version}
2018-02-26 02:41:29 +01:00
fi
fi
echo "df!!!"
df -h
if [ "${dateisystem}" == "btrfs" ]; then
btrfs filesystem df ${mountpoint}
fi
echo "umount!!!"
sleep 5
secureumount
echo ""
echo "Fertig!!!"
2018-03-05 16:53:39 +01:00
read -p "allation completed successfully. Do you want to RESTART the PC ?: [Y/n] " sicherheitsabfrage
2018-02-26 02:41:29 +01:00
if [ "$sicherheitsabfrage" != "n" ]
then
2018-03-05 16:53:39 +01:00
echo "restart now"
2018-02-26 02:41:29 +01:00
reboot
fi
exit 0