fixes plus readme updates
[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
16 #
17 #
18 # Each host defines following:
19 # The base distro:
20 # UBUNTU, DEBIAN
21 #
22 # The base disto version, only use so far is the basefile name if it exists.
23 # Debian stable basefile gets built by faisetup and gets used otherwise.
24 # With X suffix, means it has gone through the dirinstall process and has eXtra
25 # things installed, to speed up installation.
26 # STRETCH64, XENIAL64, BELENOS64, FLIDAS64, FLIDAS64X
27 #
28 # The distro subvol name, we can add as many of these as we want:
29 # VOL_TESTING, VOL_STRETCH, VOL_XENIAL, VOL_BELENOS, VOL_FLIDAS, VOL_STRETCH_BOOTSTRAP
30 # Using VOL_STRETCH_BOOTSTRAP sets up the install to act like a pxe rom if
31 # grub sets a specific var.
32 #
33 # The apt sources files we want,
34 # STRETCH_FREE, STRETCH_NONFREE, TESTING_FREE, TESTING_NONFREE,
35 # XENIAL_FREE, FLIDAS, BELENOS, STRETCH_LINODE.
36 #
37 # It's all a little redundant in some cases, but it keeps things
38 # simpler. Belenos is broken right now, planning to remove it once
39 # flidas is released and rms has upgraded.
40 #
41 #
42 # Other notable classes:
43 #
44 # INSTALL: for autodiscover iso, this is needed. We could also add it to
45 # the autodiscover grub, but then we have to burn a new iso if we want a
46 # non-install one. It sets the class for the corresponding INSTALL.var,
47 # which sets FAI_ACTION=INSTALL. I'm not sure if this variable overrides
48 # FAI_ACTION outside of autodiscover, todo: test it out, if it doesn't,
49 # make install be default in 51-multi-boot, and disable it if needed.
50 #
51 # DESKTOP: install a bunch of extra packages. For creating X suffix
52 # basefiles. See README.
53 #
54 # REPARTITION: we try to reuse partitions/filesystems to install a new
55 # os into a multi-os system, if we see some basic hueristics, like the
56 # right amount of them. This overrides that.
57 #
58 # PARTITION_PROMPT: If we don't see partitions to reuuse, prompt
59 # to make sure we really want to repartition and use a completely
60 # fresh install. I use this in case our repartition check has
61 # a bug in it, or I accidentally set REPARTITION.
62 #
63 # ROTATIONAL: in a system with ssd and hdd, install to the hdd
64 # instead of the default ssd.
65 #
66 # RAID0: Use raid 0 even if there are >= 4 disks with boot partititions.
67 #
68 #
69 # Code in 51-multi-boot, with reasonable combinations of above
70 # uncommented for easier editing, and runs as a noop until
71 # we replace _ with host names.
72 if [[ ! -e /a/bin/fai/fai-wrapper ]]; then
73 case $HOSTNAME in
74 # stretch based minimal recovery / bootstraping os:
75 _) echo DEBIAN STRETCH64 VOL_STRETCH_BOOTSTRAP STRETCH_NONFREE ;;
76 # flidas
77 _) echo UBUNTU FLIDAS64 VOL_FLIDAS FLIDAS ;;
78 # stretch
79 _) echo DEBIAN STRETCH64 VOL_STRETCH STRETCH_NONFREE ;;
80 # testing
81 _) echo DEBIAN STRETCH64 VOL_TESTING TESTING_NONFREE ;;
82 # belenos
83 _) echo UBUNTU BELENOS64 VOL_BELENOS BELENOS ;;
84 # xenial
85 _) echo UBUNTU XENIAL64 VOL_XENIAL XENIAL_FREE ;;
86 esac
87 fi
88
89 if [[ -e /a/bin/fai/fai-wrapper ]]; then
90 source /a/bin/distro-functions/src/identify-distros
91 if isdebian; then
92 echo "DEBIAN"
93 fi
94 if isdebian-stable; then
95 echo "STRETCH"
96 case $HOSTNAME in
97 li|lj) echo "STRETCH_LINODE" ;;
98 *)
99 # nonfree repo is not going away any time soon due to
100 # gcc-doc being in nonfree
101 echo "STRETCH_NONFREE"
102 ;;
103 esac
104 elif isdebian-testing; then
105 echo "TESTING_NONFREE"
106 fi
107 fi
108
109 echo "FAIBASE"
110
111 echo "PARTITION_PROMPT"
112 #echo REPARTITION
113
114
115 if grep ^52:54:00: /sys/class/net/eth0/address &>/dev/null; then
116 # if our eth0 mac is in the kvm range, we are a vm.
117 echo "VM"
118 fi