8ac4a27d7fd7175d9bac221d2e8a0034411904f1
[automated-distro-installer] / fai / config / class / 50-host-classes
1 #!/bin/bash -l
2
3 # assign classes to hosts based on their hostname
4
5 # do not use this if a menu will be presented
6 [ "$flag_menu" ] && exit 0
7
8
9 # For multi-boot system.
10 # We check that we aren't in a pxe boot environment.
11 # There is probably a better way to do this.
12 # We check the reverse condition in 51-multi-boot,
13 # and set what os we are installing, but don't check it
14 # into git since it changes regularly.
15 # It's code looks like this:
16 # if [[ ! -e /a/bin/fai/fai-wrapper ]]; then
17 # case $HOSTNAME in
18 # tp) DEBIAN STRETCH VOL_STRETCH STRETCH_FREE;;
19 # # add more multi-boot hostnames here
20 # esac
21 # fi
22 #
23 #
24 # Each host defines following:
25 # The base distro:
26 # UBUNTU, DEBIAN
27 #
28 # The base disto version, which is also the basefile name if it exists:
29 # STRETCH64, XENIAL64, BELENOS64, FLIDAS64
30 #
31 # The distro subvol name, we can add as many of these as we want:
32 # VOL_TESTING, VOL_STRETCH, VOL_XENIAL, VOL_BELENOS, VOL_FLIDAS, VOL_STRETCH_BOOTSTRAP
33 # Using VOL_STRETCH_BOOTSTRAP sets up the install to act like a pxe rom if
34 # grub sets a specific var.
35 #
36 # The apt sources files we want,
37 # STRETCH_FREE, STRETCH_NONFREE, TESTING_FREE, TESTING_NONFREE,
38 # XENIAL_FREE, FLIDAS, BELENOS, STRETCH_LINODE.
39 #
40 # It's all a little redundant in some cases, but it keeps things
41 # simpler. Belenos is broken right now, planning to remove it once
42 # flidas is released.
43 #
44 #
45 # Other notable classes:
46 #
47 # REPARTITION: we try to reuse partitions/filesystems to install a new
48 # os into a multi-os system, if we see some basic hueristics, like the
49 # right amount of them. This overrides that.
50 #
51 # PARTITION_PROMPT: If we don't see partitions to reuuse, prompt
52 # to make sure we really want to repartition and use a completely
53 # fresh install. I use this in case our repartition check has
54 # a bug in it, or I accidentally set REPARTITION.
55 #
56 # ROTATIONAL: in a system with ssd and hdd, install to the hdd
57 # instead of the default ssd.
58 #
59 # RAID0: Use raid 0 even if there are >= 4 disks with boot partititions.
60 #
61 #
62 if [[ -e /a/bin/fai/fai-wrapper ]]; then
63 source /a/bin/distro-functions/src/identify-distros
64 if isdebian; then
65 echo "DEBIAN"
66 fi
67 if isdebian-stable; then
68 echo "STRETCH"
69 case $HOSTNAME in
70 li|lj) echo "STRETCH_LINODE" ;;
71 *)
72 # nonfree repo is not going away any time soon due to
73 # gcc-doc being in nonfree
74 echo "STRETCH_NONFREE"
75 ;;
76 esac
77 elif isdebian-testing; then
78 echo "TESTING_NONFREE"
79 fi
80 fi
81
82 echo "FAIBASE"
83
84 echo "PARTITION_PROMPT"
85 #echo REPARTITION
86
87
88 if grep ^52:54:00: /sys/class/net/eth0/address &>/dev/null; then
89 # if our eth0 mac is in the kvm range, we are a vm.
90 echo "VM"
91 fi