From 08420220e949029a0d2e211edcc93c0701b23429 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Mon, 22 Feb 2016 01:48:06 -0800 Subject: [PATCH] disk detection, fixes for deb stable --- fai/config/class/50-host-classes | 6 +-- fai/config/files/etc/apt/preferences/STABLE | 20 +++++++++ fai/config/files/etc/apt/sources.list/STABLE | 11 +++++ fai/config/hooks/partition.DEFAULT | 46 +++++++++++--------- fai/config/package_config/DESKTOP | 16 ------- fai/config/scripts/GRUB_PC/11-ian | 12 ++++- 6 files changed, 71 insertions(+), 40 deletions(-) create mode 100644 fai/config/files/etc/apt/preferences/STABLE delete mode 100644 fai/config/package_config/DESKTOP diff --git a/fai/config/class/50-host-classes b/fai/config/class/50-host-classes index 6540dfc..e38fa58 100755 --- a/fai/config/class/50-host-classes +++ b/fai/config/class/50-host-classes @@ -8,11 +8,11 @@ # use a list of classes for our demo machine case $HOSTNAME in demohost) - echo "FAIBASE DEBIAN DESKTOP TWO_DISK STABLE" ;; + echo "FAIBASE DEBIAN DESKTOP STABLE" ;; x2) - echo "FAIBASE DEBIAN DESKTOP ONE_DISK STABLE" ;; + echo "FAIBASE DEBIAN DESKTOP STABLE" ;; tp) - echo "FAIBASE DEBIAN DESKTOP TWO_DISK" ;; + echo "FAIBASE DEBIAN DESKTOP" ;; # faiserver) # echo "FAIBASE DEBIAN DEMO FAISERVER" ;; # xfcehost) diff --git a/fai/config/files/etc/apt/preferences/STABLE b/fai/config/files/etc/apt/preferences/STABLE new file mode 100644 index 0000000..85b26ab --- /dev/null +++ b/fai/config/files/etc/apt/preferences/STABLE @@ -0,0 +1,20 @@ +Explanation: https://debian-handbook.info/browse/stable/sect.apt-get.html#sect.apt.priorities +Explanation: And man apt_preferences +Explanation: Installed packages get 100 priority, so this won't upgrade testing +Explanation: packages unless explicitly asked to. +Explanation: Install with apt-get install package/testing. But if dependencies are +Explanation: needed, or need upgrading, +Explanation: apt-get -t testing package, setting testing to priority +Explanation: 990 just for that command. +Explanation: Use apt-cache policy to verify these settings. +Package: * +Pin: release a=testing +Pin-Priority: 50 + +Package: * +Pin: release a=testing-updates +Pin-Priority: 50 + +Explanation: Allow this testing package to automatically upgrade. +Package: unison +Pin-Piority: 100 diff --git a/fai/config/files/etc/apt/sources.list/STABLE b/fai/config/files/etc/apt/sources.list/STABLE index 564098c..fb11f69 100644 --- a/fai/config/files/etc/apt/sources.list/STABLE +++ b/fai/config/files/etc/apt/sources.list/STABLE @@ -9,3 +9,14 @@ deb-src http://security.debian.org/ jessie/updates main # jessie-updates, previously known as 'volatile' deb http://http.us.debian.org/debian jessie-updates main deb-src http://http.us.debian.org/debian jessie-updates main + + +deb http://http.us.debian.org/debian testing main +deb-src http://http.us.debian.org/debian testing main + +deb http://security.debian.org/ testing/updates main +deb-src http://security.debian.org/ testing/updates main + +# jessie-updates, previously known as 'volatile' +deb http://http.us.debian.org/debian testing-updates main +deb-src http://http.us.debian.org/debian testing-updates main diff --git a/fai/config/hooks/partition.DEFAULT b/fai/config/hooks/partition.DEFAULT index 81475f2..0739e91 100755 --- a/fai/config/hooks/partition.DEFAULT +++ b/fai/config/hooks/partition.DEFAULT @@ -10,31 +10,39 @@ skiptask partition || ! type skiptask # for running not in fai #### begin configuration -partition=false # change to true to force a full wipe +partition=true # change to true to force a full wipe bootn=3 rootn=1 swapn=2 bios_grubn=4 boot_mib=1500 + + +##### end configuration + lastn=$bios_grubn -if ifclass VM; then - d=vd -else - d=sd -fi -letters=() -if ifclass TWO_DISK; then - letters=(a b) -elif ifclass ONE_DISK; then - letters=(a) -elif ifclass MANY_DISK; then - for dev in /dev/${d}?; do letters+=(${dev#/dev/${d}}); done +hds=() +ssds=() +cd /sys/block +for disk in [sv]d[a-z]; do + case $(cat $disk/queue/rotational) in + 0) ssds+=(/dev/$disk) ;; + 1) hds+=(/dev/$disk) ;; + *) echo "$0: error: unknown /sys/block/$disk/queue/rotational: \ +$(cat $disk/queue/rotational)"; exit 1 ;; + esac +done + +# install all ssds, or if there are none, all hdds +if (( ${#ssds[@]} > 0 )); then + devs=( ${ssds[@]} ) else - exit 1 + devs=( ${hds[@]} ) fi + if [[ ! $DISTRO ]]; then if ifclass STABLE; then DISTRO=debianjessie @@ -43,7 +51,6 @@ if [[ ! $DISTRO ]]; then fi fi -##### end configuration bpart() { # btrfs a partition @@ -54,13 +61,12 @@ bpart() { # btrfs a partition esac } -devs=(${letters[@]/#//dev/${d}}) -crypt_devs=(${letters[@]/#//dev/mapper/crypt_dev_${d}}) first_boot_dev=${devs[0]}$bootn - +crypt_devs=() # somewhat crude detection of whether to partition for dev in ${devs[@]}; do + crypt_devs+=( /dev/mapper/crypt_dev_${dev#/dev/} ) x=($dev[0-9]) [[ ${#x[@]} == ${lastn} ]] || partition=true for (( i=1; i <= $lastn; i++ )); do @@ -85,7 +91,7 @@ if ifclass demohost; then fi -crypt=/dev/mapper/crypt_dev_${d##/dev/}a$rootn +crypt=${crypt_devs[0]}$rootn bios_grub_end=4 # 1.5 x based on https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/sect-disk-partitioning-setup-x86.html#sect-custom-partitioning-x86 @@ -180,7 +186,7 @@ for x in root/a q/a; do done # could set default like this, but no reason to. # btrfs subvolume set-default \ -# $(btrfs subvolume list . | grep "root_$DISTRO$" | awk '{print $2}') . + # $(btrfs subvolume list . | grep "root_$DISTRO$" | awk '{print $2}') . chattr -Rf +C root_$DISTRO cd / umount /mnt diff --git a/fai/config/package_config/DESKTOP b/fai/config/package_config/DESKTOP deleted file mode 100644 index b2d8d1a..0000000 --- a/fai/config/package_config/DESKTOP +++ /dev/null @@ -1,16 +0,0 @@ -# unison version compat: -# deb/ubuntu, it depends what version they have. -# arch and fedora have unison240 and unison-240-compat respectively, -# but that failed to sync with an ubuntu 12.04 which had unson 2.40, -# so I installed latest stable manualy - -# wget http://caml.inria.fr/pub/distrib/ocaml-4.02/ocaml-4.02.3.tar.gz -# ./configure -# make world opt -# s make install - -# wget http://www.seas.upenn.edu/~bcpierce/unison//download/releases/stable/unison-2.48.3.tar.gz -# make -# s cp unison /usr/local/bin -PACKAGES install -unison diff --git a/fai/config/scripts/GRUB_PC/11-ian b/fai/config/scripts/GRUB_PC/11-ian index cca3493..6823a0b 100755 --- a/fai/config/scripts/GRUB_PC/11-ian +++ b/fai/config/scripts/GRUB_PC/11-ian @@ -6,10 +6,17 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?"' ERR $ROOTCMD adduser --disabled-password --gecos ian ian $ROOTCMD usermod -p "$ROOTPW" ian +if ifclass STABLE; then + fcopy -M /etc/apt/preferences +fi -fcopy -rM -i /home/ian/.ssh + +# -i, ignore nonmatching class error, always return 0. +fcopy -r -M -i /home/ian/.ssh /var/lib/fai/config/distro-install-common/end + +# could also use: chroot /target script-file $ROOTCMD chown -R 1000:1000 /home/ian/.ssh $ROOTCMD chmod -R u=Xrw,og= /home/ian/.ssh $ROOTCMD cp -ar /home/ian/.ssh /root @@ -17,3 +24,6 @@ $ROOTCMD chown -R root:root /root/.ssh # default jessie groups + kvm & systemd-journal $ROOTCMD usermod -aG cdrom,floppy,sudo,audio,dip,video,plugdev,netdev,kvm,systemd-journal ian + + +$ROOTCMD apt-get -y install unison/testing -- 2.30.2