0e16c0e98ebf82281aaa8093d04657210c394978
[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 #
30 # STRETCH64, BUSTER64, BULLSEYE64, BOOKWORM64
31 # FLIDAS64, FLIDAS64BIG, ETIONA64, NABIA64
32 # XENIAL64, BIONIC64, FOCAL64,
33 #
34 # The distro subvol name, we can add as many of these as we want:
35 # VOL_TESTING, VOL_STRETCH, VOL_BUSTER, VOL_BULLSEYE, VOL_BOOKWORM
36 # VOL_FLIDAS, VOL_ETIONA, VOL_NABIA
37 # VOL_XENIAL, VOL_BIONIC VOL_FOCAL
38 # VOL_BUSTER_BOOTSTRAP.
39 # Using VOL_BUSTER_BOOTSTRAP sets up the install to act like a pxe rom if
40 # grub sets a specific var.
41 #
42 # The apt sources files we want,
43 # STRETCH_FREE, STRETCH_NONFREE,
44 # BUSTER_FREE, BUSTER_NONFREE,
45 # BULLSEYE_FREE, BULLSEYE_NONFREE
46 # BOOKWORM_FREE, BOOKWORM_NONFREE
47 # TESTING_FREE, TESTING_NONFREE,
48 # XENIAL_FREE, BIONIC, FOCAL, FLIDAS, ETIONA, NABIA, STRETCH_LINODE.
49 #
50 # It's all a little redundant in some cases, but it keeps things
51 # simpler.
52 #
53 #
54 # Other notable classes:
55 #
56 # INSTALL: for autodiscover iso, this is needed. We could also add it to
57 # the autodiscover grub, but then we have to burn a new iso if we want a
58 # non-install one. It sets the class for the corresponding INSTALL.var,
59 # which sets FAI_ACTION=INSTALL. I'm not sure if this variable overrides
60 # FAI_ACTION outside of autodiscover, todo: test it out, if it doesn't,
61 # make install be default in 51-multi-boot, and disable it if needed.
62 #
63 # DESKTOP: install a bunch of extra packages. For creating X suffix
64 # basefiles. See README.
65 #
66 # REPARTITION: we try to reuse partitions/filesystems to install a new
67 # os into a multi-os system, if we see some basic hueristics, like the
68 # right amount of them. This overrides that.
69 #
70 # REROOTFS: Don't reuse the root filesystem, even if we normally would
71 #
72 # NOWIPE: use existing subvolumes if they exist
73 #
74 # PARTITION_PROMPT: If we don't see partitions to reuuse, prompt
75 # to make sure we really want to repartition and use a completely
76 # fresh install. I use this in case our repartition check has
77 # a bug in it, or I accidentally set REPARTITION.
78 #
79 # ROTATIONAL: in a system with ssd and hdd, install to the hdd
80 # instead of the default ssd.
81 #
82 # RAID0: Use raid 0 even if there are >= 4 disks with boot partitions.
83 #
84 # LINODE: For running a vm on linode, especially one created with fai-cd.
85 #
86 # IANK / FSF: general setup of my machine vs FSF machines
87 # NABIA_EXTRA: extra repos for NABIA from other distros
88
89
90 if [[ -e /a/bin/fai/fai-wrapper ]]; then
91 source /a/bin/distro-functions/src/identify-distros
92 if isdeb; then
93 codename=$(debian-codename)
94 echo ${codename^^}
95 distro=$(distro-name)
96 case $distro in
97 debian)
98 echo ${distro^^}
99 # nonfree repo is not going away any time soon due to
100 # gcc-doc being in nonfree
101 echo ${codename^^}_NONFREE
102 ;;
103 trisquel)
104 # easier to stay with fai example config if we just call it ubuntu
105 echo UBUNTU
106 ;;
107 esac
108 fi
109 case $HOSTNAME in
110 li|lj) echo "LINODE" ;;
111 bk|je) echo "NOCRYPT" ;;
112 esac
113 fi
114
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
124
125 exit 0
126 ### Below here is a comment of code, exit above is so it does not get executed ###
127
128 ###### begin Template for 51-multi-boot ######
129 #
130 # It has reasonable combinations of above classes.
131 # It's a noop until we replace _ with host names.
132
133 #!/bin/bash
134
135 echo IANK
136 if [[ ! -e /a/bin/fai/fai-wrapper || $FAI_ACTION == dirinstall ]]; then
137 case $HOSTNAME in
138 # bullseye based minimal recovery / bootstraping os:
139 _) echo BULLSEYE64 VOL_BULLSEYE_BOOTSTRAP BULLSEYE_FREE ;;
140 # flidas
141 _) echo UBUNTU FLIDAS64 VOL_FLIDAS FLIDAS ;;
142 # etiona
143 _) echo UBUNTU ETIONA64 VOL_ETIONA ETIONA ;;
144 # nabia
145 _) echo UBUNTU NABIA64 VOL_NABIA NABIA NABIA_EXTRA ;;
146 # aramo
147 _) echo UBUNTU ARAMO64 VOL_ARAMO ARAMO ARAMO_EXTRA ;;
148 # stretch
149 _) echo STRETCH64 VOL_STRETCH STRETCH_NONFREE ;;
150 # buster
151 _) echo BUSTER64 VOL_BUSTER BUSTER_NONFREE ;;
152 # bullseye
153 _) echo BULLSEYE64 VOL_BULLSEYE BULLSEYE_NONFREE ;;
154 # bookworm
155 _) echo BOOKWORM64 VOL_BOOKWORM BOOKWORM_NONFREE ;;
156 # testing
157 _) echo BOOKWORM64 VOL_TESTING TESTING_NONFREE ;;
158 # xenial
159 _) echo UBUNTU XENIAL64 VOL_XENIAL XENIAL_FREE ;;
160 # bionic
161 _) echo UBUNTU BIONIC64 VOL_BIONIC BIONIC ;;
162 # focal
163 _) echo UBUNTU FOCAL64 VOL_FOCAL FOCAL ;;
164 # jammy
165 _) echo UBUNTU JAMMY64 VOL_JAMMY JAMMY ;;
166 esac
167 fi
168 ###### end Template for 51-multi-boot ######