ed1d3522a32f2822fd629a8ca650da895215ed65
[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, FLIDAS64BIG
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
70 ###### begin Template for 51-multi-boot ######
71 #
72 # It has reasonable combinations of above classes.
73 # It's a noop until we replace _ with host names.
74
75 #!/bin/bash
76 if [[ ! -e /a/bin/fai/fai-wrapper || $FAI_ACTION == dirinstall ]]; then
77 case $HOSTNAME in
78 # stretch based minimal recovery / bootstraping os:
79 _) echo DEBIAN STRETCH64 VOL_STRETCH_BOOTSTRAP STRETCH_FREE ;;
80 # flidas
81 _) echo UBUNTU FLIDAS64 VOL_FLIDAS FLIDAS ;;
82 # stretch
83 _) echo DEBIAN STRETCH64 VOL_STRETCH STRETCH_NONFREE ;;
84 # testing
85 _) echo DEBIAN STRETCH64 VOL_TESTING TESTING_NONFREE ;;
86 # belenos
87 _) echo UBUNTU BELENOS64 VOL_BELENOS BELENOS ;;
88 # xenial
89 _) echo UBUNTU XENIAL64 VOL_XENIAL XENIAL_FREE ;;
90 esac
91 fi
92 ###### end Template for 51-multi-boot ######
93
94 if [[ -e /a/bin/fai/fai-wrapper ]]; then
95 source /a/bin/distro-functions/src/identify-distros
96 if isdebian; then
97 echo "DEBIAN"
98 fi
99 if isdebian-stable; then
100 echo "STRETCH"
101 case $HOSTNAME in
102 li|lj) echo "STRETCH_LINODE" ;;
103 *)
104 # nonfree repo is not going away any time soon due to
105 # gcc-doc being in nonfree
106 echo "STRETCH_NONFREE"
107 ;;
108 esac
109 elif isdebian-testing; then
110 echo "TESTING_NONFREE"
111 fi
112 fi
113
114 echo "STANDARD"
115
116 #echo "PARTITION_PROMPT"
117 #echo REPARTITION
118
119
120 if grep ^52:54:00: /sys/class/net/eth0/address &>/dev/null; then
121 # if our eth0 mac is in the kvm range, we are a vm.
122 echo "VM"
123 fi