various fixes
[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 # DESKTOP: install a bunch of extra packages. For creating X suffix
45 # basefiles. See README.
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 # Code in 51-multi-boot, with reasonable combinations of above
63 # uncommented for easier editing, and runs as a noop until
64 # we replace _ with host names.
65 if [[ ! -e /a/bin/fai/fai-wrapper ]]; then
66 case $HOSTNAME in
67 # stretch based minimal recovery / bootstraping os:
68 _) echo DEBIAN STRETCH64 VOL_STRETCH_BOOTSTRAP STRETCH_NONFREE ;;
69 # flidas
70 _) echo UBUNTU FLIDAS64 VOL_FLIDAS FLIDAS ;;
71 # stretch
72 _) echo DEBIAN STRETCH64 VOL_STRETCH STRETCH_NONFREE ;;
73 # testing
74 _) echo DEBIAN STRETCH64 VOL_TESTING TESTING_NONFREE ;;
75 # belenos
76 _) echo UBUNTU BELENOS64 VOL_BELENOS BELENOS ;;
77 # xenial
78 _) echo UBUNTU XENIAL64 VOL_XENIAL XENIAL_FREE ;;
79 esac
80 fi
81
82 if [[ -e /a/bin/fai/fai-wrapper ]]; then
83 source /a/bin/distro-functions/src/identify-distros
84 if isdebian; then
85 echo "DEBIAN"
86 fi
87 if isdebian-stable; then
88 echo "STRETCH"
89 case $HOSTNAME in
90 li|lj) echo "STRETCH_LINODE" ;;
91 *)
92 # nonfree repo is not going away any time soon due to
93 # gcc-doc being in nonfree
94 echo "STRETCH_NONFREE"
95 ;;
96 esac
97 elif isdebian-testing; then
98 echo "TESTING_NONFREE"
99 fi
100 fi
101
102 echo "FAIBASE"
103
104 echo "PARTITION_PROMPT"
105 #echo REPARTITION
106
107
108 if grep ^52:54:00: /sys/class/net/eth0/address &>/dev/null; then
109 # if our eth0 mac is in the kvm range, we are a vm.
110 echo "VM"
111 fi