61a55934d0054397c6c89c073942d5aca3f3e7ee
[automated-distro-installer] / fai / config / class / 50-host-classes
1 #!/bin/bash
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 # set these early so they are lowest priority.
9 echo FAIBASE STANDARD DEBIAN
10
11
12 # For multi-boot system.
13 # We check that we aren't in a pxe boot environment.
14 # There is probably a better way to do this.
15 # We check the reverse condition in 51-multi-boot,
16 # and set what os we are installing, but don't check it
17 # into git since it changes regularly.
18
19 #
20 #
21 # Each host defines following:
22 # The base distro:
23 # UBUNTU or nothing. DEBIAN is always defined as a base.
24 #
25 # The base disto version, only use so far is the basefile name if it exists.
26 # Debian stable basefile gets built by faisetup and gets used otherwise.
27 # With X suffix, means it has gone through the dirinstall process and has eXtra
28 # things installed, to speed up installation.
29 # STRETCH64, BUSTER64, XENIAL64, FLIDAS64, FLIDAS64BIG, ETIONA64, BIONIC64, FOCAL64
30 #
31 # The distro subvol name, we can add as many of these as we want:
32 # VOL_TESTING, VOL_STRETCH, VOL_BUSTER, VOL_XENIAL, VOL_FLIDAS,
33 # VOL_ETIONA VOL_STRETCH_BOOTSTRAP. Using VOL_STRETCH_BOOTSTRAP sets up
34 # the install to act like a pxe rom if grub sets a specific var.
35 #
36 # The apt sources files we want, STRETCH_FREE, STRETCH_NONFREE,
37 # BUSTER_FREE, BUSTER_NONFREE, TESTING_FREE, TESTING_NONFREE,
38 # XENIAL_FREE, BIONIC, FOCAL, FLIDAS, ETIONA, STRETCH_LINODE.
39 #
40 # It's all a little redundant in some cases, but it keeps things
41 # simpler.
42 #
43 #
44 # Other notable classes:
45 #
46 # INSTALL: for autodiscover iso, this is needed. We could also add it to
47 # the autodiscover grub, but then we have to burn a new iso if we want a
48 # non-install one. It sets the class for the corresponding INSTALL.var,
49 # which sets FAI_ACTION=INSTALL. I'm not sure if this variable overrides
50 # FAI_ACTION outside of autodiscover, todo: test it out, if it doesn't,
51 # make install be default in 51-multi-boot, and disable it if needed.
52 #
53 # DESKTOP: install a bunch of extra packages. For creating X suffix
54 # basefiles. See README.
55 #
56 # REPARTITION: we try to reuse partitions/filesystems to install a new
57 # os into a multi-os system, if we see some basic hueristics, like the
58 # right amount of them. This overrides that.
59 #
60 # PARTITION_PROMPT: If we don't see partitions to reuuse, prompt
61 # to make sure we really want to repartition and use a completely
62 # fresh install. I use this in case our repartition check has
63 # a bug in it, or I accidentally set REPARTITION.
64 #
65 # ROTATIONAL: in a system with ssd and hdd, install to the hdd
66 # instead of the default ssd.
67 #
68 # RAID0: Use raid 0 even if there are >= 4 disks with boot partititions.
69 #
70 # LINODE: For running a vm on linode, especially one created with fai-cd.
71
72 ###### begin Template for 51-multi-boot ######
73 #
74 # It has reasonable combinations of above classes.
75 # It's a noop until we replace _ with host names.
76
77 #!/bin/bash
78 if [[ ! -e /a/bin/fai/fai-wrapper || $FAI_ACTION == dirinstall ]]; then
79 case $HOSTNAME in
80 # stretch based minimal recovery / bootstraping os:
81 _) echo STRETCH64 VOL_STRETCH_BOOTSTRAP STRETCH_FREE ;;
82 # flidas
83 _) echo UBUNTU FLIDAS64 VOL_FLIDAS FLIDAS ;;
84 # etiona
85 _) echo UBUNTU ETIONA64 VOL_ETIONA ETIONA ;;
86 # stretch
87 _) echo STRETCH64 VOL_STRETCH STRETCH_FREE ;;
88 # buster
89 _) echo BUSTER64 VOL_BUSTER BUSTER_FREE ;;
90 # testing
91 _) echo STRETCH64 VOL_TESTING TESTING_FREE ;;
92 # xenial
93 _) echo UBUNTU XENIAL64 VOL_XENIAL XENIAL_FREE ;;
94 # bionic
95 _) echo UBUNTU BIONIC64 VOL_BIONIC BIONIC ;;
96 # focal
97 _) echo UBUNTU FOCAL64 VOL_FOCAL FOCAL ;;
98 esac
99 fi
100 ###### end Template for 51-multi-boot ######
101
102 if [[ -e /a/bin/fai/fai-wrapper ]]; then
103 source /a/bin/distro-functions/src/identify-distros
104 if isdeb; then
105 codename=$(debian-codename)
106 echo ${codename^^}
107 distro=$(distro-name)
108 case $distro in
109 debian)
110 echo ${distro^^}
111 # nonfree repo is not going away any time soon due to
112 # gcc-doc being in nonfree
113 echo ${codename^^}_NONFREE
114 ;;
115 trisquel)
116 # easier to stay with fai example config if we just call it ubuntu
117 echo UBUNTU
118 ;;
119 esac
120 fi
121 case $HOSTNAME in
122 li|lj) echo "LINODE" ;;
123 bk|je) echo "NOCRYPT" ;;
124 esac
125 fi
126
127
128 #echo "PARTITION_PROMPT"
129 #echo REPARTITION
130
131
132 if grep ^52:54:00: /sys/class/net/eth0/address &>/dev/null; then
133 # if our eth0 mac is in the kvm range, we are a vm.
134 echo "VM"
135 fi